Lots of comments and cleanup
This commit is contained in:
parent
120a575b15
commit
1a95fc2371
8 changed files with 351 additions and 518 deletions
|
|
@ -1,8 +1,8 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ContentModelStore">
|
<component name="ContentModelStore">
|
||||||
<e p="$USER_HOME$/.cache/JetBrains/Rider2020.2/extResources" t="IncludeRecursive" />
|
<e p="$USER_HOME$/.cache/JetBrains/Rider2020.3/extResources" t="IncludeRecursive" />
|
||||||
<e p="$USER_HOME$/.cache/JetBrains/Rider2020.2/resharper-host/local/Transient/Rider/v202/SolutionCaches/_Compiler.-1470031901.00" t="ExcludeRecursive" />
|
<e p="$USER_HOME$/.cache/JetBrains/Rider2020.3/resharper-host/local/Transient/Rider/v203/SolutionCaches/_Compiler.-1470031901.00" t="ExcludeRecursive" />
|
||||||
<e p="$PROJECT_DIR$" t="IncludeRecursive">
|
<e p="$PROJECT_DIR$" t="IncludeRecursive">
|
||||||
<e p="Compiler.cs" t="Include" />
|
<e p="Compiler.cs" t="Include" />
|
||||||
<e p="Compiler.csproj" t="IncludeRecursive" />
|
<e p="Compiler.csproj" t="IncludeRecursive" />
|
||||||
|
|
|
||||||
2
Compiler/.idea/.idea.Compiler/.idea/modules.xml
generated
2
Compiler/.idea/.idea.Compiler/.idea/modules.xml
generated
|
|
@ -3,7 +3,7 @@
|
||||||
<component name="ProjectModuleManager">
|
<component name="ProjectModuleManager">
|
||||||
<modules>
|
<modules>
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/.idea.Compiler/.idea/.idea.Compiler.iml" filepath="$PROJECT_DIR$/.idea/.idea.Compiler/.idea/.idea.Compiler.iml" />
|
<module fileurl="file://$PROJECT_DIR$/.idea/.idea.Compiler/.idea/.idea.Compiler.iml" filepath="$PROJECT_DIR$/.idea/.idea.Compiler/.idea/.idea.Compiler.iml" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/.idea.Compiler/riderModule.iml" filepath="$PROJECT_DIR$/.idea/.idea.Compiler/riderModule.iml" />
|
<module fileurl="file://$PROJECT_DIR$/.idea/.idea.Compiler/.idea/riderModule.iml" filepath="$PROJECT_DIR$/.idea/.idea.Compiler/.idea/riderModule.iml" />
|
||||||
</modules>
|
</modules>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
7
Compiler/.idea/.idea.Compiler/.idea/riderModule.iml
generated
Normal file
7
Compiler/.idea/.idea.Compiler/.idea/riderModule.iml
generated
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="RIDER_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$/../.." />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
279
Compiler/.idea/.idea.Compiler/.idea/workspace.xml
generated
279
Compiler/.idea/.idea.Compiler/.idea/workspace.xml
generated
|
|
@ -20,8 +20,11 @@
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="a54bb6de-191c-4bd1-91ab-3953adfc5dfb" name="Default Changelist" comment="">
|
<list default="true" id="a54bb6de-191c-4bd1-91ab-3953adfc5dfb" name="Default Changelist" comment="">
|
||||||
|
<change afterPath="$PROJECT_DIR$/.idea/.idea.Compiler/.idea/riderModule.iml" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/../test.s" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/.idea/.idea.Compiler/.idea/contentModel.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.Compiler/.idea/contentModel.xml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/.idea/.idea.Compiler/.idea/modules.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.Compiler/.idea/modules.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.Compiler/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.Compiler/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/.idea.Compiler/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.Compiler/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Compiler.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Compiler.cs" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/DevFunctions.cs" beforeDir="false" afterPath="$PROJECT_DIR$/DevFunctions.cs" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/DevFunctions.cs" beforeDir="false" afterPath="$PROJECT_DIR$/DevFunctions.cs" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Generator/Generator.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Generator/Generator.cs" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Generator/Generator.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Generator/Generator.cs" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Parser/Parser.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Parser/Parser.cs" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Parser/Parser.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Parser/Parser.cs" afterDir="false" />
|
||||||
|
|
@ -43,81 +46,38 @@
|
||||||
</component>
|
</component>
|
||||||
<component name="HighlightingSettingsPerFile">
|
<component name="HighlightingSettingsPerFile">
|
||||||
<setting file="file://$PROJECT_DIR$/Compiler.cs" root0="FORCE_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/Compiler.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/714153FB-3DE5-4537-8A59-8AE8F7F7655E/44/126d3750/String.cs" root0="SKIP_HIGHLIGHTING" />
|
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/714153FB-3DE5-4537-8A59-8AE8F7F7655E/74/559b3670/String.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
|
<setting file="file://$PROJECT_DIR$/Parser/Nodes/Node.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
|
<setting file="file://$PROJECT_DIR$/Parser/Nodes/NodeType.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/714153FB-3DE5-4537-8A59-8AE8F7F7655E/46/638f55dc/List`1.cs" root0="SKIP_HIGHLIGHTING" />
|
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/714153FB-3DE5-4537-8A59-8AE8F7F7655E/46/638f55dc/List`1.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
|
<setting file="file://$PROJECT_DIR$/Parser/Nodes/ReturnNode.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
|
<setting file="file://$PROJECT_DIR$/Parser/Nodes/ProgramNode.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
|
<setting file="file://$PROJECT_DIR$/Parser/Nodes/FunctionNode.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
|
<setting file="file://$PROJECT_DIR$/Parser/Nodes/ConstantNode.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
|
<setting file="file://$PROJECT_DIR$/Parser/Exceptions/MissingSemicolonException.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
|
<setting file="file://$PROJECT_DIR$/Parser/Exceptions/WrongTypeException.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
|
<setting file="file://$PROJECT_DIR$/Parser/Parser.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
|
<setting file="file://$PROJECT_DIR$/Parser/Exceptions/UnexpectedTokenException.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
|
<setting file="file://$PROJECT_DIR$/Parser/Exceptions/InvalidIdentifierException.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
|
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/714153FB-3DE5-4537-8A59-8AE8F7F7655E/44/126d3750/String.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
|
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/EEDBFCB1-C56E-4F7A-8B60-B8DD27E0DC7D/86/71102cca/Enumerable.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
|
<setting file="file://$PROJECT_DIR$/Lexer/Pattern.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
<setting file="file://$PROJECT_DIR$/Lexer/Lexer.cs" root0="FORCE_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/Lexer/Lexer.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
<setting file="file://$PROJECT_DIR$/Lexer/Token.cs" root0="FORCE_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/Lexer/Token.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/EEDBFCB1-C56E-4F7A-8B60-B8DD27E0DC7D/86/71102cca/Enumerable.cs" root0="SKIP_HIGHLIGHTING" />
|
|
||||||
<setting file="file://$PROJECT_DIR$/Lexer/TokenType.cs" root0="FORCE_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/Lexer/TokenType.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
<setting file="file://$PROJECT_DIR$/Lexer/Pattern.cs" root0="FORCE_HIGHLIGHTING" />
|
|
||||||
<setting file="file://$PROJECT_DIR$/Parser/Parser.cs" root0="FORCE_HIGHLIGHTING" />
|
|
||||||
<setting file="file://$PROJECT_DIR$/Parser/Nodes/ProgramNode.cs" root0="FORCE_HIGHLIGHTING" />
|
|
||||||
<setting file="file://$PROJECT_DIR$/Parser/Nodes/ConstantNode.cs" root0="FORCE_HIGHLIGHTING" />
|
|
||||||
<setting file="file://$PROJECT_DIR$/Parser/Nodes/NodeType.cs" root0="FORCE_HIGHLIGHTING" />
|
|
||||||
<setting file="file://$PROJECT_DIR$/Parser/Nodes/FunctionNode.cs" root0="FORCE_HIGHLIGHTING" />
|
|
||||||
<setting file="file://$PROJECT_DIR$/Parser/Nodes/Node.cs" root0="FORCE_HIGHLIGHTING" />
|
|
||||||
<setting file="file://$PROJECT_DIR$/Parser/Nodes/ReturnNode.cs" root0="FORCE_HIGHLIGHTING" />
|
|
||||||
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/714153FB-3DE5-4537-8A59-8AE8F7F7655E/74/559b3670/String.cs" root0="SKIP_HIGHLIGHTING" />
|
|
||||||
<setting file="file://$PROJECT_DIR$/Parser/Exceptions/UnexpectedTokenException.cs" root0="FORCE_HIGHLIGHTING" />
|
|
||||||
<setting file="file://$PROJECT_DIR$/Parser/Exceptions/WrongTypeException.cs" root0="FORCE_HIGHLIGHTING" />
|
|
||||||
<setting file="file://$PROJECT_DIR$/Parser/Exceptions/InvalidIdentifierException.cs" root0="FORCE_HIGHLIGHTING" />
|
|
||||||
<setting file="file://$PROJECT_DIR$/Parser/Exceptions/MissingSemicolonException.cs" root0="FORCE_HIGHLIGHTING" />
|
|
||||||
</component>
|
</component>
|
||||||
<component name="IdeDocumentHistory">
|
<component name="IdeDocumentHistory">
|
||||||
<option name="CHANGED_PATHS">
|
<changedPaths>
|
||||||
<list>
|
|
||||||
<option value="$PROJECT_DIR$/Compiler/Program.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/Program.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/Tokens.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/Pattern.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/Token.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/TokenType.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/Lexer.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/Parser.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/Lexer/Pattern.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/Parser/LeafType.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/Parser/NodeType.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/Parser/Node.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/Parser/FunctionNode.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/Parser/ConstantNode.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/Parser/ReturnNode.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/Parser/ProgramNode.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/Parser/Nodes/ProgramNode.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/Parser/Exceptions.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/Parser/Nodes/FunctionNode.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/Parser/Exceptions/InvalidIdentifierException.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/Parser/Exceptions/MissingSemicolonException.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/Parser/Exceptions/WronghTypeException.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/Parser/Exceptions/WrongTypeException.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/Lexer/Token.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/Parser/Nodes/Node.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/Parser/Exceptions/MissingTokenException.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/Parser/Exceptions/UnexpectedTokenException.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/t.tt" />
|
|
||||||
<option value="$PROJECT_DIR$/Parser/Nodes/ReturnNode.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/Parser/Nodes/OperatorTypes.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/Parser/Nodes/UnaryOperatorNode.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/Generator/NotSpecifiedException.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/../test.s" />
|
|
||||||
<option value="$PROJECT_DIR$/Lexer/TokenType.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/Lexer/Lexer.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/Parser/Nodes/NodeType.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/Parser/Nodes/BinaryOperatorNode.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/Parser/Nodes/OperatorType.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/Parser/Nodes/ConstantNode.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/../grammar" />
|
|
||||||
<option value="$PROJECT_DIR$/Compiler.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/Parser/Parser.cs" />
|
|
||||||
<option value="$PROJECT_DIR$/DevFunctions.cs" />
|
<option value="$PROJECT_DIR$/DevFunctions.cs" />
|
||||||
<option value="$PROJECT_DIR$/Generator/Generator.cs" />
|
<option value="$PROJECT_DIR$/Parser/Parser.cs" />
|
||||||
</list>
|
</changedPaths>
|
||||||
</option>
|
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectId" id="1g8sEwibYOXRSHf7VBAgyNtiM21" />
|
<component name="ProjectId" id="1g8sEwibYOXRSHf7VBAgyNtiM21" />
|
||||||
<component name="ProjectLevelVcsManager" settingsEditedManually="true">
|
<component name="ProjectLevelVcsManager" settingsEditedManually="true">
|
||||||
<ConfirmationsSetting value="2" id="Add" />
|
<ConfirmationsSetting value="2" id="Add" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectViewState">
|
<component name="ProjectViewState">
|
||||||
|
<option name="autoscrollToSource" value="true" />
|
||||||
<option name="hideEmptyMiddlePackages" value="true" />
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
<option name="showLibraryContents" value="true" />
|
<option name="showLibraryContents" value="true" />
|
||||||
</component>
|
</component>
|
||||||
|
|
@ -132,7 +92,9 @@
|
||||||
<property name="WebServerToolWindowFactoryState" value="false" />
|
<property name="WebServerToolWindowFactoryState" value="false" />
|
||||||
<property name="XThreadsFramesViewSplitterKey" value="0.44757032" />
|
<property name="XThreadsFramesViewSplitterKey" value="0.44757032" />
|
||||||
<property name="last_opened_file_path" value="$PROJECT_DIR$/.." />
|
<property name="last_opened_file_path" value="$PROJECT_DIR$/.." />
|
||||||
|
<property name="nodejs_package_manager_path" value="npm" />
|
||||||
<property name="settings.editor.selected.configurable" value="preferences.pluginManager" />
|
<property name="settings.editor.selected.configurable" value="preferences.pluginManager" />
|
||||||
|
<property name="vue.rearranger.settings.migration" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="RunManager">
|
<component name="RunManager">
|
||||||
<configuration name="Compiler" type="DotNetProject" factoryName=".NET Project">
|
<configuration name="Compiler" type="DotNetProject" factoryName=".NET Project">
|
||||||
|
|
@ -178,6 +140,9 @@
|
||||||
<workItem from="1598123734996" duration="12557000" />
|
<workItem from="1598123734996" duration="12557000" />
|
||||||
<workItem from="1598197309733" duration="2969000" />
|
<workItem from="1598197309733" duration="2969000" />
|
||||||
<workItem from="1598260697761" duration="4427000" />
|
<workItem from="1598260697761" duration="4427000" />
|
||||||
|
<workItem from="1598873360208" duration="3527000" />
|
||||||
|
<workItem from="1608233616774" duration="1881000" />
|
||||||
|
<workItem from="1608235612613" duration="1783000" />
|
||||||
</task>
|
</task>
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
|
|
@ -202,195 +167,7 @@
|
||||||
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
|
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
|
||||||
<option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="true" />
|
<option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="WindowStateProjectService">
|
|
||||||
<state x="2029" y="149" width="738" height="749" key="#Compiler" timestamp="1597507583637">
|
|
||||||
<screen x="1920" y="0" width="1920" height="1080" />
|
|
||||||
</state>
|
|
||||||
<state x="2029" y="149" width="738" height="749" key="#Compiler/1920.0.1920.1080/0.0.1920.1080@1920.0.1920.1080" timestamp="1597507583637" />
|
|
||||||
<state x="2942" y="395" width="193" height="172" key="#Custom_Plugin_Repositories" timestamp="1597932245664">
|
|
||||||
<screen x="1920" y="0" width="1920" height="1080" />
|
|
||||||
</state>
|
|
||||||
<state x="2942" y="395" width="193" height="172" key="#Custom_Plugin_Repositories/1920.0.1920.1080/0.0.1920.1080@1920.0.1920.1080" timestamp="1597932245664" />
|
|
||||||
<state x="2327" y="101" key="#com.intellij.execution.impl.EditConfigurationsDialog" timestamp="1597933234768">
|
|
||||||
<screen x="1920" y="0" width="1920" height="1080" />
|
|
||||||
</state>
|
|
||||||
<state x="2327" y="101" key="#com.intellij.execution.impl.EditConfigurationsDialog/1920.0.1920.1080/0.0.1920.1080@1920.0.1920.1080" timestamp="1597933234768" />
|
|
||||||
<state x="2169" y="170" width="430" height="508" key="FileChooserDialogImpl" timestamp="1597507670532">
|
|
||||||
<screen x="1920" y="0" width="1920" height="1080" />
|
|
||||||
</state>
|
|
||||||
<state x="2169" y="170" width="430" height="508" key="FileChooserDialogImpl/1920.0.1920.1080/0.0.1920.1080@1920.0.1920.1080" timestamp="1597507670532" />
|
|
||||||
<state width="1868" height="383" key="GridCell.Tab.-1.bottom" timestamp="1597955238557">
|
|
||||||
<screen x="1920" y="0" width="1920" height="1080" />
|
|
||||||
</state>
|
|
||||||
<state width="1868" height="383" key="GridCell.Tab.-1.bottom/1920.0.1920.1080/0.0.1920.1080@1920.0.1920.1080" timestamp="1597955238557" />
|
|
||||||
<state width="1868" height="383" key="GridCell.Tab.-1.center" timestamp="1597955238557">
|
|
||||||
<screen x="1920" y="0" width="1920" height="1080" />
|
|
||||||
</state>
|
|
||||||
<state width="1868" height="383" key="GridCell.Tab.-1.center/1920.0.1920.1080/0.0.1920.1080@1920.0.1920.1080" timestamp="1597955238557" />
|
|
||||||
<state width="1868" height="383" key="GridCell.Tab.-1.left" timestamp="1597955238557">
|
|
||||||
<screen x="1920" y="0" width="1920" height="1080" />
|
|
||||||
</state>
|
|
||||||
<state width="1868" height="383" key="GridCell.Tab.-1.left/1920.0.1920.1080/0.0.1920.1080@1920.0.1920.1080" timestamp="1597955238557" />
|
|
||||||
<state width="1868" height="383" key="GridCell.Tab.-1.right" timestamp="1597955238557">
|
|
||||||
<screen x="1920" y="0" width="1920" height="1080" />
|
|
||||||
</state>
|
|
||||||
<state width="1868" height="383" key="GridCell.Tab.-1.right/1920.0.1920.1080/0.0.1920.1080@1920.0.1920.1080" timestamp="1597955238557" />
|
|
||||||
<state width="908" height="239" key="GridCell.Tab.0.bottom" timestamp="1598264325655">
|
|
||||||
<screen x="0" y="0" width="1920" height="1080" />
|
|
||||||
</state>
|
|
||||||
<state width="908" height="239" key="GridCell.Tab.0.bottom/0.0.1920.1080@0.0.1920.1080" timestamp="1598264325655" />
|
|
||||||
<state width="1292" height="330" key="GridCell.Tab.0.bottom/1920.0.1920.1080/0.0.1920.1080@1920.0.1920.1080" timestamp="1598200278840" />
|
|
||||||
<state width="908" height="239" key="GridCell.Tab.0.center" timestamp="1598264325654">
|
|
||||||
<screen x="0" y="0" width="1920" height="1080" />
|
|
||||||
</state>
|
|
||||||
<state width="908" height="239" key="GridCell.Tab.0.center/0.0.1920.1080@0.0.1920.1080" timestamp="1598264325654" />
|
|
||||||
<state width="1292" height="330" key="GridCell.Tab.0.center/1920.0.1920.1080/0.0.1920.1080@1920.0.1920.1080" timestamp="1598200278840" />
|
|
||||||
<state width="908" height="239" key="GridCell.Tab.0.left" timestamp="1598264325654">
|
|
||||||
<screen x="0" y="0" width="1920" height="1080" />
|
|
||||||
</state>
|
|
||||||
<state width="908" height="239" key="GridCell.Tab.0.left/0.0.1920.1080@0.0.1920.1080" timestamp="1598264325654" />
|
|
||||||
<state width="1292" height="330" key="GridCell.Tab.0.left/1920.0.1920.1080/0.0.1920.1080@1920.0.1920.1080" timestamp="1598200278840" />
|
|
||||||
<state width="908" height="239" key="GridCell.Tab.0.right" timestamp="1598264325655">
|
|
||||||
<screen x="0" y="0" width="1920" height="1080" />
|
|
||||||
</state>
|
|
||||||
<state width="908" height="239" key="GridCell.Tab.0.right/0.0.1920.1080@0.0.1920.1080" timestamp="1598264325655" />
|
|
||||||
<state width="1292" height="330" key="GridCell.Tab.0.right/1920.0.1920.1080/0.0.1920.1080@1920.0.1920.1080" timestamp="1598200278840" />
|
|
||||||
<state width="908" height="318" key="GridCell.Tab.1.bottom" timestamp="1598263677978">
|
|
||||||
<screen x="0" y="0" width="1920" height="1080" />
|
|
||||||
</state>
|
|
||||||
<state width="908" height="318" key="GridCell.Tab.1.bottom/0.0.1920.1080@0.0.1920.1080" timestamp="1598263677978" />
|
|
||||||
<state width="1292" height="330" key="GridCell.Tab.1.bottom/1920.0.1920.1080/0.0.1920.1080@1920.0.1920.1080" timestamp="1598200278840" />
|
|
||||||
<state width="908" height="318" key="GridCell.Tab.1.center" timestamp="1598263677978">
|
|
||||||
<screen x="0" y="0" width="1920" height="1080" />
|
|
||||||
</state>
|
|
||||||
<state width="908" height="318" key="GridCell.Tab.1.center/0.0.1920.1080@0.0.1920.1080" timestamp="1598263677978" />
|
|
||||||
<state width="1292" height="330" key="GridCell.Tab.1.center/1920.0.1920.1080/0.0.1920.1080@1920.0.1920.1080" timestamp="1598200278840" />
|
|
||||||
<state width="908" height="318" key="GridCell.Tab.1.left" timestamp="1598263677978">
|
|
||||||
<screen x="0" y="0" width="1920" height="1080" />
|
|
||||||
</state>
|
|
||||||
<state width="908" height="318" key="GridCell.Tab.1.left/0.0.1920.1080@0.0.1920.1080" timestamp="1598263677978" />
|
|
||||||
<state width="1292" height="330" key="GridCell.Tab.1.left/1920.0.1920.1080/0.0.1920.1080@1920.0.1920.1080" timestamp="1598200278840" />
|
|
||||||
<state width="908" height="318" key="GridCell.Tab.1.right" timestamp="1598263677978">
|
|
||||||
<screen x="0" y="0" width="1920" height="1080" />
|
|
||||||
</state>
|
|
||||||
<state width="908" height="318" key="GridCell.Tab.1.right/0.0.1920.1080@0.0.1920.1080" timestamp="1598263677978" />
|
|
||||||
<state width="1292" height="330" key="GridCell.Tab.1.right/1920.0.1920.1080/0.0.1920.1080@1920.0.1920.1080" timestamp="1598200278840" />
|
|
||||||
<state width="908" height="318" key="GridCell.Tab.2.bottom" timestamp="1598263677978">
|
|
||||||
<screen x="0" y="0" width="1920" height="1080" />
|
|
||||||
</state>
|
|
||||||
<state width="908" height="318" key="GridCell.Tab.2.bottom/0.0.1920.1080@0.0.1920.1080" timestamp="1598263677978" />
|
|
||||||
<state width="1292" height="330" key="GridCell.Tab.2.bottom/1920.0.1920.1080/0.0.1920.1080@1920.0.1920.1080" timestamp="1598200278840" />
|
|
||||||
<state width="908" height="318" key="GridCell.Tab.2.center" timestamp="1598263677978">
|
|
||||||
<screen x="0" y="0" width="1920" height="1080" />
|
|
||||||
</state>
|
|
||||||
<state width="908" height="318" key="GridCell.Tab.2.center/0.0.1920.1080@0.0.1920.1080" timestamp="1598263677978" />
|
|
||||||
<state width="1292" height="330" key="GridCell.Tab.2.center/1920.0.1920.1080/0.0.1920.1080@1920.0.1920.1080" timestamp="1598200278840" />
|
|
||||||
<state width="908" height="318" key="GridCell.Tab.2.left" timestamp="1598263677978">
|
|
||||||
<screen x="0" y="0" width="1920" height="1080" />
|
|
||||||
</state>
|
|
||||||
<state width="908" height="318" key="GridCell.Tab.2.left/0.0.1920.1080@0.0.1920.1080" timestamp="1598263677978" />
|
|
||||||
<state width="1292" height="330" key="GridCell.Tab.2.left/1920.0.1920.1080/0.0.1920.1080@1920.0.1920.1080" timestamp="1598200278840" />
|
|
||||||
<state width="908" height="318" key="GridCell.Tab.2.right" timestamp="1598263677978">
|
|
||||||
<screen x="0" y="0" width="1920" height="1080" />
|
|
||||||
</state>
|
|
||||||
<state width="908" height="318" key="GridCell.Tab.2.right/0.0.1920.1080@0.0.1920.1080" timestamp="1598263677978" />
|
|
||||||
<state width="1292" height="330" key="GridCell.Tab.2.right/1920.0.1920.1080/0.0.1920.1080@1920.0.1920.1080" timestamp="1598200278840" />
|
|
||||||
<state width="908" height="318" key="GridCell.Tab.3.bottom" timestamp="1598263677979">
|
|
||||||
<screen x="0" y="0" width="1920" height="1080" />
|
|
||||||
</state>
|
|
||||||
<state width="908" height="318" key="GridCell.Tab.3.bottom/0.0.1920.1080@0.0.1920.1080" timestamp="1598263677979" />
|
|
||||||
<state width="1292" height="330" key="GridCell.Tab.3.bottom/1920.0.1920.1080/0.0.1920.1080@1920.0.1920.1080" timestamp="1598200278840" />
|
|
||||||
<state width="908" height="318" key="GridCell.Tab.3.center" timestamp="1598263677979">
|
|
||||||
<screen x="0" y="0" width="1920" height="1080" />
|
|
||||||
</state>
|
|
||||||
<state width="908" height="318" key="GridCell.Tab.3.center/0.0.1920.1080@0.0.1920.1080" timestamp="1598263677979" />
|
|
||||||
<state width="1292" height="330" key="GridCell.Tab.3.center/1920.0.1920.1080/0.0.1920.1080@1920.0.1920.1080" timestamp="1598200278840" />
|
|
||||||
<state width="908" height="318" key="GridCell.Tab.3.left" timestamp="1598263677979">
|
|
||||||
<screen x="0" y="0" width="1920" height="1080" />
|
|
||||||
</state>
|
|
||||||
<state width="908" height="318" key="GridCell.Tab.3.left/0.0.1920.1080@0.0.1920.1080" timestamp="1598263677979" />
|
|
||||||
<state width="1292" height="330" key="GridCell.Tab.3.left/1920.0.1920.1080/0.0.1920.1080@1920.0.1920.1080" timestamp="1598200278840" />
|
|
||||||
<state width="908" height="318" key="GridCell.Tab.3.right" timestamp="1598263677979">
|
|
||||||
<screen x="0" y="0" width="1920" height="1080" />
|
|
||||||
</state>
|
|
||||||
<state width="908" height="318" key="GridCell.Tab.3.right/0.0.1920.1080@0.0.1920.1080" timestamp="1598263677979" />
|
|
||||||
<state width="1292" height="330" key="GridCell.Tab.3.right/1920.0.1920.1080/0.0.1920.1080@1920.0.1920.1080" timestamp="1598200278840" />
|
|
||||||
<state width="1868" height="383" key="GridCell.Tab.4.bottom" timestamp="1597955234640">
|
|
||||||
<screen x="1920" y="0" width="1920" height="1080" />
|
|
||||||
</state>
|
|
||||||
<state width="1868" height="383" key="GridCell.Tab.4.bottom/1920.0.1920.1080/0.0.1920.1080@1920.0.1920.1080" timestamp="1597955234640" />
|
|
||||||
<state width="1868" height="383" key="GridCell.Tab.4.center" timestamp="1597955234640">
|
|
||||||
<screen x="1920" y="0" width="1920" height="1080" />
|
|
||||||
</state>
|
|
||||||
<state width="1868" height="383" key="GridCell.Tab.4.center/1920.0.1920.1080/0.0.1920.1080@1920.0.1920.1080" timestamp="1597955234640" />
|
|
||||||
<state width="1868" height="383" key="GridCell.Tab.4.left" timestamp="1597955234640">
|
|
||||||
<screen x="1920" y="0" width="1920" height="1080" />
|
|
||||||
</state>
|
|
||||||
<state width="1868" height="383" key="GridCell.Tab.4.left/1920.0.1920.1080/0.0.1920.1080@1920.0.1920.1080" timestamp="1597955234640" />
|
|
||||||
<state width="1868" height="383" key="GridCell.Tab.4.right" timestamp="1597955234640">
|
|
||||||
<screen x="1920" y="0" width="1920" height="1080" />
|
|
||||||
</state>
|
|
||||||
<state width="1868" height="383" key="GridCell.Tab.4.right/1920.0.1920.1080/0.0.1920.1080@1920.0.1920.1080" timestamp="1597955234640" />
|
|
||||||
<state x="631" y="291" width="806" height="524" key="Rider.ProjectTemplateDialog.Size" timestamp="1597872082099">
|
|
||||||
<screen x="0" y="0" width="1920" height="1080" />
|
|
||||||
</state>
|
|
||||||
<state x="631" y="291" width="806" height="524" key="Rider.ProjectTemplateDialog.Size/1920.0.1920.1080/0.0.1920.1080@1920.0.1920.1080" timestamp="1597872082099" />
|
|
||||||
<state x="2315" y="-106" width="709" height="485" key="RiderGenerateDialog" timestamp="1598127182892">
|
|
||||||
<screen x="1920" y="0" width="1920" height="1080" />
|
|
||||||
</state>
|
|
||||||
<state x="2315" y="-106" width="709" height="485" key="RiderGenerateDialog/1920.0.1920.1080/0.0.1920.1080@1920.0.1920.1080" timestamp="1598127182892" />
|
|
||||||
<state x="2525" y="135" width="1031" height="724" key="SettingsEditor" timestamp="1597932248704">
|
|
||||||
<screen x="1920" y="0" width="1920" height="1080" />
|
|
||||||
</state>
|
|
||||||
<state x="2525" y="135" width="1031" height="724" key="SettingsEditor/1920.0.1920.1080/0.0.1920.1080@1920.0.1920.1080" timestamp="1597932248704" />
|
|
||||||
<state x="2560" y="0" width="640" height="1080" key="VCS.FileHistoryDialog" timestamp="1597605666894">
|
|
||||||
<screen x="1920" y="0" width="1920" height="1080" />
|
|
||||||
</state>
|
|
||||||
<state x="2560" y="0" width="640" height="1080" key="VCS.FileHistoryDialog/1920.0.1920.1080/0.0.1920.1080@1920.0.1920.1080" timestamp="1597605666894" />
|
|
||||||
<state width="480" height="540" key="XDebugger.FullValuePopup" timestamp="1597698247338">
|
|
||||||
<screen x="1920" y="0" width="1920" height="1080" />
|
|
||||||
</state>
|
|
||||||
<state width="480" height="540" key="XDebugger.FullValuePopup/1920.0.1920.1080/0.0.1920.1080@1920.0.1920.1080" timestamp="1597698247338" />
|
|
||||||
<state x="2182" y="199" width="432" height="650" key="com.intellij.openapi.editor.actions.MultiplePasteAction$ClipboardContentChooser" timestamp="1597510086756">
|
|
||||||
<screen x="1920" y="0" width="1920" height="1080" />
|
|
||||||
</state>
|
|
||||||
<state x="2182" y="199" width="432" height="650" key="com.intellij.openapi.editor.actions.MultiplePasteAction$ClipboardContentChooser/1920.0.1920.1080/0.0.1920.1080@1920.0.1920.1080" timestamp="1597510086756" />
|
|
||||||
<state x="3264" y="0" width="576" height="1080" key="dock-window-1" timestamp="1598199648208">
|
|
||||||
<screen x="1920" y="0" width="1920" height="1080" />
|
|
||||||
</state>
|
|
||||||
<state x="3264" y="0" width="576" height="1080" key="dock-window-1/1920.0.1920.1080/0.0.1920.1080@1920.0.1920.1080" timestamp="1598199648208" />
|
|
||||||
<state x="3200" y="0" width="640" height="1080" key="dock-window-2" timestamp="1597959520918">
|
|
||||||
<screen x="1920" y="0" width="1920" height="1080" />
|
|
||||||
</state>
|
|
||||||
<state x="3200" y="0" width="640" height="1080" key="dock-window-2/1920.0.1920.1080/0.0.1920.1080@1920.0.1920.1080" timestamp="1597959520918" />
|
|
||||||
<state x="0" y="557" width="1920" height="523" key="dock-window-3" timestamp="1597934748776">
|
|
||||||
<screen x="0" y="0" width="1920" height="1080" />
|
|
||||||
</state>
|
|
||||||
<state x="0" y="557" width="1920" height="523" key="dock-window-3/1920.0.1920.1080/0.0.1920.1080@1920.0.1920.1080" timestamp="1597934748776" />
|
|
||||||
<state x="623" y="239" width="672" height="678" key="search.everywhere.popup" timestamp="1598261278301">
|
|
||||||
<screen x="0" y="0" width="1920" height="1080" />
|
|
||||||
</state>
|
|
||||||
<state x="623" y="239" width="672" height="678" key="search.everywhere.popup/0.0.1920.1080@0.0.1920.1080" timestamp="1598261278301" />
|
|
||||||
<state x="2543" y="239" width="672" height="678" key="search.everywhere.popup/1920.0.1920.1080/0.0.1920.1080@1920.0.1920.1080" timestamp="1597698616567" />
|
|
||||||
</component>
|
|
||||||
<component name="XDebuggerManager">
|
<component name="XDebuggerManager">
|
||||||
<breakpoint-manager>
|
|
||||||
<breakpoints>
|
|
||||||
<line-breakpoint enabled="true" type="DotNet Breakpoints">
|
|
||||||
<url>file://$PROJECT_DIR$/Parser/Parser.cs</url>
|
|
||||||
<line>262</line>
|
|
||||||
<properties documentPath="$PROJECT_DIR$/Parser/Parser.cs" initialLine="261">
|
|
||||||
<startOffsets>
|
|
||||||
<option value="10930" />
|
|
||||||
</startOffsets>
|
|
||||||
<endOffsets>
|
|
||||||
<option value="10956" />
|
|
||||||
</endOffsets>
|
|
||||||
</properties>
|
|
||||||
<option name="timeStamp" value="14" />
|
|
||||||
</line-breakpoint>
|
|
||||||
</breakpoints>
|
|
||||||
</breakpoint-manager>
|
|
||||||
<pin-to-top-manager>
|
<pin-to-top-manager>
|
||||||
<pinned-members>
|
<pinned-members>
|
||||||
<PinnedItemInfo parentTag="Type#Compiler.Parser.Nodes.Node" memberName="Children" />
|
<PinnedItemInfo parentTag="Type#Compiler.Parser.Nodes.Node" memberName="Children" />
|
||||||
|
|
|
||||||
|
|
@ -112,12 +112,12 @@ namespace Compiler
|
||||||
{
|
{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
string file = "/home/clemens/repositorys/lcc/stage_3/valid/sub.c";
|
string file = "/home/clemens/repositorys/lcc/stage_3/valid/complicated.c";
|
||||||
|
|
||||||
Console.WriteLine("-------------");
|
Console.WriteLine("-------------");
|
||||||
List<Token> tokens = TestLexer(file, 0);
|
List<Token> tokens = TestLexer(file, 0);
|
||||||
Node programNode = TestParser(tokens, file, 1);
|
Node programNode = TestParser(tokens, file, 1);
|
||||||
TestGenerator(programNode, 1);
|
//TestGenerator(programNode, 1);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -92,10 +92,11 @@ namespace Compiler.Generator
|
||||||
s = $"{Generate(rootNode.Children[0])}" +
|
s = $"{Generate(rootNode.Children[0])}" +
|
||||||
"push %rax\n" +
|
"push %rax\n" +
|
||||||
$"{Generate(rootNode.Children[1])}" +
|
$"{Generate(rootNode.Children[1])}" +
|
||||||
"movl %eax, %ecx" + //move calculated divisor to %ecx
|
"movl %eax, %ecx\n" + //move calculated divisor to %ecx
|
||||||
"pop %rbx\n" + //pop divident do %ebx
|
"pop %rax\n" + //pop divident do %eax
|
||||||
"cdq\n" +
|
"cdq\n" +
|
||||||
"idivl %ecx\n";
|
"divl %ecx\n" +
|
||||||
|
"movl %ecx, %eax\n";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new ArgumentOutOfRangeException();
|
throw new ArgumentOutOfRangeException();
|
||||||
|
|
|
||||||
|
|
@ -34,36 +34,76 @@ namespace Compiler.Parser
|
||||||
//The main RDP function
|
//The main RDP function
|
||||||
public Node Parse(NodeType nodeType, bool unopPrecedence = false)
|
public Node Parse(NodeType nodeType, bool unopPrecedence = false)
|
||||||
{
|
{
|
||||||
//declare node to be returned
|
|
||||||
Node n;
|
|
||||||
|
|
||||||
//switch over the nodeType to check in which part of the parser we are
|
//switch over the nodeType to check in which part of the parser we are
|
||||||
switch (nodeType)
|
switch (nodeType)
|
||||||
{
|
{
|
||||||
|
//parse the root programm node
|
||||||
case NodeType.ProgramNode:
|
case NodeType.ProgramNode:
|
||||||
n = new ProgramNode();
|
return ParseProgrammNode();
|
||||||
|
|
||||||
|
//parse the function node
|
||||||
|
case NodeType.FunctionNode:
|
||||||
|
return ParseFunctionNode();
|
||||||
|
|
||||||
|
//parse the whole return statement
|
||||||
|
case NodeType.ReturnStatementNode:
|
||||||
|
return ParseReturnNode();
|
||||||
|
|
||||||
|
case NodeType.ExpressionNode:
|
||||||
|
return ParseExpressionNode(unopPrecedence);
|
||||||
|
|
||||||
|
//the case for term node is almost the same as the one for expression node
|
||||||
|
case NodeType.TermNode:
|
||||||
|
return ParseTermNode(unopPrecedence);
|
||||||
|
|
||||||
|
case NodeType.FactorNode:
|
||||||
|
return ParseFactorNode();
|
||||||
|
|
||||||
|
//code to parse unary operator nodes
|
||||||
|
case NodeType.UnaryOperatorNode:
|
||||||
|
return ParseUnopNode(unopPrecedence);
|
||||||
|
|
||||||
|
//parse constant nodes
|
||||||
|
case NodeType.ConstantNode:
|
||||||
|
return ParseConstantNode();
|
||||||
|
|
||||||
|
//default case if the supplied NodeType is unknown
|
||||||
|
default:
|
||||||
|
throw new Exception("Unknown Node Type " + nodeType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Node ParseProgrammNode()
|
||||||
|
{
|
||||||
|
Node n = new ProgramNode();
|
||||||
|
|
||||||
//if this node is a program node, the next one must be a function node
|
//if this node is a program node, the next one must be a function node
|
||||||
Node childNode = Parse(NodeType.FunctionNode);
|
Node childNode = Parse(NodeType.FunctionNode);
|
||||||
n.Children.Add(childNode);
|
n.Children.Add(childNode);
|
||||||
break;
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
case NodeType.FunctionNode:
|
private Node ParseFunctionNode()
|
||||||
n = new FunctionNode();
|
{
|
||||||
|
Node n = new FunctionNode();
|
||||||
|
|
||||||
//check each element of the signature and raise corresponding errors
|
//check each element of the signature and raise corresponding errors
|
||||||
|
//check if the first element is "int"
|
||||||
CheckFirstTokenAndRemove(TokenType.IntToken);
|
CheckFirstTokenAndRemove(TokenType.IntToken);
|
||||||
|
|
||||||
|
//check if the next token is an identifier, but don't remove it
|
||||||
if (_tokenList.Count == 0)
|
if (_tokenList.Count == 0)
|
||||||
{
|
{
|
||||||
throw new MissingTokenException(TokenType.IdentifierToken);
|
throw new MissingTokenException(TokenType.IdentifierToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//check if the identifier has a value
|
||||||
if (_tokenList[0].Value != null)
|
if (_tokenList[0].Value != null)
|
||||||
{
|
{
|
||||||
|
//check if the first token is really an identifier
|
||||||
if (_tokenList[0].TokenType == TokenType.IdentifierToken)
|
if (_tokenList[0].TokenType == TokenType.IdentifierToken)
|
||||||
{
|
{
|
||||||
|
//assign the function name
|
||||||
((FunctionNode) n).Name = _tokenList[0].Value.ToString();
|
((FunctionNode) n).Name = _tokenList[0].Value.ToString();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -79,6 +119,7 @@ namespace Compiler.Parser
|
||||||
//remove <id>
|
//remove <id>
|
||||||
_tokenList.RemoveAt(0);
|
_tokenList.RemoveAt(0);
|
||||||
|
|
||||||
|
//check (){
|
||||||
CheckFirstTokenAndRemove(TokenType.OpenParenthesisToken);
|
CheckFirstTokenAndRemove(TokenType.OpenParenthesisToken);
|
||||||
CheckFirstTokenAndRemove(TokenType.CloseParenthesisToken);
|
CheckFirstTokenAndRemove(TokenType.CloseParenthesisToken);
|
||||||
CheckFirstTokenAndRemove(TokenType.OpenBraceToken);
|
CheckFirstTokenAndRemove(TokenType.OpenBraceToken);
|
||||||
|
|
@ -89,12 +130,13 @@ namespace Compiler.Parser
|
||||||
//remove trailing }
|
//remove trailing }
|
||||||
CheckFirstTokenAndRemove(TokenType.CloseBraceToken);
|
CheckFirstTokenAndRemove(TokenType.CloseBraceToken);
|
||||||
|
|
||||||
break;
|
return n;
|
||||||
|
}
|
||||||
case NodeType.ReturnStatementNode:
|
|
||||||
|
|
||||||
|
private Node ParseReturnNode()
|
||||||
|
{
|
||||||
//TODO: This Type of return/statement node will probably need fixing later
|
//TODO: This Type of return/statement node will probably need fixing later
|
||||||
n = new ReturnNode();
|
Node n = new ReturnNode();
|
||||||
|
|
||||||
//get return token and remove it
|
//get return token and remove it
|
||||||
CheckFirstTokenAndRemove(TokenType.ReturnToken);
|
CheckFirstTokenAndRemove(TokenType.ReturnToken);
|
||||||
|
|
@ -106,10 +148,11 @@ namespace Compiler.Parser
|
||||||
//remove trailing ;
|
//remove trailing ;
|
||||||
CheckFirstTokenAndRemove(TokenType.SemicolonToken);
|
CheckFirstTokenAndRemove(TokenType.SemicolonToken);
|
||||||
|
|
||||||
break;
|
return n;
|
||||||
|
}
|
||||||
case NodeType.ExpressionNode:
|
|
||||||
|
|
||||||
|
private Node ParseExpressionNode(bool unopPrecedence)
|
||||||
|
{
|
||||||
if (_tokenList.Count == 0)
|
if (_tokenList.Count == 0)
|
||||||
{
|
{
|
||||||
throw new MissingTokenException(TokenType.IntegerLiteralToken);
|
throw new MissingTokenException(TokenType.IntegerLiteralToken);
|
||||||
|
|
@ -118,7 +161,7 @@ namespace Compiler.Parser
|
||||||
//an expression always has a first term
|
//an expression always has a first term
|
||||||
//this first term is parsed here
|
//this first term is parsed here
|
||||||
Node firstTerm = Parse(NodeType.TermNode);
|
Node firstTerm = Parse(NodeType.TermNode);
|
||||||
n = firstTerm;
|
Node n = firstTerm;
|
||||||
|
|
||||||
//get next token
|
//get next token
|
||||||
Token expressionToken = _tokenList[0];
|
Token expressionToken = _tokenList[0];
|
||||||
|
|
@ -164,12 +207,11 @@ namespace Compiler.Parser
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
return n;
|
||||||
|
}
|
||||||
//the case for term node is almost the same as the one for expression node
|
|
||||||
case NodeType.TermNode:
|
|
||||||
|
|
||||||
|
|
||||||
|
private Node ParseTermNode(bool unopPrecedence)
|
||||||
|
{
|
||||||
if (_tokenList.Count == 0)
|
if (_tokenList.Count == 0)
|
||||||
{
|
{
|
||||||
throw new MissingTokenException(TokenType.IntegerLiteralToken);
|
throw new MissingTokenException(TokenType.IntegerLiteralToken);
|
||||||
|
|
@ -177,7 +219,7 @@ namespace Compiler.Parser
|
||||||
|
|
||||||
//parse first factor
|
//parse first factor
|
||||||
Node firstFactor = Parse(NodeType.FactorNode);
|
Node firstFactor = Parse(NodeType.FactorNode);
|
||||||
n = firstFactor;
|
Node n = firstFactor;
|
||||||
|
|
||||||
Token termToken = _tokenList[0];
|
Token termToken = _tokenList[0];
|
||||||
|
|
||||||
|
|
@ -213,10 +255,12 @@ namespace Compiler.Parser
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Node ParseFactorNode()
|
||||||
case NodeType.FactorNode:
|
{
|
||||||
|
Node n;
|
||||||
if (_tokenList.Count == 0)
|
if (_tokenList.Count == 0)
|
||||||
{
|
{
|
||||||
throw new MissingTokenException(TokenType.IntegerLiteralToken);
|
throw new MissingTokenException(TokenType.IntegerLiteralToken);
|
||||||
|
|
@ -256,16 +300,18 @@ namespace Compiler.Parser
|
||||||
factorToken.TokenType);
|
factorToken.TokenType);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
//code to parse unary operator nodes
|
private Node ParseUnopNode(bool unopPrecedence)
|
||||||
case NodeType.UnaryOperatorNode:
|
{
|
||||||
if (_tokenList.Count == 0)
|
if (_tokenList.Count == 0)
|
||||||
{
|
{
|
||||||
throw new MissingTokenException(TokenType.IntegerLiteralToken);
|
throw new MissingTokenException(TokenType.IntegerLiteralToken);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
Node n;
|
||||||
|
|
||||||
//get operator
|
//get operator
|
||||||
Token unaryOperator = _tokenList[0];
|
Token unaryOperator = _tokenList[0];
|
||||||
_tokenList.RemoveAt(0);
|
_tokenList.RemoveAt(0);
|
||||||
|
|
@ -289,13 +335,12 @@ namespace Compiler.Parser
|
||||||
throw new UnexpectedTokenException(TokenType.IntegerLiteralToken,
|
throw new UnexpectedTokenException(TokenType.IntegerLiteralToken,
|
||||||
unaryOperator.TokenType);
|
unaryOperator.TokenType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
private Node ParseConstantNode()
|
||||||
|
{
|
||||||
//parse constant nodes
|
|
||||||
case NodeType.ConstantNode:
|
|
||||||
|
|
||||||
if (_tokenList.Count == 0)
|
if (_tokenList.Count == 0)
|
||||||
{
|
{
|
||||||
throw new MissingTokenException(TokenType.IntegerLiteralToken);
|
throw new MissingTokenException(TokenType.IntegerLiteralToken);
|
||||||
|
|
@ -306,19 +351,10 @@ namespace Compiler.Parser
|
||||||
{
|
{
|
||||||
throw new UnexpectedTokenException(TokenType.IntegerLiteralToken, _tokenList[0].TokenType);
|
throw new UnexpectedTokenException(TokenType.IntegerLiteralToken, _tokenList[0].TokenType);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
//return final constant node to end recursion
|
//return final constant node to end recursion
|
||||||
n = new ConstantNode((int) _tokenList[0].Value);
|
Node n = new ConstantNode((int) _tokenList[0].Value);
|
||||||
_tokenList.RemoveAt(0);
|
_tokenList.RemoveAt(0);
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
//default case if the supplied NodeType is unknown
|
|
||||||
default:
|
|
||||||
throw new Exception("Unknown Node Type " + nodeType);
|
|
||||||
}
|
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
12
test.s
Normal file
12
test.s
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
.globl main
|
||||||
|
main:
|
||||||
|
movl $3, %eax
|
||||||
|
push %rax
|
||||||
|
movl $2, %eax
|
||||||
|
pop %rcx
|
||||||
|
sub %ecx, %eax
|
||||||
|
push %rax
|
||||||
|
movl $1, %eax
|
||||||
|
pop %rcx
|
||||||
|
sub %ecx, %eax
|
||||||
|
ret
|
||||||
Loading…
Add table
Add a link
Reference in a new issue