Update
This commit is contained in:
parent
dc397a794e
commit
fa10fb123a
|
@ -2,47 +2,49 @@ cmake_minimum_required(VERSION 2.8.3)
|
|||
|
||||
project(Blang)
|
||||
|
||||
if(NOT INSTALL_RUNTIME_DIR)
|
||||
set(INSTALL_RUNTIME_DIR bin)
|
||||
endif()
|
||||
set(Blang_VERSION 1.0.0)
|
||||
set(Blang_RELEASE 1)
|
||||
|
||||
if(NOT INSTALL_LIBRARY_DIR)
|
||||
set(INSTALL_LIBRARY_DIR bin)
|
||||
endif()
|
||||
if (NOT INSTALL_RUNTIME_DIR)
|
||||
set(INSTALL_RUNTIME_DIR bin)
|
||||
endif ()
|
||||
|
||||
if(NOT INSTALL_DATA_DIR)
|
||||
set(INSTALL_DATA_DIR share/blang)
|
||||
endif()
|
||||
if (NOT INSTALL_LIBRARY_DIR)
|
||||
set(INSTALL_LIBRARY_DIR bin)
|
||||
endif ()
|
||||
|
||||
if(NOT INSTALL_DOC_DIR)
|
||||
set(INSTALL_DOC_DIR doc/blang)
|
||||
endif()
|
||||
if (NOT INSTALL_DATA_DIR)
|
||||
set(INSTALL_DATA_DIR share/blang)
|
||||
endif ()
|
||||
|
||||
if(NOT INSTALL_CLIB_DIR)
|
||||
set(INSTALL_CLIB_DIR clib)
|
||||
endif()
|
||||
if (NOT INSTALL_DOC_DIR)
|
||||
set(INSTALL_DOC_DIR doc/blang)
|
||||
endif ()
|
||||
|
||||
if (NOT INSTALL_CLIB_DIR)
|
||||
set(INSTALL_CLIB_DIR clib)
|
||||
endif ()
|
||||
|
||||
set(CMAKE_CXX_FLAGS "-std=c++11")
|
||||
|
||||
find_package(BISON REQUIRED)
|
||||
find_package(FLEX REQUIRED)
|
||||
|
||||
add_subdirectory(utils)
|
||||
add_subdirectory(tools)
|
||||
add_subdirectory(src)
|
||||
|
||||
option(BUILD_UNIT_TESTS "Build unit tests" OFF)
|
||||
if(BUILD_UNIT_TESTS)
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
if (BUILD_UNIT_TESTS)
|
||||
add_subdirectory(tests)
|
||||
endif ()
|
||||
|
||||
option(BUILD_DOC "Build documentation" OFF)
|
||||
if(BUILD_DOC)
|
||||
add_subdirectory(doc)
|
||||
endif()
|
||||
if (BUILD_DOC)
|
||||
add_subdirectory(doc)
|
||||
endif ()
|
||||
|
||||
install(DIRECTORY share/blang/ DESTINATION "${INSTALL_DATA_DIR}")
|
||||
|
||||
install(DIRECTORY clib/ DESTINATION "${INSTALL_CLIB_DIR}")
|
||||
|
||||
install(FILES "LICENSE" "NOTICE" DESTINATION "${INSTALL_DOC_DIR}" )
|
||||
install(FILES "LICENSE" "NOTICE" DESTINATION "${INSTALL_DOC_DIR}")
|
||||
|
|
|
@ -1,480 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.0.2, 2016-06-25T11:50:12. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
<value type="QByteArray">{3fb93d8a-9d4c-46aa-821b-80ac79602a86}</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||
<value type="int">0</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
|
||||
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
|
||||
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
|
||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
|
||||
<value type="QString" key="language">Cpp</value>
|
||||
<valuemap type="QVariantMap" key="value">
|
||||
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
|
||||
<value type="QString" key="language">QmlJS</value>
|
||||
<valuemap type="QVariantMap" key="value">
|
||||
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
|
||||
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
|
||||
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
|
||||
<value type="int" key="EditorConfiguration.IndentSize">4</value>
|
||||
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
|
||||
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
|
||||
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
|
||||
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
|
||||
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
|
||||
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
|
||||
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
|
||||
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
|
||||
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
|
||||
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
|
||||
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
|
||||
<value type="int" key="EditorConfiguration.TabSize">8</value>
|
||||
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
|
||||
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
|
||||
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
|
||||
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
|
||||
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
|
||||
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.PluginSettings</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value type="bool" key="ClangCodeModel.UseGlobalWarningConfig">true</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Target.0</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.6.1 MinGW 32bit</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.6.1 MinGW 32bit</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.56.win32_mingw49_kit</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">2</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||
<valuelist type="QVariantList" key="CMake.Configuration">
|
||||
<value type="QString">CMAKE_CXX_COMPILER:FILEPATH=C:/Dev/mingw32/bin/g++.exe</value>
|
||||
</valuelist>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/Yoann/Documents/Informatique/GitHub/Blang-build</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="QString" key="CMakeProjectManager.MakeStep.AdditionalArguments"></value>
|
||||
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
|
||||
<value type="QString">all</value>
|
||||
</valuelist>
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="QString" key="CMakeProjectManager.MakeStep.AdditionalArguments"></value>
|
||||
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
|
||||
<value type="QString">clean</value>
|
||||
</valuelist>
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Default</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Default</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
|
||||
<value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
|
||||
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
|
||||
<value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
|
||||
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
|
||||
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
|
||||
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
|
||||
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
|
||||
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
|
||||
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
|
||||
<value type="int">0</value>
|
||||
<value type="int">1</value>
|
||||
<value type="int">2</value>
|
||||
<value type="int">3</value>
|
||||
<value type="int">4</value>
|
||||
<value type="int">5</value>
|
||||
<value type="int">6</value>
|
||||
<value type="int">7</value>
|
||||
<value type="int">8</value>
|
||||
<value type="int">9</value>
|
||||
<value type="int">10</value>
|
||||
<value type="int">11</value>
|
||||
<value type="int">12</value>
|
||||
<value type="int">13</value>
|
||||
<value type="int">14</value>
|
||||
</valuelist>
|
||||
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguation.Title">PreBlang</value>
|
||||
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguration.Arguments"></value>
|
||||
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguration.UserWorkingDirectory"></value>
|
||||
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguration.UserWorkingDirectory.default">C:/Users/Yoann/Documents/Informatique/GitHub/Blang-build/tools/PreBlang</value>
|
||||
<value type="int" key="PE.EnvironmentAspect.Base">-1</value>
|
||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">PreBlang</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.PreBlang</value>
|
||||
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.1">
|
||||
<value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
|
||||
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
|
||||
<value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
|
||||
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
|
||||
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
|
||||
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
|
||||
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
|
||||
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
|
||||
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
|
||||
<value type="int">0</value>
|
||||
<value type="int">1</value>
|
||||
<value type="int">2</value>
|
||||
<value type="int">3</value>
|
||||
<value type="int">4</value>
|
||||
<value type="int">5</value>
|
||||
<value type="int">6</value>
|
||||
<value type="int">7</value>
|
||||
<value type="int">8</value>
|
||||
<value type="int">9</value>
|
||||
<value type="int">10</value>
|
||||
<value type="int">11</value>
|
||||
<value type="int">12</value>
|
||||
<value type="int">13</value>
|
||||
<value type="int">14</value>
|
||||
</valuelist>
|
||||
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguation.Title">Lex</value>
|
||||
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguration.Arguments"></value>
|
||||
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguration.UserWorkingDirectory"></value>
|
||||
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguration.UserWorkingDirectory.default">C:/Users/Yoann/Documents/Informatique/GitHub/Blang-build/tools/lex</value>
|
||||
<value type="int" key="PE.EnvironmentAspect.Base">-1</value>
|
||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Lex</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.Lex</value>
|
||||
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.2">
|
||||
<value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
|
||||
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
|
||||
<value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
|
||||
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
|
||||
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
|
||||
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
|
||||
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
|
||||
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
|
||||
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
|
||||
<value type="int">0</value>
|
||||
<value type="int">1</value>
|
||||
<value type="int">2</value>
|
||||
<value type="int">3</value>
|
||||
<value type="int">4</value>
|
||||
<value type="int">5</value>
|
||||
<value type="int">6</value>
|
||||
<value type="int">7</value>
|
||||
<value type="int">8</value>
|
||||
<value type="int">9</value>
|
||||
<value type="int">10</value>
|
||||
<value type="int">11</value>
|
||||
<value type="int">12</value>
|
||||
<value type="int">13</value>
|
||||
<value type="int">14</value>
|
||||
</valuelist>
|
||||
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguation.Title">Blang</value>
|
||||
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguration.Arguments"></value>
|
||||
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguration.UserWorkingDirectory"></value>
|
||||
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguration.UserWorkingDirectory.default">C:/Users/Yoann/Documents/Informatique/GitHub/Blang-build/src</value>
|
||||
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Blang</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.Blang</value>
|
||||
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.3">
|
||||
<value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
|
||||
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
|
||||
<value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
|
||||
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
|
||||
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
|
||||
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
|
||||
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
|
||||
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
|
||||
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
|
||||
<value type="int">0</value>
|
||||
<value type="int">1</value>
|
||||
<value type="int">2</value>
|
||||
<value type="int">3</value>
|
||||
<value type="int">4</value>
|
||||
<value type="int">5</value>
|
||||
<value type="int">6</value>
|
||||
<value type="int">7</value>
|
||||
<value type="int">8</value>
|
||||
<value type="int">9</value>
|
||||
<value type="int">10</value>
|
||||
<value type="int">11</value>
|
||||
<value type="int">12</value>
|
||||
<value type="int">13</value>
|
||||
<value type="int">14</value>
|
||||
</valuelist>
|
||||
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguation.Title">LibBlangTests</value>
|
||||
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguration.Arguments"></value>
|
||||
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguration.UserWorkingDirectory"></value>
|
||||
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguration.UserWorkingDirectory.default">C:/Users/Yoann/Documents/Informatique/GitHub/Blang-build/unittests/libblang</value>
|
||||
<value type="int" key="PE.EnvironmentAspect.Base">-1</value>
|
||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">LibBlangTests (disabled)</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.LibBlangTests</value>
|
||||
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.4">
|
||||
<value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
|
||||
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
|
||||
<value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
|
||||
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
|
||||
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
|
||||
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
|
||||
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
|
||||
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
|
||||
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
|
||||
<value type="int">0</value>
|
||||
<value type="int">1</value>
|
||||
<value type="int">2</value>
|
||||
<value type="int">3</value>
|
||||
<value type="int">4</value>
|
||||
<value type="int">5</value>
|
||||
<value type="int">6</value>
|
||||
<value type="int">7</value>
|
||||
<value type="int">8</value>
|
||||
<value type="int">9</value>
|
||||
<value type="int">10</value>
|
||||
<value type="int">11</value>
|
||||
<value type="int">12</value>
|
||||
<value type="int">13</value>
|
||||
<value type="int">14</value>
|
||||
</valuelist>
|
||||
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguation.Title">lexTest</value>
|
||||
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguration.Arguments"></value>
|
||||
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguration.UserWorkingDirectory"></value>
|
||||
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguration.UserWorkingDirectory.default">C:/Users/Yoann/Documents/Informatique/GitHub/Blang-build/unittests/lex</value>
|
||||
<value type="int" key="PE.EnvironmentAspect.Base">-1</value>
|
||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">lexTest (disabled)</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.lexTest</value>
|
||||
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.5">
|
||||
<value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
|
||||
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
|
||||
<value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
|
||||
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
|
||||
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
|
||||
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
|
||||
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
|
||||
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
|
||||
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
|
||||
<value type="int">0</value>
|
||||
<value type="int">1</value>
|
||||
<value type="int">2</value>
|
||||
<value type="int">3</value>
|
||||
<value type="int">4</value>
|
||||
<value type="int">5</value>
|
||||
<value type="int">6</value>
|
||||
<value type="int">7</value>
|
||||
<value type="int">8</value>
|
||||
<value type="int">9</value>
|
||||
<value type="int">10</value>
|
||||
<value type="int">11</value>
|
||||
<value type="int">12</value>
|
||||
<value type="int">13</value>
|
||||
<value type="int">14</value>
|
||||
</valuelist>
|
||||
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguation.Title">MustacheTest</value>
|
||||
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguration.Arguments"></value>
|
||||
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguration.UserWorkingDirectory"></value>
|
||||
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguration.UserWorkingDirectory.default">C:/Users/Yoann/Documents/Informatique/GitHub/Blang-build/unittests/Mustache</value>
|
||||
<value type="int" key="PE.EnvironmentAspect.Base">-1</value>
|
||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">MustacheTest (disabled)</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.MustacheTest</value>
|
||||
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">6</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.TargetCount</variable>
|
||||
<value type="int">1</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
|
||||
<value type="int">18</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>Version</variable>
|
||||
<value type="int">18</value>
|
||||
</data>
|
||||
</qtcreator>
|
|
@ -1,28 +1,14 @@
|
|||
G1M-assembler
|
||||
*******
|
||||
### G1M-assembler
|
||||
|
||||
Introduction
|
||||
============
|
||||
## Introduction
|
||||
|
||||
G1M-assembler is a Text-to-BasicCasio converter tools.
|
||||
|
||||
Manual
|
||||
======
|
||||
Blang is a Text-to-BasicCasio converter tools.
|
||||
|
||||
See the `mkg1m(1)`_ manual page for instructions to run the tool.
|
||||
## Build
|
||||
|
||||
.. _`mkg1m(1)`: man/mkg1m.1
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
CastXML is licensed under the `GPL V3`_.
|
||||
See the `<LICENSE>`__ and `<NOTICE>`__ files for details.
|
||||
|
||||
Build
|
||||
=====
|
||||
|
||||
To build g1m-assembler tools from source, first obtain the prerequisites:
|
||||
To build Blang tools from source, first obtain the prerequisites:
|
||||
|
||||
* A C/C++ compiler
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
import json
|
||||
json_data = open('file')
|
||||
data = json.load(json_data)
|
|
@ -0,0 +1,3 @@
|
|||
lib/src/Parser.cpp
|
||||
lib/parser_gen.cpp
|
||||
lib/src/Parser.h
|
|
@ -1,15 +1,11 @@
|
|||
|
||||
include_directories(include)
|
||||
include_directories(lib/src)
|
||||
|
||||
set(LIBRARY_OUTPUT_PATH lib/${CMAKE_BUILD_TYPE})
|
||||
|
||||
set(Blang_VERSION 1.0.0)
|
||||
set(Blang_RELEASE 1)
|
||||
configure_file(include/version.h.in include/version.h @ONLY)
|
||||
|
||||
BISON_TARGET(BlangParser parser.y lib/parser_gen.cpp)
|
||||
FLEX_TARGET(BlangScanner lexer.l lib/lexer_gen.cpp)
|
||||
ADD_FLEX_BISON_DEPENDENCY(BlangScanner BlangParser)
|
||||
add_subdirectory(lib)
|
||||
add_subdirectory(ast)
|
||||
add_subdirectory(code-gen)
|
||||
|
||||
file(
|
||||
GLOB_RECURSE
|
||||
|
@ -19,25 +15,8 @@ file(
|
|||
|
||||
add_executable(Blang ${sources_files})
|
||||
|
||||
file(
|
||||
GLOB_RECURSE
|
||||
lib_files
|
||||
lib/*
|
||||
)
|
||||
|
||||
add_library(
|
||||
libblang
|
||||
SHARED
|
||||
${lib_files}
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
Blang
|
||||
libblang
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
libblang
|
||||
libpreblang
|
||||
blangutils
|
||||
)
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
file(
|
||||
GLOB_RECURSE
|
||||
sources_files
|
||||
src/*
|
||||
)
|
||||
|
||||
add_executable(blang-ast ${sources_files})
|
||||
|
||||
target_link_libraries(
|
||||
blang-ast
|
||||
libblang
|
||||
)
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <fstream>
|
||||
#include <getopt.h>
|
||||
#include <cstdlib>
|
||||
|
||||
using namespace std;
|
||||
|
||||
string getHelpString(){
|
||||
return "\nUsage : Blang input-file [OPTION]\n\n"
|
||||
" -o output\t\tWrite output to file.\n"
|
||||
" -l lib\t\tSearch the library named library.\n"
|
||||
" -L dir\t\tadd all the libraries in the folder dir.\n"
|
||||
" -v\t\t\tShow version then exit\n"
|
||||
" -h\t\t\tShow help then exit\n";
|
||||
}
|
||||
|
||||
string getVersionString(){
|
||||
string str;
|
||||
/*
|
||||
str += "g1m-assembler-mkg1m version ";
|
||||
str += BLANG_VERSION;
|
||||
str += " release ";
|
||||
str += BLANG_RELEASE;
|
||||
*/
|
||||
return str;
|
||||
}
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
vector<string> outputFiles;
|
||||
vector<string> CLibraries;
|
||||
vector<string> CLibraryDir;
|
||||
|
||||
int c;
|
||||
opterr = 0; // disable getopt error
|
||||
|
||||
int option_index = 0;
|
||||
static struct option long_options[] = {
|
||||
{"version", no_argument, 0, 'v' },
|
||||
{"help", no_argument, 0, 'h' },
|
||||
{"output", required_argument, 0, 'o' },
|
||||
{0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
while ((c = getopt_long(argc, argv, "o:l:L:vh", long_options,&option_index)) != -1){
|
||||
switch (c){
|
||||
case 'o':
|
||||
outputFiles.push_back(optarg); //get output files
|
||||
break;
|
||||
case 'l':
|
||||
CLibraries.push_back(optarg); //get input files
|
||||
break;
|
||||
case 'L':
|
||||
CLibraryDir.push_back(optarg); //get input files
|
||||
break;
|
||||
case 'v':
|
||||
cout << getVersionString();
|
||||
return 0;
|
||||
case 'h':
|
||||
cout << getHelpString();
|
||||
return 0;
|
||||
case '?':
|
||||
if (optopt == 'o')
|
||||
fprintf (stderr, "Option -%c requires an argument.\n", optopt);
|
||||
else if (isprint (optopt))
|
||||
fprintf (stderr, "Unknown option `-%c'.\n", optopt);
|
||||
else
|
||||
fprintf (stderr,"Unknown option character `\\x%x'.\n",optopt);
|
||||
return 1;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
string inputStr;
|
||||
|
||||
if(optind < argc) {
|
||||
string file = argv[optind];
|
||||
ifstream fileStream(file, std::ios::in);
|
||||
if(fileStream.is_open()) {
|
||||
// TODO
|
||||
} else {
|
||||
cerr << "Cannot open file: " << file;
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
cin >> inputStr;
|
||||
}
|
||||
|
||||
// TODO
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
file(
|
||||
GLOB_RECURSE
|
||||
sources_files
|
||||
src/*
|
||||
)
|
||||
|
||||
add_executable(blang-codegen ${sources_files})
|
||||
|
||||
target_link_libraries(
|
||||
blang-codegen
|
||||
libblang
|
||||
)
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
#ifndef BREAKSTATEMENT_HPP
|
||||
#define BREAKSTATEMENT_HPP
|
||||
|
||||
#include "Statement.hpp"
|
||||
#include "SourceLocation.hpp"
|
||||
|
||||
|
||||
class BreakStatement: public Statement{
|
||||
public:
|
||||
SourceLocation getBreakLocation() const;
|
||||
void setBreakLocation(SourceLocation);
|
||||
|
||||
private:
|
||||
SourceLocation _BreakLoc;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,28 +0,0 @@
|
|||
#ifndef EXPRSTATEMENT_HPP
|
||||
#define EXPRSTATEMENT_HPP
|
||||
|
||||
#include "Statement.hpp"
|
||||
|
||||
class Expr : public Statement
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
void getCond();
|
||||
void getCond() const;
|
||||
void setCond();
|
||||
|
||||
void getThen();
|
||||
void getThen() const;
|
||||
void setThen();
|
||||
|
||||
void getElse();
|
||||
void getElse() const;
|
||||
void setElse();
|
||||
|
||||
void getIfLocation();
|
||||
void getThenLocation();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,11 +0,0 @@
|
|||
#ifndef BLANG_NUMBERLITERALEXPR_H
|
||||
#define BLANG_NUMBERLITERALEXPR_H
|
||||
|
||||
|
||||
class NumberLiteralExpr
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //BLANG_NUMBERLITERALEXPR_H
|
|
@ -1,16 +0,0 @@
|
|||
#ifndef RETURNSTATEMENT_HPP
|
||||
#define RETURNSTATEMENT_HPP
|
||||
|
||||
#include "Statement.hpp"
|
||||
#include "SourceLocation.hpp"
|
||||
|
||||
|
||||
class ReturnStatement: public Statement{
|
||||
public:
|
||||
|
||||
SourceLocation getReturnLocation() const;
|
||||
void setReturnLocation(SourceLocation);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,30 +0,0 @@
|
|||
#ifndef WHILESTATEMENT_HPP
|
||||
#define WHILESTATEMENT_HPP
|
||||
|
||||
#include "Statement.hpp"
|
||||
#include "Expr.hpp"
|
||||
#include "SourceLocation.hpp"
|
||||
|
||||
|
||||
class WhileStatement: public Statement{
|
||||
|
||||
public:
|
||||
|
||||
ExprStatement* getCond();
|
||||
const ExprStatement* getCond() const;
|
||||
void setCond(ExprStatement*);
|
||||
|
||||
Statement* getBody();
|
||||
const Statement* getBody() const;
|
||||
void setBody(Statement*);
|
||||
|
||||
SourceLocation getWhileLocation() const;
|
||||
void setWhileLocation(SourceLocation);
|
||||
|
||||
private:
|
||||
SourceLocation _WhileLoc;
|
||||
enum { VAR, COND, BODY, END_EXPR };
|
||||
Statement* _subExprs[END_EXPR];
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,33 @@
|
|||
|
||||
configure_file(src/version.h.in include/version.h @ONLY)
|
||||
|
||||
BISON_TARGET(BlangParser lib/src/parser.yy lib/src/Parser.cpp DEFINES_FILE lib/src/Parser.h)
|
||||
FLEX_TARGET(BlangScanner lib/src/lexer.l lib/src/lexer_gen.cpp)
|
||||
ADD_FLEX_BISON_DEPENDENCY(BlangScanner BlangParser)
|
||||
|
||||
file(
|
||||
GLOB_RECURSE
|
||||
src_files
|
||||
src/*
|
||||
)
|
||||
|
||||
add_library(
|
||||
libblang
|
||||
SHARED
|
||||
${src_files}
|
||||
src/Parser.cpp
|
||||
src/lexer_gen.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
libblang
|
||||
libpreblang
|
||||
)
|
||||
|
||||
file(
|
||||
GLOB_RECURSE
|
||||
header_files
|
||||
src/*.h
|
||||
)
|
||||
|
||||
install(FILES header_files DESTINATION include)
|
|
@ -1,46 +0,0 @@
|
|||
#include "Lexer.hpp"
|
||||
#include "TokenList.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
|
||||
#include <utils/src/string.hpp>
|
||||
|
||||
using namespace Blang;
|
||||
|
||||
static std::map<Token::TokenKind,std::regex> regexMap;
|
||||
|
||||
TokenList Lexer::tokenize(const std::string& t){
|
||||
|
||||
string text(t);
|
||||
|
||||
std::string::const_iterator itt;
|
||||
TokenList tokenList;
|
||||
|
||||
for ( itt = text.begin (); itt != text.end (); ++ itt ){
|
||||
if(text.substr(itt, itt+1) == "If"){
|
||||
itt += 2;
|
||||
}else if(*itt == '\"'){
|
||||
int bpos = itt;
|
||||
while(*itt != '\"')
|
||||
itt++;
|
||||
tokenList << Token(Token::Token_StringLiteral, text.substr(itt, itt+1));
|
||||
} else if(std::string(" \t").find(*itt) >= 0){
|
||||
tokenList << Token(Token::Token_Whitespace, itt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TokenList Lexer::tokenizeFile(const std::string& filename){
|
||||
std::ifstream fileStream(filename);
|
||||
if(fileStream){
|
||||
std::string text, line;
|
||||
while(getline(fileStream, line)){
|
||||
text += line + std::endl;
|
||||
}
|
||||
tokenizeFile(text);
|
||||
} else {
|
||||
std::cout << "Error: Unable to read file" << std::endl;
|
||||
}
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
#include "../../include/Statement/AssignStatement.hpp"
|
|
@ -1,9 +0,0 @@
|
|||
#include "Statement/BreakStatement.hpp"
|
||||
|
||||
SourceLocation BreakStatement::getBreakLocation() const{
|
||||
return _BreakLoc;
|
||||
}
|
||||
|
||||
void BreakStatement::setBreakLocation(SourceLocation loc){
|
||||
_BreakLoc = loc;
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
//
|
||||
// Created by yoann on 24/11/16.
|
||||
//
|
||||
|
||||
#include "../../include/Statement/CallExpr.h"
|
|
@ -1,56 +0,0 @@
|
|||
#include "Statement/CompoundStatement.hpp"
|
||||
|
||||
unsigned int CompoundStatement::size() const
|
||||
{
|
||||
return _body.size();
|
||||
}
|
||||
|
||||
bool CompoundStatement::empty() const
|
||||
{
|
||||
return _body.empty();
|
||||
}
|
||||
|
||||
void CompoundStatement::setLastStatement(Statement *S)
|
||||
{
|
||||
_body.push_back(S);
|
||||
}
|
||||
|
||||
const_body_iterator CompoundStatement::body_begin() const
|
||||
{
|
||||
return _body.begin();
|
||||
}
|
||||
|
||||
body_iterator CompoundStatement::body_begin()
|
||||
{
|
||||
return _body.begin();
|
||||
}
|
||||
|
||||
const_body_iterator CompoundStatement::body_end() const
|
||||
{
|
||||
return _body.end();
|
||||
}
|
||||
|
||||
body_iterator CompoundStatement::body_end()
|
||||
{
|
||||
return _body.end();
|
||||
}
|
||||
|
||||
const_reverse_body_iterator CompoundStatement::body_rbegin() const
|
||||
{
|
||||
return _body.rbegin();
|
||||
}
|
||||
|
||||
reverse_body_iterator CompoundStatement::body_rbegin()
|
||||
{
|
||||
return _body.rbegin();
|
||||
}
|
||||
|
||||
const_reverse_body_iterator CompoundStatement::body_rend() const
|
||||
{
|
||||
return _body.rend();
|
||||
}
|
||||
|
||||
reverse_body_iterator CompoundStatement::body_rend()
|
||||
{
|
||||
return _body.rend();
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
#include "Statement/Expr.hpp"
|
|
@ -1 +0,0 @@
|
|||
#include "Statement/NumberLiteralExpr.h"
|
|
@ -1 +0,0 @@
|
|||
#include "Statement/ReturnStatement.hpp"
|
|
@ -1 +0,0 @@
|
|||
#include "Statement/StringLiteralExpr.h"
|
|
@ -1,33 +0,0 @@
|
|||
#include "Statement/WhileStatement.hpp"
|
||||
|
||||
ExprStatement* WhileStatement::getCond(){
|
||||
return reinterpret_cast<ExprStatement*>(_subExprs[COND]);
|
||||
}
|
||||
|
||||
const ExprStatement* WhileStatement::getCond() const{
|
||||
return getCond();
|
||||
}
|
||||
|
||||
void WhileStatement::setCond(ExprStatement* e){
|
||||
_subExprs[COND] = reinterpret_cast<Statement *>(e);
|
||||
}
|
||||
|
||||
Statement* WhileStatement::getBody(){
|
||||
return _subExprs[BODY];
|
||||
}
|
||||
|
||||
const Statement* WhileStatement::getBody() const{
|
||||
return getBody();
|
||||
}
|
||||
|
||||
void WhileStatement::setBody(Statement* s){
|
||||
_subExprs[BODY] = s;
|
||||
}
|
||||
|
||||
SourceLocation WhileStatement::getWhileLocation() const{
|
||||
return _WhileLoc;
|
||||
}
|
||||
|
||||
void WhileStatement::setWhileLocation(SourceLocation loc){
|
||||
_WhileLoc = loc;
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
%{
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "Token.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
string val;
|
||||
int nbLines = 0;
|
||||
int nbChars = 0;
|
||||
%}
|
||||
|
||||
%option noyywrap
|
||||
|
||||
%x strEnv
|
||||
|
||||
integer [0-9]+
|
||||
real [0-9]+\.[0-9]*|\.[0-9]+
|
||||
value {integer}|{real}
|
||||
operator "+"|"-"|"/"|"*"|"=>"|"<="|">="|"="|"->"
|
||||
keyword "+"|"-"|"/"|"*"|"=>"|"<="|">="|"="|"->"
|
||||
ident [a-zA-Z_][0-9a-zA-Z_]*
|
||||
|
||||
%%
|
||||
|
||||
{value} { val=yytext; return(Token::Token_NumberLiteral); }
|
||||
{operator} { val=yytext; return(Token::Token_Operator); }
|
||||
{keyword} { val=yytext; return(Token::Token_Keyword); }
|
||||
{ident} { val=yytext; return(Token::Token_Identifier); }
|
||||
"\"" { val.clear(); BEGIN(strEnv); }
|
||||
<strEnv>"\"" { BEGIN(INITIAL); return(Token::Token_StringLiteral); }
|
||||
<strEnv>"\n" { cerr << "multi-line strings not allowed" << endl; ++nbLines; }
|
||||
<strEnv>"\\\n" { val+='\n'; ++nbLines; } // line cut by \
|
||||
<strEnv>"\\". { val+=yytext[1]; }
|
||||
<strEnv><<EOF>> { BEGIN(INITIAL); return(STRING); }
|
||||
<strEnv>. { val+=yytext[0]; }
|
||||
[ \t]+ { /* nothing to be done */ }
|
||||
"\n" { ++nbLines; }
|
||||
. { val=yytext; return(Token::Token_Unknown); }
|
||||
|
||||
%%
|
||||
int main(int argc,char ** argv)
|
||||
{
|
||||
int token;
|
||||
if(argc>1)
|
||||
yyin=fopen(argv[1],"r"); // check result !!!
|
||||
TODO
|
||||
do {
|
||||
token=yylex();
|
||||
switch(token) {
|
||||
case STRING: cerr << "STRING[" << val << "]" << endl; break;
|
||||
case INTEGER: cerr << "INTEGER[" << val << "]" << endl; break;
|
||||
}
|
||||
} while(token);
|
||||
|
||||
cerr << nbLines << " lines" << endl;
|
||||
return(0);
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
int yylex(void); // defini dans progL.cpp, utilise par yyparse()
|
||||
void yyerror(const char * msg); // defini plus loin, utilise par yyparse()
|
||||
int lineNumber; // notre compteur de lignes
|
||||
extern FILE * yyin; // defini dans progL.cpp, utilise par main()
|
||||
|
||||
%}
|
||||
|
||||
%token START END // les lexemes que doit fournir yylex()
|
||||
%token ASSIGN SEMICOLON
|
||||
%token IDENT REAL INTEGER
|
||||
%start program // l'axiome de notre grammaire
|
||||
|
||||
%%
|
||||
|
||||
program : stmtList
|
||||
;
|
||||
stmtList : stmtList stmt { CompoundStatement* stmt = $1; stmt.setLastStatement($2); $$ = stmt; }
|
||||
| stmt { CompoundStatement* stmt = new CompoundStatement(); stmt.setLastStatement($1); $$ = stmt; }
|
||||
;
|
||||
stmt : assign
|
||||
| ifStmt
|
||||
| WHILE expr EOL stmtList EOL WHILEEND {}
|
||||
| DO EOL stmtList EOL LPWHILE expr {}
|
||||
| FOR assignStmt TO expr EOL stmtList EOL NEXT { $$ = new ForStatement($2, $4, $6);}
|
||||
| FOR assignStmt TO expr STEP expr EOL stmtList EOL NEXT { $$ = new ForStatement($2, $4, $8, $6);}
|
||||
| GOTO IDENT
|
||||
| LABEL IDENT
|
||||
| BREAK
|
||||
| RETURN
|
||||
| STOP
|
||||
| expr
|
||||
;
|
||||
expr : IDENT { cerr << "integer expr" << endl; }
|
||||
| NUMBER { cerr << "real expr" << endl; }
|
||||
| expr OPERATOR expr { cerr << "ident expr" << endl; }
|
||||
;
|
||||
assignStmt : expr ASSIGN IDENT
|
||||
;
|
||||
ifStmt : IF expr EOL THEN EOL stmtList EOL IFEND { $$ = new IfStatement($2, $6); }
|
||||
| IF expr EOL THEN EOL stmtList EOL ELSE EOL stmtList EOL IFEND { $$ = new IfStatement($2, $6, $10); }
|
||||
| expr => assign { $$ = new IfStatement($2, $3); }
|
||||
|
||||
%%
|
||||
|
||||
void yyerror(const char * msg)
|
||||
{
|
||||
cerr << "line " << lineNumber << ": " << msg << endl;
|
||||
}
|
||||
|
||||
int main(int argc,char ** argv)
|
||||
{
|
||||
if(argc>1)
|
||||
yyin=fopen(argv[1],"r"); // check result !!!
|
||||
lineNumber=1;
|
||||
if(!yyparse())
|
||||
cerr << "Success" << endl;
|
||||
return(0);
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
#include "Lexer.hpp"
|
||||
#include "TokenList.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
|
||||
using namespace Blang;
|
||||
|
||||
|
||||
TokenList Lexer::tokenizeFile(const std::string& filename){
|
||||
std::ifstream fileStream(filename);
|
||||
if(fileStream){
|
||||
std::string text, line;
|
||||
// TODO
|
||||
} else {
|
||||
std::cout << "Error: Unable to read file" << std::endl;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -2,15 +2,27 @@
|
|||
|
||||
#include "SourceLocation.hpp"
|
||||
|
||||
SourceLocation::SourceLocation(std::string file, int line, int column, int offset):
|
||||
SourceLocation::SourceLocation(std::string file, int line, int column):
|
||||
_file(file),
|
||||
_line(line),
|
||||
_column(column),
|
||||
_offset(offset)
|
||||
_column(column)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SourceLocation::SourceLocation():
|
||||
_file(""),
|
||||
_line(0),
|
||||
_column(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool SourceLocation::isValid() const
|
||||
{
|
||||
return _line > 0 && _column > 0 && !_file.empty();
|
||||
}
|
||||
|
||||
void SourceLocation::print() const
|
||||
{
|
||||
std::cout << printToString();
|
||||
|
@ -49,14 +61,4 @@ int SourceLocation::columnLocation() const
|
|||
void SourceLocation::setColumnLocation(int c)
|
||||
{
|
||||
_column = c;
|
||||
}
|
||||
|
||||
int SourceLocation::offset() const
|
||||
{
|
||||
return _offset;
|
||||
}
|
||||
|
||||
void SourceLocation::setOffset(int offset)
|
||||
{
|
||||
_offset = offset;
|
||||
}
|
|
@ -7,7 +7,7 @@ class SourceLocation
|
|||
{
|
||||
public:
|
||||
SourceLocation();
|
||||
SourceLocation(std::string file, int line, int column, int offset);
|
||||
SourceLocation(std::string file, int line, int column);
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
|
@ -28,7 +28,6 @@ public:
|
|||
|
||||
private:
|
||||
std::string _file;
|
||||
int _offset;
|
||||
int _column;
|
||||
int _line;
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef STATEMENT_HPP
|
||||
#define STATEMENT_HPP
|
||||
|
||||
#include "SourceLocation.hpp"
|
||||
|
||||
class Statement{
|
||||
|
|
@ -0,0 +1 @@
|
|||
#include "AssignStatement.h"
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef BLANG_ASSIGNSTATEMENT_H
|
||||
#define BLANG_ASSIGNSTATEMENT_H
|
||||
|
||||
#include "Statement.hpp"
|
||||
#include "../Statement.hpp"
|
||||
|
||||
class AssignStatement: public Statement
|
||||
{
|
|
@ -1,11 +1,11 @@
|
|||
#include "Statement/BinaryOperatorExpr.h"
|
||||
#include "BinaryOperatorExpr.h"
|
||||
|
||||
static std::string BinaryOperatorExpr::getOpcodeStr(BinaryOperatorExpr::Opcode opc) const
|
||||
std::string BinaryOperatorExpr::getOpcodeStr(BinaryOperatorExpr::Opcode opc)
|
||||
{
|
||||
switch (opc) {
|
||||
#define BINARY_OPERATION(Name, Spelling) case BO_##Name: return Spelling;
|
||||
|
||||
#include "OperationKinds.def"
|
||||
#include "Statement/OperationKinds.def"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ BinaryOperatorExpr::BinaryOperatorExpr(Expr *lhs, Expr *rhs, BinaryOperatorExpr:
|
|||
|
||||
Expr *BinaryOperatorExpr::getLHS() const
|
||||
{
|
||||
return _subExprs.at(LHS);
|
||||
}
|
||||
|
||||
void BinaryOperatorExpr::setLHS(Expr *E)
|
||||
|
@ -27,7 +28,7 @@ void BinaryOperatorExpr::setLHS(Expr *E)
|
|||
|
||||
Expr *BinaryOperatorExpr::getRHS() const
|
||||
{
|
||||
return _subExprs[RHS];
|
||||
return _subExprs.at(RHS);
|
||||
}
|
||||
|
||||
void BinaryOperatorExpr::setRHS(Expr *E)
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef BLANG_BINARYOPERATOREXPR_H
|
||||
#define BLANG_BINARYOPERATOREXPR_H
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "Expr.hpp"
|
||||
|
||||
class BinaryOperatorExpr: public Expr
|
||||
|
@ -23,7 +25,8 @@ public:
|
|||
void setOpcode (Opcode O);
|
||||
std::string getOpcodeStr() const;
|
||||
|
||||
static std::string getOpcodeStr(Opcode opc) const;
|
||||
static std::string getOpcodeStr(Opcode opc);
|
||||
static Opcode getStrOpcode(std::string str);
|
||||
|
||||
private:
|
||||
Opcode _opc;
|
|
@ -0,0 +1,17 @@
|
|||
#include "BreakStatement.h"
|
||||
|
||||
BreakStatement::BreakStatement(SourceLocation l):
|
||||
_BreakLoc(l)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SourceLocation BreakStatement::getBreakLocation() const
|
||||
{
|
||||
return _BreakLoc;
|
||||
}
|
||||
|
||||
void BreakStatement::setBreakLocation(SourceLocation loc)
|
||||
{
|
||||
_BreakLoc = loc;
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
#ifndef BREAKSTATEMENT_HPP
|
||||
#define BREAKSTATEMENT_HPP
|
||||
|
||||
#include "../Statement.hpp"
|
||||
#include "../SourceLocation.hpp"
|
||||
|
||||
|
||||
class BreakStatement : public Statement
|
||||
{
|
||||
public:
|
||||
BreakStatement(SourceLocation l);
|
||||
|
||||
SourceLocation getBreakLocation() const;
|
||||
void setBreakLocation(SourceLocation);
|
||||
|
||||
private:
|
||||
SourceLocation _BreakLoc;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,5 @@
|
|||
//
|
||||
// Created by yoann on 24/11/16.
|
||||
//
|
||||
|
||||
#include "CallExpr.h"
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef CALLEXPR_H
|
||||
#define CALLEXPR_H
|
||||
|
||||
#include "Expr.hpp"
|
||||
|
||||
/*!Represents a function call */
|
||||
class CallExpr: public Expr
|
||||
{
|
|
@ -0,0 +1,56 @@
|
|||
#include "CompoundStatement.h"
|
||||
|
||||
unsigned int CompoundStatement::size() const
|
||||
{
|
||||
return _body.size();
|
||||
}
|
||||
|
||||
bool CompoundStatement::empty() const
|
||||
{
|
||||
return _body.empty();
|
||||
}
|
||||
|
||||
void CompoundStatement::setLastStatement(Statement *S)
|
||||
{
|
||||
_body.push_back(S);
|
||||
}
|
||||
|
||||
CompoundStatement::const_body_iterator CompoundStatement::body_begin() const
|
||||
{
|
||||
return _body.begin();
|
||||
}
|
||||
|
||||
CompoundStatement::body_iterator CompoundStatement::body_begin()
|
||||
{
|
||||
return _body.begin();
|
||||
}
|
||||
|
||||
CompoundStatement::const_body_iterator CompoundStatement::body_end() const
|
||||
{
|
||||
return _body.end();
|
||||
}
|
||||
|
||||
CompoundStatement::body_iterator CompoundStatement::body_end()
|
||||
{
|
||||
return _body.end();
|
||||
}
|
||||
|
||||
CompoundStatement::const_reverse_body_iterator CompoundStatement::body_rbegin() const
|
||||
{
|
||||
return _body.rbegin();
|
||||
}
|
||||
|
||||
CompoundStatement::reverse_body_iterator CompoundStatement::body_rbegin()
|
||||
{
|
||||
return _body.rbegin();
|
||||
}
|
||||
|
||||
CompoundStatement::const_reverse_body_iterator CompoundStatement::body_rend() const
|
||||
{
|
||||
return _body.rend();
|
||||
}
|
||||
|
||||
CompoundStatement::reverse_body_iterator CompoundStatement::body_rend()
|
||||
{
|
||||
return _body.rend();
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <vector>
|
||||
|
||||
#include "Statement.hpp"
|
||||
#include "../Statement.hpp"
|
||||
|
||||
class CompoundStatement : public Statement
|
||||
{
|
|
@ -1,4 +1,4 @@
|
|||
#include "Statement/DoStatement.hpp"
|
||||
#include "DoStatement.h"
|
||||
|
||||
DoStatement::DoStatement(Statement *body, Expr *cond, SourceLocation DL, SourceLocation WL):
|
||||
_doLoc(DL),
|
||||
|
@ -11,12 +11,12 @@ DoStatement::DoStatement(Statement *body, Expr *cond, SourceLocation DL, SourceL
|
|||
|
||||
Expr *DoStatement::getCond()
|
||||
{
|
||||
return reinterpret_cast<Expr *>(_subStmts[COND]);
|
||||
return reinterpret_cast<Expr *>(_subStmts.at(COND));
|
||||
}
|
||||
|
||||
const Expr *DoStatement::getCond() const
|
||||
{
|
||||
return reinterpret_cast<Expr *>(_subStmts[COND]);
|
||||
return reinterpret_cast<Expr *>(_subStmts.at(COND));
|
||||
}
|
||||
|
||||
void DoStatement::setCond(Expr *e)
|
||||
|
@ -31,7 +31,7 @@ Statement *DoStatement::getBody()
|
|||
|
||||
const Statement *DoStatement::getBody() const
|
||||
{
|
||||
return _subStmts[BODY];
|
||||
return _subStmts.at(BODY);
|
||||
}
|
||||
|
||||
void DoStatement::setBody(Statement *s)
|
|
@ -1,10 +1,11 @@
|
|||
#ifndef DOSTATEMENT_HPP
|
||||
#define DOSTATEMENT_HPP
|
||||
|
||||
#include "Statement.hpp"
|
||||
#include "Expr.hpp"
|
||||
#include "SourceLocation.hpp"
|
||||
#include <map>
|
||||
|
||||
#include "../Statement.hpp"
|
||||
#include "Expr.hpp"
|
||||
#include "../SourceLocation.hpp"
|
||||
|
||||
class DoStatement : public Statement
|
||||
{
|
|
@ -0,0 +1 @@
|
|||
#include "Expr.hpp"
|
|
@ -0,0 +1,11 @@
|
|||
#ifndef EXPRSTATEMENT_HPP
|
||||
#define EXPRSTATEMENT_HPP
|
||||
|
||||
#include "../Statement.hpp"
|
||||
|
||||
class Expr : public Statement
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,16 @@
|
|||
#include "FloatLiteralExpr.h"
|
||||
|
||||
FloatLiteralExpr::FloatLiteralExpr(float value, SourceLocation l): NumberLiteralExpr(l),
|
||||
_value(value)
|
||||
{
|
||||
}
|
||||
|
||||
float FloatLiteralExpr::getValue() const
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
void FloatLiteralExpr::setValue(float v)
|
||||
{
|
||||
_value = v;
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
#ifndef BLANG_FLOATLITERALEXPR_H
|
||||
#define BLANG_FLOATLITERALEXPR_H
|
||||
|
||||
#include "NumberLiteralExpr.h"
|
||||
|
||||
class FloatLiteralExpr: public NumberLiteralExpr
|
||||
{
|
||||
public:
|
||||
FloatLiteralExpr(float value, SourceLocation);
|
||||
|
||||
float getValue() const;
|
||||
void setValue(float);
|
||||
|
||||
private:
|
||||
float _value;
|
||||
};
|
||||
|
||||
|
||||
#endif //BLANG_FLOATLITERALEXPR_H
|
|
@ -1,5 +1,5 @@
|
|||
#include <Statement/Expr.hpp>
|
||||
#include "Statement/ForStatement.hpp"
|
||||
#include "Expr.hpp"
|
||||
#include "ForStatement.h"
|
||||
|
||||
ForStatement::ForStatement(SourceLocation forLocation, AssignStatement *init, Expr *cond, Statement *body,
|
||||
Expr *inc):
|
||||
|
@ -15,12 +15,12 @@ ForStatement::ForStatement(SourceLocation forLocation, AssignStatement *init, Ex
|
|||
|
||||
AssignStatement *ForStatement::getInit()
|
||||
{
|
||||
return reinterpret_cast<AssignStatement *>(_subStmts[INIT]);
|
||||
return reinterpret_cast<AssignStatement *>(_subStmts.at(INIT));
|
||||
}
|
||||
|
||||
const AssignStatement *ForStatement::getInit() const
|
||||
{
|
||||
return reinterpret_cast<AssignStatement *>(_subStmts[INIT]);
|
||||
return reinterpret_cast<AssignStatement *>(_subStmts.at(INIT));
|
||||
}
|
||||
|
||||
void ForStatement::setInit(AssignStatement *init)
|
||||
|
@ -30,12 +30,12 @@ void ForStatement::setInit(AssignStatement *init)
|
|||
|
||||
Expr *ForStatement::getCond()
|
||||
{
|
||||
return reinterpret_cast<Expr *>(_subStmts[COND]);
|
||||
return reinterpret_cast<Expr *>(_subStmts.at(COND));
|
||||
}
|
||||
|
||||
const Expr *ForStatement::getCond() const
|
||||
{
|
||||
return reinterpret_cast<Expr *>(_subStmts[COND]);
|
||||
return reinterpret_cast<Expr *>(_subStmts.at(COND));
|
||||
}
|
||||
|
||||
void ForStatement::setCond(Expr *cond)
|
||||
|
@ -45,12 +45,12 @@ void ForStatement::setCond(Expr *cond)
|
|||
|
||||
Expr *ForStatement::getInc()
|
||||
{
|
||||
return reinterpret_cast<Expr *>(_subStmts[INC]);
|
||||
return reinterpret_cast<Expr *>(_subStmts.at(INC));
|
||||
}
|
||||
|
||||
const Expr *ForStatement::getInc() const
|
||||
{
|
||||
return reinterpret_cast<Expr *>(_subStmts[INC]);
|
||||
return reinterpret_cast<Expr *>(_subStmts.at(INC));
|
||||
}
|
||||
|
||||
void ForStatement::setInc(Expr *inc)
|
||||
|
@ -60,12 +60,12 @@ void ForStatement::setInc(Expr *inc)
|
|||
|
||||
Statement *ForStatement::getBody()
|
||||
{
|
||||
return _subStmts[BODY];
|
||||
return _subStmts.at(BODY);
|
||||
}
|
||||
|
||||
const Statement *ForStatement::getBody() const
|
||||
{
|
||||
return _subStmts[BODY];
|
||||
return _subStmts.at(BODY);
|
||||
}
|
||||
|
||||
void ForStatement::setBody(Statement *body)
|
|
@ -1,9 +1,11 @@
|
|||
#ifndef FORSTATEMENT_HPP
|
||||
#define FORSTATEMENT_HPP
|
||||
|
||||
#include "Statement.hpp"
|
||||
#include "SourceLocation.hpp"
|
||||
#include "AssignStatement.hpp"
|
||||
#include <map>
|
||||
|
||||
#include "../Statement.hpp"
|
||||
#include "../SourceLocation.hpp"
|
||||
#include "AssignStatement.h"
|
||||
|
||||
|
||||
class ForStatement : public Statement
|
|
@ -1,4 +1,4 @@
|
|||
#include "Statement/GotoStatement.hpp"
|
||||
#include "GotoStatement.h"
|
||||
|
||||
GotoStatement::GotoStatement(LabelDecl* label, SourceLocation gl, SourceLocation ll):
|
||||
_label(label),
|
||||
|
@ -34,12 +34,13 @@ void GotoStatement::setGotoLocation(SourceLocation loc)
|
|||
|
||||
SourceLocation GotoStatement::getLabelLocation() const
|
||||
{
|
||||
if (_Label)
|
||||
return _Label->getLabelLocation();
|
||||
if (_label)
|
||||
return _label->getLabelLocation();
|
||||
return SourceLocation();
|
||||
}
|
||||
|
||||
void GotoStatement::setLabelLocation(SourceLocation loc)
|
||||
{
|
||||
if (_Label)
|
||||
return _Label->setLabelLocation(loc);
|
||||
if (_label)
|
||||
_label->setLabelLocation(loc);
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef GOTOSTATEMENT_HPP
|
||||
#define GOTOSTATEMENT_HPP
|
||||
|
||||
#include "Statement.hpp"
|
||||
#include "LabelStatement.hpp"
|
||||
#include "SourceLocation.hpp"
|
||||
#include "../Statement.hpp"
|
||||
#include "LabelStatement.h"
|
||||
#include "../SourceLocation.hpp"
|
||||
|
||||
|
||||
class GotoStatement : public Statement
|
||||
|
@ -11,9 +11,9 @@ class GotoStatement : public Statement
|
|||
public:
|
||||
GotoStatement(LabelDecl* label, SourceLocation gl, SourceLocation ll);
|
||||
|
||||
LabelDecl *getLabel();
|
||||
/*LabelDecl *getLabel();
|
||||
const LabelDecl *getLabel() const;
|
||||
void setLabel(LabelDecl *);
|
||||
void setLabel(LabelDecl *);*/
|
||||
|
||||
SourceLocation getGotoLocation() const;
|
||||
void setGotoLocation(SourceLocation);
|
|
@ -1,6 +1,6 @@
|
|||
#include "Statement/IfStatement.hpp"
|
||||
#include "IfStatement.h"
|
||||
|
||||
IfStatement::IfStatement(SourceLocation IfLocation, Expr* cond, Statement* then, SourceLocation ElseLocation = SourceLocation(), Statement* elses = NULL):
|
||||
IfStatement::IfStatement(SourceLocation IfLocation, Expr* cond, Statement* then, SourceLocation ElseLocation, Statement* elses):
|
||||
_IfLoc(IfLocation),
|
||||
_ElseLoc(ElseLocation)
|
||||
{
|
||||
|
@ -14,12 +14,12 @@ IfStatement::IfStatement(SourceLocation IfLocation, Expr* cond, Statement* then,
|
|||
|
||||
Expr* IfStatement::getCond()
|
||||
{
|
||||
return reinterpret_cast<Expr *>(_subStmts[COND]);
|
||||
return reinterpret_cast<Expr *>(_subStmts.at(COND));
|
||||
}
|
||||
|
||||
const Expr *IfStatement::getCond() const
|
||||
{
|
||||
return reinterpret_cast<Expr *>(_subStmts[COND]);
|
||||
return reinterpret_cast<Expr *>(_subStmts.at(COND));
|
||||
}
|
||||
|
||||
void IfStatement::setCond(Expr *e)
|
||||
|
@ -29,13 +29,12 @@ void IfStatement::setCond(Expr *e)
|
|||
|
||||
Statement *IfStatement::getThen()
|
||||
{
|
||||
return _subStmts[THEN];
|
||||
return _subStmts.at(THEN);
|
||||
}
|
||||
|
||||
const Statement *IfStatement::getThen() const
|
||||
{
|
||||
SourceLocation getThenLocation() const;
|
||||
void setThenLocation(SourceLocation);
|
||||
return _subStmts.at(THEN);
|
||||
}
|
||||
|
||||
void IfStatement::setThen(Statement *s)
|
||||
|
@ -45,12 +44,12 @@ void IfStatement::setThen(Statement *s)
|
|||
|
||||
Statement *IfStatement::getElse()
|
||||
{
|
||||
return _subStmts[ELSE];
|
||||
return _subStmts.at(ELSE);
|
||||
}
|
||||
|
||||
const Statement *IfStatement::getElse() const
|
||||
{
|
||||
return _subStmts[ELSE];
|
||||
return _subStmts.at(ELSE);
|
||||
}
|
||||
|
||||
void IfStatement::setElse(Statement *s)
|
|
@ -3,19 +3,19 @@
|
|||
|
||||
#include <map>
|
||||
|
||||
#include "Statement.hpp"
|
||||
#include "../Statement.hpp"
|
||||
#include "Expr.hpp"
|
||||
#include "SourceLocation.hpp"
|
||||
#include "../SourceLocation.hpp"
|
||||
|
||||
class IfStatement : public Statement
|
||||
{
|
||||
|
||||
public:
|
||||
IfStatement(SourceLocation IfLocation, Expr* cond, Statement* then, SourceLocation EL = SourceLocation(), Statement* elses);
|
||||
IfStatement(SourceLocation IfLocation, Expr* cond, Statement* then, SourceLocation EL = SourceLocation(), Statement* elses = NULL);
|
||||
|
||||
ExprStatement* getCond();
|
||||
const ExprStatement *getCond() const;
|
||||
void setCond(ExprStatement *);
|
||||
Expr* getCond();
|
||||
const Expr *getCond() const;
|
||||
void setCond(Expr *);
|
||||
|
||||
Statement *getThen();
|
||||
const Statement *getThen() const;
|
|
@ -0,0 +1,16 @@
|
|||
#include "IntegerLiteralExpr.h"
|
||||
|
||||
IntegerLiteralExpr::IntegerLiteralExpr(int value, SourceLocation l): NumberLiteralExpr(l),
|
||||
_value(value)
|
||||
{
|
||||
}
|
||||
|
||||
int IntegerLiteralExpr::getValue() const
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
void IntegerLiteralExpr::setValue(int v)
|
||||
{
|
||||
_value = v;
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
#ifndef BLANG_INTEGERLITERALEXPR_H
|
||||
#define BLANG_INTEGERLITERALEXPR_H
|
||||
|
||||
#include "NumberLiteralExpr.h"
|
||||
|
||||
class IntegerLiteralExpr: public NumberLiteralExpr
|
||||
{
|
||||
public:
|
||||
IntegerLiteralExpr(int value, SourceLocation);
|
||||
|
||||
int getValue() const;
|
||||
void setValue(int);
|
||||
|
||||
private:
|
||||
int _value;
|
||||
};
|
||||
|
||||
|
||||
#endif //BLANG_INTEGERLITERALEXPR_H
|
|
@ -1,4 +1,4 @@
|
|||
#include "Statement/LabelStatement.hpp"
|
||||
#include "LabelStatement.h"
|
||||
|
||||
LabelStatement::LabelStatement(SourceLocation ll, LabelDecl* decl):
|
||||
_decl(decl),
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef LABELSTATEMENT_HPP
|
||||
#define LABELSTATEMENT_HPP
|
||||
|
||||
#include "Statement.hpp"
|
||||
#include "../Statement.hpp"
|
||||
#include "Expr.hpp"
|
||||
#include "SourceLocation.hpp"
|
||||
#include "../SourceLocation.hpp"
|
||||
|
||||
|
||||
class LabelStatement : public Statement
|
|
@ -0,0 +1,13 @@
|
|||
#include "NumberLiteralExpr.h"
|
||||
|
||||
NumberLiteralExpr::NumberLiteralExpr(SourceLocation l):
|
||||
_l(l)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SourceLocation NumberLiteralExpr::getLocation() const
|
||||
{
|
||||
return _l;
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
#ifndef BLANG_NUMBERLITERALEXPR_H
|
||||
#define BLANG_NUMBERLITERALEXPR_H
|
||||
|
||||
#include "Expr.hpp"
|
||||
|
||||
class NumberLiteralExpr: public Expr
|
||||
{
|
||||
public:
|
||||
NumberLiteralExpr(SourceLocation l);
|
||||
SourceLocation getLocation() const;
|
||||
|
||||
protected:
|
||||
SourceLocation _l;
|
||||
};
|
||||
|
||||
|
||||
#endif //BLANG_NUMBERLITERALEXPR_H
|
|
@ -35,5 +35,4 @@ BINARY_OPERATION(GE, ">=")
|
|||
BINARY_OPERATION(EQ, "=")
|
||||
BINARY_OPERATION(NE, "!=")
|
||||
|
||||
#undef CAST_OPERATION
|
||||
#undef BINARY_OPERATION
|
|
@ -0,0 +1,16 @@
|
|||
#include "ReturnStatement.h"
|
||||
|
||||
ReturnStatement::ReturnStatement(SourceLocation l):
|
||||
_returnLocation(l)
|
||||
{
|
||||
}
|
||||
|
||||
SourceLocation ReturnStatement::getReturnLocation() const
|
||||
{
|
||||
return _returnLocation;
|
||||
}
|
||||
|
||||
void ReturnStatement::setReturnLocation(SourceLocation l)
|
||||
{
|
||||
_returnLocation = l;
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
#ifndef RETURNSTATEMENT_HPP
|
||||
#define RETURNSTATEMENT_HPP
|
||||
|
||||
#include "../Statement.hpp"
|
||||
#include "../SourceLocation.hpp"
|
||||
|
||||
|
||||
class ReturnStatement : public Statement
|
||||
{
|
||||
public:
|
||||
ReturnStatement(SourceLocation l);
|
||||
|
||||
SourceLocation getReturnLocation() const;
|
||||
void setReturnLocation(SourceLocation);
|
||||
|
||||
private:
|
||||
SourceLocation _returnLocation;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1 @@
|
|||
#include "StopStatement.h"
|
|
@ -0,0 +1,11 @@
|
|||
#ifndef BLANG_STOPSTATEMENT_H
|
||||
#define BLANG_STOPSTATEMENT_H
|
||||
|
||||
|
||||
class StopStatement
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //BLANG_STOPSTATEMENT_H
|
|
@ -0,0 +1 @@
|
|||
#include "StringLiteralExpr.h"
|
|
@ -1,8 +1,9 @@
|
|||
#ifndef BLANG_STRINGLITERALEXPR_H
|
||||
#define BLANG_STRINGLITERALEXPR_H
|
||||
|
||||
#include "Expr.hpp"
|
||||
|
||||
class StringLiteralExpr
|
||||
class StringLiteralExpr: public Expr
|
||||
{
|
||||
public:
|
||||
StringLiteralExpr(std::string str, SourceLocation loc);
|
|
@ -0,0 +1,48 @@
|
|||
#include "WhileStatement.h"
|
||||
|
||||
WhileStatement::WhileStatement(Expr *cond, Statement *body, SourceLocation wl):
|
||||
_whileLoc(wl)
|
||||
{
|
||||
_subStmts[COND] = cond;
|
||||
_subStmts[BODY] = body;
|
||||
}
|
||||
|
||||
Expr *WhileStatement::getCond()
|
||||
{
|
||||
return reinterpret_cast<Expr *>(_subStmts.at(COND));
|
||||
}
|
||||
|
||||
const Expr *WhileStatement::getCond() const
|
||||
{
|
||||
return reinterpret_cast<Expr *>(_subStmts.at(COND));
|
||||
}
|
||||
|
||||
void WhileStatement::setCond(Expr *e)
|
||||
{
|
||||
_subStmts[COND] = reinterpret_cast<Statement *>(e);
|
||||
}
|
||||
|
||||
Statement *WhileStatement::getBody()
|
||||
{
|
||||
return _subStmts.at(BODY);
|
||||
}
|
||||
|
||||
const Statement *WhileStatement::getBody() const
|
||||
{
|
||||
return _subStmts.at(BODY);
|
||||
}
|
||||
|
||||
void WhileStatement::setBody(Statement *s)
|
||||
{
|
||||
_subStmts[BODY] = s;
|
||||
}
|
||||
|
||||
SourceLocation WhileStatement::getWhileLocation() const
|
||||
{
|
||||
return _whileLoc;
|
||||
}
|
||||
|
||||
void WhileStatement::setWhileLocation(SourceLocation loc)
|
||||
{
|
||||
_whileLoc = loc;
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
#ifndef WHILESTATEMENT_HPP
|
||||
#define WHILESTATEMENT_HPP
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "../Statement.hpp"
|
||||
#include "Expr.hpp"
|
||||
#include "../SourceLocation.hpp"
|
||||
|
||||
class WhileStatement : public Statement
|
||||
{
|
||||
|
||||
public:
|
||||
WhileStatement(Expr* cond, Statement* body, SourceLocation wl);
|
||||
|
||||
Expr *getCond();
|
||||
const Expr *getCond() const;
|
||||
void setCond(Expr *);
|
||||
|
||||
Statement *getBody();
|
||||
const Statement *getBody() const;
|
||||
void setBody(Statement *);
|
||||
|
||||
SourceLocation getWhileLocation() const;
|
||||
void setWhileLocation(SourceLocation);
|
||||
|
||||
private:
|
||||
SourceLocation _whileLoc;
|
||||
enum StmtIdentifier
|
||||
{
|
||||
COND, BODY
|
||||
};
|
||||
std::map<StmtIdentifier, Statement*> _subStmts;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,20 @@
|
|||
#ifndef STATEMENTS
|
||||
#define STATEMENTS
|
||||
|
||||
#include "Statement/AssignStatement.h"
|
||||
#include "Statement/BinaryOperatorExpr.h"
|
||||
#include "Statement/BreakStatement.h"
|
||||
#include "Statement/CallExpr.h"
|
||||
#include "Statement/CompoundStatement.h"
|
||||
#include "Statement/DoStatement.h"
|
||||
#include "Statement/ForStatement.h"
|
||||
#include "Statement/GotoStatement.h"
|
||||
#include "Statement/IfStatement.h"
|
||||
#include "Statement/LabelStatement.h"
|
||||
#include "Statement/NumberLiteralExpr.h"
|
||||
#include "Statement/ReturnStatement.h"
|
||||
#include "Statement/StopStatement.h"
|
||||
#include "Statement/StringLiteralExpr.h"
|
||||
#include "Statement/WhileStatement.h"
|
||||
|
||||
#endif
|
|
@ -0,0 +1,49 @@
|
|||
%{
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "Token.hpp"
|
||||
#include "parser_gen.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
%}
|
||||
|
||||
%option noyywrap
|
||||
|
||||
integer [0-9]+
|
||||
real [0-9]+\.[0-9]*|\.[0-9]+
|
||||
operator "+"|"-"|"/"|"*"|">"|"<"|"<="|">="|"="|"!="
|
||||
ident [a-zA-Z_][0-9a-zA-Z_]*
|
||||
string \"[^\n"]+\"
|
||||
%%
|
||||
|
||||
{integer} { return(INTEGER); }
|
||||
{real} { return(FLOAT); }
|
||||
{string} { return(STRING); }
|
||||
{operator} { return(DO) }
|
||||
"->" { return(ASSIGN); }
|
||||
"=>" { return(IMPLIES); }
|
||||
"Do" { return(DO); }
|
||||
"LpWhile" { return(LPWHILE); }
|
||||
"While" { return(WHILE); }
|
||||
"WhileEnd" { return(WHILEEND); }
|
||||
"If" { return(IF); }
|
||||
"Then" { return(THEN); }
|
||||
"Else" { return(ELSE); }
|
||||
"IfEnd" { return(IFEND); }
|
||||
"For" { return(FOR); }
|
||||
"To" { return(TO); }
|
||||
"Step" { return(STEP); }
|
||||
"Next" { return(NEXT); }
|
||||
"Goto" { return(GOTO); }
|
||||
"Lbl" { return(LABEL); }
|
||||
"Break" { return(BREAK); }
|
||||
"Return" { return(RETURN); }
|
||||
"Stop" { return(STOP); }
|
||||
{ident} { return(IDENTIFIER); }
|
||||
"\n" { return(EOL); }
|
||||
[ \t]+
|
||||
. { cerr << "Invalid character: " << yytext << endl; }
|
||||
|
||||
%%
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,192 @@
|
|||
// A Bison parser, made by GNU Bison 3.0.4.
|
||||
|
||||
// Locations for Bison parsers in C++
|
||||
|
||||
// Copyright (C) 2002-2015 Free Software Foundation, Inc.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// As a special exception, you may create a larger work that contains
|
||||
// part or all of the Bison parser skeleton and distribute that work
|
||||
// under terms of your choice, so long as that work isn't itself a
|
||||
// parser generator using the skeleton or a modified version thereof
|
||||
// as a parser skeleton. Alternatively, if you modify or redistribute
|
||||
// the parser skeleton itself, you may (at your option) remove this
|
||||
// special exception, which will cause the skeleton and the resulting
|
||||
// Bison output files to be licensed under the GNU General Public
|
||||
// License without this special exception.
|
||||
|
||||
// This special exception was added by the Free Software Foundation in
|
||||
// version 2.2 of Bison.
|
||||
|
||||
/**
|
||||
** \file lib/location.hh
|
||||
** Define the yy::location class.
|
||||
*/
|
||||
|
||||
#ifndef YY_YY_LIB_LOCATION_HH_INCLUDED
|
||||
# define YY_YY_LIB_LOCATION_HH_INCLUDED
|
||||
|
||||
# include "position.hh"
|
||||
|
||||
|
||||
namespace yy {
|
||||
#line 46 "lib/location.hh" // location.cc:296
|
||||
/// Abstract a location.
|
||||
class location
|
||||
{
|
||||
public:
|
||||
|
||||
/// Construct a location from \a b to \a e.
|
||||
location (const position& b, const position& e)
|
||||
: begin (b)
|
||||
, end (e)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a 0-width location in \a p.
|
||||
explicit location (const position& p = position ())
|
||||
: begin (p)
|
||||
, end (p)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a 0-width location in \a f, \a l, \a c.
|
||||
explicit location (std::string* f,
|
||||
unsigned int l = 1u,
|
||||
unsigned int c = 1u)
|
||||
: begin (f, l, c)
|
||||
, end (f, l, c)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/// Initialization.
|
||||
void initialize (std::string* f = YY_NULLPTR,
|
||||
unsigned int l = 1u,
|
||||
unsigned int c = 1u)
|
||||
{
|
||||
begin.initialize (f, l, c);
|
||||
end = begin;
|
||||
}
|
||||
|
||||
/** \name Line and Column related manipulators
|
||||
** \{ */
|
||||
public:
|
||||
/// Reset initial location to final location.
|
||||
void step ()
|
||||
{
|
||||
begin = end;
|
||||
}
|
||||
|
||||
/// Extend the current location to the COUNT next columns.
|
||||
void columns (int count = 1)
|
||||
{
|
||||
end += count;
|
||||
}
|
||||
|
||||
/// Extend the current location to the COUNT next lines.
|
||||
void lines (int count = 1)
|
||||
{
|
||||
end.lines (count);
|
||||
}
|
||||
/** \} */
|
||||
|
||||
|
||||
public:
|
||||
/// Beginning of the located region.
|
||||
position begin;
|
||||
/// End of the located region.
|
||||
position end;
|
||||
};
|
||||
|
||||
/// Join two locations, in place.
|
||||
inline location& operator+= (location& res, const location& end)
|
||||
{
|
||||
res.end = end.end;
|
||||
return res;
|
||||
}
|
||||
|
||||
/// Join two locations.
|
||||
inline location operator+ (location res, const location& end)
|
||||
{
|
||||
return res += end;
|
||||
}
|
||||
|
||||
/// Add \a width columns to the end position, in place.
|
||||
inline location& operator+= (location& res, int width)
|
||||
{
|
||||
res.columns (width);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// Add \a width columns to the end position.
|
||||
inline location operator+ (location res, int width)
|
||||
{
|
||||
return res += width;
|
||||
}
|
||||
|
||||
/// Subtract \a width columns to the end position, in place.
|
||||
inline location& operator-= (location& res, int width)
|
||||
{
|
||||
return res += -width;
|
||||
}
|
||||
|
||||
/// Subtract \a width columns to the end position.
|
||||
inline location operator- (location res, int width)
|
||||
{
|
||||
return res -= width;
|
||||
}
|
||||
|
||||
/// Compare two location objects.
|
||||
inline bool
|
||||
operator== (const location& loc1, const location& loc2)
|
||||
{
|
||||
return loc1.begin == loc2.begin && loc1.end == loc2.end;
|
||||
}
|
||||
|
||||
/// Compare two location objects.
|
||||
inline bool
|
||||
operator!= (const location& loc1, const location& loc2)
|
||||
{
|
||||
return !(loc1 == loc2);
|
||||
}
|
||||
|
||||
/** \brief Intercept output stream redirection.
|
||||
** \param ostr the destination output stream
|
||||
** \param loc a reference to the location to redirect
|
||||
**
|
||||
** Avoid duplicate information.
|
||||
*/
|
||||
template <typename YYChar>
|
||||
inline std::basic_ostream<YYChar>&
|
||||
operator<< (std::basic_ostream<YYChar>& ostr, const location& loc)
|
||||
{
|
||||
unsigned int end_col = 0 < loc.end.column ? loc.end.column - 1 : 0;
|
||||
ostr << loc.begin;
|
||||
if (loc.end.filename
|
||||
&& (!loc.begin.filename
|
||||
|| *loc.begin.filename != *loc.end.filename))
|
||||
ostr << '-' << loc.end.filename << ':' << loc.end.line << '.' << end_col;
|
||||
else if (loc.begin.line < loc.end.line)
|
||||
ostr << '-' << loc.end.line << '.' << end_col;
|
||||
else if (loc.begin.column < end_col)
|
||||
ostr << '-' << end_col;
|
||||
return ostr;
|
||||
}
|
||||
|
||||
|
||||
} // yy
|
||||
#line 192 "lib/location.hh" // location.cc:296
|
||||
#endif // !YY_YY_LIB_LOCATION_HH_INCLUDED
|
|
@ -0,0 +1,113 @@
|
|||
%{
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
|
||||
#include <Statements>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
int yylex(void);
|
||||
void yyerror(const char * msg);
|
||||
|
||||
std::string filename;
|
||||
SourceLocation createLocation(int line,int column);
|
||||
|
||||
extern FILE * yyin;
|
||||
%}
|
||||
|
||||
%skeleton "lalr1.cc" /* -*- C++ -*- */
|
||||
%require "3.0"
|
||||
%defines
|
||||
|
||||
%define parser_class_name { Parser }
|
||||
%define api.token.constructor
|
||||
%define api.value.type variant
|
||||
%define parse.assert
|
||||
|
||||
%locations
|
||||
|
||||
%define parse.trace
|
||||
%define parse.error verbose
|
||||
|
||||
%left '-' '+'
|
||||
%left '*' '/'
|
||||
|
||||
%token DO LPWHILE
|
||||
%token WHILE WHILEEND
|
||||
%token IF THEN ELSE IFEND
|
||||
%token FOR TO STEP NEXT
|
||||
%token GOTO LABEL
|
||||
%token BREAK RETURN STOP
|
||||
%token <std::string> STRING
|
||||
%token <int> INTEGER;
|
||||
%token <int> FLOAT;
|
||||
%token <std::string> IDENTIFIER
|
||||
%token <std::string> OPERATOR
|
||||
%token ASSIGN IMPLIES EOL
|
||||
|
||||
%start program
|
||||
|
||||
%type <CompoundStatement*> stmtList;
|
||||
%type <Statement*> stmt;
|
||||
%type <IfStatement*> ifStmt;
|
||||
%type <ForStatement*> forStmt;
|
||||
%type <Expr*> expr;
|
||||
%type <AssignStatement*> assignStmt;
|
||||
%%
|
||||
|
||||
program : stmtList
|
||||
;
|
||||
stmtList : stmtList stmt { CompoundStatement* stmt = $1; stmt.setLastStatement($2); $$ = stmt; }
|
||||
| stmt { CompoundStatement* stmt = new CompoundStatement(); stmt.setLastStatement($1); $$ = stmt; }
|
||||
;
|
||||
stmt : assignStmt
|
||||
| ifStmt
|
||||
| WHILE expr EOL stmtList EOL WHILEEND { $$ = new WhileStatement($2, $4, createLocation(@$.first_line, @$.first_column)); }
|
||||
| DO EOL stmtList EOL LPWHILE expr { $$ = new DoStatement($3, $6, createLocation(@1.first_line, @1.first_column), createLocation(@6.first_line, @6.first_column)); }
|
||||
| forStmt
|
||||
| GOTO identifier
|
||||
| LABEL identifier
|
||||
| BREAK { $$ = new BreakStatement(createLocation(@$.first_line, @$.first_column)); }
|
||||
| RETURN { $$ = new ReturnStatement(createLocation(@$.first_line, @$.first_column)); }
|
||||
| STOP { $$ = new StopStatement(createLocation(@$.first_line, @$.first_column)); }
|
||||
| expr
|
||||
;
|
||||
expr : identifier
|
||||
| STRING { $$ = new StringLiteralExpr($1, createLocation(@1.first_line, @1.first_column)); }
|
||||
| INTEGER { $$ = new IntegerLiteralExpr($1, createLocation(@1.first_line, @1.first_column)) }
|
||||
| FLOAT { $$ = new FloatLiteralExpr($1, createLocation(@1.first_line, @1.first_column)) }
|
||||
| expr OPERATOR expr { $$ = new BinaryOperatorExpr($1, $3, BinaryOperatorExpr::getStrOpcode($2)); }
|
||||
;
|
||||
identifier: IDENTIFIER
|
||||
;
|
||||
assignStmt : expr ASSIGN identifier
|
||||
;
|
||||
ifStmt : IF expr EOL THEN EOL stmtList EOL IFEND { $$ = new IfStatement(createLocation(@$.first_line, @$.first_column), $2, $6); }
|
||||
| IF expr EOL THEN EOL stmtList EOL ELSE EOL stmtList EOL IFEND { $$ = new IfStatement(createLocation(@$.first_line, @$.first_column), $2, $6, createLocation(@10.first_line, @10.first_column), $10); }
|
||||
| expr IMPLIES assignStmt { $$ = new IfStatement($1, $3); }
|
||||
;
|
||||
forStmt : FOR assignStmt TO expr EOL stmtList EOL NEXT { $$ = new ForStatement(createLocation(@$.first_line, @$.first_column), $2, $4, $6);}
|
||||
| FOR assignStmt TO expr STEP expr EOL stmtList EOL NEXT { $$ = new ForStatement(createLocation(@$.first_line, @$.first_column), $2, $4, $8, $6);}
|
||||
%%
|
||||
|
||||
void yyerror(const char * msg)
|
||||
{
|
||||
cerr << "line " << lineNumber << ": " << msg << endl;
|
||||
}
|
||||
|
||||
SourceLocation createLocation(int line,int column)
|
||||
{
|
||||
return SourceLocation(filename, line, column);
|
||||
}
|
||||
|
||||
|
||||
AST* parse_str(std::string str)
|
||||
{
|
||||
if(argc>1)
|
||||
yyin=fopen(argv[1],"r"); // check result !!!
|
||||
lineNumber=1;
|
||||
if(!yyparse())
|
||||
cerr << "Success" << endl;
|
||||
return(0);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
#include "TranslationUnit.hpp"
|
||||
#include "../lib/src/TranslationUnit.hpp"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
|
|
@ -33,5 +33,4 @@ function(add_blang_unittest test_name)
|
|||
endfunction()
|
||||
|
||||
add_subdirectory(libblang)
|
||||
add_subdirectory(Lex)
|
||||
add_subdirectory(Mustache)
|
||||
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
If A = ":"
|
||||
|
||||
If A > 0
|
||||
IfEnd
|
||||
If A < 0
|
||||
IfEnd
|
|
@ -1,22 +0,0 @@
|
|||
include_directories(src)
|
||||
|
||||
set(BLANG_UTILS_INCLUDE ${CMAKE_CURRENT_LIST_DIR}/src CACHE STRING "BlangUtils include directory")
|
||||
|
||||
file(
|
||||
|
||||
GLOB_RECURSE
|
||||
|
||||
src_files
|
||||
|
||||
src/*
|
||||
|
||||
)
|
||||
|
||||
add_library(
|
||||
|
||||
blangutils
|
||||
|
||||
SHARED
|
||||
|
||||
${src_files}
|
||||
)
|
|
@ -1,31 +0,0 @@
|
|||
#include <algorithm>
|
||||
|
||||
#include "string.hpp"
|
||||
|
||||
Blang::string::string(): std::string(){
|
||||
|
||||
}
|
||||
|
||||
Blang::string::string(const std::string& str):std::string(str){
|
||||
|
||||
}
|
||||
|
||||
Blang::string::string (const char* s):std::string(s){
|
||||
|
||||
}
|
||||
|
||||
Blang::string Blang::string::ltrim(){
|
||||
Blang::string str = Blang::string(*this);
|
||||
str.erase(str.begin(), std::find_if(str.begin(), str.end(), not1(std::ptr_fun<int, int>(std::isspace))));
|
||||
return str;
|
||||
}
|
||||
|
||||
Blang::string Blang::string::rtrim(){
|
||||
Blang::string str = Blang::string(*this);
|
||||
str.erase(std::find_if(str.rbegin(), str.rend(), not1(std::ptr_fun<int, int>(std::isspace))).base(), str.end());
|
||||
return str;
|
||||
}
|
||||
|
||||
Blang::string Blang::string::trim(){
|
||||
return ltrim().rtrim();
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
#ifndef BLANGSTRING_HPP
|
||||
#define BLANGSTRING_HPP
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <regex>
|
||||
|
||||
namespace Blang{
|
||||
class string : public std::string
|
||||
{
|
||||
public:
|
||||
string();
|
||||
string(const std::string& str);
|
||||
string (const char* s);
|
||||
|
||||
string ltrim();
|
||||
string rtrim();
|
||||
string trim();
|
||||
|
||||
bool startsWith(string str, bool caseSensitive = true);
|
||||
bool startsWith(string str,string splitter, bool caseSensitive = true);
|
||||
bool startsWith(std::list<string> str, bool caseSensitive = true);
|
||||
bool startsWith(std::regex reg, bool caseSensitive = true);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue