Lots of comments and cleanup

This commit is contained in:
Clemens-Dautermann 2020-12-17 21:36:39 +01:00
parent 120a575b15
commit 1a95fc2371
8 changed files with 351 additions and 518 deletions

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ContentModelStore">
<e p="$USER_HOME$/.cache/JetBrains/Rider2020.2/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/extResources" t="IncludeRecursive" />
<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="Compiler.cs" t="Include" />
<e p="Compiler.csproj" t="IncludeRecursive" />

View file

@ -3,7 +3,7 @@
<component name="ProjectModuleManager">
<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/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>
</component>
</project>

View 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>

View file

@ -20,8 +20,11 @@
</component>
<component name="ChangeListManager">
<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$/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$/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" />
@ -43,81 +46,38 @@
</component>
<component name="HighlightingSettingsPerFile">
<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://$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/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/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 name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<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$/Generator/Generator.cs" />
</list>
</option>
<changedPaths>
<option value="$PROJECT_DIR$/DevFunctions.cs" />
<option value="$PROJECT_DIR$/Parser/Parser.cs" />
</changedPaths>
</component>
<component name="ProjectId" id="1g8sEwibYOXRSHf7VBAgyNtiM21" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true">
<ConfirmationsSetting value="2" id="Add" />
</component>
<component name="ProjectViewState">
<option name="autoscrollToSource" value="true" />
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
@ -132,7 +92,9 @@
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="XThreadsFramesViewSplitterKey" value="0.44757032" />
<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="vue.rearranger.settings.migration" value="true" />
</component>
<component name="RunManager">
<configuration name="Compiler" type="DotNetProject" factoryName=".NET Project">
@ -178,6 +140,9 @@
<workItem from="1598123734996" duration="12557000" />
<workItem from="1598197309733" duration="2969000" />
<workItem from="1598260697761" duration="4427000" />
<workItem from="1598873360208" duration="3527000" />
<workItem from="1608233616774" duration="1881000" />
<workItem from="1608235612613" duration="1783000" />
</task>
<servers />
</component>
@ -202,195 +167,7 @@
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
<option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="true" />
</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">
<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>
<pinned-members>
<PinnedItemInfo parentTag="Type#Compiler.Parser.Nodes.Node" memberName="Children" />

View file

@ -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("-------------");
List<Token> tokens = TestLexer(file, 0);
Node programNode = TestParser(tokens, file, 1);
TestGenerator(programNode, 1);
//TestGenerator(programNode, 1);
//}
/*

View file

@ -92,10 +92,11 @@ namespace Compiler.Generator
s = $"{Generate(rootNode.Children[0])}" +
"push %rax\n" +
$"{Generate(rootNode.Children[1])}" +
"movl %eax, %ecx" + //move calculated divisor to %ecx
"pop %rbx\n" + //pop divident do %ebx
"movl %eax, %ecx\n" + //move calculated divisor to %ecx
"pop %rax\n" + //pop divident do %eax
"cdq\n" +
"idivl %ecx\n";
"divl %ecx\n" +
"movl %ecx, %eax\n";
break;
default:
throw new ArgumentOutOfRangeException();

View file

@ -34,291 +34,327 @@ namespace Compiler.Parser
//The main RDP function
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 (nodeType)
{
//parse the root programm node
case NodeType.ProgramNode:
n = new ProgramNode();
//if this node is a program node, the next one must be a function node
Node childNode = Parse(NodeType.FunctionNode);
n.Children.Add(childNode);
break;
return ParseProgrammNode();
//parse the function node
case NodeType.FunctionNode:
n = new FunctionNode();
//check each element of the signature and raise corresponding errors
CheckFirstTokenAndRemove(TokenType.IntToken);
if (_tokenList.Count == 0)
{
throw new MissingTokenException(TokenType.IdentifierToken);
}
if (_tokenList[0].Value != null)
{
if (_tokenList[0].TokenType == TokenType.IdentifierToken)
{
((FunctionNode) n).Name = _tokenList[0].Value.ToString();
}
else
{
throw new UnexpectedTokenException(TokenType.IdentifierToken, _tokenList[0].TokenType);
}
}
else
{
throw new InvalidIdentifierException(null);
}
//remove <id>
_tokenList.RemoveAt(0);
CheckFirstTokenAndRemove(TokenType.OpenParenthesisToken);
CheckFirstTokenAndRemove(TokenType.CloseParenthesisToken);
CheckFirstTokenAndRemove(TokenType.OpenBraceToken);
//add returned child node to AST
n.Children.Add(Parse(NodeType.ReturnStatementNode));
//remove trailing }
CheckFirstTokenAndRemove(TokenType.CloseBraceToken);
break;
return ParseFunctionNode();
//parse the whole return statement
case NodeType.ReturnStatementNode:
//TODO: This Type of return/statement node will probably need fixing later
n = new ReturnNode();
//get return token and remove it
CheckFirstTokenAndRemove(TokenType.ReturnToken);
//add returned child node to AST
n.Children.Add(Parse(NodeType.ExpressionNode));
//remove trailing ;
CheckFirstTokenAndRemove(TokenType.SemicolonToken);
break;
return ParseReturnNode();
case NodeType.ExpressionNode:
if (_tokenList.Count == 0)
{
throw new MissingTokenException(TokenType.IntegerLiteralToken);
}
//an expression always has a first term
//this first term is parsed here
Node firstTerm = Parse(NodeType.TermNode);
n = firstTerm;
//get next token
Token expressionToken = _tokenList[0];
//if the next token is a + or a - it must be a binary operator because we are in an expression
//that means that this is not a plain constant but a BinaryOperator node
//also check if the last token was a unary operator
while ((expressionToken.TokenType == TokenType.AdditionToken ||
expressionToken.TokenType == TokenType.NegationToken) && !unopPrecedence)
{
//remove the - or + token
_tokenList.RemoveAt(0);
switch (expressionToken.TokenType)
{
//1. create a BinOp Node
//2. Add the first term as a child
//3. Parse the rest as an expression and add it as the second term
case TokenType.AdditionToken:
n = new BinaryOperatorNode(OperatorType.Addition);
n.Children.Add(firstTerm);
n.Children.Add(Parse(NodeType.ExpressionNode));
break;
case TokenType.NegationToken:
n = new BinaryOperatorNode(OperatorType.Subtraction);
n.Children.Add(firstTerm);
n.Children.Add(Parse(NodeType.ExpressionNode));
break;
default:
//this should never happen because the while loop checks for token types, that are
//handled by case statements above only
throw new Exception("WeirdException");
}
//if there are still tokens left over pop one off
if (_tokenList.Count > 0)
{
expressionToken = _tokenList[0];
}
else
{
//there must be tokens left because we are in an expression.
throw new MissingTokenException(TokenType.IntegerLiteralToken);
}
}
break;
return ParseExpressionNode(unopPrecedence);
//the case for term node is almost the same as the one for expression node
case NodeType.TermNode:
if (_tokenList.Count == 0)
{
throw new MissingTokenException(TokenType.IntegerLiteralToken);
}
//parse first factor
Node firstFactor = Parse(NodeType.FactorNode);
n = firstFactor;
Token termToken = _tokenList[0];
//parse second factor if it exists
while ((termToken.TokenType == TokenType.MultiplicationToken ||
termToken.TokenType == TokenType.DivisionToken) && !unopPrecedence)
{
_tokenList.RemoveAt(0);
switch (termToken.TokenType)
{
case TokenType.MultiplicationToken:
n = new BinaryOperatorNode(OperatorType.Multiplication);
n.Children.Add(firstFactor);
n.Children.Add(Parse(NodeType.TermNode));
break;
case TokenType.DivisionToken:
n = new BinaryOperatorNode(OperatorType.Division);
n.Children.Add(firstFactor);
n.Children.Add(Parse(NodeType.TermNode));
break;
default:
throw new Exception("WeirdException");
}
if (_tokenList.Count > 0)
{
termToken = _tokenList[0];
}
else
{
throw new MissingTokenException(TokenType.IntegerLiteralToken);
}
}
break;
return ParseTermNode(unopPrecedence);
case NodeType.FactorNode:
if (_tokenList.Count == 0)
{
throw new MissingTokenException(TokenType.IntegerLiteralToken);
}
Token factorToken = _tokenList[0];
//switch over possible next tokens. There are three possible options
switch (factorToken.TokenType)
{
//first option:
//a parenthesised expression follows.
case TokenType.OpenParenthesisToken:
//check and remove openParenthesis (it has already been checked in the case, so removal would be enough)
CheckFirstTokenAndRemove(TokenType.OpenParenthesisToken);
//parse the things inside as an expression
n = Parse(NodeType.ExpressionNode);
//check if close parenthesis is supplied
CheckFirstTokenAndRemove(TokenType.CloseParenthesisToken);
break;
//second option:
//this is a unary operator expression
case TokenType.NegationToken:
case TokenType.BitwiseComplementToken:
case TokenType.LogicalNegationToken:
//just parse this as a unary operator node
n = Parse(NodeType.UnaryOperatorNode);
break;
//this is an integer literal.
case TokenType.IntegerLiteralToken:
//parse it as a constant
n = Parse(NodeType.ConstantNode);
break;
default:
throw new UnexpectedTokenException(TokenType.IntegerLiteralToken,
factorToken.TokenType);
}
break;
return ParseFactorNode();
//code to parse unary operator nodes
case NodeType.UnaryOperatorNode:
if (_tokenList.Count == 0)
{
throw new MissingTokenException(TokenType.IntegerLiteralToken);
}
else
{
//get operator
Token unaryOperator = _tokenList[0];
_tokenList.RemoveAt(0);
//switch over three different operators and parse the rest as an expression
switch (unaryOperator.TokenType)
{
case TokenType.BitwiseComplementToken:
n = new UnaryOperatorNode(OperatorType.BitwiseComplement);
n.Children.Add(Parse(NodeType.ExpressionNode, unopPrecedence = true));
break;
case TokenType.NegationToken:
n = new UnaryOperatorNode(OperatorType.Negation);
n.Children.Add(Parse(NodeType.ExpressionNode, unopPrecedence = true));
break;
case TokenType.LogicalNegationToken:
n = new UnaryOperatorNode(OperatorType.LogicalNegation);
n.Children.Add(Parse(NodeType.ExpressionNode, unopPrecedence = true));
break;
default:
throw new UnexpectedTokenException(TokenType.IntegerLiteralToken,
unaryOperator.TokenType);
}
}
break;
return ParseUnopNode(unopPrecedence);
//parse constant nodes
case NodeType.ConstantNode:
if (_tokenList.Count == 0)
{
throw new MissingTokenException(TokenType.IntegerLiteralToken);
}
//double check, for safety. Pbly unnecesarry
if (_tokenList[0].TokenType != TokenType.IntegerLiteralToken)
{
throw new UnexpectedTokenException(TokenType.IntegerLiteralToken, _tokenList[0].TokenType);
}
else
{
//return final constant node to end recursion
n = new ConstantNode((int) _tokenList[0].Value);
_tokenList.RemoveAt(0);
break;
}
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
Node childNode = Parse(NodeType.FunctionNode);
n.Children.Add(childNode);
return n;
}
private Node ParseFunctionNode()
{
Node n = new FunctionNode();
//check each element of the signature and raise corresponding errors
//check if the first element is "int"
CheckFirstTokenAndRemove(TokenType.IntToken);
//check if the next token is an identifier, but don't remove it
if (_tokenList.Count == 0)
{
throw new MissingTokenException(TokenType.IdentifierToken);
}
//check if the identifier has a value
if (_tokenList[0].Value != null)
{
//check if the first token is really an identifier
if (_tokenList[0].TokenType == TokenType.IdentifierToken)
{
//assign the function name
((FunctionNode) n).Name = _tokenList[0].Value.ToString();
}
else
{
throw new UnexpectedTokenException(TokenType.IdentifierToken, _tokenList[0].TokenType);
}
}
else
{
throw new InvalidIdentifierException(null);
}
//remove <id>
_tokenList.RemoveAt(0);
//check (){
CheckFirstTokenAndRemove(TokenType.OpenParenthesisToken);
CheckFirstTokenAndRemove(TokenType.CloseParenthesisToken);
CheckFirstTokenAndRemove(TokenType.OpenBraceToken);
//add returned child node to AST
n.Children.Add(Parse(NodeType.ReturnStatementNode));
//remove trailing }
CheckFirstTokenAndRemove(TokenType.CloseBraceToken);
return n;
}
private Node ParseReturnNode()
{
//TODO: This Type of return/statement node will probably need fixing later
Node n = new ReturnNode();
//get return token and remove it
CheckFirstTokenAndRemove(TokenType.ReturnToken);
//add returned child node to AST
n.Children.Add(Parse(NodeType.ExpressionNode));
//remove trailing ;
CheckFirstTokenAndRemove(TokenType.SemicolonToken);
return n;
}
private Node ParseExpressionNode(bool unopPrecedence)
{
if (_tokenList.Count == 0)
{
throw new MissingTokenException(TokenType.IntegerLiteralToken);
}
//an expression always has a first term
//this first term is parsed here
Node firstTerm = Parse(NodeType.TermNode);
Node n = firstTerm;
//get next token
Token expressionToken = _tokenList[0];
//if the next token is a + or a - it must be a binary operator because we are in an expression
//that means that this is not a plain constant but a BinaryOperator node
//also check if the last token was a unary operator
while ((expressionToken.TokenType == TokenType.AdditionToken ||
expressionToken.TokenType == TokenType.NegationToken) && !unopPrecedence)
{
//remove the - or + token
_tokenList.RemoveAt(0);
switch (expressionToken.TokenType)
{
//1. create a BinOp Node
//2. Add the first term as a child
//3. Parse the rest as an expression and add it as the second term
case TokenType.AdditionToken:
n = new BinaryOperatorNode(OperatorType.Addition);
n.Children.Add(firstTerm);
n.Children.Add(Parse(NodeType.ExpressionNode));
break;
case TokenType.NegationToken:
n = new BinaryOperatorNode(OperatorType.Subtraction);
n.Children.Add(firstTerm);
n.Children.Add(Parse(NodeType.ExpressionNode));
break;
default:
//this should never happen because the while loop checks for token types, that are
//handled by case statements above only
throw new Exception("WeirdException");
}
//if there are still tokens left over pop one off
if (_tokenList.Count > 0)
{
expressionToken = _tokenList[0];
}
else
{
//there must be tokens left because we are in an expression.
throw new MissingTokenException(TokenType.IntegerLiteralToken);
}
}
return n;
}
private Node ParseTermNode(bool unopPrecedence)
{
if (_tokenList.Count == 0)
{
throw new MissingTokenException(TokenType.IntegerLiteralToken);
}
//parse first factor
Node firstFactor = Parse(NodeType.FactorNode);
Node n = firstFactor;
Token termToken = _tokenList[0];
//parse second factor if it exists
while ((termToken.TokenType == TokenType.MultiplicationToken ||
termToken.TokenType == TokenType.DivisionToken) && !unopPrecedence)
{
_tokenList.RemoveAt(0);
switch (termToken.TokenType)
{
case TokenType.MultiplicationToken:
n = new BinaryOperatorNode(OperatorType.Multiplication);
n.Children.Add(firstFactor);
n.Children.Add(Parse(NodeType.TermNode));
break;
case TokenType.DivisionToken:
n = new BinaryOperatorNode(OperatorType.Division);
n.Children.Add(firstFactor);
n.Children.Add(Parse(NodeType.TermNode));
break;
default:
throw new Exception("WeirdException");
}
if (_tokenList.Count > 0)
{
termToken = _tokenList[0];
}
else
{
throw new MissingTokenException(TokenType.IntegerLiteralToken);
}
}
return n;
}
private Node ParseFactorNode()
{
Node n;
if (_tokenList.Count == 0)
{
throw new MissingTokenException(TokenType.IntegerLiteralToken);
}
Token factorToken = _tokenList[0];
//switch over possible next tokens. There are three possible options
switch (factorToken.TokenType)
{
//first option:
//a parenthesised expression follows.
case TokenType.OpenParenthesisToken:
//check and remove openParenthesis (it has already been checked in the case, so removal would be enough)
CheckFirstTokenAndRemove(TokenType.OpenParenthesisToken);
//parse the things inside as an expression
n = Parse(NodeType.ExpressionNode);
//check if close parenthesis is supplied
CheckFirstTokenAndRemove(TokenType.CloseParenthesisToken);
break;
//second option:
//this is a unary operator expression
case TokenType.NegationToken:
case TokenType.BitwiseComplementToken:
case TokenType.LogicalNegationToken:
//just parse this as a unary operator node
n = Parse(NodeType.UnaryOperatorNode);
break;
//this is an integer literal.
case TokenType.IntegerLiteralToken:
//parse it as a constant
n = Parse(NodeType.ConstantNode);
break;
default:
throw new UnexpectedTokenException(TokenType.IntegerLiteralToken,
factorToken.TokenType);
}
return n;
}
private Node ParseUnopNode(bool unopPrecedence)
{
if (_tokenList.Count == 0)
{
throw new MissingTokenException(TokenType.IntegerLiteralToken);
}
Node n;
//get operator
Token unaryOperator = _tokenList[0];
_tokenList.RemoveAt(0);
//switch over three different operators and parse the rest as an expression
switch (unaryOperator.TokenType)
{
case TokenType.BitwiseComplementToken:
n = new UnaryOperatorNode(OperatorType.BitwiseComplement);
n.Children.Add(Parse(NodeType.ExpressionNode, unopPrecedence = true));
break;
case TokenType.NegationToken:
n = new UnaryOperatorNode(OperatorType.Negation);
n.Children.Add(Parse(NodeType.ExpressionNode, unopPrecedence = true));
break;
case TokenType.LogicalNegationToken:
n = new UnaryOperatorNode(OperatorType.LogicalNegation);
n.Children.Add(Parse(NodeType.ExpressionNode, unopPrecedence = true));
break;
default:
throw new UnexpectedTokenException(TokenType.IntegerLiteralToken,
unaryOperator.TokenType);
}
return n;
}
private Node ParseConstantNode()
{
if (_tokenList.Count == 0)
{
throw new MissingTokenException(TokenType.IntegerLiteralToken);
}
//double check, for safety. Pbly unnecesarry
if (_tokenList[0].TokenType != TokenType.IntegerLiteralToken)
{
throw new UnexpectedTokenException(TokenType.IntegerLiteralToken, _tokenList[0].TokenType);
}
//return final constant node to end recursion
Node n = new ConstantNode((int) _tokenList[0].Value);
_tokenList.RemoveAt(0);
return n;
}
}

12
test.s Normal file
View 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