From 78db1807796dbf10229cf35def19f08a50ac538f Mon Sep 17 00:00:00 2001 From: Mark Daryl Caguia Date: Thu, 2 Feb 2017 10:49:04 +0800 Subject: [PATCH 01/10] Lexical, Syntax, Semantics --- CodeGeneration/Code Generation.csproj | 73 + CodeGeneration/CodeGenInitialize.cs | 4366 +++++++++++ CodeGeneration/Properties/AssemblyInfo.cs | 36 + .../Core Library RE/AlternativeElement.cs | 108 + .../Core Library RE/CharacterSetElement.cs | 428 ++ .../Core Library RE/CombineElement.cs | 110 + Core Library/Core Library RE/Element.cs | 63 + Core Library/Core Library RE/Matcher.cs | 222 + Core Library/Core Library RE/RegExp.cs | 649 ++ .../Core Library RE/RegExpException.cs | 147 + Core Library/Core Library RE/RepeatElement.cs | 351 + Core Library/Core Library RE/StringElement.cs | 115 + Core Library/Core Library.csproj | 86 + Core Library/Core Library/Analyzer.cs | 377 + Core Library/Core Library/LookAheadSet.cs | 875 +++ Core Library/Core Library/Node.cs | 492 ++ Core Library/Core Library/ParseException.cs | 395 + Core Library/Core Library/Parser.cs | 818 ++ .../Core Library/ParserCreationException.cs | 318 + .../Core Library/ParserLogException.cs | 127 + Core Library/Core Library/PredictSet.cs | 220 + Core Library/Core Library/PredictSets.cs | 291 + Core Library/Core Library/Production.cs | 153 + .../Core Library/ProductionPattern.cs | 375 + .../ProductionPatternAlternative.cs | 371 + .../Core Library/ProductionPatternElement.cs | 256 + Core Library/Core Library/ReaderBuffer.cs | 324 + .../Core Library/RecursiveDescentParser.cs | 916 +++ Core Library/Core Library/SyntaxConstants.cs | 186 + .../Core Library/SyntaxProductions.cs | 64 + Core Library/Core Library/Token.cs | 358 + Core Library/Core Library/TokenMatch.cs | 72 + Core Library/Core Library/TokenNFA.cs | 1272 ++++ Core Library/Core Library/TokenPattern.cs | 492 ++ .../Core Library/TokenRegExpParser.cs | 679 ++ Core Library/Core Library/TokenStringDFA.cs | 298 + Core Library/Core Library/Tokenizer.cs | 784 ++ Core Library/Properties/AssemblyInfo.cs | 36 + Semantics Analyzer/Properties/AssemblyInfo.cs | 36 + Semantics Analyzer/Semantics Analyzer.csproj | 69 + Semantics Analyzer/SemanticsConstants.cs | 235 + Semantics Analyzer/SemanticsInitializer.cs | 2080 +++++ SemanticsAnalyzer/Properties/AssemblyInfo.cs | 36 + SemanticsAnalyzer/SemanticsAnalyzer.csproj | 70 + SemanticsAnalyzer/SemanticsConstants.cs | 235 + SemanticsAnalyzer/SemanticsInitializer.cs | 4575 +++++++++++ Syntax Analyzer/Class1.cs | 12 + Syntax Analyzer/Properties/AssemblyInfo.cs | 36 + Syntax Analyzer/Syntax Analyzer.csproj | 71 + Syntax Analyzer/SyntaxAnalyzer.cs | 6679 +++++++++++++++++ Syntax Analyzer/SyntaxConstants.cs | 175 + Syntax Analyzer/SyntaxInitializer.cs | 289 + Syntax Analyzer/SyntaxParser.cs | 1211 +++ Syntax Analyzer/SyntaxProductions.cs | 239 + Syntax Analyzer/SyntaxTokenizer.cs | 456 ++ Token/Class1.vb | 3 + Token/ErrorClass.vb | 39 + Token/My Project/Application.Designer.vb | 13 + Token/My Project/Application.myapp | 10 + Token/My Project/AssemblyInfo.vb | 35 + Token/My Project/Resources.Designer.vb | 63 + Token/My Project/Resources.resx | 117 + Token/My Project/Settings.Designer.vb | 73 + Token/My Project/Settings.settings | 7 + Token/TokenClass.vb | 37 + Token/TokenLibrary.vbproj | 113 + Zootopia_Compiler.sln | 30 + Zootopia_Compiler/App.config | 6 +- Zootopia_Compiler/Form1.Designer.vb | 372 +- Zootopia_Compiler/Form1.vb | 4666 +++++++++--- .../My Project/Application.Designer.vb | 25 - .../My Project/Resources.Designer.vb | 75 +- Zootopia_Compiler/My Project/Resources.resx | 29 +- .../My Project/Settings.Designer.vb | 62 +- Zootopia_Compiler/Resources/Zoo_whale.png | Bin 0 -> 14928 bytes Zootopia_Compiler/Resources/analyze.png | Bin 0 -> 5521 bytes Zootopia_Compiler/Resources/analyzer.png | Bin 0 -> 10098 bytes Zootopia_Compiler/Resources/lexi.png | Bin 0 -> 7883 bytes Zootopia_Compiler/Resources/lexical.png | Bin 0 -> 8118 bytes Zootopia_Compiler/SyntaxAnalyzer.vb | 6426 ++++++++++++++++ Zootopia_Compiler/SyntaxConstants.vb | 181 + Zootopia_Compiler/SyntaxInitializer.vb | 155 + Zootopia_Compiler/SyntaxParser.vb | 1207 +++ Zootopia_Compiler/SyntaxTokenizer.vb | 241 + Zootopia_Compiler/Zootopia_Compiler.vbproj | 51 +- 85 files changed, 46813 insertions(+), 1030 deletions(-) create mode 100644 CodeGeneration/Code Generation.csproj create mode 100644 CodeGeneration/CodeGenInitialize.cs create mode 100644 CodeGeneration/Properties/AssemblyInfo.cs create mode 100644 Core Library/Core Library RE/AlternativeElement.cs create mode 100644 Core Library/Core Library RE/CharacterSetElement.cs create mode 100644 Core Library/Core Library RE/CombineElement.cs create mode 100644 Core Library/Core Library RE/Element.cs create mode 100644 Core Library/Core Library RE/Matcher.cs create mode 100644 Core Library/Core Library RE/RegExp.cs create mode 100644 Core Library/Core Library RE/RegExpException.cs create mode 100644 Core Library/Core Library RE/RepeatElement.cs create mode 100644 Core Library/Core Library RE/StringElement.cs create mode 100644 Core Library/Core Library.csproj create mode 100644 Core Library/Core Library/Analyzer.cs create mode 100644 Core Library/Core Library/LookAheadSet.cs create mode 100644 Core Library/Core Library/Node.cs create mode 100644 Core Library/Core Library/ParseException.cs create mode 100644 Core Library/Core Library/Parser.cs create mode 100644 Core Library/Core Library/ParserCreationException.cs create mode 100644 Core Library/Core Library/ParserLogException.cs create mode 100644 Core Library/Core Library/PredictSet.cs create mode 100644 Core Library/Core Library/PredictSets.cs create mode 100644 Core Library/Core Library/Production.cs create mode 100644 Core Library/Core Library/ProductionPattern.cs create mode 100644 Core Library/Core Library/ProductionPatternAlternative.cs create mode 100644 Core Library/Core Library/ProductionPatternElement.cs create mode 100644 Core Library/Core Library/ReaderBuffer.cs create mode 100644 Core Library/Core Library/RecursiveDescentParser.cs create mode 100644 Core Library/Core Library/SyntaxConstants.cs create mode 100644 Core Library/Core Library/SyntaxProductions.cs create mode 100644 Core Library/Core Library/Token.cs create mode 100644 Core Library/Core Library/TokenMatch.cs create mode 100644 Core Library/Core Library/TokenNFA.cs create mode 100644 Core Library/Core Library/TokenPattern.cs create mode 100644 Core Library/Core Library/TokenRegExpParser.cs create mode 100644 Core Library/Core Library/TokenStringDFA.cs create mode 100644 Core Library/Core Library/Tokenizer.cs create mode 100644 Core Library/Properties/AssemblyInfo.cs create mode 100644 Semantics Analyzer/Properties/AssemblyInfo.cs create mode 100644 Semantics Analyzer/Semantics Analyzer.csproj create mode 100644 Semantics Analyzer/SemanticsConstants.cs create mode 100644 Semantics Analyzer/SemanticsInitializer.cs create mode 100644 SemanticsAnalyzer/Properties/AssemblyInfo.cs create mode 100644 SemanticsAnalyzer/SemanticsAnalyzer.csproj create mode 100644 SemanticsAnalyzer/SemanticsConstants.cs create mode 100644 SemanticsAnalyzer/SemanticsInitializer.cs create mode 100644 Syntax Analyzer/Class1.cs create mode 100644 Syntax Analyzer/Properties/AssemblyInfo.cs create mode 100644 Syntax Analyzer/Syntax Analyzer.csproj create mode 100644 Syntax Analyzer/SyntaxAnalyzer.cs create mode 100644 Syntax Analyzer/SyntaxConstants.cs create mode 100644 Syntax Analyzer/SyntaxInitializer.cs create mode 100644 Syntax Analyzer/SyntaxParser.cs create mode 100644 Syntax Analyzer/SyntaxProductions.cs create mode 100644 Syntax Analyzer/SyntaxTokenizer.cs create mode 100644 Token/Class1.vb create mode 100644 Token/ErrorClass.vb create mode 100644 Token/My Project/Application.Designer.vb create mode 100644 Token/My Project/Application.myapp create mode 100644 Token/My Project/AssemblyInfo.vb create mode 100644 Token/My Project/Resources.Designer.vb create mode 100644 Token/My Project/Resources.resx create mode 100644 Token/My Project/Settings.Designer.vb create mode 100644 Token/My Project/Settings.settings create mode 100644 Token/TokenClass.vb create mode 100644 Token/TokenLibrary.vbproj create mode 100644 Zootopia_Compiler/Resources/Zoo_whale.png create mode 100644 Zootopia_Compiler/Resources/analyze.png create mode 100644 Zootopia_Compiler/Resources/analyzer.png create mode 100644 Zootopia_Compiler/Resources/lexi.png create mode 100644 Zootopia_Compiler/Resources/lexical.png create mode 100644 Zootopia_Compiler/SyntaxAnalyzer.vb create mode 100644 Zootopia_Compiler/SyntaxConstants.vb create mode 100644 Zootopia_Compiler/SyntaxInitializer.vb create mode 100644 Zootopia_Compiler/SyntaxParser.vb create mode 100644 Zootopia_Compiler/SyntaxTokenizer.vb diff --git a/CodeGeneration/Code Generation.csproj b/CodeGeneration/Code Generation.csproj new file mode 100644 index 0000000..f616e28 --- /dev/null +++ b/CodeGeneration/Code Generation.csproj @@ -0,0 +1,73 @@ + + + + + Debug + AnyCPU + {A371B79E-2C88-40A3-8AA5-3C5731FF607F} + Library + Properties + CodeGeneration + CodeGeneration + v4.5 + 512 + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + {100bf7e7-b634-4e6b-948e-22d0566fb2af} + Core Library + + + {e187009e-0b2b-4569-b16c-c35ef06fdfe1} + SemanticsAnalyzer + + + {c19858d3-1865-438d-afea-d2451a2ca503} + Syntax Analyzer + + + {17d6f07e-f7be-41de-8d3c-1881ee21f14a} + TokenLibrary + + + + + \ No newline at end of file diff --git a/CodeGeneration/CodeGenInitialize.cs b/CodeGeneration/CodeGenInitialize.cs new file mode 100644 index 0000000..eb1bebf --- /dev/null +++ b/CodeGeneration/CodeGenInitialize.cs @@ -0,0 +1,4366 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Syntax_Analyzer; +using Core.Library; +using TokenLibrary.TokenLibrary; +using System.IO; +using Semantics_Analyzer; + +namespace Code_Generation +{ + + public class CodeGenInitialize : SyntaxAnalyzer + { + public CodeGenInitialize() + : this(new List(), new Semantics_Analyzer.SemanticsInitializer()) { } + public Boolean runtime_error = false; + private List tokens; + private List arrays; + private List identifiers; + private List index; + private List objects; + private List task; + + + public CodeGenInitialize(List tokens, SemanticsInitializer semantics) + { + this.tokens = tokens; + this.arrays = semantics.arrays; + this.identifiers = semantics.identifiers; + this.index = semantics.indexes; + this.objects = semantics.objects; + this.task = semantics.tasks; + } + + public class Tokens : TokenClass + { + public List attribute = new List(); + + public void addAttribute(string attribute) + { + this.attribute.Add(attribute); + } + + public List getAttribute() + { + return this.attribute; + } + } + + public string error = ""; + + public string Start() + { + string tokenstream = ""; + string result = "Code Generation Failed...\n"; + int line = 1; + int linejump = 0; + + foreach (var t in tokens) + { + if (t.getLines() != line) + { + linejump = t.getLines() - line; + line = t.getLines(); + for (int i = 0; i < linejump; i++) + { + tokenstream += "\n"; + } + } + tokenstream += t.getTokens() + " "; + } + tokenstream = tokenstream.TrimEnd(); + + Parser p; + p = CreateParser(tokenstream); + + try + { + p.Parse(); + if (error == "") + result = "Code Generation Succeeded..."; + } + catch (ParserCreationException) + { + result = "Code Generation Halted due to Runtime Error..."; + } + catch (ParserLogException) + { + result = "Code Generation Halted due to Runtime Log Error..."; + } + return result; + } + + private Parser CreateParser(string input) + { + SyntaxParser parser = null; + try + { + parser = new SyntaxParser(new StringReader(input), this); + parser.Prepare(); + } + catch (ParserCreationException e) + { + throw new Exception(e.Message); + } + return parser; + } + + public Tokens GetTokens(int line, int column) + { + List t = new List(); + Tokens token = new Tokens(); + int endline = 0; + foreach (var item in tokens) + { + if (item.getLines() == line) + t.Add(item); + } + foreach (var item in t) + { + endline += item.getTokens().Length + 1; + if (column <= endline) + { + token = item; + break; + } + } + return token; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdProgram(Production node) + { + Console.Clear(); + } + + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdProgram(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdProgram(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdComment(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdComment(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdComment(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdGlobalDec(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdGlobalDec(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdGlobalDec(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdVarDec(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdVarDec(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdVarDec(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdFuncVar(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdFuncVar(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdFuncVar(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdIdentVar(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdIdentVar(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdIdentVar(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdDtype(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdDtype(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdDtype(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdNext2var(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdNext2var(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdNext2var(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdNext2varTail(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdNext2varTail(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdNext2varTail(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdVal(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdVal(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdVal(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdVal1(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdVal1(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdVal1(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdVal2(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdVal2(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdVal2(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdBulLit(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdBulLit(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdBulLit(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdArray1d(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdArray1d(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdArray1d(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdElem1dNext(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdElem1dNext(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdElem1dNext(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdElem1dList(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdElem1dList(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdElem1dList(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdElemlist1dTail(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdElemlist1dTail(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdElemlist1dTail(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdElem2dNext(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdElem2dNext(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdElem2dNext(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdElem2dList(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdElem2dList(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdElem2dList(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdElem2dListTail(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdElem2dListTail(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdElem2dListTail(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdSize(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdSize(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdSize(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdConstDec(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdConstDec(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdConstDec(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdConstNext(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdConstNext(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdConstNext(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdFuncName(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdFuncName(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdFuncName(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdParam(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdParam(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdParam(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdParam2(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdParam2(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdParam2(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdStorkDec(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdStorkDec(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdStorkDec(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdStorkElem(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdStorkElem(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdStorkElem(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdMultiVardec(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdMultiVardec(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdMultiVardec(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdMultistorkElem(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdMultistorkElem(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdMultistorkElem(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdObjDec(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdObjDec(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdObjDec(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdMane(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdMane(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdMane(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdLocalDec(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdLocalDec(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdLocalDec(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdStatement(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdStatement(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdStatement(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdStateNext(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdStateNext(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdStateNext(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdAssign1(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdAssign1(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdAssign1(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdAssignTail(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdAssignTail(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdAssignTail(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdNextFig(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdNextFig(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdNextFig(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdScanNext(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdScanNext(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdScanNext(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdArgs1(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdArgs1(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdArgs1(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdArgsTail(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdArgsTail(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdArgsTail(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdArgIn(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdArgIn(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdArgIn(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdMathEqtail1(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdMathEqtail1(Production node) + { + Node math = node.GetChildAt(1); + Node mathfig = math.GetChildAt(0); + if (mathfig.GetName() == "ID") + { + + } + else if (mathfig.GetName() == "prod_va1") + { + + } + else + { + + } + + + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdMathEqtail1(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdMathEqtail2(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdMathEqtail2(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdMathEqtail2(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdMathTail(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdMathTail(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdMathTail(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdMathOp(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdMathOp(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdMathOp(Production node, Node child) + { + //Node op = child.GetChildAt(0); + //if (op.GetName() == "ADD") + //{ + + //} + //else if (op.GetName() == "SUB") + //{ + + //} + //else if (op.GetName() == "MUL") + //{ + + //} + //else if (op.GetName() == "DIV") + //{ + + //} + //else + //{ + + //} + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdMathFig(Production node) + { + + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdMathFig(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdMathFig(Production node, Node child) + { + Node val = child.GetChildAt(0); + + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdMathFig1(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdMathFig1(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdMathFig1(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdMatheqNext(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdMatheqNext(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdMatheqNext(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdFunctionCall(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdFunctionCall(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdFunctionCall(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdClrscr(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdClrscr(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdClrscr(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdInput(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdInput(Production node) + { + Node input = node.GetChildAt(1); + Tokens token; + if (input.GetName() == "CDA") + { + Node ident = node.GetChildAt(2); + int idline = ident.GetStartLine(); + int idcol = ident.GetStartColumn(); + token = GetTokens(idline, idcol); + foreach (var item in identifiers) + { + if (item.getId() == token.getLexemes()) + { + var ins = (String)Console.ReadLine(); + if (String.IsNullOrEmpty(ins)) + { + ins = Console.ReadLine(); + } + string dtype = item.getDtype(); + bool isneg = false; + switch (dtype) + { + + case "Newt": + int input_int = 0; + if (ins.Contains("~")) + { + isneg = true; + ins = ins.Remove(0, 1); + } + if (Int32.TryParse(ins, out input_int)) + { + if (isneg) + { + input_int *= -1; + } + item.setValue(input_int.ToString()); + } + else + { + runtime_error = true; + Console.WriteLine(""); + Console.WriteLine("Runtime Error: Type Mismatch"); + } + break; + case "Duck": + double input_double = 0.0; + if (ins.Contains("~")) + { + isneg = true; + ins = ins.Remove(0, 1); + } + if (Double.TryParse(ins, out input_double)) + { + if (isneg) + { + input_double *= -1; + } + item.setValue(input_double.ToString()); + } + else + { + runtime_error = true; + Console.WriteLine(""); + Console.WriteLine("Runtime Error: Type Mismatch"); + } + break; + case "Bull": + if (ins == "true" || ins == "false") + { + item.setValue(ins); + } + else + { + runtime_error = true; + Console.WriteLine(""); + Console.WriteLine("Runtime Error: Type Mismatch"); + } + break; + case "Starling": + item.setValue(ins); + break; + } + + } + } + + } + + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdInput(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdScanFig(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdScanFig(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdScanFig(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdMultiInput(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdMultiInput(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdMultiInput(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdArr1d(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdArr1d(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdArr1d(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdArr2d(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdArr2d(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdArr2d(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdStorkAccess1(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdStorkAccess1(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdStorkAccess1(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdOutput(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdOutput(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdOutput(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdOut(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdOut(Production node) + { + + return node; + + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdOut(Production node, Node child) + { + //Node output = node.GetChildAt(0); + Tokens token; + int count = node.GetChildCount(); + if (child.GetName() == "STARLIT") + { + int idline = child.GetStartLine(); + int idcol = child.GetStartColumn(); + token = GetTokens(idline, idcol); + string outs = token.getLexemes(); + Console.Write(outs); + } + else + { + int idline = child.GetStartLine(); + int idcol = child.GetStartColumn(); + token = GetTokens(idline, idcol); + string outs = token.getLexemes(); + + foreach (var item in identifiers) + { + if(item.getId() == token.getLexemes()) + { + Console.Write(item.getValue().ToString()); + } + } + } + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdMultiOutput(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdMultiOutput(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdMultiOutput(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdConditional(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdConditional(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdConditional(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdCondi(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdCondi(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdCondi(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdNotFig(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdNotFig(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdNotFig(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdCondExpr(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdCondExpr(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdCondExpr(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdCondTail(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdCondTail(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdCondTail(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdRelExpr(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdRelExpr(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdRelExpr(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdRelexTail(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdRelexTail(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdRelexTail(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdExpression(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdExpression(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdExpression(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdRelOp1(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdRelOp1(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdRelOp1(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdRelOp2(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdRelOp2(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdRelOp2(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdRelFig(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdRelFig(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdRelFig(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdLogExpr(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdLogExpr(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdLogExpr(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdLogExprNext(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdLogExprNext(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdLogExprNext(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdLogOp(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdLogOp(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdLogOp(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdCondEelsif(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdCondEelsif(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdCondEelsif(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdCondEels(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdCondEels(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdCondEels(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdSwaspCase(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdSwaspCase(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdSwaspCase(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdSwaspCase1(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdSwaspCase1(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdSwaspCase1(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdTermExpr(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdTermExpr(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdTermExpr(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdDefault(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdDefault(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdDefault(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdIterative(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdIterative(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdIterative(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdLoopFig1(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdLoopFig1(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdLoopFig1(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdRelExpr1(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdRelExpr1(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdRelExpr1(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdLoopFig2(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdLoopFig2(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdLoopFig2(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdIncremDecrem(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdIncremDecrem(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdIncremDecrem(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdVar(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdVar(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdVar(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdUnaryOp(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdUnaryOp(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdUnaryOp(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdSubFunction(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdSubFunction(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdSubFunction(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdFuncInside(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdFuncInside(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdFuncInside(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdFuncArgs(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdFuncArgs(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdFuncArgs(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdMultifuncArgs(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdMultifuncArgs(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdMultifuncArgs(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdResult(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdResult(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdResult(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdFigTail(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdFigTail(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdFigTail(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdResultTail(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdResultTail(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdResultTail(Production node, Node child) + { + node.AddChild(child); + } + } +} diff --git a/CodeGeneration/Properties/AssemblyInfo.cs b/CodeGeneration/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..c7666ba --- /dev/null +++ b/CodeGeneration/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("CodeGeneration")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("CodeGeneration")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("a371b79e-2c88-40a3-8aa5-3c5731ff607f")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Core Library/Core Library RE/AlternativeElement.cs b/Core Library/Core Library RE/AlternativeElement.cs new file mode 100644 index 0000000..937e1ef --- /dev/null +++ b/Core Library/Core Library RE/AlternativeElement.cs @@ -0,0 +1,108 @@ +/* + * AlternativeElement.cs + */ + +using Core.Library; +using System.IO; + +namespace Core.Library.RE { + + /** + * A regular expression alternative element. This element matches + * the longest alternative element. + * + + * + */ + internal class AlternativeElement : Element { + + /** + * The first alternative element. + */ + private Element elem1; + + /** + * The second alternative element. + */ + private Element elem2; + + /** + * Creates a new alternative element. + * + * @param first the first alternative + * @param second the second alternative + */ + public AlternativeElement(Element first, Element second) { + elem1 = first; + elem2 = second; + } + + /** + * Creates a copy of this element. The copy will be an + * instance of the same class matching the same strings. + * Copies of elements are necessary to allow elements to cache + * intermediate results while matching strings without + * interfering with other threads. + * + * @return a copy of this element + */ + public override object Clone() { + return new AlternativeElement(elem1, elem2); + } + + /** + * Returns the length of a matching string starting at the + * specified position. The number of matches to skip can also + * be specified, but numbers higher than zero (0) cause a + * failed match for any element that doesn't attempt to + * combine other elements. + * + * @param m the matcher being used + * @param buffer the input character buffer to match + * @param start the starting position + * @param skip the number of matches to skip + * + * @return the length of the longest matching string, or + * -1 if no match was found + * + * @throws IOException if an I/O error occurred + */ + public override int Match(Matcher m, + ReaderBuffer buffer, + int start, + int skip) { + + int length = 0; + int length1 = -1; + int length2 = -1; + int skip1 = 0; + int skip2 = 0; + + while (length >= 0 && skip1 + skip2 <= skip) { + length1 = elem1.Match(m, buffer, start, skip1); + length2 = elem2.Match(m, buffer, start, skip2); + if (length1 >= length2) { + length = length1; + skip1++; + } else { + length = length2; + skip2++; + } + } + return length; + } + + /** + * Prints this element to the specified output stream. + * + * @param output the output stream to use + * @param indent the current indentation + */ + public override void PrintTo(TextWriter output, string indent) { + output.WriteLine(indent + "Alternative 1"); + elem1.PrintTo(output, indent + " "); + output.WriteLine(indent + "Alternative 2"); + elem2.PrintTo(output, indent + " "); + } + } +} diff --git a/Core Library/Core Library RE/CharacterSetElement.cs b/Core Library/Core Library RE/CharacterSetElement.cs new file mode 100644 index 0000000..6f08de2 --- /dev/null +++ b/Core Library/Core Library RE/CharacterSetElement.cs @@ -0,0 +1,428 @@ +/* + * CharacterSetElement.cs + */ + +using System; +using System.Collections; +using System.IO; +using System.Text; + +using Core.Library; + +namespace Core.Library.RE { + + /** + * A regular expression character set element. This element + * matches a single character inside (or outside) a character set. + * The character set is user defined and may contain ranges of + * characters. The set may also be inverted, meaning that only + * characters not inside the set will be considered to match. + * + + * + */ + internal class CharacterSetElement : Element { + + /** + * The dot ('.') character set. This element matches a single + * character that is not equal to a newline character. + */ + public static CharacterSetElement DOT = + new CharacterSetElement(false); + + /** + * The digit character set. This element matches a single + * numeric character. + */ + public static CharacterSetElement DIGIT = + new CharacterSetElement(false); + + /** + * The non-digit character set. This element matches a single + * non-numeric character. + */ + public static CharacterSetElement NON_DIGIT = + new CharacterSetElement(true); + + /** + * The whitespace character set. This element matches a single + * whitespace character. + */ + public static CharacterSetElement WHITESPACE = + new CharacterSetElement(false); + + /** + * The non-whitespace character set. This element matches a + * single non-whitespace character. + */ + public static CharacterSetElement NON_WHITESPACE = + new CharacterSetElement(true); + + /** + * The word character set. This element matches a single word + * character. + */ + public static CharacterSetElement WORD = + new CharacterSetElement(false); + + /** + * The non-word character set. This element matches a single + * non-word character. + */ + public static CharacterSetElement NON_WORD = + new CharacterSetElement(true); + + /** + * The inverted character set flag. + */ + private bool inverted; + + /** + * The character set content. This array may contain either + * range objects or Character objects. + */ + private ArrayList contents = new ArrayList(); + + /** + * Creates a new character set element. If the inverted character + * set flag is set, only characters NOT in the set will match. + * + * @param inverted the inverted character set flag + */ + public CharacterSetElement(bool inverted) { + this.inverted = inverted; + } + + /** + * Adds a single character to this character set. + * + * @param c the character to add + */ + public void AddCharacter(char c) { + contents.Add(c); + } + + /** + * Adds multiple characters to this character set. + * + * @param str the string with characters to add + */ + public void AddCharacters(string str) { + for (int i = 0; i < str.Length; i++) { + AddCharacter(str[i]); + } + } + + /** + * Adds multiple characters to this character set. + * + * @param elem the string element with characters to add + */ + public void AddCharacters(StringElement elem) { + AddCharacters(elem.GetString()); + } + + /** + * Adds a character range to this character set. + * + * @param min the minimum character value + * @param max the maximum character value + */ + public void AddRange(char min, char max) { + contents.Add(new Range(min, max)); + } + + /** + * Adds a character subset to this character set. + * + * @param elem the character set to add + */ + public void AddCharacterSet(CharacterSetElement elem) { + contents.Add(elem); + } + + /** + * Returns this element as the character set shouldn't be + * modified after creation. This partially breaks the contract + * of clone(), but as new characters are not added to the + * character set after creation, this will work correctly. + * + * @return this character set element + */ + public override object Clone() { + return this; + } + + /** + * Returns the length of a matching string starting at the + * specified position. The number of matches to skip can also be + * specified, but numbers higher than zero (0) cause a failed + * match for any element that doesn't attempt to combine other + * elements. + * + * @param m the matcher being used + * @param buffer the input character buffer to match + * @param start the starting position + * @param skip the number of matches to skip + * + * @return the length of the matching string, or + * -1 if no match was found + * + * @throws IOException if an I/O error occurred + */ + public override int Match(Matcher m, + ReaderBuffer buffer, + int start, + int skip) { + + int c; + + if (skip != 0) { + return -1; + } + c = buffer.Peek(start); + if (c < 0) { + m.SetReadEndOfString(); + return -1; + } + if (m.IsCaseInsensitive()) { + c = (int) Char.ToLower((char) c); + } + return InSet((char) c) ? 1 : -1; + } + + /** + * Checks if the specified character matches this character + * set. This method takes the inverted flag into account. + * + * @param c the character to check + * + * @return true if the character matches, or + * false otherwise + */ + private bool InSet(char c) { + if (this == DOT) { + return InDotSet(c); + } else if (this == DIGIT || this == NON_DIGIT) { + return InDigitSet(c) != inverted; + } else if (this == WHITESPACE || this == NON_WHITESPACE) { + return InWhitespaceSet(c) != inverted; + } else if (this == WORD || this == NON_WORD) { + return InWordSet(c) != inverted; + } else { + return InUserSet(c) != inverted; + } + } + + /** + * Checks if the specified character is present in the 'dot' + * set. This method does not consider the inverted flag. + * + * @param c the character to check + * + * @return true if the character is present, or + * false otherwise + */ + private bool InDotSet(char c) { + switch (c) { + case '\n': + case '\r': + case '\u0085': + case '\u2028': + case '\u2029': + return false; + default: + return true; + } + } + + /** + * Checks if the specified character is a digit. This method + * does not consider the inverted flag. + * + * @param c the character to check + * + * @return true if the character is a digit, or + * false otherwise + */ + private bool InDigitSet(char c) { + return '0' <= c && c <= '9'; + } + + /** + * Checks if the specified character is a whitespace + * character. This method does not consider the inverted flag. + * + * @param c the character to check + * + * @return true if the character is a whitespace character, or + * false otherwise + */ + private bool InWhitespaceSet(char c) { + switch (c) { + case ' ': + case '\t': + case '\n': + case '\f': + case '\r': + case (char) 11: + return true; + default: + return false; + } + } + + /** + * Checks if the specified character is a word character. This + * method does not consider the inverted flag. + * + * @param c the character to check + * + * @return true if the character is a word character, or + * false otherwise + */ + private bool InWordSet(char c) { + return ('a' <= c && c <= 'z') + || ('A' <= c && c <= 'Z') + || ('0' <= c && c <= '9') + || c == '_'; + } + + /** + * Checks if the specified character is present in the user- + * defined set. This method does not consider the inverted + * flag. + * + * @param value the character to check + * + * @return true if the character is present, or + * false otherwise + */ + private bool InUserSet(char value) { + object obj; + char c; + Range r; + CharacterSetElement e; + + for (int i = 0; i < contents.Count; i++) { + obj = contents[i]; + if (obj is char) { + c = (char) obj; + if (c == value) { + return true; + } + } else if (obj is Range) { + r = (Range) obj; + if (r.Inside(value)) { + return true; + } + } else if (obj is CharacterSetElement) { + e = (CharacterSetElement) obj; + if (e.InSet(value)) { + return true; + } + } + } + return false; + } + + /** + * Prints this element to the specified output stream. + * + * @param output the output stream to use + * @param indent the current indentation + */ + public override void PrintTo(TextWriter output, string indent) { + output.WriteLine(indent + ToString()); + } + + /** + * Returns a string description of this character set. + * + * @return a string description of this character set + */ + public override string ToString() { + StringBuilder buffer; + + // Handle predefined character sets + if (this == DOT) { + return "."; + } else if (this == DIGIT) { + return "\\d"; + } else if (this == NON_DIGIT) { + return "\\D"; + } else if (this == WHITESPACE) { + return "\\s"; + } else if (this == NON_WHITESPACE) { + return "\\S"; + } else if (this == WORD) { + return "\\w"; + } else if (this == NON_WORD) { + return "\\W"; + } + + // Handle user-defined character sets + buffer = new StringBuilder(); + if (inverted) { + buffer.Append("^["); + } else { + buffer.Append("["); + } + for (int i = 0; i < contents.Count; i++) { + buffer.Append(contents[i]); + } + buffer.Append("]"); + + return buffer.ToString(); + } + + + /** + * A character range class. + */ + private class Range { + + /** + * The minimum character value. + */ + private char min; + + /** + * The maximum character value. + */ + private char max; + + /** + * Creates a new character range. + * + * @param min the minimum character value + * @param max the maximum character value + */ + public Range(char min, char max) { + this.min = min; + this.max = max; + } + + /** + * Checks if the specified character is inside the range. + * + * @param c the character to check + * + * @return true if the character is in the range, or + * false otherwise + */ + public bool Inside(char c) { + return min <= c && c <= max; + } + + /** + * Returns a string representation of this object. + * + * @return a string representation of this object + */ + public override string ToString() { + return min + "-" + max; + } + } + } +} diff --git a/Core Library/Core Library RE/CombineElement.cs b/Core Library/Core Library RE/CombineElement.cs new file mode 100644 index 0000000..b90f873 --- /dev/null +++ b/Core Library/Core Library RE/CombineElement.cs @@ -0,0 +1,110 @@ +/* + * CombineElement.cs + */ + +using System.IO; + +using Core.Library; + +namespace Core.Library.RE { + + /** + * A regular expression combination element. This element matches + * two consecutive elements. + * + + * + */ + internal class CombineElement : Element { + + /** + * The first element. + */ + private Element elem1; + + /** + * The second element. + */ + private Element elem2; + + /** + * Creates a new combine element. + * + * @param first the first element + * @param second the second element + */ + public CombineElement(Element first, Element second) { + elem1 = first; + elem2 = second; + } + + /** + * Creates a copy of this element. The copy will be an + * instance of the same class matching the same strings. + * Copies of elements are necessary to allow elements to cache + * intermediate results while matching strings without + * interfering with other threads. + * + * @return a copy of this element + */ + public override object Clone() { + return new CombineElement(elem1, elem2); + } + + /** + * Returns the length of a matching string starting at the + * specified position. The number of matches to skip can also be + * specified, but numbers higher than zero (0) cause a failed + * match for any element that doesn't attempt to combine other + * elements. + * + * @param m the matcher being used + * @param buffer the input character buffer to match + * @param start the starting position + * @param skip the number of matches to skip + * + * @return the length of the longest matching string, or + * -1 if no match was found + * + * @throws IOException if an I/O error occurred + */ + public override int Match(Matcher m, + ReaderBuffer buffer, + int start, + int skip) { + + int length1 = -1; + int length2 = 0; + int skip1 = 0; + int skip2 = 0; + + while (skip >= 0) { + length1 = elem1.Match(m, buffer, start, skip1); + if (length1 < 0) { + return -1; + } + length2 = elem2.Match(m, buffer, start + length1, skip2); + if (length2 < 0) { + skip1++; + skip2 = 0; + } else { + skip2++; + skip--; + } + } + + return length1 + length2; + } + + /** + * Prints this element to the specified output stream. + * + * @param output the output stream to use + * @param indent the current indentation + */ + public override void PrintTo(TextWriter output, string indent) { + elem1.PrintTo(output, indent); + elem2.PrintTo(output, indent); + } + } +} diff --git a/Core Library/Core Library RE/Element.cs b/Core Library/Core Library RE/Element.cs new file mode 100644 index 0000000..4c74f40 --- /dev/null +++ b/Core Library/Core Library RE/Element.cs @@ -0,0 +1,63 @@ +/* + * Element.cs + */ + +using System; +using System.IO; + +using Core.Library; + +namespace Core.Library.RE { + + /** + * A regular expression element. This is the common base class for + * all regular expression elements, i.e. the parts of the regular + * expression. + * + + * + */ + internal abstract class Element : ICloneable { + + /** + * Creates a copy of this element. The copy will be an + * instance of the same class matching the same strings. + * Copies of elements are necessary to allow elements to cache + * intermediate results while matching strings without + * interfering with other threads. + * + * @return a copy of this element + */ + public abstract object Clone(); + + /** + * Returns the length of a matching string starting at the + * specified position. The number of matches to skip can also + * be specified, but numbers higher than zero (0) cause a + * failed match for any element that doesn't attempt to + * combine other elements. + * + * @param m the matcher being used + * @param buffer the input character buffer to match + * @param start the starting position + * @param skip the number of matches to skip + * + * @return the length of the matching string, or + * -1 if no match was found + * + * @throws IOException if an I/O error occurred + */ + public abstract int Match(Matcher m, + ReaderBuffer buffer, + int start, + int skip); + + /** + * Prints this element to the specified output stream. + * + * @param output the output stream to use + * @param indent the current indentation + */ + public abstract void PrintTo(TextWriter output, string indent); + } +} diff --git a/Core Library/Core Library RE/Matcher.cs b/Core Library/Core Library RE/Matcher.cs new file mode 100644 index 0000000..b71f64c --- /dev/null +++ b/Core Library/Core Library RE/Matcher.cs @@ -0,0 +1,222 @@ +/* + * Matcher.cs + */ + +using System.IO; + +using Core.Library; + +namespace Core.Library.RE { + + /** + * A regular expression string matcher. This class handles the + * matching of a specific string with a specific regular + * expression. It contains state information about the matching + * process, as for example the position of the latest match, and a + * number of flags that were set. This class is not thread-safe. + * + + * + */ + public class Matcher { + + /** + * The base regular expression element. + */ + private Element element; + + /** + * The input character buffer to work with. + */ + private ReaderBuffer buffer; + + /** + * The character case ignore flag. + */ + private bool ignoreCase; + + /** + * The start of the latest match found. + */ + private int start; + + /** + * The length of the latest match found. + */ + private int length; + + /** + * The end of string reached flag. This flag is set if the end + * of the string was encountered during the latest match. + */ + private bool endOfString; + + /** + * Creates a new matcher with the specified element. + * + * @param e the base regular expression element + * @param buffer the input character buffer to work with + * @param ignoreCase the character case ignore flag + */ + internal Matcher(Element e, ReaderBuffer buffer, bool ignoreCase) { + this.element = e; + this.buffer = buffer; + this.ignoreCase = ignoreCase; + this.start = 0; + Reset(); + } + + /** + * Checks if this matcher compares in case-insensitive mode. + * + * @return true if the matching is case-insensitive, or + * false otherwise + * + * + */ + public bool IsCaseInsensitive() { + return ignoreCase; + } + + /** + * Resets the information about the last match. This will + * clear all flags and set the match length to a negative + * value. This method is automatically called before starting + * a new match. + */ + public void Reset() { + length = -1; + endOfString = false; + } + + /** + * Resets the matcher for use with a new input string. This + * will clear all flags and set the match length to a negative + * value. + * + * @param str the new string to work with + * + * + */ + public void Reset(string str) { + Reset(new ReaderBuffer(new StringReader(str))); + } + + /** + * Resets the matcher for use with a new look-ahead character + * input stream. This will clear all flags and set the match + * length to a negative value. + * + * @param buffer the character input buffer + * + * + */ + public void Reset(ReaderBuffer buffer) { + this.buffer = buffer; + Reset(); + } + + /** + * Returns the start position of the latest match. If no match + * has been encountered, this method returns zero (0). + * + * @return the start position of the latest match + */ + public int Start() { + return start; + } + + /** + * Returns the end position of the latest match. This is one + * character after the match end, i.e. the first character + * after the match. If no match has been encountered, this + * method returns the same value as start(). + * + * @return the end position of the latest match + */ + public int End() { + if (length > 0) { + return start + length; + } else { + return start; + } + } + + /** + * Returns the length of the latest match. + * + * @return the length of the latest match, or + * -1 if no match was found + */ + public int Length() { + return length; + } + + /** + * Checks if the end of the string was encountered during the + * last match attempt. This flag signals that more input may + * be needed in order to get a match (or a longer match). + * + * @return true if the end of string was encountered, or + * false otherwise + */ + public bool HasReadEndOfString() { + return endOfString; + } + + /** + * Attempts to find a match starting at the beginning of the + * string. + * + * @return true if a match was found, or + * false otherwise + * + * @throws IOException if an I/O error occurred while reading + * an input stream + */ + public bool MatchFromBeginning() { + return MatchFrom(0); + } + + /** + * Attempts to find a match starting at the specified position + * in the string. + * + * @param pos the starting position of the match + * + * @return true if a match was found, or + * false otherwise + * + * @throws IOException if an I/O error occurred while reading + * an input stream + */ + public bool MatchFrom(int pos) { + Reset(); + start = pos; + length = element.Match(this, buffer, start, 0); + return length >= 0; + } + + /** + * Returns the latest matched string. If no string has been + * matched, an empty string will be returned. + * + * @return the latest matched string + */ + public override string ToString() { + if (length <= 0) { + return ""; + } else { + return buffer.Substring(buffer.Position, length); + } + } + + /** + * Sets the end of string encountered flag. This method is + * called by the various elements analyzing the string. + */ + internal void SetReadEndOfString() { + endOfString = true; + } + } +} diff --git a/Core Library/Core Library RE/RegExp.cs b/Core Library/Core Library RE/RegExp.cs new file mode 100644 index 0000000..3d4912c --- /dev/null +++ b/Core Library/Core Library RE/RegExp.cs @@ -0,0 +1,649 @@ +/* + * RegExp.cs + */ + +using System; +using System.Collections; +using System.IO; +using System.Globalization; +using System.Text; + +using Core.Library; + +namespace Core.Library.RE { + + /** + * A regular expression. This class creates and holds an internal + * data structure representing a regular expression. It also + * allows creating matchers. This class is thread-safe. Multiple + * matchers may operate simultanously on the same regular + * expression. + * + + * + */ + public class RegExp { + + /** + * The base regular expression element. + */ + private Element element; + + /** + * The regular expression pattern. + */ + private string pattern; + + /** + * The character case ignore flag. + */ + private bool ignoreCase; + + /** + * The current position in the pattern. This variable is used by + * the parsing methods. + */ + private int pos; + + /** + * Creates a new case-sensitive regular expression. + * + * @param pattern the regular expression pattern + * + * @throws RegExpException if the regular expression couldn't be + * parsed correctly + */ + public RegExp(string pattern) + : this(pattern, false) { + } + + /** + * Creates a new regular expression. The regular expression + * can be either case-sensitive or case-insensitive. + * + * @param pattern the regular expression pattern + * @param ignoreCase the character case ignore flag + * + * @throws RegExpException if the regular expression couldn't be + * parsed correctly + * + * + */ + public RegExp(string pattern, bool ignoreCase) { + this.pattern = pattern; + this.ignoreCase = ignoreCase; + this.pos = 0; + this.element = ParseExpr(); + if (pos < pattern.Length) { + throw new RegExpException( + RegExpException.ErrorType.UNEXPECTED_CHARACTER, + pos, + pattern); + } + } + + /** + * Creates a new matcher for the specified string. + * + * @param str the string to work with + * + * @return the regular expresion matcher + */ + public Matcher Matcher(string str) { + return Matcher(new ReaderBuffer(new StringReader(str))); + } + + /** + * Creates a new matcher for the specified look-ahead + * character input stream. + * + * @param buffer the character input buffer + * + * @return the regular expresion matcher + * + * + */ + public Matcher Matcher(ReaderBuffer buffer) { + return new Matcher((Element) element.Clone(), buffer, ignoreCase); + } + + /** + * Returns a string representation of the regular expression. + * + * @return a string representation of the regular expression + */ + public override string ToString() { + StringWriter str; + + str = new StringWriter(); + str.WriteLine("Regular Expression"); + str.WriteLine(" Pattern: " + pattern); + str.Write(" Flags:"); + if (ignoreCase) { + str.Write(" caseignore"); + } + str.WriteLine(); + str.WriteLine(" Compiled:"); + element.PrintTo(str, " "); + return str.ToString(); + } + + /** + * Parses a regular expression. This method handles the Expr + * production in the grammar (see regexp.grammar). + * + * @return the element representing this expression + * + * @throws RegExpException if an error was encountered in the + * pattern string + */ + private Element ParseExpr() { + Element first; + Element second; + + first = ParseTerm(); + if (PeekChar(0) != '|') { + return first; + } else { + ReadChar('|'); + second = ParseExpr(); + return new AlternativeElement(first, second); + } + } + + /** + * Parses a regular expression term. This method handles the + * Term production in the grammar (see regexp.grammar). + * + * @return the element representing this term + * + * @throws RegExpException if an error was encountered in the + * pattern string + */ + private Element ParseTerm() { + ArrayList list = new ArrayList(); + + list.Add(ParseFact()); + while (true) { + switch (PeekChar(0)) { + case -1: + case ')': + case ']': + case '{': + case '}': + case '?': + case '+': + case '|': + return CombineElements(list); + default: + list.Add(ParseFact()); + break; + } + } + } + + /** + * Parses a regular expression factor. This method handles the + * Fact production in the grammar (see regexp.grammar). + * + * @return the element representing this factor + * + * @throws RegExpException if an error was encountered in the + * pattern string + */ + private Element ParseFact() { + Element elem; + + elem = ParseAtom(); + switch (PeekChar(0)) { + case '?': + case '*': + case '+': + case '{': + return ParseAtomModifier(elem); + default: + return elem; + } + } + + /** + * Parses a regular expression atom. This method handles the + * Atom production in the grammar (see regexp.grammar). + * + * @return the element representing this atom + * + * @throws RegExpException if an error was encountered in the + * pattern string + */ + private Element ParseAtom() { + Element elem; + + switch (PeekChar(0)) { + case '.': + ReadChar('.'); + return CharacterSetElement.DOT; + case '(': + ReadChar('('); + elem = ParseExpr(); + ReadChar(')'); + return elem; + case '[': + ReadChar('['); + elem = ParseCharSet(); + ReadChar(']'); + return elem; + case -1: + case ')': + case ']': + case '{': + case '}': + case '?': + case '*': + case '+': + case '|': + throw new RegExpException( + RegExpException.ErrorType.UNEXPECTED_CHARACTER, + pos, + pattern); + default: + return ParseChar(); + } + } + + /** + * Parses a regular expression atom modifier. This method handles + * the AtomModifier production in the grammar (see regexp.grammar). + * + * @param elem the element to modify + * + * @return the modified element + * + * @throws RegExpException if an error was encountered in the + * pattern string + */ + private Element ParseAtomModifier(Element elem) { + int min = 0; + int max = -1; + RepeatElement.RepeatType type; + int firstPos; + + // Read min and max + type = RepeatElement.RepeatType.GREEDY; + switch (ReadChar()) { + case '?': + min = 0; + max = 1; + break; + case '*': + min = 0; + max = -1; + break; + case '+': + min = 1; + max = -1; + break; + case '{': + firstPos = pos - 1; + min = ReadNumber(); + max = min; + if (PeekChar(0) == ',') { + ReadChar(','); + max = -1; + if (PeekChar(0) != '}') { + max = ReadNumber(); + } + } + ReadChar('}'); + if (max == 0 || (max > 0 && min > max)) { + throw new RegExpException( + RegExpException.ErrorType.INVALID_REPEAT_COUNT, + firstPos, + pattern); + } + break; + default: + throw new RegExpException( + RegExpException.ErrorType.UNEXPECTED_CHARACTER, + pos - 1, + pattern); + } + + // Read operator mode + if (PeekChar(0) == '?') { + ReadChar('?'); + type = RepeatElement.RepeatType.RELUCTANT; + } else if (PeekChar(0) == '+') { + ReadChar('+'); + type = RepeatElement.RepeatType.POSSESSIVE; + } + + return new RepeatElement(elem, min, max, type); + } + + /** + * Parses a regular expression character set. This method handles + * the contents of the '[...]' construct in a regular expression. + * + * @return the element representing this character set + * + * @throws RegExpException if an error was encountered in the + * pattern string + */ + private Element ParseCharSet() { + CharacterSetElement charset; + Element elem; + bool repeat = true; + char start; + char end; + + if (PeekChar(0) == '^') { + ReadChar('^'); + charset = new CharacterSetElement(true); + } else { + charset = new CharacterSetElement(false); + } + + while (PeekChar(0) > 0 && repeat) { + start = (char) PeekChar(0); + switch (start) { + case ']': + repeat = false; + break; + case '\\': + elem = ParseEscapeChar(); + if (elem is StringElement) { + charset.AddCharacters((StringElement) elem); + } else { + charset.AddCharacterSet((CharacterSetElement) elem); + } + break; + default: + ReadChar(start); + if (PeekChar(0) == '-' + && PeekChar(1) > 0 + && PeekChar(1) != ']') { + + ReadChar('-'); + end = ReadChar(); + charset.AddRange(FixChar(start), FixChar(end)); + } else { + charset.AddCharacter(FixChar(start)); + } + break; + } + } + + return charset; + } + + /** + * Parses a regular expression character. This method handles + * a single normal character in a regular expression. + * + * @return the element representing this character + * + * @throws RegExpException if an error was encountered in the + * pattern string + */ + private Element ParseChar() { + switch (PeekChar(0)) { + case '\\': + return ParseEscapeChar(); + case '^': + case '$': + throw new RegExpException( + RegExpException.ErrorType.UNSUPPORTED_SPECIAL_CHARACTER, + pos, + pattern); + default: + return new StringElement(FixChar(ReadChar())); + } + } + + /** + * Parses a regular expression character escape. This method + * handles a single character escape in a regular expression. + * + * @return the element representing this character escape + * + * @throws RegExpException if an error was encountered in the + * pattern string + */ + private Element ParseEscapeChar() { + char c; + string str; + int value; + + ReadChar('\\'); + c = ReadChar(); + switch (c) { + case '0': + c = ReadChar(); + if (c < '0' || c > '3') { + throw new RegExpException( + RegExpException.ErrorType.UNSUPPORTED_ESCAPE_CHARACTER, + pos - 3, + pattern); + } + value = c - '0'; + c = (char) PeekChar(0); + if ('0' <= c && c <= '7') { + value *= 8; + value += ReadChar() - '0'; + c = (char) PeekChar(0); + if ('0' <= c && c <= '7') { + value *= 8; + value += ReadChar() - '0'; + } + } + return new StringElement(FixChar((char) value)); + case 'x': + str = ReadChar().ToString() + + ReadChar().ToString(); + try { + value = Int32.Parse(str, + NumberStyles.AllowHexSpecifier); + return new StringElement(FixChar((char) value)); + } catch (FormatException) { + throw new RegExpException( + RegExpException.ErrorType.UNSUPPORTED_ESCAPE_CHARACTER, + pos - str.Length - 2, + pattern); + } + case 'u': + str = ReadChar().ToString() + + ReadChar().ToString() + + ReadChar().ToString() + + ReadChar().ToString(); + try { + value = Int32.Parse(str, + NumberStyles.AllowHexSpecifier); + return new StringElement(FixChar((char) value)); + } catch (FormatException) { + throw new RegExpException( + RegExpException.ErrorType.UNSUPPORTED_ESCAPE_CHARACTER, + pos - str.Length - 2, + pattern); + } + case 't': + return new StringElement('\t'); + case 'n': + return new StringElement('\n'); + case 'r': + return new StringElement('\r'); + case 'f': + return new StringElement('\f'); + case 'a': + return new StringElement('\u0007'); + case 'e': + return new StringElement('\u001B'); + case 'd': + return CharacterSetElement.DIGIT; + case 'D': + return CharacterSetElement.NON_DIGIT; + case 's': + return CharacterSetElement.WHITESPACE; + case 'S': + return CharacterSetElement.NON_WHITESPACE; + case 'w': + return CharacterSetElement.WORD; + case 'W': + return CharacterSetElement.NON_WORD; + default: + if (('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z')) { + throw new RegExpException( + RegExpException.ErrorType.UNSUPPORTED_ESCAPE_CHARACTER, + pos - 2, + pattern); + } + return new StringElement(FixChar(c)); + } + } + + /** + * Adjusts a character for inclusion in a string or character + * set element. For case-insensitive regular expressions, this + * transforms the character to lower-case. + * + * @param c the input character + * + * @return the adjusted character + */ + private char FixChar(char c) { + return ignoreCase ? Char.ToLower(c) : c; + } + + /** + * Reads a number from the pattern. If the next character isn't a + * numeric character, an exception is thrown. This method reads + * several consecutive numeric characters. + * + * @return the numeric value read + * + * @throws RegExpException if an error was encountered in the + * pattern string + */ + private int ReadNumber() { + StringBuilder buf = new StringBuilder(); + int c; + + c = PeekChar(0); + while ('0' <= c && c <= '9') { + buf.Append(ReadChar()); + c = PeekChar(0); + } + if (buf.Length <= 0) { + throw new RegExpException( + RegExpException.ErrorType.UNEXPECTED_CHARACTER, + pos, + pattern); + } + return Int32.Parse(buf.ToString()); + } + + /** + * Reads the next character in the pattern. If no next character + * exists, an exception is thrown. + * + * @return the character read + * + * @throws RegExpException if no next character was available in + * the pattern string + */ + private char ReadChar() { + int c = PeekChar(0); + + if (c < 0) { + throw new RegExpException( + RegExpException.ErrorType.UNTERMINATED_PATTERN, + pos, + pattern); + } else { + pos++; + return (char) c; + } + } + + /** + * Reads the next character in the pattern. If the character + * wasn't the specified one, an exception is thrown. + * + * @param c the character to read + * + * @return the character read + * + * @throws RegExpException if the character read didn't match the + * specified one, or if no next character was + * available in the pattern string + */ + private char ReadChar(char c) { + if (c != ReadChar()) { + throw new RegExpException( + RegExpException.ErrorType.UNEXPECTED_CHARACTER, + pos - 1, + pattern); + } + return c; + } + + /** + * Returns a character that has not yet been read from the + * pattern. If the requested position is beyond the end of the + * pattern string, -1 is returned. + * + * @param count the preview position, from zero (0) + * + * @return the character found, or + * -1 if beyond the end of the pattern string + */ + private int PeekChar(int count) { + if (pos + count < pattern.Length) { + return pattern[pos + count]; + } else { + return -1; + } + } + + /** + * Combines a list of elements. This method takes care to always + * concatenate adjacent string elements into a single string + * element. + * + * @param list the list with elements + * + * @return the combined element + */ + private Element CombineElements(ArrayList list) { + Element prev; + Element elem; + string str; + int i; + + // Concatenate string elements + prev = (Element) list[0]; + for (i = 1; i < list.Count; i++) { + elem = (Element) list[i]; + if (prev is StringElement + && elem is StringElement) { + + str = ((StringElement) prev).GetString() + + ((StringElement) elem).GetString(); + elem = new StringElement(str); + list.RemoveAt(i); + list[i - 1] = elem; + i--; + } + prev = elem; + } + + // Combine all remaining elements + elem = (Element) list[list.Count - 1]; + for (i = list.Count - 2; i >= 0; i--) { + prev = (Element) list[i]; + elem = new CombineElement(prev, elem); + } + + return elem; + } + } +} diff --git a/Core Library/Core Library RE/RegExpException.cs b/Core Library/Core Library RE/RegExpException.cs new file mode 100644 index 0000000..3134934 --- /dev/null +++ b/Core Library/Core Library RE/RegExpException.cs @@ -0,0 +1,147 @@ +/* + * RegExpException.cs + */ + +using System; +using System.Text; + +namespace Core.Library.RE { + + /** + * A regular expression exception. This exception is thrown if a + * regular expression couldn't be processed (or "compiled") + * properly. + * + + * @version 1.0 + */ + public class RegExpException : Exception { + + /** + * The error type enumeration. + */ + public enum ErrorType { + + /** + * The unexpected character error constant. This error is + * used when a character was read that didn't match the + * allowed set of characters at the given position. + */ + UNEXPECTED_CHARACTER, + + /** + * The unterminated pattern error constant. This error is + * used when more characters were expected in the pattern. + */ + UNTERMINATED_PATTERN, + + /** + * The unsupported special character error constant. This + * error is used when special regular expression + * characters are used in the pattern, but not supported + * in this implementation. + */ + UNSUPPORTED_SPECIAL_CHARACTER, + + /** + * The unsupported escape character error constant. This + * error is used when an escape character construct is + * used in the pattern, but not supported in this + * implementation. + */ + UNSUPPORTED_ESCAPE_CHARACTER, + + /** + * The invalid repeat count error constant. This error is + * used when a repetition count of zero is specified, or + * when the minimum exceeds the maximum. + */ + INVALID_REPEAT_COUNT + } + + /** + * The error type constant. + */ + private ErrorType type; + + /** + * The error position. + */ + private int position; + + /** + * The regular expression pattern. + */ + private string pattern; + + /** + * Creates a new regular expression exception. + * + * @param type the error type constant + * @param pos the error position + * @param pattern the regular expression pattern + */ + public RegExpException(ErrorType type, int pos, string pattern) { + this.type = type; + this.position = pos; + this.pattern = pattern; + } + + /** + * The message property. This property contains the detailed + * exception error message. + */ + public override string Message { + get{ + return GetMessage(); + } + } + + /** + * Returns the exception error message. + * + * @return the exception error message + */ + public string GetMessage() { + StringBuilder buffer = new StringBuilder(); + + // Append error type name + switch (type) { + case ErrorType.UNEXPECTED_CHARACTER: + buffer.Append("unexpected character"); + break; + case ErrorType.UNTERMINATED_PATTERN: + buffer.Append("unterminated pattern"); + break; + case ErrorType.UNSUPPORTED_SPECIAL_CHARACTER: + buffer.Append("unsupported character"); + break; + case ErrorType.UNSUPPORTED_ESCAPE_CHARACTER: + buffer.Append("unsupported escape character"); + break; + case ErrorType.INVALID_REPEAT_COUNT: + buffer.Append("invalid repeat count"); + break; + default: + buffer.Append("internal error"); + break; + } + + // Append erroneous character + buffer.Append(": "); + if (position < pattern.Length) { + buffer.Append('\''); + buffer.Append(pattern.Substring(position)); + buffer.Append('\''); + } else { + buffer.Append(""); + } + + // Append position + buffer.Append(" at position "); + buffer.Append(position); + + return buffer.ToString(); + } + } +} diff --git a/Core Library/Core Library RE/RepeatElement.cs b/Core Library/Core Library RE/RepeatElement.cs new file mode 100644 index 0000000..70882b6 --- /dev/null +++ b/Core Library/Core Library RE/RepeatElement.cs @@ -0,0 +1,351 @@ +/* + * RepeatElement.cs + */ + +using System; +using System.Collections; +using System.IO; + +using Core.Library; + +namespace Core.Library.RE { + + /** + * A regular expression element repeater. The element repeats the + * matches from a specified element, attempting to reach the + * maximum repetition count. + * + + * + */ + internal class RepeatElement : Element { + + /** + * The repeat type constants. + */ + public enum RepeatType { + + /** + * The greedy repeat type constant. + */ + GREEDY = 1, + + /** + * The reluctant repeat type constant. + */ + RELUCTANT = 2, + + /** + * The possesive repeat type constant. + */ + POSSESSIVE = 3 + } + + /** + * The element to repeat. + */ + private Element elem; + + /** + * The minimum number of repetitions. + */ + private int min; + + /** + * The maximum number of repetitions. + */ + private int max; + + /** + * The repeat type. + */ + private RepeatType type; + + /** + * The start position of the last set of matches. + */ + private int matchStart; + + /** + * A set with all matches starting at matchStart. A match with + * a specific length is reported by a non-zero bit in the bit + * array. + */ + private BitArray matches; + + /** + * Creats a new element repeater. + * + * @param elem the element to repeat + * @param min the minimum count + * @param max the maximum count + * @param type the repeat type constant + */ + public RepeatElement(Element elem, + int min, + int max, + RepeatType type) { + + this.elem = elem; + this.min = min; + if (max <= 0) { + this.max = Int32.MaxValue; + } else { + this.max = max; + } + this.type = type; + this.matchStart = -1; + this.matches = null; + } + + /** + * Creates a copy of this element. The copy will be an + * instance of the same class matching the same strings. + * Copies of elements are necessary to allow elements to cache + * intermediate results while matching strings without + * interfering with other threads. + * + * @return a copy of this element + */ + public override object Clone() { + return new RepeatElement((Element) elem.Clone(), + min, + max, + type); + } + + /** + * Returns the length of a matching string starting at the + * specified position. The number of matches to skip can also be + * specified. + * + * @param m the matcher being used + * @param buffer the input character buffer to match + * @param start the starting position + * @param skip the number of matches to skip + * + * @return the length of the matching string, or + * -1 if no match was found + * + * @throws IOException if an I/O error occurred + */ + public override int Match(Matcher m, + ReaderBuffer buffer, + int start, + int skip) { + + if (skip == 0) { + matchStart = -1; + matches = null; + } + switch (type) { + case RepeatType.GREEDY: + return MatchGreedy(m, buffer, start, skip); + case RepeatType.RELUCTANT: + return MatchReluctant(m, buffer, start, skip); + case RepeatType.POSSESSIVE: + if (skip == 0) { + return MatchPossessive(m, buffer, start, 0); + } + break; + } + return -1; + } + + /** + * Returns the length of the longest possible matching string + * starting at the specified position. The number of matches + * to skip can also be specified. + * + * @param m the matcher being used + * @param buffer the input character buffer to match + * @param start the starting position + * @param skip the number of matches to skip + * + * @return the length of the longest matching string, or + * -1 if no match was found + * + * @throws IOException if an I/O error occurred + */ + private int MatchGreedy(Matcher m, + ReaderBuffer buffer, + int start, + int skip) { + + // Check for simple case + if (skip == 0) { + return MatchPossessive(m, buffer, start, 0); + } + + // Find all matches + if (matchStart != start) { + matchStart = start; + matches = new BitArray(10); + FindMatches(m, buffer, start, 0, 0, 0); + } + + // Find first non-skipped match + for (int i = matches.Count - 1; i >= 0; i--) { + if (matches[i]) { + if (skip == 0) { + return i; + } + skip--; + } + } + return -1; + } + + /** + * Returns the length of the shortest possible matching string + * starting at the specified position. The number of matches to + * skip can also be specified. + * + * @param m the matcher being used + * @param buffer the input character buffer to match + * @param start the starting position + * @param skip the number of matches to skip + * + * @return the length of the shortest matching string, or + * -1 if no match was found + * + * @throws IOException if an I/O error occurred + */ + private int MatchReluctant(Matcher m, + ReaderBuffer buffer, + int start, + int skip) { + + // Find all matches + if (matchStart != start) { + matchStart = start; + matches = new BitArray(10); + FindMatches(m, buffer, start, 0, 0, 0); + } + + // Find first non-skipped match + for (int i = 0; i < matches.Count; i++) { + if (matches[i]) { + if (skip == 0) { + return i; + } + skip--; + } + } + return -1; + } + + /** + * Returns the length of the maximum number of elements matching + * the string starting at the specified position. This method + * allows no backtracking, i.e. no skips.. + * + * @param m the matcher being used + * @param buffer the input character buffer to match + * @param start the starting position + * @param count the start count, normally zero (0) + * + * @return the length of the longest matching string, or + * -1 if no match was found + * + * @throws IOException if an I/O error occurred + */ + private int MatchPossessive(Matcher m, + ReaderBuffer buffer, + int start, + int count) { + + int length = 0; + int subLength = 1; + + // Match as many elements as possible + while (subLength > 0 && count < max) { + subLength = elem.Match(m, buffer, start + length, 0); + if (subLength >= 0) { + count++; + length += subLength; + } + } + + // Return result + if (min <= count && count <= max) { + return length; + } else { + return -1; + } + } + + /** + * Finds all matches and adds the lengths to the matches set. + * + * @param m the matcher being used + * @param buffer the input character buffer to match + * @param start the starting position + * @param length the match length at the start position + * @param count the number of sub-elements matched + * @param attempt the number of match attempts here + * + * @throws IOException if an I/O error occurred + */ + private void FindMatches(Matcher m, + ReaderBuffer buffer, + int start, + int length, + int count, + int attempt) { + + int subLength; + + // Check match ending here + if (count > max) { + return; + } + if (min <= count && attempt == 0) { + if (matches.Length <= length) { + matches.Length = length + 10; + } + matches[length] = true; + } + + // Check element match + subLength = elem.Match(m, buffer, start, attempt); + if (subLength < 0) { + return; + } else if (subLength == 0) { + if (min == count + 1) { + if (matches.Length <= length) { + matches.Length = length + 10; + } + matches[length] = true; + } + return; + } + + // Find alternative and subsequent matches + FindMatches(m, buffer, start, length, count, attempt + 1); + FindMatches(m, + buffer, + start + subLength, + length + subLength, + count + 1, + 0); + } + + /** + * Prints this element to the specified output stream. + * + * @param output the output stream to use + * @param indent the current indentation + */ + public override void PrintTo(TextWriter output, string indent) { + output.Write(indent + "Repeat (" + min + "," + max + ")"); + if (type == RepeatType.RELUCTANT) { + output.Write("?"); + } else if (type == RepeatType.POSSESSIVE) { + output.Write("+"); + } + output.WriteLine(); + elem.PrintTo(output, indent + " "); + } + } +} diff --git a/Core Library/Core Library RE/StringElement.cs b/Core Library/Core Library RE/StringElement.cs new file mode 100644 index 0000000..149785a --- /dev/null +++ b/Core Library/Core Library RE/StringElement.cs @@ -0,0 +1,115 @@ +/* + * StringElement.cs + */ + +using System; +using System.IO; + +using Core.Library; + +namespace Core.Library.RE { + + /** + * A regular expression string element. This element only matches + * an exact string. Once created, the string element is immutable. + * + + * + */ + internal class StringElement : Element { + + /** + * The string to match with. + */ + private string value; + + /** + * Creates a new string element. + * + * @param c the character to match with + */ + public StringElement(char c) + : this(c.ToString()) { + } + + /** + * Creates a new string element. + * + * @param str the string to match with + */ + public StringElement(string str) { + value = str; + } + + /** + * Returns the string to be matched. + * + * @return the string to be matched + */ + public string GetString() { + return value; + } + + /** + * Returns this element as it is immutable. + * + * @return this string element + */ + public override object Clone() { + return this; + } + + /** + * Returns the length of a matching string starting at the + * specified position. The number of matches to skip can also + * be specified, but numbers higher than zero (0) cause a + * failed match for any element that doesn't attempt to + * combine other elements. + * + * @param m the matcher being used + * @param buffer the input character buffer to match + * @param start the starting position + * @param skip the number of matches to skip + * + * @return the length of the longest matching string, or + * -1 if no match was found + * + * @throws IOException if an I/O error occurred + */ + public override int Match(Matcher m, + ReaderBuffer buffer, + int start, + int skip) { + + int c; + + if (skip != 0) { + return -1; + } + for (int i = 0; i < value.Length; i++) { + c = buffer.Peek(start + i); + if (c < 0) { + m.SetReadEndOfString(); + return -1; + } + if (m.IsCaseInsensitive()) { + c = (int) Char.ToLower((char) c); + } + if (c != (int) value[i]) { + return -1; + } + } + return value.Length; + } + + /** + * Prints this element to the specified output stream. + * + * @param output the output stream to use + * @param indent the current indentation + */ + public override void PrintTo(TextWriter output, string indent) { + output.WriteLine(indent + "'" + value + "'"); + } + } +} diff --git a/Core Library/Core Library.csproj b/Core Library/Core Library.csproj new file mode 100644 index 0000000..4791b3b --- /dev/null +++ b/Core Library/Core Library.csproj @@ -0,0 +1,86 @@ + + + + + Debug + AnyCPU + {100BF7E7-B634-4E6B-948E-22D0566FB2AF} + Library + Properties + Core_Library + Core Library + v4.5 + 512 + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Core Library/Core Library/Analyzer.cs b/Core Library/Core Library/Analyzer.cs new file mode 100644 index 0000000..e24a314 --- /dev/null +++ b/Core Library/Core Library/Analyzer.cs @@ -0,0 +1,377 @@ + +using System.Collections; + +namespace Core.Library { + + /** + * A parse tree analyzer. This class provides callback methods that + * may be used either during parsing, or for a parse tree traversal. + * This class should be subclassed to provide adequate handling of the + * parse tree nodes. + * + * The general contract for the analyzer class does not guarantee a + * strict call order for the callback methods. Depending on the type + * of parser, the enter() and exit() methods for production nodes can + * be called either in a top-down or a bottom-up fashion. The only + * guarantee provided by this API, is that the calls for any given + * node will always be in the order enter(), child(), and exit(). If + * various child() calls are made, they will be made from left to + * right as child nodes are added (to the right). + */ + public class Analyzer { + + /** + * Creates a new parse tree analyzer. + */ + public Analyzer() { + } + + /** + * Resets this analyzer when the parser is reset for another + * input stream. The default implementation of this method does + * nothing. + * + * + */ + public virtual void Reset() { + // Default implementation does nothing + } + + /** + * Analyzes a parse tree node by traversing all it's child nodes. + * The tree traversal is depth-first, and the appropriate + * callback methods will be called. If the node is a production + * node, a new production node will be created and children will + * be added by recursively processing the children of the + * specified production node. This method is used to process a + * parse tree after creation. + * + * @param node the parse tree node to process + * + * @return the resulting parse tree node + * + * @throws ParserLogException if the node analysis discovered + * errors + */ + public virtual Node Analyze(Node node) { + ParserLogException log = new ParserLogException(); + + node = Analyze(node, log); + if (log.Count > 0) { + throw log; + } + return node; + } + + /** + * Analyzes a parse tree node by traversing all it's child nodes. + * The tree traversal is depth-first, and the appropriate + * callback methods will be called. If the node is a production + * node, a new production node will be created and children will + * be added by recursively processing the children of the + * specified production node. This method is used to process a + * parse tree after creation. + * + * @param node the parse tree node to process + * @param log the parser error log + * + * @return the resulting parse tree node + */ + public virtual Node Analyze(Node node, ParserLogException log) { + Production prod; + int errorCount; + + Node res = null; + errorCount = log.Count; + if (node is Production) { + prod = (Production) node; + prod = NewProduction(prod.Pattern); + try { + Enter(prod); + } catch (ParseException e) { + log.AddError(e); + } + for (int i = 0; i < node.Count; i++) { + try { + Child(prod, Analyze(node[i], log)); + } catch (ParseException e) { + log.AddError(e); + } + } + try { + res = Exit(prod); + return res; + } catch (ParseException e) { + if (errorCount == log.Count) { + log.AddError(e); + } + } + } + else { + node.Values.Clear(); + try { + Enter(node); + } catch (ParseException e) { + log.AddError(e); + } + try { + res = Exit(node); + return res; + } catch (ParseException e) { + if (errorCount == log.Count) { + log.AddError(e); + } + } + } + return null; + } + + /** + * Factory method to create a new production node. This method + * can be overridden to provide other production implementations + * than the default one. + * + * @param pattern the production pattern + * + * @return the new production node + * + */ + public virtual Production NewProduction(ProductionPattern pattern) { + return new Production(pattern); + } + + /** + * Called when entering a parse tree node. By default this method + * does nothing. A subclass can override this method to handle + * each node separately. + * + * @param node the node being entered + * + * @throws ParseException if the node analysis discovered errors + */ + public virtual void Enter(Node node) { + } + + /** + * Called when exiting a parse tree node. By default this method + * returns the node. A subclass can override this method to handle + * each node separately. If no parse tree should be created, this + * method should return null. + * + * @param node the node being exited + * + * @return the node to add to the parse tree, or + * null if no parse tree should be created + * + * @throws ParseException if the node analysis discovered errors + */ + public virtual Node Exit(Node node) { + return node; + } + + /** + * Called when adding a child to a parse tree node. By default + * this method adds the child to the production node. A subclass + * can override this method to handle each node separately. Note + * that the child node may be null if the corresponding exit() + * method returned null. + * + * @param node the parent node + * @param child the child node, or null + * + * @throws ParseException if the node analysis discovered errors + */ + public virtual void Child(Production node, Node child) { + node.AddChild(child); + } + + /** + * Returns a child at the specified position. If either the node + * or the child node is null, this method will throw a parse + * exception with the internal error type. + * + * @param node the parent node + * @param pos the child position + * + * @return the child node + * + * @throws ParseException if either the node or the child node + * was null + */ + protected Node GetChildAt(Node node, int pos) { + Node child; + + if (node == null) { + throw new ParseException( + ParseException.ErrorType.INTERNAL, + "attempt to read 'null' parse tree node", + -1, + -1); + } + child = node[pos]; + if (child == null) { + throw new ParseException( + ParseException.ErrorType.INTERNAL, + "node '" + node.Name + "' has no child at " + + "position " + pos, + node.StartLine, + node.StartColumn); + } + return child; + } + + /** + * Returns the first child with the specified id. If the node is + * null, or no child with the specified id could be found, this + * method will throw a parse exception with the internal error + * type. + * + * @param node the parent node + * @param id the child node id + * + * @return the child node + * + * @throws ParseException if the node was null, or a child node + * couldn't be found + */ + protected Node GetChildWithId(Node node, int id) { + Node child; + + if (node == null) { + throw new ParseException( + ParseException.ErrorType.INTERNAL, + "attempt to read 'null' parse tree node", + -1, + -1); + } + for (int i = 0; i < node.Count; i++) { + child = node[i]; + if (child != null && child.Id == id) { + return child; + } + } + throw new ParseException( + ParseException.ErrorType.INTERNAL, + "node '" + node.Name + "' has no child with id " + id, + node.StartLine, + node.StartColumn); + } + + /** + * Returns the node value at the specified position. If either + * the node or the value is null, this method will throw a parse + * exception with the internal error type. + * + * @param node the parse tree node + * @param pos the child position + * + * @return the value object + * + * @throws ParseException if either the node or the value was null + */ + protected object GetValue(Node node, int pos) { + object value; + + if (node == null) { + throw new ParseException( + ParseException.ErrorType.INTERNAL, + "attempt to read 'null' parse tree node", + -1, + -1); + } + value = node.Values[pos]; + if (value == null) { + throw new ParseException( + ParseException.ErrorType.INTERNAL, + "node '" + node.Name + "' has no value at " + + "position " + pos, + node.StartLine, + node.StartColumn); + } + return value; + } + + /** + * Returns the node integer value at the specified position. If + * either the node is null, or the value is not an instance of + * the Integer class, this method will throw a parse exception + * with the internal error type. + * + * @param node the parse tree node + * @param pos the child position + * + * @return the value object + * + * @throws ParseException if either the node was null, or the + * value wasn't an integer + */ + protected int GetIntValue(Node node, int pos) { + object value; + + value = GetValue(node, pos); + if (value is int) { + return (int) value; + } else { + throw new ParseException( + ParseException.ErrorType.INTERNAL, + "node '" + node.Name + "' has no integer value " + + "at position " + pos, + node.StartLine, + node.StartColumn); + } + } + + /** + * Returns the node string value at the specified position. If + * either the node is null, or the value is not an instance of + * the String class, this method will throw a parse exception + * with the internal error type. + * + * @param node the parse tree node + * @param pos the child position + * + * @return the value object + * + * @throws ParseException if either the node was null, or the + * value wasn't a string + */ + protected string GetStringValue(Node node, int pos) { + object value; + + value = GetValue(node, pos); + if (value is string) { + return (string) value; + } else { + throw new ParseException( + ParseException.ErrorType.INTERNAL, + "node '" + node.Name + "' has no string value " + + "at position " + pos, + node.StartLine, + node.StartColumn); + } + } + + /** + * Returns all the node values for all child nodes. + * + * @param node the parse tree node + * + * @return a list with all the child node values + * + */ + protected ArrayList GetChildValues(Node node) { + ArrayList result = new ArrayList(); + Node child; + ArrayList values; + + for (int i = 0; i < node.Count; i++) { + child = node[i]; + values = child.Values; + if (values != null) { + result.AddRange(values); + } + } + return result; + } + } +} diff --git a/Core Library/Core Library/LookAheadSet.cs b/Core Library/Core Library/LookAheadSet.cs new file mode 100644 index 0000000..8502e2b --- /dev/null +++ b/Core Library/Core Library/LookAheadSet.cs @@ -0,0 +1,875 @@ +/* + * LookAheadSet.cs + */ + +using System.Collections; +using System.Text; + +namespace Core.Library { + + /** + * A token look-ahead set. This class contains a set of token id + * sequences. All sequences in the set are limited in length, so + * that no single sequence is longer than a maximum value. This + * class also filters out duplicates. Each token sequence also + * contains a repeat flag, allowing the look-ahead set to contain + * information about possible infinite repetitions of certain + * sequences. That information is important when conflicts arise + * between two look-ahead sets, as such a conflict cannot be + * resolved if the conflicting sequences can be repeated (would + * cause infinite loop). + * + + * @version 1.1 + */ + internal class LookAheadSet { + + /** + * The set of token look-ahead sequences. Each sequence in + * turn is represented by an ArrayList with Integers for the + * token id:s. + */ + private ArrayList elements = new ArrayList(); + + /** + * The maximum length of any look-ahead sequence. + */ + private int maxLength; + + /** + * Creates a new look-ahead set with the specified maximum + * length. + * + * @param maxLength the maximum token sequence length + */ + public LookAheadSet(int maxLength) { + this.maxLength = maxLength; + } + + /** + * Creates a duplicate look-ahead set, possibly with a + * different maximum length. + * + * @param maxLength the maximum token sequence length + * @param set the look-ahead set to copy + */ + public LookAheadSet(int maxLength, LookAheadSet set) + : this(maxLength) { + + AddAll(set); + } + + /** + * Returns the size of this look-ahead set. + * + * @return the number of token sequences in the set + */ + public int Size() { + return elements.Count; + } + + /** + * Returns the length of the shortest token sequence in this + * set. This method will return zero (0) if the set is empty. + * + * @return the length of the shortest token sequence + */ + public int GetMinLength() { + Sequence seq; + int min = -1; + + for (int i = 0; i < elements.Count; i++) { + seq = (Sequence) elements[i]; + if (min < 0 || seq.Length() < min) { + min = seq.Length(); + } + } + return (min < 0) ? 0 : min; + } + + /** + * Returns the length of the longest token sequence in this + * set. This method will return zero (0) if the set is empty. + * + * @return the length of the longest token sequence + */ + public int GetMaxLength() { + Sequence seq; + int max = 0; + + for (int i = 0; i < elements.Count; i++) { + seq = (Sequence) elements[i]; + if (seq.Length() > max) { + max = seq.Length(); + } + } + return max; + } + + /** + * Returns a list of the initial token id:s in this look-ahead + * set. The list returned will not contain any duplicates. + * + * @return a list of the inital token id:s in this look-ahead set + */ + public int[] GetInitialTokens() { + ArrayList list = new ArrayList(); + int[] result; + object token; + int i; + + for (i = 0; i < elements.Count; i++) { + token = ((Sequence) elements[i]).GetToken(0); + if (token != null && !list.Contains(token)) { + list.Add(token); + } + } + result = new int[list.Count]; + for (i = 0; i < list.Count; i++) { + result[i] = (int) list[i]; + } + return result; + } + + /** + * Checks if this look-ahead set contains a repetitive token + * sequence. + * + * @return true if at least one token sequence is repetitive, or + * false otherwise + */ + public bool IsRepetitive() { + Sequence seq; + + for (int i = 0; i < elements.Count; i++) { + seq = (Sequence) elements[i]; + if (seq.IsRepetitive()) { + return true; + } + } + return false; + } + + /** + * Checks if the next token(s) in the parser match any token + * sequence in this set. + * + * @param parser the parser to check + * + * @return true if the next tokens are in the set, or + * false otherwise + */ + public bool IsNext(Parser parser) { + Sequence seq; + + for (int i = 0; i < elements.Count; i++) { + seq = (Sequence) elements[i]; + if (seq.IsNext(parser)) { + return true; + } + } + return false; + } + + /** + * Checks if the next token(s) in the parser match any token + * sequence in this set. + * + * @param parser the parser to check + * @param length the maximum number of tokens to check + * + * @return true if the next tokens are in the set, or + * false otherwise + */ + public bool IsNext(Parser parser, int length) { + Sequence seq; + + for (int i = 0; i < elements.Count; i++) { + seq = (Sequence) elements[i]; + if (seq.IsNext(parser, length)) { + return true; + } + } + return false; + } + + /** + * Checks if another look-ahead set has an overlapping token + * sequence. An overlapping token sequence is a token sequence + * that is identical to another sequence, but for the length. + * I.e. one of the two sequences may be longer than the other. + * + * @param set the look-ahead set to check + * + * @return true if there is some token sequence that overlaps, or + * false otherwise + */ + public bool IsOverlap(LookAheadSet set) { + for (int i = 0; i < elements.Count; i++) { + if (set.IsOverlap((Sequence) elements[i])) { + return true; + } + } + return false; + } + + /** + * Checks if a token sequence is overlapping. An overlapping token + * sequence is a token sequence that is identical to another + * sequence, but for the length. I.e. one of the two sequences may + * be longer than the other. + * + * @param seq the token sequence to check + * + * @return true if there is some token sequence that overlaps, or + * false otherwise + */ + private bool IsOverlap(Sequence seq) { + Sequence elem; + + for (int i = 0; i < elements.Count; i++) { + elem = (Sequence) elements[i]; + if (seq.StartsWith(elem) || elem.StartsWith(seq)) { + return true; + } + } + return false; + } + + /** + * Checks if the specified token sequence is present in the + * set. + * + * @param elem the token sequence to check + * + * @return true if the sequence is present in this set, or + * false otherwise + */ + private bool Contains(Sequence elem) { + return FindSequence(elem) != null; + } + + /** + * Checks if some token sequence is present in both this set + * and a specified one. + * + * @param set the look-ahead set to compare with + * + * @return true if the look-ahead sets intersect, or + * false otherwise + */ + public bool Intersects(LookAheadSet set) { + for (int i = 0; i < elements.Count; i++) { + if (set.Contains((Sequence) elements[i])) { + return true; + } + } + return false; + } + + /** + * Finds an identical token sequence if present in the set. + * + * @param elem the token sequence to search for + * + * @return an identical the token sequence if found, or + * null if not found + */ + private Sequence FindSequence(Sequence elem) { + for (int i = 0; i < elements.Count; i++) { + if (elements[i].Equals(elem)) { + return (Sequence) elements[i]; + } + } + return null; + } + + /** + * Adds a token sequence to this set. The sequence will only + * be added if it is not already in the set. Also, if the + * sequence is longer than the allowed maximum, a truncated + * sequence will be added instead. + * + * @param seq the token sequence to add + */ + private void Add(Sequence seq) { + if (seq.Length() > maxLength) { + seq = new Sequence(maxLength, seq); + } + if (!Contains(seq)) { + elements.Add(seq); + } + } + + /** + * Adds a new token sequence with a single token to this set. + * The sequence will only be added if it is not already in the + * set. + * + * @param token the token to add + */ + public void Add(int token) { + Add(new Sequence(false, token)); + } + + /** + * Adds all the token sequences from a specified set. Only + * sequences not already in this set will be added. + * + * @param set the set to add from + */ + public void AddAll(LookAheadSet set) { + for (int i = 0; i < set.elements.Count; i++) { + Add((Sequence) set.elements[i]); + } + } + + /** + * Adds an empty token sequence to this set. The sequence will + * only be added if it is not already in the set. + */ + public void AddEmpty() { + Add(new Sequence()); + } + + /** + * Removes a token sequence from this set. + * + * @param seq the token sequence to remove + */ + private void Remove(Sequence seq) { + elements.Remove(seq); + } + + /** + * Removes all the token sequences from a specified set. Only + * sequences already in this set will be removed. + * + * @param set the set to remove from + */ + public void RemoveAll(LookAheadSet set) { + for (int i = 0; i < set.elements.Count; i++) { + Remove((Sequence) set.elements[i]); + } + } + + /** + * Creates a new look-ahead set that is the result of reading + * the specified token. The new look-ahead set will contain + * the rest of all the token sequences that started with the + * specified token. + * + * @param token the token to read + * + * @return a new look-ahead set containing the remaining tokens + */ + public LookAheadSet CreateNextSet(int token) { + LookAheadSet result = new LookAheadSet(maxLength - 1); + Sequence seq; + object value; + + for (int i = 0; i < elements.Count; i++) { + seq = (Sequence) elements[i]; + value = seq.GetToken(0); + if (value != null && token == (int) value) { + result.Add(seq.Subsequence(1)); + } + } + return result; + } + + /** + * Creates a new look-ahead set that is the intersection of + * this set with another set. The token sequences in the net + * set will only have the repeat flag set if it was set in + * both the identical token sequences. + * + * @param set the set to intersect with + * + * @return a new look-ahead set containing the intersection + */ + public LookAheadSet CreateIntersection(LookAheadSet set) { + LookAheadSet result = new LookAheadSet(maxLength); + Sequence seq1; + Sequence seq2; + + for (int i = 0; i < elements.Count; i++) { + seq1 = (Sequence) elements[i]; + seq2 = set.FindSequence(seq1); + if (seq2 != null && seq1.IsRepetitive()) { + result.Add(seq2); + } else if (seq2 != null) { + result.Add(seq1); + } + } + return result; + } + + /** + * Creates a new look-ahead set that is the combination of + * this set with another set. The combination is created by + * creating new token sequences that consist of appending all + * elements from the specified set onto all elements in this + * set. This is sometimes referred to as the cartesian + * product. + * + * @param set the set to combine with + * + * @return a new look-ahead set containing the combination + */ + public LookAheadSet CreateCombination(LookAheadSet set) { + LookAheadSet result = new LookAheadSet(maxLength); + Sequence first; + Sequence second; + + // Handle special cases + if (this.Size() <= 0) { + return set; + } else if (set.Size() <= 0) { + return this; + } + + // Create combinations + for (int i = 0; i < elements.Count; i++) { + first = (Sequence) elements[i]; + if (first.Length() >= maxLength) { + result.Add(first); + } else if (first.Length() <= 0) { + result.AddAll(set); + } else { + for (int j = 0; j < set.elements.Count; j++) { + second = (Sequence) set.elements[j]; + result.Add(first.Concat(maxLength, second)); + } + } + } + return result; + } + + /** + * Creates a new look-ahead set with overlaps from another. All + * token sequences in this set that overlaps with the other set + * will be added to the new look-ahead set. + * + * @param set the look-ahead set to check with + * + * @return a new look-ahead set containing the overlaps + */ + public LookAheadSet CreateOverlaps(LookAheadSet set) { + LookAheadSet result = new LookAheadSet(maxLength); + Sequence seq; + + for (int i = 0; i < elements.Count; i++) { + seq = (Sequence) elements[i]; + if (set.IsOverlap(seq)) { + result.Add(seq); + } + } + return result; + } + + /** + * Creates a new look-ahead set filter. The filter will contain + * all sequences from this set, possibly left trimmed by each one + * of the sequences in the specified set. + * + * @param set the look-ahead set to trim with + * + * @return a new look-ahead set filter + */ + public LookAheadSet CreateFilter(LookAheadSet set) { + LookAheadSet result = new LookAheadSet(maxLength); + Sequence first; + Sequence second; + + // Handle special cases + if (this.Size() <= 0 || set.Size() <= 0) { + return this; + } + + // Create combinations + for (int i = 0; i < elements.Count; i++) { + first = (Sequence) elements[i]; + for (int j = 0; j < set.elements.Count; j++) { + second = (Sequence) set.elements[j]; + if (first.StartsWith(second)) { + result.Add(first.Subsequence(second.Length())); + } + } + } + return result; + } + + /** + * Creates a new identical look-ahead set, except for the + * repeat flag being set in each token sequence. + * + * @return a new repetitive look-ahead set + */ + public LookAheadSet CreateRepetitive() { + LookAheadSet result = new LookAheadSet(maxLength); + Sequence seq; + + for (int i = 0; i < elements.Count; i++) { + seq = (Sequence) elements[i]; + if (seq.IsRepetitive()) { + result.Add(seq); + } else { + result.Add(new Sequence(true, seq)); + } + } + return result; + } + + /** + * Returns a string representation of this object. + * + * @return a string representation of this object + */ + public override string ToString() { + return ToString(null); + } + + /** + * Returns a string representation of this object. + * + * @param tokenizer the tokenizer containing the tokens + * + * @return a string representation of this object + */ + public string ToString(Tokenizer tokenizer) { + StringBuilder buffer = new StringBuilder(); + Sequence seq; + + buffer.Append("{"); + for (int i = 0; i < elements.Count; i++) { + seq = (Sequence) elements[i]; + buffer.Append("\n "); + buffer.Append(seq.ToString(tokenizer)); + } + buffer.Append("\n}"); + return buffer.ToString(); + } + + + /** + * A token sequence. This class contains a list of token ids. + * It is immutable after creation, meaning that no changes + * will be made to an instance after creation. + * + + * @version 1.0 + */ + private class Sequence { + + /** + * The repeat flag. If this flag is set, the token + * sequence or some part of it may be repeated infinitely. + */ + private bool repeat = false; + + /** + * The list of token ids in this sequence. + */ + private ArrayList tokens = null; + + /** + * Creates a new empty token sequence. The repeat flag + * will be set to false. + */ + public Sequence() { + this.repeat = false; + this.tokens = new ArrayList(0); + } + + /** + * Creates a new token sequence with a single token. + * + * @param repeat the repeat flag value + * @param token the token to add + */ + public Sequence(bool repeat, int token) { + this.repeat = false; + this.tokens = new ArrayList(1); + this.tokens.Add(token); + } + + /** + * Creates a new token sequence that is a duplicate of + * another sequence. Only a limited number of tokens will + * be copied however. The repeat flag from the original + * will be kept intact. + * + * @param length the maximum number of tokens to copy + * @param seq the sequence to copy + */ + public Sequence(int length, Sequence seq) { + this.repeat = seq.repeat; + this.tokens = new ArrayList(length); + if (seq.Length() < length) { + length = seq.Length(); + } + for (int i = 0; i < length; i++) { + tokens.Add(seq.tokens[i]); + } + } + + /** + * Creates a new token sequence that is a duplicate of + * another sequence. The new value of the repeat flag will + * be used however. + * + * @param repeat the new repeat flag value + * @param seq the sequence to copy + */ + public Sequence(bool repeat, Sequence seq) { + this.repeat = repeat; + this.tokens = seq.tokens; + } + + /** + * Returns the length of the token sequence. + * + * @return the number of tokens in the sequence + */ + public int Length() { + return tokens.Count; + } + + /** + * Returns a token at a specified position in the sequence. + * + * @param pos the sequence position + * + * @return the token id found, or null + */ + public object GetToken(int pos) { + if (pos >= 0 && pos < tokens.Count) { + return tokens[pos]; + } else { + return null; + } + } + + /** + * Checks if this sequence is equal to another object. + * Only token sequences with the same tokens in the same + * order will be considered equal. The repeat flag will be + * disregarded. + * + * @param obj the object to compare with + * + * @return true if the objects are equal, or + * false otherwise + */ + public override bool Equals(object obj) { + if (obj is Sequence) { + return Equals((Sequence) obj); + } else { + return false; + } + } + + /** + * Checks if this sequence is equal to another sequence. + * Only sequences with the same tokens in the same order + * will be considered equal. The repeat flag will be + * disregarded. + * + * @param seq the sequence to compare with + * + * @return true if the sequences are equal, or + * false otherwise + */ + public bool Equals(Sequence seq) { + if (tokens.Count != seq.tokens.Count) { + return false; + } + for (int i = 0; i < tokens.Count; i++) { + if (!tokens[i].Equals(seq.tokens[i])) { + return false; + } + } + return true; + } + + /** + * Returns a hash code for this object. + * + * @return a hash code for this object + */ + public override int GetHashCode() { + return tokens.Count.GetHashCode(); + } + + /** + * Checks if this token sequence starts with the tokens from + * another sequence. If the other sequence is longer than this + * sequence, this method will always return false. + * + * @param seq the token sequence to check + * + * @return true if this sequence starts with the other, or + * false otherwise + */ + public bool StartsWith(Sequence seq) { + if (Length() < seq.Length()) { + return false; + } + for (int i = 0; i < seq.tokens.Count; i++) { + if (!tokens[i].Equals(seq.tokens[i])) { + return false; + } + } + return true; + } + + /** + * Checks if this token sequence is repetitive. A repetitive + * token sequence is one with the repeat flag set. + * + * @return true if this token sequence is repetitive, or + * false otherwise + */ + public bool IsRepetitive() { + return repeat; + } + + /** + * Checks if the next token(s) in the parser matches this + * token sequence. + * + * @param parser the parser to check + * + * @return true if the next tokens are in the sequence, or + * false otherwise + */ + public bool IsNext(Parser parser) { + Token token; + int id; + + for (int i = 0; i < tokens.Count; i++) { + id = (int) tokens[i]; + token = parser.PeekToken(i); + if (token == null || token.Id != id) { + return false; + } + } + return true; + } + + /** + * Checks if the next token(s) in the parser matches this + * token sequence. + * + * @param parser the parser to check + * @param length the maximum number of tokens to check + * + * @return true if the next tokens are in the sequence, or + * false otherwise + */ + public bool IsNext(Parser parser, int length) { + Token token; + int id; + + if (length > tokens.Count) { + length = tokens.Count; + } + for (int i = 0; i < length; i++) { + id = (int) tokens[i]; + token = parser.PeekToken(i); + if (token == null || token.Id != id) { + return false; + } + } + return true; + } + + /** + * Returns a string representation of this object. + * + * @return a string representation of this object + */ + public override string ToString() { + return ToString(null); + } + + /** + * Returns a string representation of this object. + * + * @param tokenizer the tokenizer containing the tokens + * + * @return a string representation of this object + */ + public string ToString(Tokenizer tokenizer) { + StringBuilder buffer = new StringBuilder(); + string str; + int id; + + if (tokenizer == null) { + buffer.Append(tokens.ToString()); + } else { + buffer.Append("["); + for (int i = 0; i < tokens.Count; i++) { + id = (int) tokens[i]; + str = tokenizer.GetPatternDescription(id); + if (i > 0) { + buffer.Append(" "); + } + buffer.Append(str); + } + buffer.Append("]"); + } + if (repeat) { + buffer.Append(" *"); + } + return buffer.ToString(); + } + + /** + * Creates a new token sequence that is the concatenation + * of this sequence and another. A maximum length for the + * new sequence is also specified. + * + * @param length the maximum length of the result + * @param seq the other sequence + * + * @return the concatenated token sequence + */ + public Sequence Concat(int length, Sequence seq) { + Sequence res = new Sequence(length, this); + + if (seq.repeat) { + res.repeat = true; + } + length -= this.Length(); + if (length > seq.Length()) { + res.tokens.AddRange(seq.tokens); + } else { + for (int i = 0; i < length; i++) { + res.tokens.Add(seq.tokens[i]); + } + } + return res; + } + + /** + * Creates a new token sequence that is a subsequence of + * this one. + * + * @param start the subsequence start position + * + * @return the new token subsequence + */ + public Sequence Subsequence(int start) { + Sequence res = new Sequence(Length(), this); + + while (start > 0 && res.tokens.Count > 0) { + res.tokens.RemoveAt(0); + start--; + } + return res; + } + } + } +} diff --git a/Core Library/Core Library/Node.cs b/Core Library/Core Library/Node.cs new file mode 100644 index 0000000..1f486c5 --- /dev/null +++ b/Core Library/Core Library/Node.cs @@ -0,0 +1,492 @@ +/* + * Node.cs + */ + +using System.Collections; +using System.IO; + +namespace Core.Library { + + /** + * An abstract parse tree node. This class is inherited by all + * nodes in the parse tree, i.e. by the token and production + * classes. + * + + * + */ + public abstract class Node { + + /** + * The parent node. + */ + private Node parent = null; + + /** + * The computed node values. + */ + private ArrayList values = null; + + /** + * Checks if this node is hidden, i.e. if it should not be + * visible outside the parser. + * + * @return true if the node should be hidden, or + * false otherwise + */ + internal virtual bool IsHidden() { + return false; + } + + /** + * The node type id property (read-only). This value is set as + * a unique identifier for each type of node, in order to + * simplify later identification. + * + * + */ + public abstract int Id { + get; + } + + /** + * Returns the node type id. This value is set as a unique + * identifier for each type of node, in order to simplify + * later identification. + * + * @return the node type id + * + * @see #Id + * + * @deprecated Use the Id property instead. + */ + public virtual int GetId() { + return Id; + } + + /** + * The node name property (read-only). + * + * + */ + public abstract string Name { + get; + } + + /** + * Returns the node name. + * + * @return the node name + * + * @see #Name + * + * @deprecated Use the Name property instead. + */ + public virtual string GetName() { + return Name; + } + + /** + * The line number property of the first character in this + * node (read-only). If the node has child elements, this + * value will be fetched from the first child. + * + * + */ + public virtual int StartLine { + get { + int line; + + for (int i = 0; i < Count; i++) { + line = this[i].StartLine; + if (line >= 0) { + return line; + } + } + return -1; + } + } + + /** + * The line number of the first character in this node. If the + * node has child elements, this value will be fetched from + * the first child. + * + * @return the line number of the first character, or + * -1 if not applicable + * + * @see #StartLine + * + * @deprecated Use the StartLine property instead. + */ + public virtual int GetStartLine() { + return StartLine; + } + + /** + * The column number property of the first character in this + * node (read-only). If the node has child elements, this + * value will be fetched from the first child. + * + * + */ + public virtual int StartColumn { + get { + int col; + + for (int i = 0; i < Count; i++) { + col = this[i].StartColumn; + if (col >= 0) { + return col; + } + } + return -1; + } + } + + /** + * The column number of the first character in this node. If + * the node has child elements, this value will be fetched + * from the first child. + * + * @return the column number of the first token character, or + * -1 if not applicable + * + * @see #StartColumn + * + * @deprecated Use the StartColumn property instead. + */ + public virtual int GetStartColumn() { + return StartColumn; + } + + /** + * The line number property of the last character in this node + * (read-only). If the node has child elements, this value + * will be fetched from the last child. + * + * + */ + public virtual int EndLine { + get { + int line; + + for (int i = Count - 1; i >= 0; i--) { + line = this[i].EndLine; + if (line >= 0) { + return line; + } + } + return -1; + } + } + + /** + * The line number of the last character in this node. If the + * node has child elements, this value will be fetched from + * the last child. + * + * @return the line number of the last token character, or + * -1 if not applicable + * + * @see #EndLine + * + * @deprecated Use the EndLine property instead. + */ + public virtual int GetEndLine() { + return EndLine; + } + + /** + * The column number property of the last character in this + * node (read-only). If the node has child elements, this + * value will be fetched from the last child. + * + * + */ + public virtual int EndColumn { + get { + int col; + + for (int i = Count - 1; i >= 0; i--) { + col = this[i].EndColumn; + if (col >= 0) { + return col; + } + } + return -1; + } + } + + /** + * The column number of the last character in this node. If + * the node has child elements, this value will be fetched + * from the last child. + * + * @return the column number of the last token character, or + * -1 if not applicable + * + * @see #EndColumn + * + * @deprecated Use the EndColumn property instead. + */ + public virtual int GetEndColumn() { + return EndColumn; + } + + /** + * The parent node property (read-only). + * + * + */ + public Node Parent { + get { + return parent; + } + set { + this.parent = value; + } + } + + /** + * Returns the parent node. + * + * @return the parent parse tree node + * + * @see #Parent + * + * @deprecated Use the Parent property instead. + */ + public Node GetParent() { + return Parent; + } + + /** + * Sets the parent node. + * + * @param parent the new parent node + */ + public void SetParent(Node parent) { + Parent = parent; + } + + /** + * The child node count property (read-only). + * + * + */ + public virtual int Count { + get { + return 0; + } + } + + /** + * Returns the number of child nodes. + * + * @return the number of child nodes + * + * @deprecated Use the Count property instead. + */ + public virtual int GetChildCount() { + return Count; + } + + /** + * Returns the number of descendant nodes. + * + * @return the number of descendant nodes + * + * + */ + public int GetDescendantCount() { + int count = 0; + + for (int i = 0; i < Count; i++) { + count += 1 + this[i].GetDescendantCount(); + } + return count; + } + + /** + * The child node index (read-only). + * + * @param index the child index, 0 <= index < Count + * + * @return the child node found, or + * null if index out of bounds + * + * + */ + public virtual Node this[int index] { + get { + return null; + } + } + + /** + * Returns the child node with the specified index. + * + * @param index the child index, 0 <= index < count + * + * @return the child node found, or + * null if index out of bounds + * + * @deprecated Use the class indexer instead. + */ + public virtual Node GetChildAt(int index) { + return this[index]; + } + + /** + * The node values property. This property provides direct + * access to the list of computed values associated with this + * node during analysis. Note that setting this property to + * null will remove all node values. Any operation on the + * value array list is allowed and is immediately reflected + * through the various value reading and manipulation methods. + * + * + */ + public ArrayList Values { + get { + if (values == null) { + values = new ArrayList(); + } + return values; + } + set { + this.values = value; + } + } + + /** + * Returns the number of computed values associated with this + * node. Any number of values can be associated with a node + * through calls to AddValue(). + * + * @return the number of values associated with this node + * + * @see #Values + * + * @deprecated Use the Values and Values.Count properties + * instead. + */ + public int GetValueCount() { + if (values == null) { + return 0; + } else { + return values.Count; + } + } + + /** + * Returns a computed value of this node, if previously set. A + * value may be used for storing intermediate results in the + * parse tree during analysis. + * + * @param pos the value position, 0 <= pos < count + * + * @return the computed node value, or + * null if not set + * + * @see #Values + * + * @deprecated Use the Values property and it's array indexer + * instead. + */ + public object GetValue(int pos) { + return Values[pos]; + } + + /** + * Returns the list with all the computed values for this + * node. Note that the list is not a copy, so changes will + * affect the values in this node (as it is the same object). + * + * @return a list with all values, or + * null if no values have been set + * + * @see #Values + * + * @deprecated Use the Values property instead. Note that the + * Values property will never be null, but possibly empty. + */ + public ArrayList GetAllValues() { + return values; + } + + /** + * Adds a computed value to this node. The computed value may + * be used for storing intermediate results in the parse tree + * during analysis. + * + * @param value the node value + * + * @see #Values + * + * @deprecated Use the Values property and the Values.Add + * method instead. + */ + public void AddValue(object value) { + if (value != null) { + Values.Add(value); + } + } + + /** + * Adds a set of computed values to this node. + * + * @param values the vector with node values + * + * @see #Values + * + * @deprecated Use the Values property and the Values.AddRange + * method instead. + */ + public void AddValues(ArrayList values) { + if (values != null) { + Values.AddRange(values); + } + } + + /** + * Removes all computed values stored in this node. + * + * @see #Values + * + * @deprecated Use the Values property and the Values.Clear + * method instead. Alternatively the Values property can + * be set to null. + */ + public void RemoveAllValues() { + values = null; + } + + /** + * Prints this node and all subnodes to the specified output + * stream. + * + * @param output the output stream to use + */ + public void PrintTo(TextWriter output) { + PrintTo(output, ""); + output.Flush(); + } + + /** + * Prints this node and all subnodes to the specified output + * stream. + * + * @param output the output stream to use + * @param indent the indentation string + */ + private void PrintTo(TextWriter output, string indent) { + output.WriteLine(indent + ToString()); + indent = indent + " "; + for (int i = 0; i < Count; i++) { + this[i].PrintTo(output, indent); + } + } + } +} diff --git a/Core Library/Core Library/ParseException.cs b/Core Library/Core Library/ParseException.cs new file mode 100644 index 0000000..85057c7 --- /dev/null +++ b/Core Library/Core Library/ParseException.cs @@ -0,0 +1,395 @@ +/* + * ParseException.cs + */ + +using System; +using System.Collections; +using System.Text; + +namespace Core.Library { + + /** + * A parse exception. + * + + * + */ + public class ParseException : Exception { + + /** + * The error type enumeration. + */ + public enum ErrorType { + + /** + * The internal error type is only used to signal an error + * that is a result of a bug in the parser or tokenizer + * code. + */ + INTERNAL, + + /** + * The I/O error type is used for stream I/O errors. + */ + IO, + + /** + * The unexpected end of file error type is used when end + * of file is encountered instead of a valid token. + */ + UNEXPECTED_EOF, + + /** + * The unexpected character error type is used when a + * character is read that isn't handled by one of the + * token patterns. + */ + UNEXPECTED_CHAR, + + /** + * The unexpected token error type is used when another + * token than the expected one is encountered. + */ + UNEXPECTED_TOKEN, + + /** + * The invalid token error type is used when a token + * pattern with an error message is matched. The + * additional information provided should contain the + * error message. + */ + INVALID_TOKEN, + + /** + * The analysis error type is used when an error is + * encountered in the analysis. The additional information + * provided should contain the error message. + */ + ANALYSIS + } + + /** + * The error type. + */ + private ErrorType type; + + /** + * The additional information string. + */ + private string info; + + /** + * The additional details information. This variable is only + * used for unexpected token errors. + */ + private ArrayList details; + + /** + * The line number. + */ + private int line; + + /** + * The column number. + */ + private int column; + + /** + * Creates a new parse exception. + * + * @param type the parse error type + * @param info the additional information + * @param line the line number, or -1 for unknown + * @param column the column number, or -1 for unknown + */ + public ParseException(ErrorType type, + string info, + int line, + int column) + : this(type, info, null, line, column) { + } + + /** + * Creates a new parse exception. This constructor is only + * used to supply the detailed information array, which is + * only used for expected token errors. The list then contains + * descriptions of the expected tokens. + * + * @param type the parse error type + * @param info the additional information + * @param details the additional detailed information + * @param line the line number, or -1 for unknown + * @param column the column number, or -1 for unknown + */ + public ParseException(ErrorType type, + string info, + ArrayList details, + int line, + int column) { + + this.type = type; + this.info = info; + this.details = details; + this.line = line; + this.column = column; + } + + /** + * The error type property (read-only). + * + * + */ + public ErrorType Type { + get { + return type; + } + } + + /** + * Returns the error type. + * + * @return the error type + * + * @see #Type + * + * @deprecated Use the Type property instead. + */ + public ErrorType GetErrorType() { + return Type; + } + + /** + * The additional error information property (read-only). + * + * + */ + public string Info { + get { + return info; + } + } + + /** + * Returns the additional error information. + * + * @return the additional error information + * + * @see #Info + * + * @deprecated Use the Info property instead. + */ + public string GetInfo() { + return Info; + } + + /** + * The additional detailed error information property + * (read-only). + * + * + */ + public ArrayList Details { + get { + return new ArrayList(details); + } + } + + /** + * Returns the additional detailed error information. + * + * @return the additional detailed error information + * + * @see #Details + * + * @deprecated Use the Details property instead. + */ + public ArrayList GetDetails() { + return Details; + } + + /** + * The line number property (read-only). This is the line + * number where the error occured, or -1 if unknown. + * + * + */ + public int Line { + get { + return line; + } + } + + /** + * Returns the line number where the error occured. + * + * @return the line number of the error, or + * -1 if unknown + * + * @see #Line + * + * @deprecated Use the Line property instead. + */ + public int GetLine() { + return Line; + } + + /** + * The column number property (read-only). This is the column + * number where the error occured, or -1 if unknown. + * + * + */ + public int Column { + get { + return column; + } + } + + /** + * Returns the column number where the error occured. + * + * @return the column number of the error, or + * -1 if unknown + * + * @see #Column + * + * @deprecated Use the Column property instead. + */ + public int GetColumn() { + return column; + } + + /** + * The message property (read-only). This property contains + * the detailed exception error message, including line and + * column numbers when available. + * + * @see #ErrorMessage + */ + public override string Message { + get{ + StringBuilder buffer = new StringBuilder(); + + // Add error description + buffer.Append(ErrorMessage); + + // Add line and column + if (line > 0 && column > 0) { + buffer.Append(", on line: "); + buffer.Append(line); + buffer.Append(" column: "); + buffer.Append(column); + } + + return buffer.ToString(); + } + } + + /** + * Returns a default error message. + * + * @return a default error message + * + * @see #Message + * + * @deprecated Use the Message property instead. + */ + public string GetMessage() { + return Message; + } + + /** + * The error message property (read-only). This property + * contains all the information available, except for the line + * and column number information. + * + * @see #Message + * + * + */ + public string ErrorMessage { + get { + StringBuilder buffer = new StringBuilder(); + + // Add type and info + switch (type) { + case ErrorType.IO: + buffer.Append("I/O error: "); + buffer.Append(info); + break; + case ErrorType.UNEXPECTED_EOF: + buffer.Append("unexpected end of file"); + break; + case ErrorType.UNEXPECTED_CHAR: + buffer.Append("unexpected character '"); + buffer.Append(info); + buffer.Append("'"); + break; + case ErrorType.UNEXPECTED_TOKEN: + buffer.Append("unexpected token "); + buffer.Append(info); + if (details != null) { + buffer.Append(", expected "); + if (details.Count > 1) { + buffer.Append("one of "); + } + buffer.Append(GetMessageDetails()); + } + break; + case ErrorType.INVALID_TOKEN: + buffer.Append(info); + break; + case ErrorType.ANALYSIS: + buffer.Append(info); + break; + default: + buffer.Append("internal error"); + if (info != null) { + buffer.Append(": "); + buffer.Append(info); + } + break; + } + + return buffer.ToString(); + } + } + + /** + * Returns the error message. This message will contain all the + * information available, except for the line and column number + * information. + * + * @return the error message + * + * @see #ErrorMessage + * + * @deprecated Use the ErrorMessage property instead. + */ + public string GetErrorMessage() { + return ErrorMessage; + } + + /** + * Returns a string containing all the detailed information in + * a list. The elements are separated with a comma. + * + * @return the detailed information string + */ + private string GetMessageDetails() { + StringBuilder buffer = new StringBuilder(); + + for (int i = 0; i < details.Count; i++) { + if (i > 0) { + buffer.Append(", "); + if (i + 1 == details.Count) { + buffer.Append("or "); + } + } + buffer.Append(details[i]); + } + + return buffer.ToString(); + } + } +} diff --git a/Core Library/Core Library/Parser.cs b/Core Library/Core Library/Parser.cs new file mode 100644 index 0000000..89a67cd --- /dev/null +++ b/Core Library/Core Library/Parser.cs @@ -0,0 +1,818 @@ +/* + * Parser.cs + * + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Text; + +namespace Core.Library { + + /** + * A base parser class. This class provides the standard parser + * interface, as well as token handling. + * + + + */ + public abstract class Parser { + + /** + * The parser initialization flag. + */ + private bool initialized = false; + + /** + * The production output out of RecursiveDescentParser. + */ + public SyntaxProductions production = new SyntaxProductions(); + + + + /** + * Get the Production set of production. + */ + public string GetRecursiveProduction() + { + return ("Enter: \n" + production.GetRecursiveProductions()); + } + + public int GetLastProductionCode() + { + return production.GetLastProductionCode(); + } + + public string GetLastProductionState() + { + return production.GetLastProductionState(); + } + + public List GetAllProductionState() + { + return production.GetAllProductionState(); + } + + public List GetAllProductionCode() + { + return production.GetAllProductionCode(); + } + + + /** + * The tokenizer to use. + */ + private Tokenizer tokenizer; + + /** + * The analyzer to use for callbacks. + */ + private Analyzer analyzer; + + /** + * The list of production patterns. + */ + private ArrayList patterns = new ArrayList(); + + /** + * The map with production patterns and their id:s. This map + * contains the production patterns indexed by their id:s. + */ + private Hashtable patternIds = new Hashtable(); + + /** + * The list of buffered tokens. This list will contain tokens that + * have been read from the tokenizer, but not yet consumed. + */ + private ArrayList tokens = new ArrayList(); + + /** + * The error log. All parse errors will be added to this log as + * the parser attempts to recover from the error. If the error + * count is higher than zero (0), this log will be thrown as the + * result from the parse() method. + */ + private ParserLogException errorLog = new ParserLogException(); + + /** + * The error recovery counter. This counter is initially set to a + * negative value to indicate that no error requiring recovery + * has been encountered. When a parse error is found, the counter + * is set to three (3), and is then decreased by one for each + * correctly read token until it reaches zero (0). + */ + private int errorRecovery = -1; + + /** + * Creates a new parser. + * + * @param input the input stream to read from + * + * @throws ParserCreationException if the tokenizer couldn't be + * initialized correctly + * + * + */ + internal Parser(TextReader input) : this(input, null) { + } + + /** + * Creates a new parser. + * + * @param input the input stream to read from + * @param analyzer the analyzer callback to use + * + * @throws ParserCreationException if the tokenizer couldn't be + * initialized correctly + * + * + */ + internal Parser(TextReader input, Analyzer analyzer) { + this.tokenizer = NewTokenizer(input); + this.analyzer = (analyzer == null) ? NewAnalyzer() : analyzer; + } + + /** + * Creates a new parser. + * + * @param tokenizer the tokenizer to use + */ + internal Parser(Tokenizer tokenizer) : this(tokenizer, null) { + } + + /** + * Creates a new parser. + * + * @param tokenizer the tokenizer to use + * @param analyzer the analyzer callback to use + */ + internal Parser(Tokenizer tokenizer, Analyzer analyzer) { + this.tokenizer = tokenizer; + this.analyzer = (analyzer == null) ? NewAnalyzer() : analyzer; + } + + /** + * Creates a new tokenizer for this parser. Can be overridden by + * a subclass to provide a custom implementation. + * + * @param in the input stream to read from + * + * @return the tokenizer created + * + * @throws ParserCreationException if the tokenizer couldn't be + * initialized correctly + * + * + */ + protected virtual Tokenizer NewTokenizer(TextReader input) { + // TODO: This method should really be abstract, but it isn't in this + // version due to backwards compatibility requirements. + return new Tokenizer(input); + } + + /** + * Creates a new analyzer for this parser. Can be overridden by a + * subclass to provide a custom implementation. + * + * @return the analyzer created + * + * + */ + protected virtual Analyzer NewAnalyzer() { + // TODO: This method should really be abstract, but it isn't in this + // version due to backwards compatibility requirements. + return new Analyzer(); + } + + /** + * The tokenizer property (read-only). This property contains + * the tokenizer in use by this parser. + * + * + */ + public Tokenizer Tokenizer { + get { + return tokenizer; + } + } + + /** + * The analyzer property (read-only). This property contains + * the analyzer in use by this parser. + * + * + */ + public Analyzer Analyzer { + get { + return analyzer; + } + } + + /** + * Returns the tokenizer in use by this parser. + * + * @return the tokenizer in use by this parser + * + * + * + * @see #Tokenizer + * + * @deprecated Use the Tokenizer property instead. + */ + public Tokenizer GetTokenizer() { + return Tokenizer; + } + + /** + * Returns the analyzer in use by this parser. + * + * @return the analyzer in use by this parser + * + * + * + * @see #Analyzer + * + * @deprecated Use the Analyzer property instead. + */ + public Analyzer GetAnalyzer() { + return Analyzer; + } + + /** + * Sets the parser initialized flag. Normally this flag is set by + * the prepare() method, but this method allows further + * modifications to it. + * + * @param initialized the new initialized flag + */ + internal void SetInitialized(bool initialized) { + this.initialized = initialized; + } + + /** + * Adds a new production pattern to the parser. The first pattern + * added is assumed to be the starting point in the grammar. The + * patterns added may be validated to some extent. + * + * @param pattern the pattern to add + * + * @throws ParserCreationException if the pattern couldn't be + * added correctly to the parser + */ + public virtual void AddPattern(ProductionPattern pattern) { + if (pattern.Count <= 0) { + throw new ParserCreationException( + ParserCreationException.ErrorType.INVALID_PRODUCTION, + pattern.Name, + "no production alternatives are present (must have at " + + "least one)"); + } + if (patternIds.ContainsKey(pattern.Id)) { + throw new ParserCreationException( + ParserCreationException.ErrorType.INVALID_PRODUCTION, + pattern.Name, + "another pattern with the same id (" + pattern.Id + + ") has already been added"); + } + patterns.Add(pattern); + patternIds.Add(pattern.Id, pattern); + SetInitialized(false); + } + + /** + * Initializes the parser. All the added production patterns will + * be analyzed for ambiguities and errors. This method also + * initializes internal data structures used during the parsing. + * + * @throws ParserCreationException if the parser couldn't be + * initialized correctly + */ + public virtual void Prepare() { + if (patterns.Count <= 0) { + throw new ParserCreationException( + ParserCreationException.ErrorType.INVALID_PARSER, + "no production patterns have been added"); + } + for (int i = 0; i < patterns.Count; i++) { + CheckPattern((ProductionPattern) patterns[i]); + } + SetInitialized(true); + } + + /** + * Checks a production pattern for completeness. If some rule + * in the pattern referenced an production pattern not added + * to this parser, a parser creation exception will be thrown. + * + * @param pattern the production pattern to check + * + * @throws ParserCreationException if the pattern referenced a + * pattern not added to this parser + */ + private void CheckPattern(ProductionPattern pattern) { + for (int i = 0; i < pattern.Count; i++) { + CheckAlternative(pattern.Name, pattern[i]); + } + } + + /** + * Checks a production pattern alternative for completeness. + * If some element in the alternative referenced a production + * pattern not added to this parser, a parser creation + * exception will be thrown. + * + * @param name the name of the pattern being checked + * @param alt the production pattern alternative + * + * @throws ParserCreationException if the alternative + * referenced a pattern not added to this parser + */ + private void CheckAlternative(string name, + ProductionPatternAlternative alt) { + + for (int i = 0; i < alt.Count; i++) { + CheckElement(name, alt[i]); + } + } + + /** + * Checks a production pattern element for completeness. If + * the element references a production pattern not added to + * this parser, a parser creation exception will be thrown. + * + * @param name the name of the pattern being checked + * @param elem the production pattern element to check + * + * @throws ParserCreationException if the element referenced a + * pattern not added to this parser + */ + private void CheckElement(string name, + ProductionPatternElement elem) { + + if (elem.IsProduction() && GetPattern(elem.Id) == null) { + throw new ParserCreationException( + ParserCreationException.ErrorType.INVALID_PRODUCTION, + name, + "an undefined production pattern id (" + elem.Id + + ") is referenced"); + } + } + + /** + * Resets this parser for usage with another input stream. The + * associated tokenizer and analyzer will also be reset. This + * method will clear all the internal state and the error log in + * the parser. It is normally called in order to reuse a parser + * and tokenizer pair with multiple input streams, thereby + * avoiding the cost of re-analyzing the grammar structures. + * + * @param input the new input stream to read + * + * @see Tokenizer#Reset + * @see Analyzer#Reset + * + * + */ + public void Reset(TextReader input) { + this.tokenizer.Reset(input); + this.analyzer.Reset(); + } + + /** + * Resets this parser for usage with another input stream. The + * associated tokenizer will also be reset and the analyzer + * replaced. This method will clear all the internal state and + * the error log in the parser. It is normally called in order + * to reuse a parser and tokenizer pair with multiple input + * streams, thereby avoiding the cost of re-analyzing the + * grammar structures. + * + * @param input the new input stream to read + * @param analyzer the new analyzer callback to use + * + * @see Tokenizer#Reset + * + * @since 1.6 + */ + public void Reset(TextReader input, Analyzer analyzer) { + this.tokenizer.Reset(input); + this.analyzer = analyzer; + } + + /** + * Parses the token stream and returns a parse tree. This + * method will call Prepare() if not previously called. It + * will also call the Reset() method, to make sure that only + * the Tokenizer.Reset() method must be explicitly called in + * order to reuse a parser for multiple input streams. In case + * of a parse error, the parser will attempt to recover and + * throw all the errors found in a parser log exception in the + * end. + * + * @return the parse tree + * + * @throws ParserCreationException if the parser couldn't be + * initialized correctly + * @throws ParserLogException if the input couldn't be parsed + * correctly + * + * @see #Prepare + * @see #Reset + * @see Tokenizer#Reset + */ + public Node Parse() { + Node root = null; + + // Initialize parser + if (!initialized) { + Prepare(); + } + this.tokens.Clear(); + this.errorLog = new ParserLogException(); + this.errorRecovery = -1; + + // Parse input + try { + root = ParseStart(); + } catch (ParseException e) { + AddError(e, true); + } + + // Check for errors + if (errorLog.Count > 0) { + throw errorLog; + } + + return root; + } + + /** + * Parses the token stream and returns a parse tree. + * + * @return the parse tree + * + * @throws ParseException if the input couldn't be parsed + * correctly + */ + protected abstract Node ParseStart(); + + /** + * Factory method to create a new production node. This method + * can be overridden to provide other production implementations + * than the default one. + * + * @param pattern the production pattern + * + * @return the new production node + * + * + */ + protected virtual Production NewProduction(ProductionPattern pattern) { + return analyzer.NewProduction(pattern); + } + + /** + * Adds an error to the error log. If the parser is in error + * recovery mode, the error will not be added to the log. If the + * recovery flag is set, this method will set the error recovery + * counter thus enter error recovery mode. Only lexical or + * syntactical errors require recovery, so this flag shouldn't be + * set otherwise. + * + * @param e the error to add + * @param recovery the recover flag + */ + internal void AddError(ParseException e, bool recovery) { + if (errorRecovery <= 0) { + errorLog.AddError(e); + } + if (recovery) { + errorRecovery = 3; + } + } + + /** + * Returns the production pattern with the specified id. + * + * @param id the production pattern id + * + * @return the production pattern found, or + * null if non-existent + */ + internal ProductionPattern GetPattern(int id) { + return (ProductionPattern) patternIds[id]; + } + + /** + * Returns the production pattern for the starting production. + * + * @return the start production pattern, or + * null if no patterns have been added + */ + internal ProductionPattern GetStartPattern() { + if (patterns.Count <= 0) { + return null; + } else { + return (ProductionPattern) patterns[0]; + } + } + + /** + * Returns the ordered set of production patterns. + * + * @return the ordered set of production patterns + */ + internal ICollection GetPatterns() { + return patterns; + } + + /** + * Handles the parser entering a production. This method calls the + * appropriate analyzer callback if the node is not hidden. Note + * that this method will not call any callback if an error + * requiring recovery has ocurred. + * + * @param node the parse tree node + */ + internal void EnterNode(Node node) { + if (!node.IsHidden() && errorRecovery < 0) { + try { + analyzer.Enter(node); + } catch (ParseException e) { + AddError(e, false); + } + } + } + + /** + * Handles the parser leaving a production. This method calls the + * appropriate analyzer callback if the node is not hidden, and + * returns the result. Note that this method will not call any + * callback if an error requiring recovery has ocurred. + * + * @param node the parse tree node + * + * @return the parse tree node, or + * null if no parse tree should be created + */ + internal Node ExitNode(Node node) { + if (!node.IsHidden() && errorRecovery < 0) { + try { + return analyzer.Exit(node); + } catch (ParseException e) { + AddError(e, false); + } + } + return node; + } + + /** + * Handles the parser adding a child node to a production. This + * method calls the appropriate analyzer callback. Note that this + * method will not call any callback if an error requiring + * recovery has ocurred. + * + * @param node the parent parse tree node + * @param child the child parse tree node, or null + */ + internal void AddNode(Production node, Node child) { + if (errorRecovery >= 0) { + // Do nothing + } else if (node.IsHidden()) { + node.AddChild(child); + } else if (child != null && child.IsHidden()) { + for (int i = 0; i < child.Count; i++) { + AddNode(node, child[i]); + } + } else { + try { + analyzer.Child(node, child); + } catch (ParseException e) { + AddError(e, false); + } + } + } + + /** + * Reads and consumes the next token in the queue. If no token + * was available for consumation, a parse error will be + * thrown. + * + * @return the token consumed + * + * @throws ParseException if the input stream couldn't be read or + * parsed correctly + */ + internal Token NextToken() { + Token token = PeekToken(0); + + if (token != null) { + tokens.RemoveAt(0); + return token; + } else { + throw new ParseException( + ParseException.ErrorType.UNEXPECTED_EOF, + null, + tokenizer.GetCurrentLine(), + tokenizer.GetCurrentColumn()); + } + } + + /** + * Reads and consumes the next token in the queue. If no token was + * available for consumation, a parse error will be thrown. A + * parse error will also be thrown if the token id didn't match + * the specified one. + * + * @param id the expected token id + * + * @return the token consumed + * + * @throws ParseException if the input stream couldn't be parsed + * correctly, or if the token wasn't expected + */ + internal Token NextToken(int id) { + Token token = NextToken(); + ArrayList list; + + if (token.Id == id) { + if (errorRecovery > 0) { + errorRecovery--; + } + return token; + } else { + list = new ArrayList(1); + list.Add(tokenizer.GetPatternDescription(id)); + throw new ParseException( + ParseException.ErrorType.UNEXPECTED_TOKEN, + token.ToShortString(), + list, + token.StartLine, + token.StartColumn); + } + } + + /** + * Returns a token from the queue. This method is used to check + * coming tokens before they have been consumed. Any number of + * tokens forward can be checked. + * + * @param steps the token queue number, zero (0) for first + * + * @return the token in the queue, or + * null if no more tokens in the queue + */ + internal Token PeekToken(int steps) { + Token token; + + while (steps >= tokens.Count) { + try { + token = tokenizer.Next(); + if (token == null) { + return null; + } else { + tokens.Add(token); + } + } catch (ParseException e) { + AddError(e, true); + } + } + return (Token) tokens[steps]; + } + + /** + * Returns a string representation of this parser. The string will + * contain all the production definitions and various additional + * information. + * + * @return a detailed string representation of this parser + */ + public override string ToString() { + StringBuilder buffer = new StringBuilder(); + + for (int i = 0; i < patterns.Count; i++) { + buffer.Append(ToString((ProductionPattern) patterns[i])); + buffer.Append("\n"); + } + return buffer.ToString(); + } + + /** + * Returns a string representation of a production pattern. + * + * @param prod the production pattern + * + * @return a detailed string representation of the pattern + */ + private string ToString(ProductionPattern prod) { + StringBuilder buffer = new StringBuilder(); + StringBuilder indent = new StringBuilder(); + LookAheadSet set; + int i; + + buffer.Append(prod.Name); + buffer.Append(" ("); + buffer.Append(prod.Id); + buffer.Append(") "); + for (i = 0; i < buffer.Length; i++) { + indent.Append(" "); + } + buffer.Append("= "); + indent.Append("| "); + for (i = 0; i < prod.Count; i++) { + if (i > 0) { + buffer.Append(indent); + } + buffer.Append(ToString(prod[i])); + buffer.Append("\n"); + } + for (i = 0; i < prod.Count; i++) { + set = prod[i].LookAhead; + if (set.GetMaxLength() > 1) { + buffer.Append("Using "); + buffer.Append(set.GetMaxLength()); + buffer.Append(" token look-ahead for alternative "); + buffer.Append(i + 1); + buffer.Append(": "); + buffer.Append(set.ToString(tokenizer)); + buffer.Append("\n"); + } + } + return buffer.ToString(); + } + + /** + * Returns a string representation of a production pattern + * alternative. + * + * @param alt the production pattern alternative + * + * @return a detailed string representation of the alternative + */ + private string ToString(ProductionPatternAlternative alt) { + StringBuilder buffer = new StringBuilder(); + + for (int i = 0; i < alt.Count; i++) { + if (i > 0) { + buffer.Append(" "); + } + buffer.Append(ToString(alt[i])); + } + return buffer.ToString(); + } + + /** + * Returns a string representation of a production pattern + * element. + * + * @param elem the production pattern element + * + * @return a detailed string representation of the element + */ + private string ToString(ProductionPatternElement elem) { + StringBuilder buffer = new StringBuilder(); + int min = elem.MinCount; + int max = elem.MaxCount; + + if (min == 0 && max == 1) { + buffer.Append("["); + } + if (elem.IsToken()) { + buffer.Append(GetTokenDescription(elem.Id)); + } else { + buffer.Append(GetPattern(elem.Id).Name); + } + if (min == 0 && max == 1) { + buffer.Append("]"); + } else if (min == 0 && max == Int32.MaxValue) { + buffer.Append("*"); + } else if (min == 1 && max == Int32.MaxValue) { + buffer.Append("+"); + } else if (min != 1 || max != 1) { + buffer.Append("{"); + buffer.Append(min); + buffer.Append(","); + buffer.Append(max); + buffer.Append("}"); + } + return buffer.ToString(); + } + + /** + * Returns a token description for a specified token. + * + * @param token the token to describe + * + * @return the token description + */ + internal string GetTokenDescription(int token) { + if (tokenizer == null) { + return ""; + } else { + return tokenizer.GetPatternDescription(token); + } + } + } +} diff --git a/Core Library/Core Library/ParserCreationException.cs b/Core Library/Core Library/ParserCreationException.cs new file mode 100644 index 0000000..d885da5 --- /dev/null +++ b/Core Library/Core Library/ParserCreationException.cs @@ -0,0 +1,318 @@ +/* + * ParserCreationException.cs + */ + +using System; +using System.Collections; +using System.Text; + +namespace Core.Library { + + /** + * A parser creation exception. This exception is used for signalling + * an error in the token or production patterns, making it impossible + * to create a working parser or tokenizer. + * + + * + */ + public class ParserCreationException : Exception { + + /** + * The error type enumeration. + */ + public enum ErrorType { + + /** + * The internal error type is only used to signal an + * error that is a result of a bug in the parser or + * tokenizer code. + */ + INTERNAL, + + /** + * The invalid parser error type is used when the parser + * as such is invalid. This error is typically caused by + * using a parser without any patterns. + */ + INVALID_PARSER, + + /** + * The invalid token error type is used when a token + * pattern is erroneous. This error is typically caused + * by an invalid pattern type or an erroneous regular + * expression. + */ + INVALID_TOKEN, + + /** + * The invalid production error type is used when a + * production pattern is erroneous. This error is + * typically caused by referencing undeclared productions, + * or violating some other production pattern constraint. + */ + INVALID_PRODUCTION, + + /** + * The infinite loop error type is used when an infinite + * loop has been detected in the grammar. One of the + * productions in the loop will be reported. + */ + INFINITE_LOOP, + + /** + * The inherent ambiguity error type is used when the set + * of production patterns (i.e. the grammar) contains + * ambiguities that cannot be resolved. + */ + INHERENT_AMBIGUITY + } + + /** + * The error type. + */ + private ErrorType type; + + /** + * The token or production pattern name. This variable is only + * set for some error types. + */ + private string name; + + /** + * The additional error information string. This variable is only + * set for some error types. + */ + private string info; + + /** + * The error details list. This variable is only set for some + * error types. + */ + private ArrayList details; + + /** + * Creates a new parser creation exception. + * + * @param type the parse error type + * @param info the additional error information + */ + public ParserCreationException(ErrorType type, + String info) + : this(type, null, info) { + } + + /** + * Creates a new parser creation exception. + * + * @param type the parse error type + * @param name the token or production pattern name + * @param info the additional error information + */ + public ParserCreationException(ErrorType type, + String name, + String info) + : this(type, name, info, null) { + } + + /** + * Creates a new parser creation exception. + * + * @param type the parse error type + * @param name the token or production pattern name + * @param info the additional error information + * @param details the error details list + */ + public ParserCreationException(ErrorType type, + String name, + String info, + ArrayList details) { + + this.type = type; + this.name = name; + this.info = info; + this.details = details; + } + + /** + * The error type property (read-only). + * + * + */ + public ErrorType Type { + get { + return type; + } + } + + /** + * Returns the error type. + * + * @return the error type + * + * @see #Type + * + * @deprecated Use the Type property instead. + */ + public ErrorType GetErrorType() { + return Type; + } + + /** + * The token or production name property (read-only). + * + * + */ + public string Name { + get { + return name; + } + } + + /** + * Returns the token or production name. + * + * @return the token or production name + * + * @see #Name + * + * @deprecated Use the Name property instead. + */ + public string GetName() { + return Name; + } + + /** + * The additional error information property (read-only). + * + * + */ + public string Info { + get { + return info; + } + } + + /** + * Returns the additional error information. + * + * @return the additional error information + * + * @see #Info + * + * @deprecated Use the Info property instead. + */ + public string GetInfo() { + return Info; + } + + /** + * The detailed error information property (read-only). + * + * + */ + public string Details { + get { + StringBuilder buffer = new StringBuilder(); + + if (details == null) { + return null; + } + for (int i = 0; i < details.Count; i++) { + if (i > 0) { + buffer.Append(", "); + if (i + 1 == details.Count) { + buffer.Append("and "); + } + } + buffer.Append(details[i]); + } + + return buffer.ToString(); + } + } + + /** + * Returns the detailed error information as a string + * + * @return the detailed error information + * + * @see #Details + * + * @deprecated Use the Details property instead. + */ + public string GetDetails() { + return Details; + } + + /** + * The message property (read-only). This property contains + * the detailed exception error message. + */ + public override string Message { + get{ + StringBuilder buffer = new StringBuilder(); + + switch (type) { + case ErrorType.INVALID_PARSER: + buffer.Append("parser is invalid, as "); + buffer.Append(info); + break; + case ErrorType.INVALID_TOKEN: + buffer.Append("token '"); + buffer.Append(name); + buffer.Append("' is invalid, as "); + buffer.Append(info); + break; + case ErrorType.INVALID_PRODUCTION: + buffer.Append("production '"); + buffer.Append(name); + buffer.Append("' is invalid, as "); + buffer.Append(info); + break; + case ErrorType.INFINITE_LOOP: + buffer.Append("infinite loop found in production pattern '"); + buffer.Append(name); + buffer.Append("'"); + break; + case ErrorType.INHERENT_AMBIGUITY: + buffer.Append("inherent ambiguity in production '"); + buffer.Append(name); + buffer.Append("'"); + if (info != null) { + buffer.Append(" "); + buffer.Append(info); + } + if (details != null) { + buffer.Append(" starting with "); + if (details.Count > 1) { + buffer.Append("tokens "); + } else { + buffer.Append("token "); + } + buffer.Append(Details); + } + break; + default: + buffer.Append("internal error"); + break; + } + return buffer.ToString(); + } + } + + /** + * Returns the error message. This message will contain all the + * information available. + * + * @return the error message + * + * @see #Message + * + * @deprecated Use the Message property instead. + */ + public string GetMessage() { + return Message; + } + } +} diff --git a/Core Library/Core Library/ParserLogException.cs b/Core Library/Core Library/ParserLogException.cs new file mode 100644 index 0000000..f780be9 --- /dev/null +++ b/Core Library/Core Library/ParserLogException.cs @@ -0,0 +1,127 @@ +/* + * ParserLogException.cs + */ + +using System; +using System.Collections; +using System.Text; + +namespace Core.Library { + + /** + * A parser log exception. This class contains a list of all the + * parse errors encountered while parsing. + * + + * + * @since 1.1 + */ + public class ParserLogException : Exception { + + /** + * The list of errors found. + */ + private ArrayList errors = new ArrayList(); + + /** + * Creates a new empty parser log exception. + */ + public ParserLogException() { + } + + /** + * The message property (read-only). This property contains + * the detailed exception error message. + */ + public override string Message { + get{ + StringBuilder buffer = new StringBuilder(); + + for (int i = 0; i < Count; i++) { + if (i > 0) { + buffer.Append("\n"); + } + buffer.Append(this[i].Message); + } + return buffer.ToString(); + } + } + + /** + * The error count property (read-only). + * + * + */ + public int Count { + get { + return errors.Count; + } + } + + /** + * Returns the number of errors in this log. + * + * @return the number of errors in this log + * + * @see #Count + * + * @deprecated Use the Count property instead. + */ + public int GetErrorCount() { + return Count; + } + + /** + * The error index (read-only). This index contains all the + * errors in this error log. + * + * @param index the error index, 0 <= index < Count + * + * @return the parse error requested + * + * + */ + public ParseException this[int index] { + get { + return (ParseException) errors[index]; + } + } + + /** + * Returns a specific error from the log. + * + * @param index the error index, 0 <= index < count + * + * @return the parse error requested + * + * @deprecated Use the class indexer instead. + */ + public ParseException GetError(int index) { + return this[index]; + } + + /** + * Adds a parse error to the log. + * + * @param e the parse error to add + */ + public void AddError(ParseException e) { + errors.Add(e); + } + + /** + * Returns the detailed error message. This message will contain + * the error messages from all errors in this log, separated by + * a newline. + * + * @return the detailed error message + * + * @see #Message + * + * @deprecated Use the Message property instead. + */ + public string GetMessage() { + return Message; + } + } +} diff --git a/Core Library/Core Library/PredictSet.cs b/Core Library/Core Library/PredictSet.cs new file mode 100644 index 0000000..f1a73be --- /dev/null +++ b/Core Library/Core Library/PredictSet.cs @@ -0,0 +1,220 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Core.Library +{ + public class PredictSet + { + string program = "\"entrance\""; + string global_choice = "\"newt\", \"duck\", \"bull\", \"starling\", \"viper\", \"mane\", \"let\", \"stork\""; + string global_dec = "\"newt\", \"duck\", \"bull\", \"starling\", \"viper\", \"mane\", \"let\", \"stork\""; + string global_funcdec = "\"newt\", \"duck\", \"bull\", \"starling\", \"viper\", \"mane\", \"let\", \"stork\""; + string var_dec = "\"newt\", \"duck\", \"bull\", \"starling\", \"viper\", \"mane\", \"let\", \"stork\", \"zooin\", \"zoout\", \"if\", \"swasp\", \"whale\", \"do\", \"fur\", \"id\", \"}}\", \"termite\", \"hop\", \":\", \")\", \"{{\""; + string ident_var = "\"=\", \",\", \"[\", \":\", \")\""; + string dtype = "\"at\""; + string next2var = "\"=\", \",\", \"[\""; + string next2var_tail = "\":\""; + string val = "\":\", \"}\", \")\""; + string bulLit = "\":\", \"}\", \")\""; + string array1D = "\":\", \"[\", \",\""; + string elem1D_next = "\":\", \"[\", \",\""; + string elem1D_list = "\"}\""; + string elemlist1D_tail = "\"}\""; + string array2D = "\":\""; + string elem2D_next = "\":\", \"[\",\",\""; + string elem2D_list = "\"}\""; + string size = "\"]\""; + string const_dec = "\"newt\", \"duck\", \"bull\", \"starling\", \"let\", \"stork\", \"viper\", \"mane\""; + string const_next = "\":\""; + string func_dec = "\"newt\", \"duck\", \"bull\", \"starling\", \"let\", \"stork\", \"viper\", \"mane\""; + string dtype1 = "\"at\""; + string param = "\")\""; + string multi_param = "\")\""; + string stork_dec = "\"newt\", \"duck\", \"bull\", \"starling\", \"let\", \"stork\", \"viper\", \"mane\""; + string stork_elem = "\"newt\", \"duck\", \"starling\", \"bull\", \"}}\""; + string multi_vardec = "\":\""; + string multistork_elem = "\"}\""; + string obj_dec = "\":\""; + string mane = "\"newt\", \"duck\", \"starling\", \"bull\", \"viper\""; + string statement_mane = "\"}}\", \"termite\""; + string local_dec = "\"zooin\", \"zoout\", \"if\", \"swasp\", \"whale\", \"do\", \"fur\", \"id\", \"}}\", \"termite\", \":\", \",\" )"; + string statement = "\"id\""; + string id_choice = "\"id\", \"zooin\", \"zoout\", \"if\", \"swasp\", \"whale\", \"do\", \"fur\""; + string string_concat = "\"id\", \"zooin\", \"zoout\", \"if\", \"swasp\", \"whale\", \"do\", \"fur\""; + string clrscr = "\"id\", \"zooin\", \"zoout\", \"if\", \"swasp\", \"whale\", \"do\", \"fur\""; + string statement1 = "\"}}\", \":\", \"termite\""; + string statement_choice = "\"id\", \"zooin\", \"zoout\", \"if\", \"swasp\", \"whale\", \"do\", \"fur\""; + string statement_tail = "\"id\", \"zooin\", \"zoout\", \"if\", \"swasp\", \"whale\", \"do\", \"fur\""; + string input = "\"id\", \"zooin\", \"zoout\", \"if\", \"swasp\", \"whale\", \"do\", \"fur\""; + string scan_fig = "\":\", \"))\""; + string multi_input = "\":\""; + string arr1D = "\":\", \")\", \"((\", \"&&\", \"||\""; + string arr2D = "\":\", \")\", \",\", \"((\", \"&&\", \"||\""; + string stork_access1 = "\":\", \")\", \",\", \"((\", \"&&\", \"||\""; + string output = "\"id\", \"zooin\", \"zoout\", \"if\", \"swasp\", \"whale\", \"do\", \"fur\""; + string output_next = "\":\", \"((\""; + string multi_output = "\":\""; + string scan_fig1 = "\":\", \"((\", \")\", \"&&\", \"||\""; + string math_eqtail = "\"(\", \"?\", \"\""; + string math_tail = "\"+\", \"-\", \"*\", \"/\", \"^\", \"%\", \":\", \")\", \"((\""; + string math_eqchoice = "\":\", \"((\""; + string math_op = "\"id\", \"newt literal\", \"duck literal\", \"~\", \"(\""; + string math_id = "\"+\", \"-\", \"*\", \"/\", \"^\", \"%\", \":\", \")\", \"((\""; + string negate = "\"(\", \"newt literal\", \"duck literal\""; + string matheq_next = "\":\", \"((\", \"+\", \"-\", \"*\", \"/\", \"^\", \"%\", \")\""; + string conditional = "\"id\", \"zooin\", \"zoout\", \"if\", \"swasp\", \"whale\", \"do\", \"fur\""; + string cond_expr = "\")\""; + string cond_expr_choice = "\"||\", \"&&\", \",\""; + string cond_tail = "\")\""; + string rel_expr1 = "\")\", \":\", \"&&\", \"||\""; + string relex_tail = "\")\", \":\", \"&&\", \"||\""; + string arithmetic = "\")\", \":\", \"&&\", \"||\""; + string arithmetic_tail = "\")\", \":\", \"&&\", \"||\""; + string expression = "\")\", \":\", \"&&\", \"||\""; + string expr_next = "\")\", \":\", \"&&\", \"||\""; + string rel_op1 = "\"newt literal\", \"duck literal\", \"id\", \"~\", \"(\""; + string rel_op2 = "\"newt literal\", \"duck literal\", \"starling literal\", \"true\", \"false\", \"[\", \"+\""; + string rel_fig = "\")\", \":\", \"&&\", \"||\""; + string log_expr = "\")\""; + string not_fig = "\")\""; + string log_expr_next = "\")\""; + string log_op = "\"(\""; + string cond_eelsif = "\"id\", \"zooin\", \"zoout\", \"if\", \"swasp\", \"whale\", \"do\", \"fur\", \"eels\""; + string cond_eels = "\"id\", \"zooin\", \"zoout\", \"if\", \"swasp\", \"whale\", \"do\", \"fur\", \"eels\""; + string swasp_case = "\"id\", \"zooin\", \"zoout\", \"if\", \"swasp\", \"whale\", \"do\", \"fur\", \"seal\""; + string swasp_case1 = "\"id\", \"zooin\", \"zoout\", \"if\", \"swasp\", \"whale\", \"do\", \"fur\""; + string term_expr = "\";\""; + string defaults = "\"}}\""; + string iterative = "\"id\", \"zooin\", \"zoout\", \"if\", \"swasp\", \"whale\", \"do\", \"fur\""; + string loop_fig1 = "\":\""; + string loop_fig2 = "\":\", \")\""; + string increm_decrem = "\":\", \")\""; + string unary_op = "\"id\", \":\", \")\""; + string function_call = "\"id\", \"zooin\", \"zoout\", \"if\", \"swasp\", \"whale\", \"do\", \"fur\""; + string args1 = "\")\""; + string args2 = "\",\" , \")\""; + string args_tail = "\":\", \")\""; + string multi_args = "\")\""; + string sub_function = "\"exit\""; + string func_args = "\")\""; + string func_tail = "\"[\""; + string one_array = "\"[\""; + string two_array = "\"[\""; + string multifunc_args = "\")\""; + string returns = "\"}}\""; + string result = "\":\""; + string result_tail = "\":\""; + string odc = "{{ "; + + public string GetPredictSet(int code) + { + switch (code) + { + case 2001: return program; + case 2002: return odc; + case 2003: return global_choice; + case 2004: return global_dec ; + case 2005: return global_funcdec; + case 2006: return var_dec; + case 2007: return ident_var; + case 2008: return dtype; + case 2009: return next2var; + case 2010: return next2var_tail; + case 2011: return val; + case 2012: return bulLit; + case 2013: return array1D; + case 2014: return elem1D_next; + case 2015: return elem1D_list; + case 2016: return elemlist1D_tail; + case 2017: return array2D; + case 2018: return elem2D_next; + case 2019: return elem2D_list; + case 2020: return size; + case 2021: return const_dec; + case 2022: return const_next; + case 2023: return func_dec; + case 2024: return dtype1; + case 2025: return param; + case 2026: return multi_param; + case 2027: return stork_dec; + case 2028: return stork_elem; + case 2029: return multi_vardec; + case 2030: return multistork_elem; + case 2031: return obj_dec; + case 2032: return mane; + case 2033: return statement_mane; + case 2034: return local_dec; + case 2035: return statement; + case 2036: return id_choice; + case 2037: return string_concat; + case 2038: return clrscr; + case 2039: return statement1; + case 2040: return statement_choice; + case 2041: return statement_tail; + case 2042: return input; + case 2043: return scan_fig; + case 2044: return multi_input; + case 2045: return arr1D; + case 2046: return arr2D; + case 2047: return stork_access1; + case 2048: return output; + case 2049: return output_next; + case 2050: return multi_output; + case 2051: return scan_fig1; + case 2052: return math_eqtail; + case 2053: return math_eqchoice; + case 2054: return math_tail; + case 2055: return math_op; + case 2056: return math_id; + case 2057: return negate; + case 2058: return matheq_next; + case 2059: return conditional; + case 2060: return cond_expr_choice; + case 2061: return cond_expr; + case 2062: return cond_tail; + case 2063: return rel_expr1; + case 2064: return relex_tail; + case 2065: return arithmetic; + case 2066: return arithmetic_tail; + case 2067: return expression; + case 2068: return expr_next; + case 2069: return rel_op1; + case 2070: return rel_op2; + case 2071: return rel_fig; + case 2072: return log_expr; + case 2073: return not_fig; + case 2074: return log_expr_next; + case 2075: return log_op; + case 2076: return cond_eelsif; + case 2077: return cond_eels; + case 2078: return swasp_case; + case 2079: return swasp_case1; + case 2080: return term_expr; + case 2081: return defaults; + case 2082: return iterative; + case 2083: return loop_fig1; + case 2084: return loop_fig2; + case 2085: return increm_decrem; + case 2086: return unary_op; + case 2087: return function_call; + case 2088: return args1; + case 2089: return args2; + case 2090: return args_tail; + case 2091: return multi_args; + case 2092: return sub_function; + case 2093: return func_args; + case 2094: return func_tail; + case 2095: return one_array; + case 2096: return two_array; + case 2097: return multifunc_args; + case 2098: return returns; + case 2099: return result; + case 2100: return result_tail; + } + return ""; + } + } +} diff --git a/Core Library/Core Library/PredictSets.cs b/Core Library/Core Library/PredictSets.cs new file mode 100644 index 0000000..ed155e5 --- /dev/null +++ b/Core Library/Core Library/PredictSets.cs @@ -0,0 +1,291 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Core.Library +{ + public class PredictSets + { + string program = "Let, Var, Task, Array, Object, Lead"; + string global = "Let, Var, Task, Array, Object, Lead"; + string global_choice = "Let, Var, Array, Task, Object"; + string dtype = "Int, Double, Char, String, Double"; + string OBJECT = "Object"; + string objdec_choice = "Object, Var, End"; + string var = "Var"; + string objvar = "Object"; + string varname = "id, ., ;, ."; + string task = "Task"; + string RETURN = "Null, Int, Double, Char, String, Boolean"; + string tparam = "(, ."; + string tparams = ";, )"; + string array = "Array"; + string size = "intlit"; + string sizes = "by, ."; + string varlet = "Let, Var"; + string vardec = "Int, Double, Char, String, Boolean"; + string varINT = "Int"; + string initINT = "is, ."; + string varDOUBLE = "Double"; + string initDOUBLE = "is, ."; + string varCHAR = "Char"; + string initCHAR = "is, ."; + string varSTRING = "String"; + string initSTRING = "is, ."; + string varBOOLEAN = "Boolean"; + string initBOOLEAN = "is, ."; + string ids1 = ";, ."; + string ids2 = ";, ."; + string ids3 = ";, ."; + string ids4 = ";, ."; + string ids5 = ";, ."; + string ids1_tail = "is"; + string ids2_tail = "is"; + string ids3_tail = "is"; + string ids4_tail = "is"; + string ids5_tail = "is"; + string value1 = "intlit, ("; + string value2 = "doublelit, ("; + string value3 = "charlit"; + string value4 = "stringlit"; + string value5 = "boollit"; + string numvalue = "intlit"; + string Operations1 = "+, -, *, /, %, ), ;, ."; + string OpInt = "intlit, ("; + string Op1 = "+, -, *, /, %, ), ;, ."; + string doublevalue = "doublelit"; + string Operations2 = "+, -, *, /, %, ), ;, ."; + string OpDouble = "doublelit, ("; + string Op2 = "+, -, *, /, %, ), ;, ."; + string mathOp = "+, - *, /, %"; + string incdec = "++, --"; + string relop1 = "==, !=, >, <, >=, <="; + string logop1 = "&&, ||"; + string logop2 = "!, boollit, id, ("; + string body = "Var, Clear, id, Int, Char, Boolean, Double, String, ++, --, Object, Until, Do, For, Array, If, Read, Say, Option"; + string statements = "Var, Clear, id, Int, Char, Boolean, Double, String, ++, --, Object, Until, Do, For, Array, If, Read, Say, Option, ., Stop, End"; + string functions = "Var, Int, Char, Boolean, Double, String, Array, Clear, id, ++, --, Read, Say, Object, If, Until, Do, For, Option"; + string id_choices = "["; + string subelement_choice = "++, --, =, Int, Double, Char, String, Boolean"; + string varinitINT = "Int"; + string varinitDOUBLE = "Double"; + string varinitCHAR = "Char"; + string varinitSTRING = "String"; + string varinitBOOLEAN = "Boolean"; + string INT = "intlit, id, (, ++, --"; + string intchoices = "@, ++, --, (, ."; + string intchoice1 = "@, ++, --"; + string intchoice2 = "("; + string incdec_null = "++, --, +, -, *, /, %, ."; + string DOUBLE = "double, id, (, ++, --"; + string doublechoices = "@, ++, --, (, ."; + string doublechoice1 = "@, ++, --"; + string doublechoice2 = "("; + string CHAR = "charlit, id"; + string STRING = "stringlit, id"; + string BOOLEAN = "boollit, id"; + string task_id = "id"; + string param = "intlit, doublelit, charlit, stringlit, boollit, id, )"; + string PARAMS = ";, )"; + string value = "intlit, doublelit, charlit, stringlit, boollit, id"; + string io_statement = "Read, Say"; + string input = "Read"; + string output = "Say"; + string input_statement = "stringlit, id"; + string concat = ",, ."; + string concat_value = "stringlit, id"; + string incdecvar = "++, --, id"; + string subelement = "@, ++, --, @, Start, ,, ., &&, ||, >=, <=, <, >, ==, !=, ), ;"; + string input_id = "id"; + string multi = "[, ="; + string index = "intlit, id, ]"; + string IfOtherwise = "If"; + string or = "Or, intlit, doublelit, charlit, stringlit, !, id, boollit, (, Otherwise"; + string otherwise = "Otherwise, EndIf"; + string cond_loop = "Var, Clear, id, Int, Char, Boolean, Double, String, ++, --, Object, Until, Do, For, Array, If, Read, Say, Option, Loop, LoopIf, Skip, Stop, Or, intlit, doublelit, charlit, stringlit, !, id, boollit, (, ), EndIf, Otherwise"; + string control = "Skip, Stop, Var, Clear, id, Int, Char, Boolean, Double, String, ++, --, Object, Until, Do, For, Array, If, Read, Say, Option, Loop, LoopIf, Skip, Stop, Or, intlit, doublelit, charlit, stringlit, !, boollit, (, ), EndIf, Otherwise"; + string conditions = "intlit, doublelit, charlit, stringlit, !, id, boollit, (, id, !, boollit, !, ("; + string conditionschoice = "intlit, doublelit, charlit, stringlit, !, id, boollit, ("; + string multiconds = "("; + string idschoice = "!, id, boollit, intlit, doublelit, charlit, stringlit"; + string idschoice1 = "id, boollit"; + string idsbody = "@, (, &&, ||, >=, <=, <, >, ==, !=, )"; + string condsTail = "&&, ||, >=, <=, <, >, ==, !=, )"; + string logOps = "&&, ||, )"; + string relOps = ">=, <=, <, >, ==, !="; + string relopNum = ">=, <=, <, >"; + string relopText = "==, !="; + string numval = "intlit, doublelit, id"; + string ids = "id, !, boollit, id"; + string ids_null = "boollit, id"; + string option = "Option"; + string optiontails = "intlit, charlit, stringlit"; + string optiontail1 = "intlit"; + string optiontail2 = "charlit"; + string optiontail3 = "stringlit"; + string state1 = "State, Var, Clear, id, Int, Char, Boolean, Double, String, ++, --, Object, Until, Do, For, Array, If, Read, Say, Option, Default"; + string state2 = "State, Var, Clear, id, Int, Char, Boolean, Double, String, ++, --, Object, Until, Do, For, Array, If, Read, Say, Option, Default"; + string state3 = "State, Var, Clear, id, Int, Char, Boolean, Double, String, ++, --, Object, Until, Do, For, Array, If, Read, Say, Option, Default"; + string DEFAULT = "Default, End"; + string loopstate = "Until, Do, For"; + string initialize = "id, ;"; + string cond = "id, ;"; + string taskdef = "Task, #"; + string returntype = "Int, Double, Char, String, Boolean, Null"; + string taskbody = "Start"; + string taskbodytail = "Var, Clear, id, Int, Char, Boolean, Double, String, ++, --, Object, Until, Do, For, Array, If, Read, Say, Option, ."; + string returnINT = "intlit, id"; + string returnDOUBLE = "doublelit, id"; + string returnCHAR = "charlit, id"; + string returnSTRING = "stringlit, id"; + string returnBOOLEAN = "boollit, id"; + string returntail = "(, @, ."; + string StartProgram = "Lead, Let, Var, Task, Array, Object"; + + public string GetPredictSet(int code) + { + switch (code) + { + // Prod_start_program = 2001, + //Prod_program = 2002, + //Prod_global = 2003, + //Prod_global_choice = 2004, + //Prod_dtype = 2005, + //Prod_object = 2006, + //Prod_objdec_choice = 2007, + //Prod_var = 2008, + //Prod_objvar = 2009, + //Prod_varname = 2010, + //Prod_varnames = 2011, + //Prod_task = 2012, + //Prod_return = 2013, + //Prod_tparam = 2014, + //Prod_tparams = 2015, + //Prod_array = 2016, + //Prod_size = 2017, + //Prod_sizes = 2018, + //Prod_varlet = 2019, + //Prod_vardec = 2020, + //Prod_var_int = 2021, + //Prod_init_int = 2022, + //Prod_var_double = 2023, + //Prod_init_double = 2024, + //Prod_var_char = 2025, + //Prod_init_char = 2026, + //Prod_var_string = 2027, + //Prod_init_string = 2028, + //Prod_var_boolean = 2029, + //Prod_init_boolean = 2030, + //Prod_ids1 = 2031, + //Prod_ids2 = 2032, + //Prod_ids3 = 2033, + //Prod_ids4 = 2034, + //Prod_ids5 = 2035, + //Prod_ids1_tail = 2036, + //Prod_ids2_tail = 2037, + //Prod_ids3_tail = 2038, + //Prod_ids4_tail = 2039, + //Prod_ids5_tail = 2040, + //Prod_value1 = 2041, + //Prod_value2 = 2042, + //Prod_value3 = 2043, + //Prod_value4 = 2044, + //Prod_value5 = 2045, + //Prod_numvalue = 2046, + //Prod_numelement = 2047, + //Prod_operations1 = 2048, + //Prod_op_int = 2049, + //Prod_op1 = 2050, + //Prod_doublevalue = 2051, + //Prod_operations2 = 2052, + //Prod_op_double = 2053, + //Prod_op2 = 2054, + //Prod_math_op = 2055, + //Prod_incdec = 2056, + //Prod_relop1 = 2057, + //Prod_logop1 = 2058, + //Prod_logop2 = 2059, + //Prod_body = 2060, + //Prod_statements = 2061, + //Prod_functions = 2062, + //Prod_id_choices = 2063, + //Prod_subelement_choice = 2064, + //Prod_varinit = 2065, + //Prod_varinit_int = 2066, + //Prod_varinit_double = 2067, + //Prod_varinit_char = 2068, + //Prod_varinit_string = 2069, + //Prod_varinit_boolean = 2070, + //Prod_int = 2071, + //Prod_intchoices = 2072, + //Prod_intchoice1 = 2073, + //Prod_intchoice2 = 2074, + //Prod_double = 2075, + //Prod_doublechoices = 2076, + //Prod_doublechoice1 = 2077, + //Prod_doublechoice2 = 2078, + //Prod_char = 2079, + //Prod_string = 2080, + //Prod_boolean = 2081, + //Prod_task_id = 2082, + //Prod_param = 2083, + //Prod_params = 2084, + //Prod_value = 2085, + //Prod_io_statement = 2086, + //Prod_input = 2087, + //Prod_output = 2088, + //Prod_input_statement = 2089, + //Prod_concat = 2090, + //Prod_concat_value = 2091, + //Prod_subelement = 2092, + //Prod_input_id = 2093, + //Prod_multi = 2094, + //Prod_index = 2095, + //Prod_if_otherwise = 2096, + //Prod_or = 2097, + //Prod_otherwise = 2098, + //Prod_cond_loop = 2099, + //Prod_control = 2100, + //Prod_conditions = 2101, + //Prod_conditionschoice = 2102, + //Prod_multiconds = 2103, + //Prod_idschoice = 2104, + //Prod_idschoice1 = 2105, + //Prod_idsbody = 2106, + //Prod_conds_tail = 2107, + //Prod_log_ops = 2108, + //Prod_rel_ops = 2109, + //Prod_relop_num = 2110, + //Prod_relop_text = 2111, + //Prod_numval = 2112, + //Prod_option = 2113, + //Prod_optiontails = 2114, + //Prod_optiontail1 = 2115, + //Prod_optiontail2 = 2116, + //Prod_optiontail3 = 2117, + //Prod_state1 = 2118, + //Prod_state2 = 2119, + //Prod_state3 = 2120, + //Prod_default = 2121, + //Prod_incdecvar = 2122, + //Prod_loopstate = 2123, + //Prod_initialize = 2124, + //Prod_cond = 2125, + //Prod_taskdef = 2126, + //Prod_returntype = 2127, + //Prod_taskbody = 2128, + //Prod_taskbodytail = 2129, + //Prod_return_int = 2130, + //Prod_return_double = 2131, + //Prod_return_char = 2132, + //Prod_return_string = 2133, + //Prod_return_boolean = 2134, + //Prod_returntail = 2135 + } + return ""; + } + } + +} diff --git a/Core Library/Core Library/Production.cs b/Core Library/Core Library/Production.cs new file mode 100644 index 0000000..7e8aa71 --- /dev/null +++ b/Core Library/Core Library/Production.cs @@ -0,0 +1,153 @@ +/* + * Production.cs + */ + +using System.Collections; + +namespace Core.Library { + + /** + * A production node. This class represents a grammar production + * (i.e. a list of child nodes) in a parse tree. The productions + * are created by a parser, that adds children a according to a + * set of production patterns (i.e. grammar rules). + * + + * + */ + public class Production : Node { + + /** + * The production pattern used for this production. + */ + private ProductionPattern pattern; + + /** + * The child nodes. + */ + private ArrayList children; + + /** + * Creates a new production node. + * + * @param pattern the production pattern + */ + public Production(ProductionPattern pattern) { + this.pattern = pattern; + this.children = new ArrayList(); + } + + /** + * The node type id property (read-only). This value is set as + * a unique identifier for each type of node, in order to + * simplify later identification. + * + * + */ + public override int Id { + get { + return pattern.Id; + } + } + + /** + * The node name property (read-only). + * + * + */ + public override string Name { + get { + return pattern.Name; + } + } + + /** + * The child node count property (read-only). + * + * + */ + public override int Count { + get { + return children.Count; + } + } + + /** + * The child node index (read-only). + * + * @param index the child index, 0 <= index < Count + * + * @return the child node found, or + * null if index out of bounds + * + * + */ + public override Node this[int index] { + get { + if (index < 0 || index >= children.Count) { + return null; + } else { + return (Node) children[index]; + } + } + } + + /** + * Adds a child node. The node will be added last in the list of + * children. + * + * @param child the child node to add + */ + public void AddChild(Node child) { + if (child != null) { + child.SetParent(this); + children.Add(child); + } + } + + /** + * The production pattern property (read-only). This property + * contains the production pattern linked to this production. + * + * + */ + public ProductionPattern Pattern { + get { + return pattern; + } + } + + /** + * Returns the production pattern for this production. + * + * @return the production pattern + * + * @see #Pattern + * + * @deprecated Use the Pattern property instead. + */ + public ProductionPattern GetPattern() { + return Pattern; + } + + /** + * Checks if this node is hidden, i.e. if it should not be visible + * outside the parser. + * + * @return true if the node should be hidden, or + * false otherwise + */ + internal override bool IsHidden() { + return pattern.Synthetic; + } + + /** + * Returns a string representation of this production. + * + * @return a string representation of this production + */ + public override string ToString() { + return pattern.Name + '(' + pattern.Id + ')'; + } + } +} diff --git a/Core Library/Core Library/ProductionPattern.cs b/Core Library/Core Library/ProductionPattern.cs new file mode 100644 index 0000000..ce02ca4 --- /dev/null +++ b/Core Library/Core Library/ProductionPattern.cs @@ -0,0 +1,375 @@ +/* + * ProductionPattern.cs + */ + +using System.Collections; +using System.Text; + +namespace Core.Library { + + /** + * A production pattern. This class represents a set of production + * alternatives that together forms a single production. A + * production pattern is identified by an integer id and a name, + * both provided upon creation. The pattern id is used for + * referencing the production pattern from production pattern + * elements. + * + + * + */ + public class ProductionPattern { + + /** + * The production pattern identity. + */ + private int id; + + /** + * The production pattern name. + */ + private string name; + + /** + * The synthectic production flag. If this flag is set, the + * production identified by this pattern has been artificially + * inserted into the grammar. + */ + private bool synthetic; + + /** + * The list of production pattern alternatives. + */ + private ArrayList alternatives; + + /** + * The default production pattern alternative. This alternative + * is used when no other alternatives match. It may be set to + * -1, meaning that there is no default (or fallback) alternative. + */ + private int defaultAlt; + + /** + * The look-ahead set associated with this pattern. + */ + private LookAheadSet lookAhead; + + /** + * Creates a new production pattern. + * + * @param id the production pattern id + * @param name the production pattern name + */ + public ProductionPattern(int id, string name) { + this.id = id; + this.name = name; + this.synthetic = false; + this.alternatives = new ArrayList(); + this.defaultAlt = -1; + this.lookAhead = null; + } + + /** + * The production pattern identity property (read-only). This + * property contains the unique identity value. + * + * + */ + public int Id { + get { + return id; + } + } + + /** + * Returns the unique production pattern identity value. + * + * @return the production pattern id + * + * @see #Id + * + * @deprecated Use the Id property instead. + */ + public int GetId() { + return Id; + } + + /** + * The production pattern name property (read-only). + * + * + */ + public string Name { + get { + return name; + } + } + + /** + * Returns the production pattern name. + * + * @return the production pattern name + * + * @see #Name + * + * @deprecated Use the Name property instead. + */ + public string GetName() { + return Name; + } + + /** + * The synthetic production pattern property. If this property + * is set, the production identified by this pattern has been + * artificially inserted into the grammar. No parse tree nodes + * will be created for such nodes, instead the child nodes + * will be added directly to the parent node. By default this + * property is set to false. + * + * + */ + public bool Synthetic { + get { + return synthetic; + } + set { + synthetic = value; + } + } + + /** + * Checks if the synthetic production flag is set. If this + * flag is set, the production identified by this pattern has + * been artificially inserted into the grammar. No parse tree + * nodes will be created for such nodes, instead the child + * nodes will be added directly to the parent node. + * + * @return true if this production pattern is synthetic, or + * false otherwise + * + * @see #Synthetic + * + * @deprecated Use the Synthetic property instead. + */ + public bool IsSyntetic() { + return Synthetic; + } + + /** + * Sets the synthetic production pattern flag. If this flag is set, + * the production identified by this pattern has been artificially + * inserted into the grammar. By default this flag is set to + * false. + * + * @param syntetic the new value of the synthetic flag + * + * @see #Synthetic + * + * @deprecated Use the Synthetic property instead. + */ + public void SetSyntetic(bool synthetic) { + Synthetic = synthetic; + } + + /** + * The look-ahead set property. This property contains the + * look-ahead set associated with this alternative. + */ + internal LookAheadSet LookAhead { + get { + return lookAhead; + } + set { + lookAhead = value; + } + } + + /** + * The default pattern alternative property. The default + * alternative is used when no other alternative matches. The + * default alternative must previously have been added to the + * list of alternatives. This property is set to null if no + * default pattern alternative has been set. + */ + internal ProductionPatternAlternative DefaultAlternative { + get { + if (defaultAlt >= 0) { + object obj = alternatives[defaultAlt]; + return (ProductionPatternAlternative) obj; + } else { + return null; + } + } + set { + defaultAlt = 0; + for (int i = 0; i < alternatives.Count; i++) { + if (alternatives[i] == value) { + defaultAlt = i; + } + } + } + } + + /** + * The production pattern alternative count property + * (read-only). + * + * + */ + public int Count { + get { + return alternatives.Count; + } + } + + /** + * Returns the number of alternatives in this pattern. + * + * @return the number of alternatives in this pattern + * + * @see #Count + * + * @deprecated Use the Count property instead. + */ + public int GetAlternativeCount() { + return Count; + } + + /** + * The production pattern alternative index (read-only). + * + * @param index the alternative index, 0 <= pos < Count + * + * @return the alternative found + * + * + */ + public ProductionPatternAlternative this[int index] { + get { + return (ProductionPatternAlternative) alternatives[index]; + } + } + + /** + * Returns an alternative in this pattern. + * + * @param pos the alternative position, 0 <= pos < count + * + * @return the alternative found + * + * @deprecated Use the class indexer instead. + */ + public ProductionPatternAlternative GetAlternative(int pos) { + return this[pos]; + } + + /** + * Checks if this pattern is recursive on the left-hand side. + * This method checks if any of the production pattern + * alternatives is left-recursive. + * + * @return true if at least one alternative is left recursive, or + * false otherwise + */ + public bool IsLeftRecursive() { + ProductionPatternAlternative alt; + + for (int i = 0; i < alternatives.Count; i++) { + alt = (ProductionPatternAlternative) alternatives[i]; + if (alt.IsLeftRecursive()) { + return true; + } + } + return false; + } + + /** + * Checks if this pattern is recursive on the right-hand side. + * This method checks if any of the production pattern + * alternatives is right-recursive. + * + * @return true if at least one alternative is right recursive, or + * false otherwise + */ + public bool IsRightRecursive() { + ProductionPatternAlternative alt; + + for (int i = 0; i < alternatives.Count; i++) { + alt = (ProductionPatternAlternative) alternatives[i]; + if (alt.IsRightRecursive()) { + return true; + } + } + return false; + } + + /** + * Checks if this pattern would match an empty stream of + * tokens. This method checks if any one of the production + * pattern alternatives would match the empty token stream. + * + * @return true if at least one alternative match no tokens, or + * false otherwise + */ + public bool IsMatchingEmpty() { + ProductionPatternAlternative alt; + + for (int i = 0; i < alternatives.Count; i++) { + alt = (ProductionPatternAlternative) alternatives[i]; + if (alt.IsMatchingEmpty()) { + return true; + } + } + return false; + } + + /** + * Adds a production pattern alternative. + * + * @param alt the production pattern alternative to add + * + * @throws ParserCreationException if an identical alternative has + * already been added + */ + public void AddAlternative(ProductionPatternAlternative alt) { + if (alternatives.Contains(alt)) { + throw new ParserCreationException( + ParserCreationException.ErrorType.INVALID_PRODUCTION, + name, + "two identical alternatives exist"); + } + alt.SetPattern(this); + alternatives.Add(alt); + } + + /** + * Returns a string representation of this object. + * + * @return a token string representation + */ + public override string ToString() { + StringBuilder buffer = new StringBuilder(); + StringBuilder indent = new StringBuilder(); + int i; + + buffer.Append(name); + buffer.Append("("); + buffer.Append(id); + buffer.Append(") "); + for (i = 0; i < buffer.Length; i++) { + indent.Append(" "); + } + for (i = 0; i < alternatives.Count; i++) { + if (i == 0) { + buffer.Append("= "); + } else { + buffer.Append("\n"); + buffer.Append(indent); + buffer.Append("| "); + } + buffer.Append(alternatives[i]); + } + return buffer.ToString(); + } + } +} diff --git a/Core Library/Core Library/ProductionPatternAlternative.cs b/Core Library/Core Library/ProductionPatternAlternative.cs new file mode 100644 index 0000000..6feee78 --- /dev/null +++ b/Core Library/Core Library/ProductionPatternAlternative.cs @@ -0,0 +1,371 @@ +/* + * ProductionPatternAlternative.cs + */ + +using System; +using System.Collections; +using System.Text; + +namespace Core.Library { + + /** + * A production pattern alternative. This class represents a list of + * production pattern elements. In order to provide productions that + * cannot be represented with the element occurance counters, multiple + * alternatives must be created and added to the same production + * pattern. A production pattern alternative is always contained + * within a production pattern. + * + + * + */ + public class ProductionPatternAlternative { + + /** + * The production pattern. + */ + private ProductionPattern pattern; + + /** + * The element list. + */ + private ArrayList elements = new ArrayList(); + + /** + * The look-ahead set associated with this alternative. + */ + private LookAheadSet lookAhead = null; + + /** + * Creates a new production pattern alternative. + */ + public ProductionPatternAlternative() { + } + + /** + * The production pattern property (read-only). This property + * contains the pattern having this alternative. + * + * + */ + public ProductionPattern Pattern { + get { + return pattern; + } + } + + /** + * Returns the production pattern containing this alternative. + * + * @return the production pattern for this alternative + * + * @see #Pattern + * + * @deprecated Use the Pattern property instead. + */ + public ProductionPattern GetPattern() { + return Pattern; + } + + /** + * The look-ahead set property. This property contains the + * look-ahead set associated with this alternative. + */ + internal LookAheadSet LookAhead { + get { + return lookAhead; + } + set { + lookAhead = value; + } + } + + /** + * The production pattern element count property (read-only). + * + * + */ + public int Count { + get { + return elements.Count; + } + } + + /** + * Returns the number of elements in this alternative. + * + * @return the number of elements in this alternative + * + * @see #Count + * + * @deprecated Use the Count property instead. + */ + public int GetElementCount() { + return Count; + } + + /** + * The production pattern element index (read-only). + * + * @param index the element index, 0 <= pos < Count + * + * @return the element found + * + * + */ + public ProductionPatternElement this[int index] { + get { + return (ProductionPatternElement) elements[index]; + } + } + + /** + * Returns an element in this alternative. + * + * @param pos the element position, 0 <= pos < count + * + * @return the element found + * + * @deprecated Use the class indexer instead. + */ + public ProductionPatternElement GetElement(int pos) { + return this[pos]; + } + + /** + * Checks if this alternative is recursive on the left-hand + * side. This method checks all the possible left side + * elements and returns true if the pattern itself is among + * them. + * + * @return true if the alternative is left side recursive, or + * false otherwise + */ + public bool IsLeftRecursive() { + ProductionPatternElement elem; + + for (int i = 0; i < elements.Count; i++) { + elem = (ProductionPatternElement) elements[i]; + if (elem.Id == pattern.Id) { + return true; + } else if (elem.MinCount > 0) { + break; + } + } + return false; + } + + /** + * Checks if this alternative is recursive on the right-hand side. + * This method checks all the possible right side elements and + * returns true if the pattern itself is among them. + * + * @return true if the alternative is right side recursive, or + * false otherwise + */ + public bool IsRightRecursive() { + ProductionPatternElement elem; + + for (int i = elements.Count - 1; i >= 0; i--) { + elem = (ProductionPatternElement) elements[i]; + if (elem.Id == pattern.Id) { + return true; + } else if (elem.MinCount > 0) { + break; + } + } + return false; + } + + /** + * Checks if this alternative would match an empty stream of + * tokens. This check is equivalent of getMinElementCount() + * returning zero (0). + * + * @return true if the rule can match an empty token stream, or + * false otherwise + */ + public bool IsMatchingEmpty() { + return GetMinElementCount() == 0; + } + + /** + * Changes the production pattern containing this alternative. + * This method should only be called by the production pattern + * class. + * + * @param pattern the new production pattern + */ + internal void SetPattern(ProductionPattern pattern) { + this.pattern = pattern; + } + + /** + * Returns the minimum number of elements needed to satisfy + * this alternative. The value returned is the sum of all the + * elements minimum count. + * + * @return the minimum number of elements + */ + public int GetMinElementCount() { + ProductionPatternElement elem; + int min = 0; + + for (int i = 0; i < elements.Count; i++) { + elem = (ProductionPatternElement) elements[i]; + min += elem.MinCount; + } + return min; + } + + /** + * Returns the maximum number of elements needed to satisfy + * this alternative. The value returned is the sum of all the + * elements maximum count. + * + * @return the maximum number of elements + */ + public int GetMaxElementCount() { + ProductionPatternElement elem; + int max = 0; + + for (int i = 0; i < elements.Count; i++) { + elem = (ProductionPatternElement) elements[i]; + if (elem.MaxCount >= Int32.MaxValue) { + return Int32.MaxValue; + } else { + max += elem.MaxCount; + } + } + return max; + } + + /** + * Adds a token to this alternative. The token is appended to + * the end of the element list. The multiplicity values + * specified define if the token is optional or required, and + * if it can be repeated. + * + * @param id the token (pattern) id + * @param min the minimum number of occurancies + * @param max the maximum number of occurancies, or + * -1 for infinite + */ + public void AddToken(int id, int min, int max) { + AddElement(new ProductionPatternElement(true, id, min, max)); + } + + /** + * Adds a production to this alternative. The production is + * appended to the end of the element list. The multiplicity + * values specified define if the production is optional or + * required, and if it can be repeated. + * + * @param id the production (pattern) id + * @param min the minimum number of occurancies + * @param max the maximum number of occurancies, or + * -1 for infinite + */ + public void AddProduction(int id, int min, int max) { + AddElement(new ProductionPatternElement(false, id, min, max)); + } + + /** + * Adds a production pattern element to this alternative. The + * element is appended to the end of the element list. + * + * @param elem the production pattern element + */ + public void AddElement(ProductionPatternElement elem) { + elements.Add(elem); + } + + /** + * Adds a production pattern element to this alternative. The + * multiplicity values in the element will be overridden with + * the specified values. The element is appended to the end of + * the element list. + * + * @param elem the production pattern element + * @param min the minimum number of occurancies + * @param max the maximum number of occurancies, or + * -1 for infinite + */ + public void AddElement(ProductionPatternElement elem, + int min, + int max) { + + if (elem.IsToken()) { + AddToken(elem.Id, min, max); + } else { + AddProduction(elem.Id, min, max); + } + } + + /** + * Checks if this object is equal to another. This method only + * returns true for another production pattern alternative + * with identical elements in the same order. + * + * @param obj the object to compare with + * + * @return true if the object is identical to this one, or + * false otherwise + */ + public override bool Equals(object obj) { + if (obj is ProductionPatternAlternative) { + return Equals((ProductionPatternAlternative) obj); + } else { + return false; + } + } + + /** + * Checks if this alternative is equal to another. This method + * returns true if the other production pattern alternative + * has identical elements in the same order. + * + * @param alt the alternative to compare with + * + * @return true if the object is identical to this one, or + * false otherwise + */ + public bool Equals(ProductionPatternAlternative alt) { + if (elements.Count != alt.elements.Count) { + return false; + } + for (int i = 0; i < elements.Count; i++) { + if (!elements[i].Equals(alt.elements[i])) { + return false; + } + } + return true; + } + + /** + * Returns a hash code for this object. + * + * @return a hash code for this object + */ + public override int GetHashCode() { + return elements.Count.GetHashCode(); + } + + /** + * Returns a string representation of this object. + * + * @return a token string representation + */ + public override string ToString() { + StringBuilder buffer = new StringBuilder(); + + for (int i = 0; i < elements.Count; i++) { + if (i > 0) { + buffer.Append(" "); + } + buffer.Append(elements[i]); + } + return buffer.ToString(); + } + } +} diff --git a/Core Library/Core Library/ProductionPatternElement.cs b/Core Library/Core Library/ProductionPatternElement.cs new file mode 100644 index 0000000..d7355f9 --- /dev/null +++ b/Core Library/Core Library/ProductionPatternElement.cs @@ -0,0 +1,256 @@ +/* + * ProductionPatternElement.cs + */ + +using System; +using System.Text; + + +namespace Core.Library +{ + + /** + * A production pattern element. This class represents a reference to + * either a token or a production. Each element also contains minimum + * and maximum occurence counters, controlling the number of + * repetitions allowed. A production pattern element is always + * contained within a production pattern rule. + * + + * + */ + public class ProductionPatternElement { + + /** + * The token flag. This flag is true for token elements, and + * false for production elements. + */ + private bool token; + + /** + * The node identity. + */ + private int id; + + /** + * The minimum occurance count. + */ + private int min; + + /** + * The maximum occurance count. + */ + private int max; + + /** + * The look-ahead set associated with this element. + */ + private LookAheadSet lookAhead; + + /** + * Creates a new element. If the maximum value if zero (0) or + * negative, it will be set to Int32.MaxValue. + * + * @param isToken the token flag + * @param id the node identity + * @param min the minimum number of occurancies + * @param max the maximum number of occurancies, or + * negative for infinite + */ + public ProductionPatternElement(bool isToken, + int id, + int min, + int max) { + + this.token = isToken; + this.id = id; + if (min < 0) { + min = 0; + } + this.min = min; + if (max <= 0) { + max = Int32.MaxValue; + } else if (max < min) { + max = min; + } + this.max = max; + this.lookAhead = null; + } + + /** + * The node identity property (read-only). + * + * + */ + public int Id { + get { + return id; + } + } + + /** + * Returns the node identity. + * + * @return the node identity + * + * @see #Id + * + * @deprecated Use the Id property instead. + */ + public int GetId() { + return Id; + } + + /** + * The minimum occurence count property (read-only). + * + * + */ + public int MinCount { + get { + return min; + } + } + + /** + * Returns the minimum occurence count. + * + * @return the minimum occurence count + * + * @see #MinCount + * + * @deprecated Use the MinCount property instead. + */ + public int GetMinCount() { + return MinCount; + } + + /** + * The maximum occurence count property (read-only). + * + * + */ + public int MaxCount { + get { + return max; + } + } + + /** + * Returns the maximum occurence count. + * + * @return the maximum occurence count + * + * @see #MaxCount + * + * @deprecated Use the MaxCount property instead. + */ + public int GetMaxCount() { + return MaxCount; + } + + /** + * The look-ahead set property. This is the look-ahead set + * associated with this alternative. + */ + internal LookAheadSet LookAhead { + get { + return lookAhead; + } + set { + lookAhead = value; + } + } + + /** + * Returns true if this element represents a token. + * + * @return true if the element is a token, or + * false otherwise + */ + public bool IsToken() { + return token; + } + + /** + * Returns true if this element represents a production. + * + * @return true if the element is a production, or + * false otherwise + */ + public bool IsProduction() { + return !token; + } + + /** + * Checks if a specific token matches this element. This + * method will only return true if this element is a token + * element, and the token has the same id and this element. + * + * @param token the token to check + * + * @return true if the token matches this element, or + * false otherwise + */ + public bool IsMatch(Token token) { + return IsToken() && token != null && token.Id == id; + } + + /** + * Checks if this object is equal to another. This method only + * returns true for another identical production pattern + * element. + * + * @param obj the object to compare with + * + * @return true if the object is identical to this one, or + * false otherwise + */ + public override bool Equals(object obj) { + ProductionPatternElement elem; + + if (obj is ProductionPatternElement) { + elem = (ProductionPatternElement) obj; + return this.token == elem.token + && this.id == elem.id + && this.min == elem.min + && this.max == elem.max; + } else { + return false; + } + } + + /** + * Returns a hash code for this object. + * + * @return a hash code for this object + */ + public override int GetHashCode() { + return this.id * 37; + } + + /** + * Returns a string representation of this object. + * + * @return a string representation of this object + */ + public override string ToString() { + StringBuilder buffer = new StringBuilder(); + + buffer.Append(id); + if (token) { + buffer.Append("(Token)"); + } else { + buffer.Append("(Production)"); + } + if (min != 1 || max != 1) { + buffer.Append("{"); + buffer.Append(min); + buffer.Append(","); + buffer.Append(max); + buffer.Append("}"); + } + return buffer.ToString(); + } + } +} diff --git a/Core Library/Core Library/ReaderBuffer.cs b/Core Library/Core Library/ReaderBuffer.cs new file mode 100644 index 0000000..adf6b17 --- /dev/null +++ b/Core Library/Core Library/ReaderBuffer.cs @@ -0,0 +1,324 @@ +/* + * ReaderBuffer.cs + */ + +using System; +using System.IO; + + +namespace Core.Library { + + /** + * A character buffer that automatically reads from an input source + * stream when needed. This class keeps track of the current position + * in the buffer and its line and column number in the original input + * source. It allows unlimited look-ahead of characters in the input, + * reading and buffering the required data internally. As the + * position is advanced, the buffer content prior to the current + * position is subject to removal to make space for reading new + * content. A few characters before the current position are always + * kept to enable boundary condition checks. + * + + * + * + */ + public class ReaderBuffer { + + /** + * The stream reading block size. All reads from the underlying + * character stream will be made in multiples of this block size. + * Also the character buffer size will always be a multiple of + * this factor. + */ + public const int BLOCK_SIZE = 1024; + + /** + * The character buffer. + */ + private char[] buffer = new char[BLOCK_SIZE * 4]; + + /** + * The current character buffer position. + */ + private int pos = 0; + + /** + * The number of characters in the buffer. + */ + private int length = 0; + + /** + * The input source character reader. + */ + private TextReader input = null; + + /** + * The line number of the next character to read. This value will + * be incremented when reading past line breaks. + */ + private int line = 1; + + /** + * The column number of the next character to read. This value + * will be updated for every character read. + */ + private int column = 1; + + /** + * Creates a new tokenizer character buffer. + * + * @param input the input source character reader + */ + public ReaderBuffer(TextReader input) { + this.input = input; + } + + /** + * Discards all resources used by this buffer. This will also + * close the source input stream. Disposing a previously disposed + * buffer has no effect. + */ + public void Dispose() { + buffer = null; + pos = 0; + length = 0; + if (input != null) { + try { + input.Close(); + } catch (Exception) { + // Do nothing + } + input = null; + } + } + + /** + * The current buffer position property (read-only). + */ + public int Position { + get { + return pos; + } + } + + /** + * The current line number property (read-only). This number + * is the line number of the next character to read. + */ + public int LineNumber { + get { + return line; + } + } + + /** + * The current column number property (read-only). This number + * is the column number of the next character to read. + */ + public int ColumnNumber { + get { + return column; + } + } + + /** + * The current character buffer length property (read-only). + * Note that the length may increase (and decrease) as more + * characters are read from the input source or removed to + * free up space. + */ + public int Length { + get { + return length; + } + } + + /** + * Returns a substring already in the buffer. Note that this + * method may behave in unexpected ways when performing + * operations that modifies the buffer content. + * + * @param index the start index, inclusive + * @param length the substring length + * + * @return the substring specified + * + * @throws IndexOutOfBoundsException if one of the indices were + * negative or not less than (or equal) than length() + */ + public string Substring(int index, int length) { + return new string(buffer, index, length); + } + + /** + * Returns the current content of the buffer as a string. Note + * that content before the current position will also be + * returned. + * + * @return the current buffer content + */ + public override string ToString() { + return new string(buffer, 0, length); + } + + /** + * Returns a character relative to the current position. This + * method may read from the input source and may also trim the + * buffer content prior to the current position. The result of + * calling this method may therefore be that the buffer length + * and content have been modified.

+ * + * The character offset must be positive, but is allowed to span + * the entire size of the input source stream. Note that the + * internal buffer must hold all the intermediate characters, + * which may be wasteful if the offset is too large. + * + * @param offset the character offset, from 0 and up + * + * @return the character found as an integer in the range 0 to + * 65535 (0x00-0xffff), or -1 if the end of the stream was reached + * + * @throws IOException if an I/O error occurred + */ + public int Peek(int offset) { + int index = pos + offset; + + // Avoid most calls to EnsureBuffered(), since we are in a + // performance hotspot here. This check is not exhaustive, + // but only present here to speed things up. + if (index >= length) { + EnsureBuffered(offset + 1); + index = pos + offset; + } + return (index >= length) ? -1 : buffer[index]; + } + + /** + * Reads the specified number of characters from the current + * position. This will also move the current position forward. + * This method will not attempt to move beyond the end of the + * input source stream. When reaching the end of file, the + * returned string might be shorter than requested. Any + * remaining characters will always be returned before returning + * null. + * + * @param offset the character offset, from 0 and up + * + * @return the string containing the characters read, or + * null no more characters remain in the buffer + * + * @throws IOException if an I/O error occurred + */ + public string Read(int offset) { + int count; + string result; + + EnsureBuffered(offset + 1); + if (pos >= length) { + return null; + } else { + count = length - pos; + if (count > offset) { + count = offset; + } + UpdateLineColumnNumbers(count); + result = new string(buffer, pos, count); + pos += count; + if (input == null && pos >= length) { + Dispose(); + } + return result; + } + } + + /** + * Updates the line and column numbers counters. This method + * requires all the characters to be processed (i.e. returned + * as read) to be present in the buffer, starting at the + * current buffer position. + * + * @param offset the number of characters to process + */ + private void UpdateLineColumnNumbers(int offset) { + for (int i = 0; i < offset; i++) { + if (buffer[pos + i] == '\n') { + line++; + column = 1; + } else { + column++; + } + } + } + + /** + * Ensures that the specified offset is read into the buffer. + * This method will read characters from the input stream and + * appends them to the buffer if needed. This method is safe to + * call even after end of file has been reached. This method also + * handles removal of characters at the beginning of the buffer + * once the current position is high enough. It will also enlarge + * the buffer as needed. + * + * @param offset the read offset, from 0 and up + * + * @throws IOException if an error was encountered while reading + * the input stream + */ + private void EnsureBuffered(int offset) { + int size; + int readSize; + + // Check for end of stream or already read characters + if (input == null || pos + offset < length) { + return; + } + + // Remove (almost all) old characters from buffer + if (pos > BLOCK_SIZE) { + length -= (pos - 16); + Array.Copy(buffer, pos - 16, buffer, 0, length); + pos = 16; + } + + // Calculate number of characters to read + size = pos + offset - length + 1; + if (size % BLOCK_SIZE != 0) { + size = (1 + size / BLOCK_SIZE) * BLOCK_SIZE; + } + EnsureCapacity(length + size); + + // Read characters + try { + while (input != null && size > 0) { + readSize = input.Read(buffer, length, size); + if (readSize > 0) { + length += readSize; + size -= readSize; + } else { + input.Close(); + input = null; + } + } + } catch (IOException e) { + input = null; + throw e; + } + } + + /** + * Ensures that the buffer has at least the specified capacity. + * + * @param size the minimum buffer size + */ + private void EnsureCapacity(int size) { + if (buffer.Length >= size) { + return; + } + if (size % BLOCK_SIZE != 0) { + size = (1 + size / BLOCK_SIZE) * BLOCK_SIZE; + } + Array.Resize(ref buffer, size); + } + } +} diff --git a/Core Library/Core Library/RecursiveDescentParser.cs b/Core Library/Core Library/RecursiveDescentParser.cs new file mode 100644 index 0000000..46ae396 --- /dev/null +++ b/Core Library/Core Library/RecursiveDescentParser.cs @@ -0,0 +1,916 @@ +/* + * RecursiveDescentParser.cs + */ + +using System; +using System.Collections; +using System.IO; + +namespace Core.Library { + + /** + * A recursive descent parser. This parser handles LL(n) grammars, + * selecting the appropriate pattern to parse based on the next few + * tokens. The parser is more efficient the fewer look-ahead tokens + * that is has to consider. + * + + * + */ + public class RecursiveDescentParser : Parser { + + /** + * Creates a new parser. + * + * @param input the input stream to read from + * + * @throws ParserCreationException if the tokenizer couldn't be + * initialized correctly + * + * + */ + public RecursiveDescentParser(TextReader input) : base(input) { + } + + /** + * Creates a new parser. + * + * @param input the input stream to read from + * @param analyzer the analyzer callback to use + * + * @throws ParserCreationException if the tokenizer couldn't be + * initialized correctly + * + * + */ + public RecursiveDescentParser(TextReader input, Analyzer analyzer) + : base(input, analyzer) { + } + + /** + * Creates a new parser. + * + * @param tokenizer the tokenizer to use + */ + public RecursiveDescentParser(Tokenizer tokenizer) + : base(tokenizer) { + } + + /** + * Creates a new parser. + * + * @param tokenizer the tokenizer to use + * @param analyzer the analyzer callback to use + */ + public RecursiveDescentParser(Tokenizer tokenizer, + Analyzer analyzer) + : base(tokenizer, analyzer) { + } + + /** + * Adds a new production pattern to the parser. The pattern + * will be added last in the list. The first pattern added is + * assumed to be the starting point in the grammar. The + * pattern will be validated against the grammar type to some + * extent. + * + * @param pattern the pattern to add + * + * @throws ParserCreationException if the pattern couldn't be + * added correctly to the parser + */ + public override void AddPattern(ProductionPattern pattern) { + + // Check for empty matches + if (pattern.IsMatchingEmpty()) { + throw new ParserCreationException( + ParserCreationException.ErrorType.INVALID_PRODUCTION, + pattern.Name, + "zero elements can be matched (minimum is one)"); + } + + // Check for left-recusive patterns + if (pattern.IsLeftRecursive()) { + throw new ParserCreationException( + ParserCreationException.ErrorType.INVALID_PRODUCTION, + pattern.Name, + "left recursive patterns are not allowed"); + } + + // Add pattern + base.AddPattern(pattern); + } + + /** + * Initializes the parser. All the added production patterns + * will be analyzed for ambiguities and errors. This method + * also initializes the internal data structures used during + * the parsing. + * + * @throws ParserCreationException if the parser couldn't be + * initialized correctly + */ + public override void Prepare() { + IEnumerator e; + + // Performs production pattern checks + base.Prepare(); + SetInitialized(false); + + // Calculate production look-ahead sets + e = GetPatterns().GetEnumerator(); + while (e.MoveNext()) { + CalculateLookAhead((ProductionPattern)e.Current); + } + + // Set initialized flag + SetInitialized(true); + } + + /** + * Parses the input stream and creates a parse tree. + * + * @return the parse tree + * + * @throws ParseException if the input couldn't be parsed + * correctly + */ + protected override Node ParseStart() { + Token token; + Node node; + ArrayList list; + + node = ParsePattern(GetStartPattern()); + token = PeekToken(0); + if (token != null) { + list = new ArrayList(1); + list.Add(""); + throw new ParseException( + ParseException.ErrorType.UNEXPECTED_TOKEN, + token.ToShortString(), + list, + token.StartLine, + token.StartColumn); + } + return node; + } + + /** + * Parses a production pattern. A parse tree node may or may + * not be created depending on the analyzer callbacks. + * + * @param pattern the production pattern to parse + * + * @return the parse tree node created, or null + * + * @throws ParseException if the input couldn't be parsed + * correctly + */ + private Node ParsePattern(ProductionPattern pattern) { + ProductionPatternAlternative alt; + ProductionPatternAlternative defaultAlt; + + defaultAlt = pattern.DefaultAlternative; + for (int i = 0; i < pattern.Count; i++) { + alt = pattern[i]; + if (defaultAlt != alt && IsNext(alt)) { + return ParseAlternative(alt); + } + } + if (defaultAlt == null || !IsNext(defaultAlt)) { + ThrowParseException(FindUnion(pattern)); + } + return ParseAlternative(defaultAlt); + } + + /** + * Parses a production pattern alternative. A parse tree node + * may or may not be created depending on the analyzer + * callbacks. + * + * @param alt the production pattern alternative + * + * @return the parse tree node created, or null + * + * @throws ParseException if the input couldn't be parsed + * correctly + */ + private Node ParseAlternative(ProductionPatternAlternative alt) { + Production node; + + node = NewProduction(alt.Pattern); + EnterNode(node); + for (int i = 0; i < alt.Count; i++) { + try { + ParseElement(node, alt[i]); + } catch (ParseException e) { + AddError(e, true); + NextToken(); + i--; + } + } + return ExitNode(node); + } + + /** + * Parses a production pattern element. All nodes parsed may + * or may not be added to the parse tree node specified, + * depending on the analyzer callbacks. + * + * @param node the production parse tree node + * @param elem the production pattern element to parse + * + * @throws ParseException if the input couldn't be parsed + * correctly + */ + private void ParseElement(Production node, + ProductionPatternElement elem) { + + Node child; + + for (int i = 0; i < elem.MaxCount; i++) { + string pr = Enum.GetName(typeof(SyntaxConstants), elem.GetId()); + if (i < elem.MinCount || IsNext(elem)) { + if (elem.IsToken()) { + child = NextToken(elem.Id); + EnterNode(child); + AddNode(node, ExitNode(child)); + if(ExitNode(child) != null) + production.AddRecursiveProduction("Enter: " + pr + "\n"); + production.AddProductionCode(elem.GetId()); + production.AddProductionState("Enter: " + pr + "\n"); + } + else { + pr = pr.Substring(5); + production.AddRecursiveProduction("Enter: <" + pr + ">\n"); + production.AddProductionCode(elem.GetId()); + production.AddProductionState("Enter: <" + pr + ">\n"); + child = ParsePattern(GetPattern(elem.Id)); + AddNode(node, child); + } + } else { + pr = pr.Substring(5); + production.AddRecursiveProduction("Enter: NULL <" + pr + ">\n"); + production.AddProductionCode(elem.GetId()); + production.AddProductionState("NULL"); + break; + } + } + } + + /** + * Checks if the next tokens match a production pattern. The + * pattern look-ahead set will be used if existing, otherwise + * this method returns false. + * + * @param pattern the pattern to check + * + * @return true if the next tokens match, or + * false otherwise + */ + private bool IsNext(ProductionPattern pattern) { + LookAheadSet set = pattern.LookAhead; + + if (set == null) { + return false; + } else { + return set.IsNext(this); + } + } + + /** + * Checks if the next tokens match a production pattern + * alternative. The pattern alternative look-ahead set will be + * used if existing, otherwise this method returns false. + * + * @param alt the pattern alternative to check + * + * @return true if the next tokens match, or + * false otherwise + */ + private bool IsNext(ProductionPatternAlternative alt) { + LookAheadSet set = alt.LookAhead; + + if (set == null) { + return false; + } else { + return set.IsNext(this); + } + } + + /** + * Checks if the next tokens match a production pattern + * element. If the element has a look-ahead set it will be + * used, otherwise the look-ahead set of the referenced + * production or token will be used. + * + * @param elem the pattern element to check + * + * @return true if the next tokens match, or + * false otherwise + */ + private bool IsNext(ProductionPatternElement elem) { + LookAheadSet set = elem.LookAhead; + + if (set != null) { + return set.IsNext(this); + } else if (elem.IsToken()) { + return elem.IsMatch(PeekToken(0)); + } else { + return IsNext(GetPattern(elem.Id)); + } + } + + /** + * Calculates the look-ahead needed for the specified production + * pattern. This method attempts to resolve any conflicts and + * stores the results in the pattern look-ahead object. + * + * @param pattern the production pattern + * + * @throws ParserCreationException if the look-ahead set couldn't + * be determined due to inherent ambiguities + */ + private void CalculateLookAhead(ProductionPattern pattern) { + ProductionPatternAlternative alt; + LookAheadSet result; + LookAheadSet[] alternatives; + LookAheadSet conflicts; + LookAheadSet previous = new LookAheadSet(0); + int length = 1; + int i; + CallStack stack = new CallStack(); + + // Calculate simple look-ahead + stack.Push(pattern.Name, 1); + result = new LookAheadSet(1); + alternatives = new LookAheadSet[pattern.Count]; + for (i = 0; i < pattern.Count; i++) { + alt = pattern[i]; + alternatives[i] = FindLookAhead(alt, 1, 0, stack, null); + alt.LookAhead = alternatives[i]; + result.AddAll(alternatives[i]); + } + if (pattern.LookAhead == null) { + pattern.LookAhead = result; + } + conflicts = FindConflicts(pattern, 1); + + // Resolve conflicts + while (conflicts.Size() > 0) { + length++; + stack.Clear(); + stack.Push(pattern.Name, length); + conflicts.AddAll(previous); + for (i = 0; i < pattern.Count; i++) { + alt = pattern[i]; + if (alternatives[i].Intersects(conflicts)) { + alternatives[i] = FindLookAhead(alt, + length, + 0, + stack, + conflicts); + alt.LookAhead = alternatives[i]; + } + if (alternatives[i].Intersects(conflicts)) { + if (pattern.DefaultAlternative == null) { + pattern.DefaultAlternative = alt; + } else if (pattern.DefaultAlternative != alt) { + result = alternatives[i].CreateIntersection(conflicts); + ThrowAmbiguityException(pattern.Name, + null, + result); + } + } + } + previous = conflicts; + conflicts = FindConflicts(pattern, length); + } + + // Resolve conflicts inside rules + for (i = 0; i < pattern.Count; i++) { + CalculateLookAhead(pattern[i], 0); + } + } + + /** + * Calculates the look-aheads needed for the specified pattern + * alternative. This method attempts to resolve any conflicts in + * optional elements by recalculating look-aheads for referenced + * productions. + * + * @param alt the production pattern alternative + * @param pos the pattern element position + * + * @throws ParserCreationException if the look-ahead set couldn't + * be determined due to inherent ambiguities + */ + private void CalculateLookAhead(ProductionPatternAlternative alt, + int pos) { + + ProductionPattern pattern; + ProductionPatternElement elem; + LookAheadSet first; + LookAheadSet follow; + LookAheadSet conflicts; + LookAheadSet previous = new LookAheadSet(0); + String location; + int length = 1; + + // Check trivial cases + if (pos >= alt.Count) { + return; + } + + // Check for non-optional element + pattern = alt.Pattern; + elem = alt[pos]; + if (elem.MinCount == elem.MaxCount) { + CalculateLookAhead(alt, pos + 1); + return; + } + + // Calculate simple look-aheads + first = FindLookAhead(elem, 1, new CallStack(), null); + follow = FindLookAhead(alt, 1, pos + 1, new CallStack(), null); + + // Resolve conflicts + location = "at position " + (pos + 1); + conflicts = FindConflicts(pattern.Name, + location, + first, + follow); + while (conflicts.Size() > 0) { + length++; + conflicts.AddAll(previous); + first = FindLookAhead(elem, + length, + new CallStack(), + conflicts); + follow = FindLookAhead(alt, + length, + pos + 1, + new CallStack(), + conflicts); + first = first.CreateCombination(follow); + elem.LookAhead = first; + if (first.Intersects(conflicts)) { + first = first.CreateIntersection(conflicts); + ThrowAmbiguityException(pattern.Name, location, first); + } + previous = conflicts; + conflicts = FindConflicts(pattern.Name, + location, + first, + follow); + } + + // Check remaining elements + CalculateLookAhead(alt, pos + 1); + } + + /** + * Finds the look-ahead set for a production pattern. The maximum + * look-ahead length must be specified. It is also possible to + * specify a look-ahead set filter, which will make sure that + * unnecessary token sequences will be avoided. + * + * @param pattern the production pattern + * @param length the maximum look-ahead length + * @param stack the call stack used for loop detection + * @param filter the look-ahead set filter + * + * @return the look-ahead set for the production pattern + * + * @throws ParserCreationException if an infinite loop was found + * in the grammar + */ + private LookAheadSet FindLookAhead(ProductionPattern pattern, + int length, + CallStack stack, + LookAheadSet filter) { + + LookAheadSet result; + LookAheadSet temp; + + // Check for infinite loop + if (stack.Contains(pattern.Name, length)) { + throw new ParserCreationException( + ParserCreationException.ErrorType.INFINITE_LOOP, + pattern.Name, + (String) null); + } + + // Find pattern look-ahead + stack.Push(pattern.Name, length); + result = new LookAheadSet(length); + for (int i = 0; i < pattern.Count; i++) { + temp = FindLookAhead(pattern[i], + length, + 0, + stack, + filter); + result.AddAll(temp); + } + stack.Pop(); + + return result; + } + + /** + * Finds the look-ahead set for a production pattern alternative. + * The pattern position and maximum look-ahead length must be + * specified. It is also possible to specify a look-ahead set + * filter, which will make sure that unnecessary token sequences + * will be avoided. + * + * @param alt the production pattern alternative + * @param length the maximum look-ahead length + * @param pos the pattern element position + * @param stack the call stack used for loop detection + * @param filter the look-ahead set filter + * + * @return the look-ahead set for the pattern alternative + * + * @throws ParserCreationException if an infinite loop was found + * in the grammar + */ + private LookAheadSet FindLookAhead(ProductionPatternAlternative alt, + int length, + int pos, + CallStack stack, + LookAheadSet filter) { + + LookAheadSet first; + LookAheadSet follow; + LookAheadSet overlaps; + + // Check trivial cases + if (length <= 0 || pos >= alt.Count) { + return new LookAheadSet(0); + } + + // Find look-ahead for this element + first = FindLookAhead(alt[pos], length, stack, filter); + if (alt[pos].MinCount == 0) { + first.AddEmpty(); + } + + // Find remaining look-ahead + if (filter == null) { + length -= first.GetMinLength(); + if (length > 0) { + follow = FindLookAhead(alt, length, pos + 1, stack, null); + first = first.CreateCombination(follow); + } + } else if (filter.IsOverlap(first)) { + overlaps = first.CreateOverlaps(filter); + length -= overlaps.GetMinLength(); + filter = filter.CreateFilter(overlaps); + follow = FindLookAhead(alt, length, pos + 1, stack, filter); + first.RemoveAll(overlaps); + first.AddAll(overlaps.CreateCombination(follow)); + } + + return first; + } + + /** + * Finds the look-ahead set for a production pattern element. The + * maximum look-ahead length must be specified. This method takes + * the element repeats into consideration when creating the + * look-ahead set, but does NOT include an empty sequence even if + * the minimum count is zero (0). It is also possible to specify a + * look-ahead set filter, which will make sure that unnecessary + * token sequences will be avoided. + * + * @param elem the production pattern element + * @param length the maximum look-ahead length + * @param stack the call stack used for loop detection + * @param filter the look-ahead set filter + * + * @return the look-ahead set for the pattern element + * + * @throws ParserCreationException if an infinite loop was found + * in the grammar + */ + private LookAheadSet FindLookAhead(ProductionPatternElement elem, + int length, + CallStack stack, + LookAheadSet filter) { + + LookAheadSet result; + LookAheadSet first; + LookAheadSet follow; + int max; + + // Find initial element look-ahead + first = FindLookAhead(elem, length, 0, stack, filter); + result = new LookAheadSet(length); + result.AddAll(first); + if (filter == null || !filter.IsOverlap(result)) { + return result; + } + + // Handle element repetitions + if (elem.MaxCount == Int32.MaxValue) { + first = first.CreateRepetitive(); + } + max = elem.MaxCount; + if (length < max) { + max = length; + } + for (int i = 1; i < max; i++) { + first = first.CreateOverlaps(filter); + if (first.Size() <= 0 || first.GetMinLength() >= length) { + break; + } + follow = FindLookAhead(elem, + length, + 0, + stack, + filter.CreateFilter(first)); + first = first.CreateCombination(follow); + result.AddAll(first); + } + + return result; + } + + /** + * Finds the look-ahead set for a production pattern element. The + * maximum look-ahead length must be specified. This method does + * NOT take the element repeat into consideration when creating + * the look-ahead set. It is also possible to specify a look-ahead + * set filter, which will make sure that unnecessary token + * sequences will be avoided. + * + * @param elem the production pattern element + * @param length the maximum look-ahead length + * @param dummy a parameter to distinguish the method + * @param stack the call stack used for loop detection + * @param filter the look-ahead set filter + * + * @return the look-ahead set for the pattern element + * + * @throws ParserCreationException if an infinite loop was found + * in the grammar + */ + private LookAheadSet FindLookAhead(ProductionPatternElement elem, + int length, + int dummy, + CallStack stack, + LookAheadSet filter) { + + LookAheadSet result; + ProductionPattern pattern; + + if (elem.IsToken()) { + result = new LookAheadSet(length); + result.Add(elem.Id); + } else { + pattern = GetPattern(elem.Id); + result = FindLookAhead(pattern, length, stack, filter); + if (stack.Contains(pattern.Name)) { + result = result.CreateRepetitive(); + } + } + + return result; + } + + /** + * Returns a look-ahead set with all conflics between + * alternatives in a production pattern. + * + * @param pattern the production pattern + * @param maxLength the maximum token sequence length + * + * @return a look-ahead set with the conflicts found + * + * @throws ParserCreationException if an inherent ambiguity was + * found among the look-ahead sets + */ + private LookAheadSet FindConflicts(ProductionPattern pattern, + int maxLength) { + + LookAheadSet result = new LookAheadSet(maxLength); + LookAheadSet set1; + LookAheadSet set2; + + for (int i = 0; i < pattern.Count; i++) { + set1 = pattern[i].LookAhead; + for (int j = 0; j < i; j++) { + set2 = pattern[j].LookAhead; + result.AddAll(set1.CreateIntersection(set2)); + } + } + if (result.IsRepetitive()) { + ThrowAmbiguityException(pattern.Name, null, result); + } + return result; + } + + /** + * Returns a look-ahead set with all conflicts between two + * look-ahead sets. + * + * @param pattern the pattern name being analyzed + * @param location the pattern location + * @param set1 the first look-ahead set + * @param set2 the second look-ahead set + * + * @return a look-ahead set with the conflicts found + * + * @throws ParserCreationException if an inherent ambiguity was + * found among the look-ahead sets + */ + private LookAheadSet FindConflicts(string pattern, + string location, + LookAheadSet set1, + LookAheadSet set2) { + + LookAheadSet result; + + result = set1.CreateIntersection(set2); + if (result.IsRepetitive()) { + ThrowAmbiguityException(pattern, location, result); + } + return result; + } + + /** + * Returns the union of all alternative look-ahead sets in a + * production pattern. + * + * @param pattern the production pattern + * + * @return a unified look-ahead set + */ + private LookAheadSet FindUnion(ProductionPattern pattern) { + LookAheadSet result; + int length = 0; + int i; + + for (i = 0; i < pattern.Count; i++) { + result = pattern[i].LookAhead; + if (result.GetMaxLength() > length) { + length = result.GetMaxLength(); + } + } + result = new LookAheadSet(length); + for (i = 0; i < pattern.Count; i++) { + result.AddAll(pattern[i].LookAhead); + } + + return result; + } + + /** + * Throws a parse exception that matches the specified look-ahead + * set. This method will take into account any initial matching + * tokens in the look-ahead set. + * + * @param set the look-ahead set to match + * + * @throws ParseException always thrown by this method + */ + private void ThrowParseException(LookAheadSet set) { + Token token; + ArrayList list = new ArrayList(); + int[] initials; + + // Read tokens until mismatch + while (set.IsNext(this, 1)) { + set = set.CreateNextSet(NextToken().Id); + } + + // Find next token descriptions + initials = set.GetInitialTokens(); + for (int i = 0; i < initials.Length; i++) { + list.Add(GetTokenDescription(initials[i])); + } + + // Create exception + token = NextToken(); + throw new ParseException(ParseException.ErrorType.UNEXPECTED_TOKEN, + token.ToShortString(), + list, + token.StartLine, + token.StartColumn); + } + + /** + * Throws a parser creation exception for an ambiguity. The + * specified look-ahead set contains the token conflicts to be + * reported. + * + * @param pattern the production pattern name + * @param location the production pattern location, or null + * @param set the look-ahead set with conflicts + * + * @throws ParserCreationException always thrown by this method + */ + private void ThrowAmbiguityException(string pattern, + string location, + LookAheadSet set) { + + ArrayList list = new ArrayList(); + int[] initials; + + // Find next token descriptions + initials = set.GetInitialTokens(); + for (int i = 0; i < initials.Length; i++) { + list.Add(GetTokenDescription(initials[i])); + } + + // Create exception + throw new ParserCreationException( + ParserCreationException.ErrorType.INHERENT_AMBIGUITY, + pattern, + location, + list); + } + + + /** + * A name value stack. This stack is used to detect loops and + * repetitions of the same production during look-ahead analysis. + */ + private class CallStack { + + /** + * A stack with names. + */ + private ArrayList nameStack = new ArrayList(); + + /** + * A stack with values. + */ + private ArrayList valueStack = new ArrayList(); + + /** + * Checks if the specified name is on the stack. + * + * @param name the name to search for + * + * @return true if the name is on the stack, or + * false otherwise + */ + public bool Contains(string name) { + return nameStack.Contains(name); + } + + /** + * Checks if the specified name and value combination is on + * the stack. + * + * @param name the name to search for + * @param value the value to search for + * + * @return true if the combination is on the stack, or + * false otherwise + */ + public bool Contains(string name, int value) { + for (int i = 0; i < nameStack.Count; i++) { + if (nameStack[i].Equals(name) + && valueStack[i].Equals(value)) { + + return true; + } + } + return false; + } + + /** + * Clears the stack. This method removes all elements on + * the stack. + */ + public void Clear() { + nameStack.Clear(); + valueStack.Clear(); + } + + /** + * Adds a new element to the top of the stack. + * + * @param name the stack name + * @param value the stack value + */ + public void Push(string name, int value) { + nameStack.Add(name); + valueStack.Add(value); + } + + /** + * Removes the top element of the stack. + */ + public void Pop() { + if (nameStack.Count > 0) { + nameStack.RemoveAt(nameStack.Count - 1); + valueStack.RemoveAt(valueStack.Count - 1); + } + } + } + } +} diff --git a/Core Library/Core Library/SyntaxConstants.cs b/Core Library/Core Library/SyntaxConstants.cs new file mode 100644 index 0000000..c671664 --- /dev/null +++ b/Core Library/Core Library/SyntaxConstants.cs @@ -0,0 +1,186 @@ +/* + * SyntaxConstants.cs + * + * THIS FILE HAS BEEN GENERATED AUTOMATICALLY. DO NOT EDIT! + */ + +/** + * An enumeration with token and production node + * constants. + */ +public enum SyntaxConstants +{ + ENTRANCE = 1001, + EXIT = 1002, + MANE = 1003, + LET = 1004, + WIPE = 1005, + ZOOIN = 1006, + ZOOUT = 1007, + IF = 1008, + EELSIF = 1009, + EELS = 1010, + CHAMOIS = 1011, + TERMITE = 1012, + SEAL = 1013, + WHALE = 1014, + DO = 1015, + FUR = 1016, + HOP = 1017, + SWASP = 1018, + STORK = 1019, + AT = 1020, + NULL = 1021, + COMSYM = 1022, + TERMI = 1023, + SC = 1024, + COMMA = 1025, + EQUAL = 1026, + OB = 1027, + CB = 1028, + OC = 1029, + CC = 1030, + OP = 1031, + CP = 1032, + ODC = 1033, + CDC = 1034, + CONC = 1035, + CON = 1036, + ODA = 1037, + CDA = 1038, + NEG = 1039, + ADD = 1040, + SUB = 1041, + MUL = 1042, + DIV = 1043, + MOD = 1044, + EXP = 1045, + OA = 1046, + CA = 1047, + OAE = 1048, + CAE = 1049, + EE = 1050, + DE = 1051, + EXC = 1052, + DAND = 1053, + DOR = 1054, + INCRE = 1055, + DECRE = 1056, + NEWT = 1057, + DUCK = 1058, + BULL = 1059, + STARLING = 1060, + VIPER = 1061, + NEWTLIT = 1062, + DUCKLIT = 1063, + STARLIT = 1064, + TRUE = 1065, + FALSE = 1066, + ID = 1067, + COMMENT = 1068, + WHITESPACE = 1069, + PROD_PROGRAM = 2001, + PROD_COMMENT = 2002, + PROD_GLOBAL_DEC = 2003, + PROD_VAR_DEC = 2004, + PROD_FUNC_VAR = 2005, + PROD_IDENT_VAR = 2006, + PROD_DTYPE = 2007, + PROD_NEXT2VAR = 2008, + PROD_NEXT2VAR_TAIL = 2009, + PROD_VAL = 2010, + PROD_VAL1 = 2011, + PROD_VAL2 = 2012, + PROD_BUL_LIT = 2013, + PROD_ARRAY1D = 2014, + PROD_ELEM1D_NEXT = 2015, + PROD_ELEM1D_LIST = 2016, + PROD_ELEMLIST1D_TAIL = 2017, + PROD_ELEM2D_NEXT = 2018, + PROD_ELEM2D_LIST = 2019, + PROD_ELEM2D_LIST_TAIL = 2020, + PROD_SIZE = 2021, + PROD_CONST_DEC = 2022, + PROD_CONST_NEXT = 2023, + PROD_FUNC_NAME = 2024, + PROD_PARAM = 2025, + PROD_PARAM2 = 2026, + PROD_STORK_DEC = 2027, + PROD_STORK_ELEM = 2028, + PROD_MULTI_VARDEC = 2029, + PROD_MULTISTORK_ELEM = 2030, + PROD_OBJ_DEC = 2031, + PROD_MANE = 2032, + PROD_LOCAL_DEC = 2033, + PROD_STATEMENT = 2034, + PROD_STATE_NEXT = 2035, + PROD_ASSIGN1 = 2036, + PROD_ASSIGN_TAIL = 2037, + PROD_NEXT_FIG = 2038, + PROD_NEXT = 2039, + PROD_SCAN_NEXT = 2040, + PROD_VALUE_DL = 2041, + PROD_FIG = 2042, + PROD_FUNC_CALL = 2043, + PROD_ARGS1 = 2044, + PROD_ARGS_TAIL = 2045, + PROD_ARG_IN = 2046, + PROD_FUNC_NEXT = 2047, + PROD_FUNC = 2048, + PROD_MATH_EQTAIL = 2049, + PROD_MATH_EQTAIL1 = 2050, + PROD_MATH_EQTAIL2 = 2051, + PROD_EXPONENT = 2052, + PROD_MATH_TAIL = 2053, + PROD_MATH_OP = 2054, + PROD_MATH_FIG = 2055, + PROD_MATH_FIG1 = 2056, + PROD_MATHEQ_NEXT = 2057, + PROD_FUNCTION_CALL = 2058, + PROD_CLRSCR = 2059, + PROD_INPUT = 2060, + PROD_SCAN_FIG = 2061, + PROD_MULTI_INPUT = 2062, + PROD_ARR1D = 2063, + PROD_ARR2D = 2064, + PROD_STORK_ACCESS1 = 2065, + PROD_OUTPUT = 2066, + PROD_OUT = 2067, + PROD_OUTPUT_NEXT = 2068, + PROD_MULTI_OUTPUT = 2069, + PROD_CONDITIONAL = 2070, + PROD_CONDI = 2071, + PROD_NOT_FIG = 2072, + PROD_COND_EXPR = 2073, + PROD_COND_TAIL = 2074, + PROD_REL_EXPR = 2075, + PROD_RELEX_TAIL = 2076, + PROD_EXPRESSION = 2077, + PROD_EXPR_NEXT = 2078, + PROD_REL_OP1 = 2079, + PROD_REL_OP2 = 2080, + PROD_REL_FIG = 2081, + PROD_LOG_EXPR = 2082, + PROD_LOG_EXPR_NEXT = 2083, + PROD_LOG_OP = 2084, + PROD_COND_EELSIF = 2085, + PROD_COND_EELS = 2086, + PROD_SWASP_CASE = 2087, + PROD_SWASP_CASE1 = 2088, + PROD_TERM_EXPR = 2089, + PROD_DEFAULT = 2090, + PROD_ITERATIVE = 2091, + PROD_LOOP_FIG1 = 2092, + PROD_REL_EXPR1 = 2093, + PROD_LOOP_FIG2 = 2094, + PROD_INCREM_DECREM = 2095, + PROD_VAR = 2096, + PROD_UNARY_OP = 2097, + PROD_SUB_FUNCTION = 2098, + PROD_FUNC_INSIDE = 2099, + PROD_FUNC_ARGS = 2100, + PROD_MULTIFUNC_ARGS = 2101, + PROD_RESULT = 2102, + PROD_FIG_TAIL = 2103, + PROD_RESULT_TAIL = 2104 +} diff --git a/Core Library/Core Library/SyntaxProductions.cs b/Core Library/Core Library/SyntaxProductions.cs new file mode 100644 index 0000000..6ec47b6 --- /dev/null +++ b/Core Library/Core Library/SyntaxProductions.cs @@ -0,0 +1,64 @@ +using System.Collections.Generic; + +namespace Core.Library +{ + public class SyntaxProductions + { + private string Productions = ""; + private string RecursiveProductions = ""; + private List ProductionCode = new List(); + private List ProductionState = new List(); + public void AddProductionCode(int code) + { + this.ProductionCode.Add(code); + } + + public int GetLastProductionCode() + { + int last = ProductionCode.Count - 1; + return this.ProductionCode[last]; + } + public List GetAllProductionCode() + { + return this.ProductionCode; + } + + + public void AddProductionState(string state) + { + this.ProductionState.Add(state); + } + + public string GetLastProductionState() + { + int last = ProductionState.Count - 1; + if (last == -1) + { + return "Enter: ENTRANCE\n"; + } + else + return this.ProductionState[last]; + } + public List GetAllProductionState() + { + return this.ProductionState; + } + + public void AddProduction(string Productions) + { + this.Productions += Productions; + } + public string GetProductions() + { + return this.Productions; + } + public void AddRecursiveProduction(string RecursiveProductions) + { + this.RecursiveProductions += RecursiveProductions; + } + public string GetRecursiveProductions() + { + return this.RecursiveProductions; + } + } +} diff --git a/Core Library/Core Library/Token.cs b/Core Library/Core Library/Token.cs new file mode 100644 index 0000000..9a75fa5 --- /dev/null +++ b/Core Library/Core Library/Token.cs @@ -0,0 +1,358 @@ +/* + * Token.cs + */ + +using System.Text; + +namespace Core.Library { + + /** + * A token node. This class represents a token (i.e. a set of adjacent + * characters) in a parse tree. The tokens are created by a tokenizer, + * that groups characters together into tokens according to a set of + * token patterns. + * + + * + */ + public class Token : Node { + + /** + * The token pattern used for this token. + */ + private TokenPattern pattern; + + /** + * The characters that constitute this token. This is normally + * referred to as the token image. + */ + private string image; + + /** + * The line number of the first character in the token image. + */ + private int startLine; + + /** + * The column number of the first character in the token image. + */ + private int startColumn; + + /** + * The line number of the last character in the token image. + */ + private int endLine; + + /** + * The column number of the last character in the token image. + */ + private int endColumn; + + /** + * The previous token in the list of tokens. + */ + private Token previous = null; + + /** + * The next token in the list of tokens. + */ + private Token next = null; + + /** + * Creates a new token. + * + * @param pattern the token pattern + * @param image the token image (i.e. characters) + * @param line the line number of the first character + * @param col the column number of the first character + */ + public Token(TokenPattern pattern, string image, int line, int col) { + this.pattern = pattern; + this.image = image; + this.startLine = line; + this.startColumn = col; + this.endLine = line; + this.endColumn = col + image.Length - 1; + for (int pos = 0; image.IndexOf('\n', pos) >= 0;) { + pos = image.IndexOf('\n', pos) + 1; + this.endLine++; + endColumn = image.Length - pos; + } + } + + /** + * The node type id property (read-only). This value is set as + * a unique identifier for each type of node, in order to + * simplify later identification. + * + * + */ + public override int Id { + get { + return pattern.Id; + } + } + + /** + * The node name property (read-only). + * + * + */ + public override string Name { + get { + return pattern.Name; + } + } + + /** + * The line number property of the first character in this + * node (read-only). If the node has child elements, this + * value will be fetched from the first child. + * + * + */ + public override int StartLine { + get { + return startLine; + } + } + + /** + * The column number property of the first character in this + * node (read-only). If the node has child elements, this + * value will be fetched from the first child. + * + * + */ + public override int StartColumn { + get { + return startColumn; + } + } + + /** + * The line number property of the last character in this node + * (read-only). If the node has child elements, this value + * will be fetched from the last child. + * + * + */ + public override int EndLine { + get { + return endLine; + } + } + + /** + * The column number property of the last character in this + * node (read-only). If the node has child elements, this + * value will be fetched from the last child. + * + * + */ + public override int EndColumn { + get { + return endColumn; + } + } + + /** + * The token image property (read-only). The token image + * consists of the input characters matched to form this + * token. + * + * + */ + public string Image { + get { + return image; + } + } + + /** + * Returns the token image. The token image consists of the + * input characters matched to form this token. + * + * @return the token image + * + * @see #Image + * + * @deprecated Use the Image property instead. + */ + public string GetImage() { + return Image; + } + + /** + * The token pattern property (read-only). + */ + internal TokenPattern Pattern { + get { + return pattern; + } + } + + /** + * The previous token property. If the token list feature is + * used in the tokenizer, all tokens found will be chained + * together in a double-linked list. The previous token may be + * a token that was ignored during the parsing, due to it's + * ignore flag being set. If there is no previous token or if + * the token list feature wasn't used in the tokenizer (the + * default), the previous token will always be null. + * + * @see #Next + * @see Tokenizer#UseTokenList + * + * + */ + public Token Previous { + get { + return previous; + } + set { + if (previous != null) { + previous.next = null; + } + previous = value; + if (previous != null) { + previous.next = this; + } + } + } + + /** + * Returns the previous token. The previous token may be a token + * that has been ignored in the parsing. Note that if the token + * list feature hasn't been used in the tokenizer, this method + * will always return null. By default the token list feature is + * not used. + * + * @return the previous token, or + * null if no such token is available + * + * @see #Previous + * @see #GetNextToken + * @see Tokenizer#UseTokenList + * + * + * + * @deprecated Use the Previous property instead. + */ + public Token GetPreviousToken() { + return Previous; + } + + /** + * The next token property. If the token list feature is used + * in the tokenizer, all tokens found will be chained together + * in a double-linked list. The next token may be a token that + * was ignored during the parsing, due to it's ignore flag + * being set. If there is no next token or if the token list + * feature wasn't used in the tokenizer (the default), the + * next token will always be null. + * + * @see #Previous + * @see Tokenizer#UseTokenList + * + * + */ + public Token Next { + get { + return next; + } + set { + if (next != null) { + next.previous = null; + } + next = value; + if (next != null) { + next.previous = this; + } + } + } + + /** + * Returns the next token. The next token may be a token that has + * been ignored in the parsing. Note that if the token list + * feature hasn't been used in the tokenizer, this method will + * always return null. By default the token list feature is not + * used. + * + * @return the next token, or + * null if no such token is available + * + * @see #Next + * @see #GetPreviousToken + * @see Tokenizer#UseTokenList + * + * + * + * @deprecated Use the Next property instead. + */ + public Token GetNextToken() { + return Next; + } + + /** + * Returns a string representation of this token. + * + * @return a string representation of this token + */ + public override string ToString() { + StringBuilder buffer = new StringBuilder(); + int newline = image.IndexOf('\n'); + + buffer.Append(pattern.Name); + buffer.Append("("); + buffer.Append(pattern.Id); + buffer.Append("): \""); + if (newline >= 0) { + if (newline > 0 && image[newline - 1] == '\r') { + newline--; + } + buffer.Append(image.Substring(0, newline)); + buffer.Append("(...)"); + } else { + buffer.Append(image); + } + buffer.Append("\", line: "); + buffer.Append(startLine); + buffer.Append(", col: "); + buffer.Append(startColumn); + + return buffer.ToString(); + } + + /** + * Returns a short string representation of this token. The + * string will only contain the token image and possibly the + * token pattern name. + * + * @return a short string representation of this token + */ + public string ToShortString() { + StringBuilder buffer = new StringBuilder(); + int newline = image.IndexOf('\n'); + + buffer.Append('"'); + if (newline >= 0) { + if (newline > 0 && image[newline - 1] == '\r') { + newline--; + } + buffer.Append(image.Substring(0, newline)); + buffer.Append("(...)"); + } else { + buffer.Append(image); + } + buffer.Append('"'); + if (pattern.Type == TokenPattern.PatternType.REGEXP) { + buffer.Append(" <"); + buffer.Append(pattern.Name); + buffer.Append(">"); + } + + return buffer.ToString(); + } + } +} diff --git a/Core Library/Core Library/TokenMatch.cs b/Core Library/Core Library/TokenMatch.cs new file mode 100644 index 0000000..58ab894 --- /dev/null +++ b/Core Library/Core Library/TokenMatch.cs @@ -0,0 +1,72 @@ +/* + * TokenMatch.cs + */ + +namespace Core.Library { + + /** + * The token match status. This class contains logic to ensure that + * only the longest match is considered. It also prefers lower token + * pattern identifiers if two matches have the same length. + * + + * + * + */ + internal class TokenMatch { + + /** + * The length of the longest match. + */ + private int length = 0; + + /** + * The pattern in the longest match. + */ + private TokenPattern pattern = null; + + /** + * Clears the current match information. + */ + public void Clear() { + length = 0; + pattern = null; + } + + /** + * The length of the longest match found (read-only). + */ + public int Length { + get { + return length; + } + } + + /** + * The token pattern for the longest match found (read-only). + */ + public TokenPattern Pattern { + get { + return pattern; + } + } + + /** + * Updates this match with new values. The new values will only + * be considered if the length is longer than any previous match + * found. + * + * @param length the matched length + * @param pattern the matched pattern + */ + public void Update(int length, TokenPattern pattern) { + if (this.length < length) { + this.length = length; + this.pattern = pattern; + } else if (this.length == length && this.pattern.Id > pattern.Id) { + this.length = length; + this.pattern = pattern; + } + } + } +} diff --git a/Core Library/Core Library/TokenNFA.cs b/Core Library/Core Library/TokenNFA.cs new file mode 100644 index 0000000..123f26b --- /dev/null +++ b/Core Library/Core Library/TokenNFA.cs @@ -0,0 +1,1272 @@ +/* + * TokenNFA.cs + */ + +using System; + +namespace Core.Library { + + /** + * A non-deterministic finite state automaton (NFA) for matching + * tokens. It supports both fixed strings and simple regular + * expressions, but should perform similar to a DFA due to highly + * optimized data structures and tuning. The memory footprint during + * matching should be near zero, since no heap memory is allocated + * unless the pre-allocated queues need to be enlarged. The NFA also + * does not use recursion, but iterates in a loop instead. + * + * + * + */ + internal class TokenNFA { + + /** + * The initial state lookup table, indexed by the first ASCII + * character. This array is used to for speed optimizing the + * first step in the match, since the initial state would + * otherwise have a long list of transitions to consider. + */ + private NFAState[] initialChar = new NFAState[128]; + + /** + * The initial state. This state contains any transitions not + * already stored in the initial text state array, i.e. non-ASCII + * or complex transitions (such as regular expressions). + */ + private NFAState initial = new NFAState(); + + /** + * The NFA state queue to use. + */ + private NFAStateQueue queue = new NFAStateQueue(); + + /** + * Adds a string match to this automaton. New states and + * transitions will be added to extend this automaton to support + * the specified string. + * + * @param str the string to match + * @param ignoreCase the case-insensitive match flag + * @param value the match value + */ + public void AddTextMatch(string str, bool ignoreCase, TokenPattern value) { + NFAState state; + char ch = str[0]; + + if (ch < 128 && !ignoreCase) { + state = initialChar[ch]; + if (state == null) { + state = initialChar[ch] = new NFAState(); + } + } else { + state = initial.AddOut(ch, ignoreCase, null); + } + for (int i = 1; i < str.Length; i++) { + state = state.AddOut(str[i], ignoreCase, null); + } + state.value = value; + } + + /** + * Adds a regular expression match to this automaton. New states + * and transitions will be added to extend this automaton to + * support the specified string. Note that this method only + * supports a subset of the full regular expression syntax, so + * a more complete regular expression library must also be + * provided. + * + * @param pattern the regular expression string + * @param ignoreCase the case-insensitive match flag + * @param value the match value + * + * @throws RegExpException if the regular expression parsing + * failed + */ + public void AddRegExpMatch(string pattern, + bool ignoreCase, + TokenPattern value) { + + TokenRegExpParser parser = new TokenRegExpParser(pattern, ignoreCase); + string debug = "DFA regexp; " + parser.GetDebugInfo(); + bool isAscii; + + isAscii = parser.start.IsAsciiOutgoing(); + for (int i = 0; isAscii && i < 128; i++) { + bool match = false; + for (int j = 0; j < parser.start.outgoing.Length; j++) { + if (parser.start.outgoing[j].Match((char) i)) { + if (match) { + isAscii = false; + break; + } + match = true; + } + } + if (match && initialChar[i] != null) { + isAscii = false; + } + } + if (parser.start.incoming.Length > 0) { + initial.AddOut(new NFAEpsilonTransition(parser.start)); + debug += ", uses initial epsilon"; + } else if (isAscii && !ignoreCase) { + for (int i = 0; isAscii && i < 128; i++) { + for (int j = 0; j < parser.start.outgoing.Length; j++) { + if (parser.start.outgoing[j].Match((char) i)) { + initialChar[i] = parser.start.outgoing[j].state; + } + } + } + debug += ", uses ASCII lookup"; + } else { + parser.start.MergeInto(initial); + debug += ", uses initial state"; + } + parser.end.value = value; + value.DebugInfo = debug; + } + + /** + * Checks if this NFA matches the specified input text. The + * matching will be performed from position zero (0) in the + * buffer. This method will not read any characters from the + * stream, just peek ahead. + * + * @param buffer the input buffer to check + * @param match the token match to update + * + * @return the number of characters matched, or + * zero (0) if no match was found + * + * @throws IOException if an I/O error occurred + */ + public int Match(ReaderBuffer buffer, TokenMatch match) { + int length = 0; + int pos = 1; + int peekChar; + NFAState state; + + // The first step of the match loop has been unrolled and + // optimized for performance below. + this.queue.Clear(); + peekChar = buffer.Peek(0); + if (0 <= peekChar && peekChar < 128) { + state = this.initialChar[peekChar]; + if (state != null) { + this.queue.AddLast(state); + } + } + if (peekChar >= 0) { + this.initial.MatchTransitions((char) peekChar, this.queue, true); + } + this.queue.MarkEnd(); + peekChar = buffer.Peek(1); + + // The remaining match loop processes all subsequent states + while (!this.queue.Empty) { + if (this.queue.Marked) { + pos++; + peekChar = buffer.Peek(pos); + this.queue.MarkEnd(); + } + state = this.queue.RemoveFirst(); + if (state.value != null) { + match.Update(pos, state.value); + } + if (peekChar >= 0) { + state.MatchTransitions((char) peekChar, this.queue, false); + } + } + return length; + } + } + + + /** + * An NFA state. The NFA consists of a series of states, each + * having zero or more transitions to other states. + */ + internal class NFAState { + + /** + * The optional state value (if it is a final state). + */ + internal TokenPattern value = null; + + /** + * The incoming transitions to this state. + */ + internal NFATransition[] incoming = new NFATransition[0]; + + /** + * The outgoing transitions from this state. + */ + internal NFATransition[] outgoing = new NFATransition[0]; + + /** + * The outgoing epsilon transitions flag. + */ + internal bool epsilonOut = false; + + /** + * Checks if this state has any incoming or outgoing + * transitions. + * + * @return true if this state has transitions, or + * false otherwise + */ + public bool HasTransitions() { + return incoming.Length > 0 || outgoing.Length > 0; + } + + /** + * Checks if all outgoing transitions only match ASCII + * characters. + * + * @return true if all transitions are ASCII-only, or + * false otherwise + */ + public bool IsAsciiOutgoing() { + for (int i = 0; i < outgoing.Length; i++) { + if (!outgoing[i].IsAscii()) { + return false; + } + } + return true; + } + + /** + * Adds a new incoming transition. + * + * @param trans the transition to add + */ + public void AddIn(NFATransition trans) { + Array.Resize(ref incoming, incoming.Length + 1); + incoming[incoming.Length - 1] = trans; + } + + /** + * Adds a new outgoing character transition. If the target + * state specified was null and an identical transition + * already exists, it will be reused and its target returned. + * + * @param ch he character to match + * @param ignoreCase the case-insensitive flag + * @param state the target state, or null + * + * @return the transition target state + */ + public NFAState AddOut(char ch, bool ignoreCase, NFAState state) { + if (ignoreCase) { + if (state == null) { + state = new NFAState(); + } + AddOut(new NFACharTransition(Char.ToLower(ch), state)); + AddOut(new NFACharTransition(Char.ToUpper(ch), state)); + return state; + } else { + if (state == null) { + state = FindUniqueCharTransition(ch); + if (state != null) { + return state; + } + state = new NFAState(); + } + return AddOut(new NFACharTransition(ch, state)); + } + } + + /** + * Adds a new outgoing transition. + * + * @param trans the transition to add + * + * @return the transition target state + */ + public NFAState AddOut(NFATransition trans) { + Array.Resize(ref outgoing, outgoing.Length + 1); + outgoing[outgoing.Length - 1] = trans; + if (trans is NFAEpsilonTransition) { + epsilonOut = true; + } + return trans.state; + } + + /** + * Merges all the transitions in this state into another + * state. + * + * @param state the state to merge into + */ + public void MergeInto(NFAState state) { + for (int i = 0; i < incoming.Length; i++) { + state.AddIn(incoming[i]); + incoming[i].state = state; + } + incoming = null; + for (int i = 0; i < outgoing.Length; i++) { + state.AddOut(outgoing[i]); + } + outgoing = null; + } + + /** + * Finds a unique character transition if one exists. The + * transition must be the only matching single character + * transition and no other transitions may reach the same + * state. + * + * @param ch the character to search for + * + * @return the unique transition state found, or + * null if not found + */ + private NFAState FindUniqueCharTransition(char ch) { + NFATransition res = null; + NFATransition trans; + + for (int i = 0; i < outgoing.Length; i++) { + trans = outgoing[i]; + if (trans.Match(ch) && trans is NFACharTransition) { + if (res != null) { + return null; + } + res = trans; + } + } + for (int i = 0; res != null && i < outgoing.Length; i++) { + trans = outgoing[i]; + if (trans != res && trans.state == res.state) { + return null; + } + } + return (res == null) ? null : res.state; + } + + /** + * Attempts a match on each of the transitions leading from + * this state. If a match is found, its state will be added + * to the queue. If the initial match flag is set, epsilon + * transitions will also be matched (and their targets called + * recursively). + * + * @param ch the character to match + * @param queue the state queue + * @param initial the initial match flag + */ + public void MatchTransitions(char ch, NFAStateQueue queue, bool initial) { + NFATransition trans; + NFAState target; + + for (int i = 0; i < outgoing.Length; i++) { + trans = outgoing[i]; + target = trans.state; + if (initial && trans is NFAEpsilonTransition) { + target.MatchTransitions(ch, queue, true); + } else if (trans.Match(ch)) { + queue.AddLast(target); + if (target.epsilonOut) { + target.MatchEmpty(queue); + } + } + } + } + + /** + * Adds all the epsilon transition targets to the specified + * queue. + * + * @param queue the state queue + */ + public void MatchEmpty(NFAStateQueue queue) { + NFATransition trans; + NFAState target; + + for (int i = 0; i < outgoing.Length; i++) { + trans = outgoing[i]; + if (trans is NFAEpsilonTransition) { + target = trans.state; + queue.AddLast(target); + if (target.epsilonOut) { + target.MatchEmpty(queue); + } + } + } + } + } + + + /** + * An NFA state transition. A transition checks a single + * character of input an determines if it is a match. If a match + * is encountered, the NFA should move forward to the transition + * state. + */ + internal abstract class NFATransition { + + /** + * The target state of the transition. + */ + internal NFAState state; + + /** + * Creates a new state transition. + * + * @param state the target state + */ + public NFATransition(NFAState state) { + this.state = state; + this.state.AddIn(this); + } + + /** + * Checks if this transition only matches ASCII characters. + * I.e. characters with numeric values between 0 and 127. + * + * @return true if this transition only matches ASCII, or + * false otherwise + */ + public abstract bool IsAscii(); + + /** + * Checks if the specified character matches the transition. + * + * @param ch the character to check + * + * @return true if the character matches, or + * false otherwise + */ + public abstract bool Match(char ch); + + /** + * Creates a copy of this transition but with another target + * state. + * + * @param state the new target state + * + * @return an identical copy of this transition + */ + public abstract NFATransition Copy(NFAState state); + } + + + /** + * The special epsilon transition. This transition matches the + * empty input, i.e. it is an automatic transition that doesn't + * read any input. As such, it returns false in the match method + * and is handled specially everywhere. + */ + internal class NFAEpsilonTransition : NFATransition { + + /** + * Creates a new epsilon transition. + * + * @param state the target state + */ + public NFAEpsilonTransition(NFAState state) : base(state) { + } + + /** + * Checks if this transition only matches ASCII characters. + * I.e. characters with numeric values between 0 and 127. + * + * @return true if this transition only matches ASCII, or + * false otherwise + */ + public override bool IsAscii() { + return false; + } + + /** + * Checks if the specified character matches the transition. + * + * @param ch the character to check + * + * @return true if the character matches, or + * false otherwise + */ + public override bool Match(char ch) { + return false; + } + + /** + * Creates a copy of this transition but with another target + * state. + * + * @param state the new target state + * + * @return an identical copy of this transition + */ + public override NFATransition Copy(NFAState state) { + return new NFAEpsilonTransition(state); + } + } + + + /** + * A single character match transition. + */ + internal class NFACharTransition : NFATransition { + + /** + * The character to match. + */ + protected char match; + + /** + * Creates a new character transition. + * + * @param match the character to match + * @param state the target state + */ + public NFACharTransition(char match, NFAState state) : base(state) { + this.match = match; + } + + /** + * Checks if this transition only matches ASCII characters. + * I.e. characters with numeric values between 0 and 127. + * + * @return true if this transition only matches ASCII, or + * false otherwise + */ + public override bool IsAscii() { + return 0 <= match && match < 128; + } + + /** + * Checks if the specified character matches the transition. + * + * @param ch the character to check + * + * @return true if the character matches, or + * false otherwise + */ + public override bool Match(char ch) { + return this.match == ch; + } + + /** + * Creates a copy of this transition but with another target + * state. + * + * @param state the new target state + * + * @return an identical copy of this transition + */ + public override NFATransition Copy(NFAState state) { + return new NFACharTransition(match, state); + } + } + + + /** + * A character range match transition. Used for user-defined + * character sets in regular expressions. + */ + internal class NFACharRangeTransition : NFATransition { + + /** + * The inverse match flag. + */ + protected bool inverse; + + /** + * The case-insensitive match flag. + */ + protected bool ignoreCase; + + /** + * The character set content. This array may contain either + * range objects or Character objects. + */ + private object[] contents = new object[0]; + + /** + * Creates a new character range transition. + * + * @param inverse the inverse match flag + * @param ignoreCase the case-insensitive match flag + * @param state the target state + */ + public NFACharRangeTransition(bool inverse, + bool ignoreCase, + NFAState state) : base(state) { + this.inverse = inverse; + this.ignoreCase = ignoreCase; + } + + /** + * Checks if this transition only matches ASCII characters. + * I.e. characters with numeric values between 0 and 127. + * + * @return true if this transition only matches ASCII, or + * false otherwise + */ + public override bool IsAscii() { + object obj; + char c; + + if (inverse) { + return false; + } + for (int i = 0; i < contents.Length; i++) { + obj = contents[i]; + if (obj is char) { + c = (char) obj; + if (c < 0 || 128 <= c) { + return false; + } + } else if (obj is Range) { + if (!((Range) obj).IsAscii()) { + return false; + } + } + } + return true; + } + + /** + * Adds a single character to this character set. + * + * @param c the character to add + */ + public void AddCharacter(char c) { + if (ignoreCase) { + c = Char.ToLower(c); + } + AddContent(c); + } + + /** + * Adds a character range to this character set. + * + * @param min the minimum character value + * @param max the maximum character value + */ + public void AddRange(char min, char max) { + if (ignoreCase) { + min = Char.ToLower(min); + max = Char.ToLower(max); + } + AddContent(new Range(min, max)); + } + + /** + * Adds an object to the character set content array. + * + * @param obj the object to add + */ + private void AddContent(Object obj) { + Array.Resize(ref contents, contents.Length + 1); + contents[contents.Length - 1] = obj; + } + + /** + * Checks if the specified character matches the transition. + * + * @param ch the character to check + * + * @return true if the character matches, or + * false otherwise + */ + public override bool Match(char ch) { + object obj; + char c; + Range r; + + if (ignoreCase) { + ch = Char.ToLower(ch); + } + for (int i = 0; i < contents.Length; i++) { + obj = contents[i]; + if (obj is char) { + c = (char) obj; + if (c == ch) { + return !inverse; + } + } else if (obj is Range) { + r = (Range) obj; + if (r.Inside(ch)) { + return !inverse; + } + } + } + return inverse; + } + + /** + * Creates a copy of this transition but with another target + * state. + * + * @param state the new target state + * + * @return an identical copy of this transition + */ + public override NFATransition Copy(NFAState state) { + NFACharRangeTransition copy; + + copy = new NFACharRangeTransition(inverse, ignoreCase, state); + copy.contents = contents; + return copy; + } + + /** + * A character range class. + */ + private class Range { + + /** + * The minimum character value. + */ + private char min; + + /** + * The maximum character value. + */ + private char max; + + /** + * Creates a new character range. + * + * @param min the minimum character value + * @param max the maximum character value + */ + public Range(char min, char max) { + this.min = min; + this.max = max; + } + + /** + * Checks if this range only matches ASCII characters + * + * @return true if this range only matches ASCII, or + * false otherwise + */ + public bool IsAscii() { + return 0 <= min && min < 128 && + 0 <= max && max < 128; + } + + /** + * Checks if the specified character is inside the range. + * + * @param c the character to check + * + * @return true if the character is in the range, or + * false otherwise + */ + public bool Inside(char c) { + return min <= c && c <= max; + } + } + } + + + /** + * The dot ('.') character set transition. This transition + * matches a single character that is not equal to a newline + * character. + */ + internal class NFADotTransition : NFATransition { + + /** + * Creates a new dot character set transition. + * + * @param state the target state + */ + public NFADotTransition(NFAState state) : base(state) { + } + + /** + * Checks if this transition only matches ASCII characters. + * I.e. characters with numeric values between 0 and 127. + * + * @return true if this transition only matches ASCII, or + * false otherwise + */ + public override bool IsAscii() { + return false; + } + + /** + * Checks if the specified character matches the transition. + * + * @param ch the character to check + * + * @return true if the character matches, or + * false otherwise + */ + public override bool Match(char ch) { + switch (ch) { + case '\n': + case '\r': + case '\u0085': + case '\u2028': + case '\u2029': + return false; + default: + return true; + } + } + + /** + * Creates a copy of this transition but with another target + * state. + * + * @param state the new target state + * + * @return an identical copy of this transition + */ + public override NFATransition Copy(NFAState state) { + return new NFADotTransition(state); + } + } + + + /** + * The digit character set transition. This transition matches a + * single numeric character. + */ + internal class NFADigitTransition : NFATransition { + + /** + * Creates a new digit character set transition. + * + * @param state the target state + */ + public NFADigitTransition(NFAState state) : base(state) { + } + + /** + * Checks if this transition only matches ASCII characters. + * I.e. characters with numeric values between 0 and 127. + * + * @return true if this transition only matches ASCII, or + * false otherwise + */ + public override bool IsAscii() { + return true; + } + + /** + * Checks if the specified character matches the transition. + * + * @param ch the character to check + * + * @return true if the character matches, or + * false otherwise + */ + public override bool Match(char ch) { + return '0' <= ch && ch <= '9'; + } + + /** + * Creates a copy of this transition but with another target + * state. + * + * @param state the new target state + * + * @return an identical copy of this transition + */ + public override NFATransition Copy(NFAState state) { + return new NFADigitTransition(state); + } + } + + + /** + * The non-digit character set transition. This transition + * matches a single non-numeric character. + */ + internal class NFANonDigitTransition : NFATransition { + + /** + * Creates a new non-digit character set transition. + * + * @param state the target state + */ + public NFANonDigitTransition(NFAState state) : base(state) { + } + + /** + * Checks if this transition only matches ASCII characters. + * I.e. characters with numeric values between 0 and 127. + * + * @return true if this transition only matches ASCII, or + * false otherwise + */ + public override bool IsAscii() { + return false; + } + + /** + * Checks if the specified character matches the transition. + * + * @param ch the character to check + * + * @return true if the character matches, or + * false otherwise + */ + public override bool Match(char ch) { + return ch < '0' || '9' < ch; + } + + /** + * Creates a copy of this transition but with another target + * state. + * + * @param state the new target state + * + * @return an identical copy of this transition + */ + public override NFATransition Copy(NFAState state) { + return new NFANonDigitTransition(state); + } + } + + + /** + * The whitespace character set transition. This transition + * matches a single whitespace character. + */ + internal class NFAWhitespaceTransition : NFATransition { + + /** + * Creates a new whitespace character set transition. + * + * @param state the target state + */ + public NFAWhitespaceTransition(NFAState state) : base(state) { + } + + /** + * Checks if this transition only matches ASCII characters. + * I.e. characters with numeric values between 0 and 127. + * + * @return true if this transition only matches ASCII, or + * false otherwise + */ + public override bool IsAscii() { + return true; + } + + /** + * Checks if the specified character matches the transition. + * + * @param ch the character to check + * + * @return true if the character matches, or + * false otherwise + */ + public override bool Match(char ch) { + switch (ch) { + case ' ': + case '\t': + case '\n': + case '\f': + case '\r': + case (char) 11: + return true; + default: + return false; + } + } + + /** + * Creates a copy of this transition but with another target + * state. + * + * @param state the new target state + * + * @return an identical copy of this transition + */ + public override NFATransition Copy(NFAState state) { + return new NFAWhitespaceTransition(state); + } + } + + + /** + * The non-whitespace character set transition. This transition + * matches a single non-whitespace character. + */ + internal class NFANonWhitespaceTransition : NFATransition { + + /** + * Creates a new non-whitespace character set transition. + * + * @param state the target state + */ + public NFANonWhitespaceTransition(NFAState state) : base(state) { + } + + /** + * Checks if this transition only matches ASCII characters. + * I.e. characters with numeric values between 0 and 127. + * + * @return true if this transition only matches ASCII, or + * false otherwise + */ + public override bool IsAscii() { + return false; + } + + /** + * Checks if the specified character matches the transition. + * + * @param ch the character to check + * + * @return true if the character matches, or + * false otherwise + */ + public override bool Match(char ch) { + switch (ch) { + case ' ': + case '\t': + case '\n': + case '\f': + case '\r': + case (char) 11: + return false; + default: + return true; + } + } + + /** + * Creates a copy of this transition but with another target + * state. + * + * @param state the new target state + * + * @return an identical copy of this transition + */ + public override NFATransition Copy(NFAState state) { + return new NFANonWhitespaceTransition(state); + } + } + + + /** + * The word character set transition. This transition matches a + * single word character. + */ + internal class NFAWordTransition : NFATransition { + + /** + * Creates a new word character set transition. + * + * @param state the target state + */ + public NFAWordTransition(NFAState state) : base(state) { + } + + /** + * Checks if this transition only matches ASCII characters. + * I.e. characters with numeric values between 0 and 127. + * + * @return true if this transition only matches ASCII, or + * false otherwise + */ + public override bool IsAscii() { + return true; + } + + /** + * Checks if the specified character matches the transition. + * + * @param ch the character to check + * + * @return true if the character matches, or + * false otherwise + */ + public override bool Match(char ch) { + return ('a' <= ch && ch <= 'z') + || ('A' <= ch && ch <= 'Z') + || ('0' <= ch && ch <= '9') + || ch == '_'; + } + + /** + * Creates a copy of this transition but with another target + * state. + * + * @param state the new target state + * + * @return an identical copy of this transition + */ + public override NFATransition Copy(NFAState state) { + return new NFAWordTransition(state); + } + } + + + /** + * The non-word character set transition. This transition matches + * a single non-word character. + */ + internal class NFANonWordTransition : NFATransition { + + /** + * Creates a new non-word character set transition. + * + * @param state the target state + */ + public NFANonWordTransition(NFAState state) : base(state) { + } + + /** + * Checks if this transition only matches ASCII characters. + * I.e. characters with numeric values between 0 and 127. + * + * @return true if this transition only matches ASCII, or + * false otherwise + */ + public override bool IsAscii() { + return false; + } + + /** + * Checks if the specified character matches the transition. + * + * @param ch the character to check + * + * @return true if the character matches, or + * false otherwise + */ + public override bool Match(char ch) { + bool word = ('a' <= ch && ch <= 'z') + || ('A' <= ch && ch <= 'Z') + || ('0' <= ch && ch <= '9') + || ch == '_'; + return !word; + } + + /** + * Creates a copy of this transition but with another target + * state. + * + * @param state the new target state + * + * @return an identical copy of this transition + */ + public override NFATransition Copy(NFAState state) { + return new NFANonWordTransition(state); + } + } + + + /** + * An NFA state queue. This queue is used during processing to + * keep track of the current and subsequent NFA states. The + * current state is read from the beginning of the queue, and new + * states are added at the end. A marker index is used to + * separate the current from the subsequent states.

+ * + * The queue implementation is optimized for quick removal at the + * beginning and addition at the end. It will attempt to use a + * fixed-size array to store the whole queue, and moves the data + * in this array only when absolutely needed. The array is also + * enlarged automatically if too many states are being processed + * at a single time. + */ + internal class NFAStateQueue { + + /** + * The state queue array. Will be enlarged as needed. + */ + private NFAState[] queue = new NFAState[2048]; + + /** + * The position of the first entry in the queue (inclusive). + */ + private int first = 0; + + /** + * The position just after the last entry in the queue + * (exclusive). + */ + private int last = 0; + + /** + * The current queue mark position. + */ + private int mark = 0; + + /** + * The empty queue property (read-only). + */ + public bool Empty { + get { + return (last <= first); + } + } + + /** + * The marked first entry property (read-only). This is set + * to true if the first entry in the queue has been marked. + */ + public bool Marked { + get { + return first == mark; + } + } + + /** + * Clears this queue. This operation is fast, as it just + * resets the queue position indices. + */ + public void Clear() { + first = 0; + last = 0; + mark = 0; + } + + /** + * Marks the end of the queue. This means that the next entry + * added to the queue will be marked (when it becomes the + * first in the queue). This operation is fast. + */ + public void MarkEnd() { + mark = last; + } + + /** + * Removes and returns the first entry in the queue. This + * operation is fast, since it will only update the index of + * the first entry in the queue. + * + * @return the previous first entry in the queue + */ + public NFAState RemoveFirst() { + if (first < last) { + first++; + return queue[first - 1]; + } else { + return null; + } + } + + /** + * Adds a new entry at the end of the queue. This operation + * is mostly fast, unless all the allocated queue space has + * already been used. + * + * @param state the state to add + */ + public void AddLast(NFAState state) { + if (last >= queue.Length) { + if (first <= 0) { + Array.Resize(ref queue, queue.Length * 2); + } else { + Array.Copy(queue, first, queue, 0, last - first); + last -= first; + mark -= first; + first = 0; + } + } + queue[last++] = state; + } + } +} diff --git a/Core Library/Core Library/TokenPattern.cs b/Core Library/Core Library/TokenPattern.cs new file mode 100644 index 0000000..0bedfd0 --- /dev/null +++ b/Core Library/Core Library/TokenPattern.cs @@ -0,0 +1,492 @@ +/* + * TokenPattern.cs +*/ + +using System; +using System.Text; + +namespace Core.Library { + + /** + * A token pattern. This class contains the definition of a token + * (i.e. it's pattern), and allows testing a string against this + * pattern. A token pattern is uniquely identified by an integer id, + * that must be provided upon creation. + * + + * + */ + public class TokenPattern { + + /** + * The pattern type enumeration. + */ + public enum PatternType { + + /** + * The string pattern type is used for tokens that only + * match an exact string. + */ + STRING, + + /** + * The regular expression pattern type is used for tokens + * that match a regular expression. + */ + REGEXP + } + + /** + * The token pattern identity. + */ + private int id; + + /** + * The token pattern name. + */ + private string name; + + /** + * The token pattern type. + */ + private PatternType type; + + /** + * The token pattern. + */ + private string pattern; + + /** + * The token error flag. If this flag is set, it means that an + * error should be reported if the token is found. The error + * message is present in the errorMessage variable. + * + * @see #errorMessage + */ + private bool error = false; + + /** + * The token error message. This message will only be set if the + * token error flag is set. + * + * @see #error + */ + private string errorMessage = null; + + /** + * The token ignore flag. If this flag is set, it means that the + * token should be ignored if found. If an ignore message is + * present in the ignoreMessage variable, it will also be reported + * as a warning. + * + * @see #ignoreMessage + */ + private bool ignore = false; + + /** + * The token ignore message. If this message is set when the token + * ignore flag is also set, a warning message will be printed if + * the token is found. + * + * @see #ignore + */ + private string ignoreMessage = null; + + /** + * The optional debug information message. This is normally set + * when the token pattern is analyzed by the tokenizer. + */ + private string debugInfo = null; + + /** + * Creates a new token pattern. + * + * @param id the token pattern id + * @param name the token pattern name + * @param type the token pattern type + * @param pattern the token pattern + */ + public TokenPattern(int id, + string name, + PatternType type, + string pattern) { + + this.id = id; + this.name = name; + this.type = type; + this.pattern = pattern; + } + + /** + * The token pattern identity property (read-only). This + * property contains the unique token pattern identity value. + * + * + */ + public int Id { + get { + return id; + } + } + + /** + * Returns the unique token pattern identity value. + * + * @return the token pattern id + * + * @see #Id + * + * @deprecated Use the Id property instead. + */ + public int GetId() { + return id; + } + + /** + * The token pattern name property (read-only). + * + * + */ + public string Name { + get { + return name; + } + } + + /** + * Returns the token pattern name. + * + * @return the token pattern name + * + * @see #Name + * + * @deprecated Use the Name property instead. + */ + public string GetName() { + return name; + } + + /** + * The token pattern type property (read-only). + * + * + */ + public PatternType Type { + get { + return type; + } + } + + /** + * Returns the token pattern type. + * + * @return the token pattern type + * + * @see #Type + * + * @deprecated Use the Type property instead. + */ + public PatternType GetPatternType() { + return type; + } + + /** + * The token pattern property (read-only). This property + * contains the actual pattern (string or regexp) which have + * to be matched. + * + * + */ + public string Pattern { + get { + return pattern; + } + } + + /** + * Returns te token pattern. + * + * @return the token pattern + * + * @see #Pattern + * + * @deprecated Use the Pattern property instead. + */ + public string GetPattern() { + return pattern; + } + + /** + * The error flag property. If this property is true, the + * token pattern corresponds to an error token and an error + * should be reported if a match is found. When setting this + * property to true, a default error message is created if + * none was previously set. + * + * + */ + public bool Error { + get { + return error; + } + set { + error = value; + if (error && errorMessage == null) { + errorMessage = "unrecognized token found"; + } + } + } + + /** + * The token error message property. The error message is + * printed whenever the token is matched. Setting the error + * message property also sets the error flag to true. + * + * @see #Error + * + * + */ + public string ErrorMessage { + get { + return errorMessage; + } + set { + error = true; + errorMessage = value; + } + } + + /** + * Checks if the pattern corresponds to an error token. If this + * is true, it means that an error should be reported if a + * matching token is found. + * + * @return true if the pattern maps to an error token, or + * false otherwise + * + * @see #Error + * + * @deprecated Use the Error property instead. + */ + public bool IsError() { + return Error; + } + + /** + * Returns the token error message if the pattern corresponds to + * an error token. + * + * @return the token error message + * + * @see #ErrorMessage + * + * @deprecated Use the ErrorMessage property instead. + */ + public string GetErrorMessage() { + return ErrorMessage; + } + + /** + * Sets the token error flag and assigns a default error message. + * + * @see #Error + * + * @deprecated Use the Error property instead. + */ + public void SetError() { + Error = true; + } + + /** + * Sets the token error flag and assigns the specified error + * message. + * + * @param message the error message to display + * + * @see #ErrorMessage + * + * @deprecated Use the ErrorMessage property instead. + */ + public void SetError(string message) { + ErrorMessage = message; + } + + /** + * The ignore flag property. If this property is true, the + * token pattern corresponds to an ignore token and should be + * skipped if a match is found. + * + * + */ + public bool Ignore { + get { + return ignore; + } + set { + ignore = value; + } + } + + /** + * The token ignore message property. The ignore message is + * printed whenever the token is matched. Setting the ignore + * message property also sets the ignore flag to true. + * + * @see #Ignore + * + * + */ + public string IgnoreMessage { + get { + return ignoreMessage; + } + set { + ignore = true; + ignoreMessage = value; + } + } + + /** + * Checks if the pattern corresponds to an ignored token. If this + * is true, it means that the token should be ignored if found. + * + * @return true if the pattern maps to an ignored token, or + * false otherwise + * + * @see #Ignore + * + * @deprecated Use the Ignore property instead. + */ + public bool IsIgnore() { + return Ignore; + } + + /** + * Returns the token ignore message if the pattern corresponds to + * an ignored token. + * + * @return the token ignore message + * + * @see #IgnoreMessage + * + * @deprecated Use the IgnoreMessage property instead. + */ + public string GetIgnoreMessage() { + return IgnoreMessage; + } + + /** + * Sets the token ignore flag and clears the ignore message. + * + * @see #Ignore + * + * @deprecated Use the Ignore property instead. + */ + public void SetIgnore() { + Ignore = true; + } + + /** + * Sets the token ignore flag and assigns the specified ignore + * message. + * + * @param message the ignore message to display + * + * @see #IgnoreMessage + * + * @deprecated Use the IgnoreMessage property instead. + */ + public void SetIgnore(string message) { + IgnoreMessage = message; + } + + /** + * The token debug info message property. This is normally be + * set when the token pattern is analyzed by the tokenizer. + * + * + */ + public string DebugInfo { + get { + return debugInfo; + } + set { + debugInfo = value; + } + } + + /** + * Returns a string representation of this object. + * + * @return a token pattern string representation + */ + public override string ToString() { + StringBuilder buffer = new StringBuilder(); + + buffer.Append(name); + buffer.Append(" ("); + buffer.Append(id); + buffer.Append("): "); + switch (type) { + case PatternType.STRING: + buffer.Append("\""); + buffer.Append(pattern); + buffer.Append("\""); + break; + case PatternType.REGEXP: + buffer.Append("<<"); + buffer.Append(pattern); + buffer.Append(">>"); + break; + } + if (error) { + buffer.Append(" ERROR: \""); + buffer.Append(errorMessage); + buffer.Append("\""); + } + if (ignore) { + buffer.Append(" IGNORE"); + if (ignoreMessage != null) { + buffer.Append(": \""); + buffer.Append(ignoreMessage); + buffer.Append("\""); + } + } + if (debugInfo != null) { + buffer.Append("\n "); + buffer.Append(debugInfo); + } + return buffer.ToString(); + } + + /** + * Returns a short string representation of this object. + * + * @return a short string representation of this object + */ + public string ToShortString() { + StringBuilder buffer = new StringBuilder(); + int newline = pattern.IndexOf('\n'); + + if (type == PatternType.STRING) { + buffer.Append("\""); + if (newline >= 0) { + if (newline > 0 && pattern[newline - 1] == '\r') { + newline--; + } + buffer.Append(pattern.Substring(0, newline)); + buffer.Append("(...)"); + } else { + buffer.Append(pattern); + } + buffer.Append("\""); + } else { + buffer.Append("<"); + buffer.Append(name); + buffer.Append(">"); + } + + return buffer.ToString(); + } + } +} diff --git a/Core Library/Core Library/TokenRegExpParser.cs b/Core Library/Core Library/TokenRegExpParser.cs new file mode 100644 index 0000000..12083c3 --- /dev/null +++ b/Core Library/Core Library/TokenRegExpParser.cs @@ -0,0 +1,679 @@ +/* + * TokenRegExpParser.cs + */ + +using System; +using System.Collections; +using System.Globalization; +using System.Text; +using Core.Library.RE; + +namespace Core.Library { + + /** + * A regular expression parser. The parser creates an NFA for the + * regular expression having a single start and acceptance states. + * + + * + * + */ + internal class TokenRegExpParser { + + /** + * The regular expression pattern. + */ + private string pattern; + + /** + * The character case ignore flag. + */ + private bool ignoreCase; + + /** + * The current position in the pattern. This variable is used by + * the parsing methods. + */ + private int pos; + + /** + * The start NFA state for this regular expression. + */ + internal NFAState start = new NFAState(); + + /** + * The end NFA state for this regular expression. + */ + internal NFAState end = null; + + /** + * The number of states found. + */ + private int stateCount = 0; + + /** + * The number of transitions found. + */ + private int transitionCount = 0; + + /** + * The number of epsilon transitions found. + */ + private int epsilonCount = 0; + + /** + * Creates a new case-sensitive regular expression parser. Note + * that this will trigger the parsing of the regular expression. + * + * @param pattern the regular expression pattern + * + * @throws RegExpException if the regular expression couldn't be + * parsed correctly + */ + public TokenRegExpParser(string pattern) : this(pattern, false) { + } + + /** + * Creates a new regular expression parser. The regular + * expression can be either case-sensitive or case-insensitive. + * Note that this will trigger the parsing of the regular + * expression. + * + * @param pattern the regular expression pattern + * @param ignoreCase the character case ignore flag + * + * @throws RegExpException if the regular expression couldn't be + * parsed correctly + */ + public TokenRegExpParser(string pattern, bool ignoreCase) { + this.pattern = pattern; + this.ignoreCase = ignoreCase; + this.pos = 0; + this.end = ParseExpr(start); + if (pos < pattern.Length) { + throw new RegExpException( + RegExpException.ErrorType.UNEXPECTED_CHARACTER, + pos, + pattern); + } + } + + /** + * Returns the debug information for the generated NFA. + * + * @return the debug information for the generated NFA + */ + public string GetDebugInfo() { + if (stateCount == 0) { + UpdateStats(start, new Hashtable()); + } + return stateCount + " states, " + + transitionCount + " transitions, " + + epsilonCount + " epsilons"; + } + + /** + * Updates the statistical counters for the NFA generated. + * + * @param state the current state to visit + * @param visited the lookup map of visited states + */ + private void UpdateStats(NFAState state, Hashtable visited) { + if (!visited.ContainsKey(state)) { + visited.Add(state, state); + stateCount++; + for (int i = 0; i < state.outgoing.Length; i++) { + transitionCount++; + if (state.outgoing[i] is NFAEpsilonTransition) { + epsilonCount++; + } + UpdateStats(state.outgoing[i].state, visited); + } + } + } + + /** + * Parses a regular expression. This method handles the Expr + * production in the grammar (see regexp.grammar). + * + * @param start the initial NFA state + * + * @return the terminating NFA state + * + * @throws RegExpException if an error was encountered in the + * pattern string + */ + private NFAState ParseExpr(NFAState start) { + NFAState end = new NFAState(); + NFAState subStart; + NFAState subEnd; + + do { + if (PeekChar(0) == '|') { + ReadChar('|'); + } + subStart = new NFAState(); + subEnd = ParseTerm(subStart); + if (subStart.incoming.Length == 0) { + subStart.MergeInto(start); + } else { + start.AddOut(new NFAEpsilonTransition(subStart)); + } + if (subEnd.outgoing.Length == 0 || + (!end.HasTransitions() && PeekChar(0) != '|')) { + subEnd.MergeInto(end); + } else { + subEnd.AddOut(new NFAEpsilonTransition(end)); + } + } while (PeekChar(0) == '|'); + return end; + } + + /** + * Parses a regular expression term. This method handles the + * Term production in the grammar (see regexp.grammar). + * + * @param start the initial NFA state + * + * @return the terminating NFA state + * + * @throws RegExpException if an error was encountered in the + * pattern string + */ + private NFAState ParseTerm(NFAState start) { + NFAState end; + + end = ParseFact(start); + while (true) { + switch (PeekChar(0)) { + case -1: + case ')': + case ']': + case '{': + case '}': + case '?': + case '+': + case '|': + return end; + default: + end = ParseFact(end); + break; + } + } + } + + /** + * Parses a regular expression factor. This method handles the + * Fact production in the grammar (see regexp.grammar). + * + * @param start the initial NFA state + * + * @return the terminating NFA state + * + * @throws RegExpException if an error was encountered in the + * pattern string + */ + private NFAState ParseFact(NFAState start) { + NFAState placeholder = new NFAState(); + NFAState end; + + end = ParseAtom(placeholder); + switch (PeekChar(0)) { + case '?': + case '*': + case '+': + case '{': + end = ParseAtomModifier(placeholder, end); + break; + } + if (placeholder.incoming.Length > 0 && start.outgoing.Length > 0) { + start.AddOut(new NFAEpsilonTransition(placeholder)); + return end; + } else { + placeholder.MergeInto(start); + return (end == placeholder) ? start : end; + } + } + + /** + * Parses a regular expression atom. This method handles the + * Atom production in the grammar (see regexp.grammar). + * + * @param start the initial NFA state + * + * @return the terminating NFA state + * + * @throws RegExpException if an error was encountered in the + * pattern string + */ + private NFAState ParseAtom(NFAState start) { + NFAState end; + + switch (PeekChar(0)) { + case '.': + ReadChar('.'); + return start.AddOut(new NFADotTransition(new NFAState())); + case '(': + ReadChar('('); + end = ParseExpr(start); + ReadChar(')'); + return end; + case '[': + ReadChar('['); + end = ParseCharSet(start); + ReadChar(']'); + return end; + case -1: + case ')': + case ']': + case '{': + case '}': + case '?': + case '*': + case '+': + case '|': + throw new RegExpException( + RegExpException.ErrorType.UNEXPECTED_CHARACTER, + pos, + pattern); + default: + return ParseChar(start); + } + } + + /** + * Parses a regular expression atom modifier. This method handles + * the AtomModifier production in the grammar (see regexp.grammar). + * + * @param start the initial NFA state + * @param end the terminal NFA state + * + * @return the terminating NFA state + * + * @throws RegExpException if an error was encountered in the + * pattern string + */ + private NFAState ParseAtomModifier(NFAState start, NFAState end) { + int min = 0; + int max = -1; + int firstPos = pos; + + // Read min and max + switch (ReadChar()) { + case '?': + min = 0; + max = 1; + break; + case '*': + min = 0; + max = -1; + break; + case '+': + min = 1; + max = -1; + break; + case '{': + min = ReadNumber(); + max = min; + if (PeekChar(0) == ',') { + ReadChar(','); + max = -1; + if (PeekChar(0) != '}') { + max = ReadNumber(); + } + } + ReadChar('}'); + if (max == 0 || (max > 0 && min > max)) { + throw new RegExpException( + RegExpException.ErrorType.INVALID_REPEAT_COUNT, + firstPos, + pattern); + } + break; + default: + throw new RegExpException( + RegExpException.ErrorType.UNEXPECTED_CHARACTER, + pos - 1, + pattern); + } + + // Read possessive or reluctant modifiers + if (PeekChar(0) == '?') { + throw new RegExpException( + RegExpException.ErrorType.UNSUPPORTED_SPECIAL_CHARACTER, + pos, + pattern); + } else if (PeekChar(0) == '+') { + throw new RegExpException( + RegExpException.ErrorType.UNSUPPORTED_SPECIAL_CHARACTER, + pos, + pattern); + } + + // Handle supported repeaters + if (min == 0 && max == 1) { + return start.AddOut(new NFAEpsilonTransition(end)); + } else if (min == 0 && max == -1) { + if (end.outgoing.Length == 0) { + end.MergeInto(start); + } else { + end.AddOut(new NFAEpsilonTransition(start)); + } + return start; + } else if (min == 1 && max == -1) { + if (start.outgoing.Length == 1 && + end.outgoing.Length == 0 && + end.incoming.Length == 1 && + start.outgoing[0] == end.incoming[0]) { + + end.AddOut(start.outgoing[0].Copy(end)); + } else { + end.AddOut(new NFAEpsilonTransition(start)); + } + return end; + } else { + throw new RegExpException( + RegExpException.ErrorType.INVALID_REPEAT_COUNT, + firstPos, + pattern); + } + } + + /** + * Parses a regular expression character set. This method handles + * the contents of the '[...]' construct in a regular expression. + * + * @param start the initial NFA state + * + * @return the terminating NFA state + * + * @throws RegExpException if an error was encountered in the + * pattern string + */ + private NFAState ParseCharSet(NFAState start) { + NFAState end = new NFAState(); + NFACharRangeTransition range; + char min; + char max; + + if (PeekChar(0) == '^') { + ReadChar('^'); + range = new NFACharRangeTransition(true, ignoreCase, end); + } else { + range = new NFACharRangeTransition(false, ignoreCase, end); + } + start.AddOut(range); + while (PeekChar(0) > 0) { + min = (char) PeekChar(0); + switch (min) { + case ']': + return end; + case '\\': + range.AddCharacter(ReadEscapeChar()); + break; + default: + ReadChar(min); + if (PeekChar(0) == '-' && + PeekChar(1) > 0 && + PeekChar(1) != ']') { + + ReadChar('-'); + max = ReadChar(); + range.AddRange(min, max); + } else { + range.AddCharacter(min); + } + break; + } + } + return end; + } + + /** + * Parses a regular expression character. This method handles + * a single normal character in a regular expression. + * + * @param start the initial NFA state + * + * @return the terminating NFA state + * + * @throws RegExpException if an error was encountered in the + * pattern string + */ + private NFAState ParseChar(NFAState start) { + switch (PeekChar(0)) { + case '\\': + return ParseEscapeChar(start); + case '^': + case '$': + throw new RegExpException( + RegExpException.ErrorType.UNSUPPORTED_SPECIAL_CHARACTER, + pos, + pattern); + default: + return start.AddOut(ReadChar(), ignoreCase, new NFAState()); + } + } + + /** + * Parses a regular expression character escape. This method + * handles a single character escape in a regular expression. + * + * @param start the initial NFA state + * + * @return the terminating NFA state + * + * @throws RegExpException if an error was encountered in the + * pattern string + */ + private NFAState ParseEscapeChar(NFAState start) { + NFAState end = new NFAState(); + + if (PeekChar(0) == '\\' && PeekChar(1) > 0) { + switch ((char) PeekChar(1)) { + case 'd': + ReadChar(); + ReadChar(); + return start.AddOut(new NFADigitTransition(end)); + case 'D': + ReadChar(); + ReadChar(); + return start.AddOut(new NFANonDigitTransition(end)); + case 's': + ReadChar(); + ReadChar(); + return start.AddOut(new NFAWhitespaceTransition(end)); + case 'S': + ReadChar(); + ReadChar(); + return start.AddOut(new NFANonWhitespaceTransition(end)); + case 'w': + ReadChar(); + ReadChar(); + return start.AddOut(new NFAWordTransition(end)); + case 'W': + ReadChar(); + ReadChar(); + return start.AddOut(new NFANonWordTransition(end)); + } + } + return start.AddOut(ReadEscapeChar(), ignoreCase, end); + } + + /** + * Reads a regular expression character escape. This method + * handles a single character escape in a regular expression. + * + * @return the character read + * + * @throws RegExpException if an error was encountered in the + * pattern string + */ + private char ReadEscapeChar() { + char c; + string str; + int value; + + ReadChar('\\'); + c = ReadChar(); + switch (c) { + case '0': + c = ReadChar(); + if (c < '0' || c > '3') { + throw new RegExpException( + RegExpException.ErrorType.UNSUPPORTED_ESCAPE_CHARACTER, + pos - 3, + pattern); + } + value = c - '0'; + c = (char) PeekChar(0); + if ('0' <= c && c <= '7') { + value *= 8; + value += ReadChar() - '0'; + c = (char) PeekChar(0); + if ('0' <= c && c <= '7') { + value *= 8; + value += ReadChar() - '0'; + } + } + return (char) value; + case 'x': + str = ReadChar().ToString() + ReadChar().ToString(); + try { + value = Int32.Parse(str, NumberStyles.AllowHexSpecifier); + return (char) value; + } catch (FormatException) { + throw new RegExpException( + RegExpException.ErrorType.UNSUPPORTED_ESCAPE_CHARACTER, + pos - str.Length - 2, + pattern); + } + case 'u': + str = ReadChar().ToString() + + ReadChar().ToString() + + ReadChar().ToString() + + ReadChar().ToString(); + try { + value = Int32.Parse(str, NumberStyles.AllowHexSpecifier); + return (char) value; + } catch (FormatException) { + throw new RegExpException( + RegExpException.ErrorType.UNSUPPORTED_ESCAPE_CHARACTER, + pos - str.Length - 2, + pattern); + } + case 't': + return '\t'; + case 'n': + return '\n'; + case 'r': + return '\r'; + case 'f': + return '\f'; + case 'a': + return '\u0007'; + case 'e': + return '\u001B'; + default: + if (('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z')) { + throw new RegExpException( + RegExpException.ErrorType.UNSUPPORTED_ESCAPE_CHARACTER, + pos - 2, + pattern); + } + return c; + } + } + + /** + * Reads a number from the pattern. If the next character isn't a + * numeric character, an exception is thrown. This method reads + * several consecutive numeric characters. + * + * @return the numeric value read + * + * @throws RegExpException if an error was encountered in the + * pattern string + */ + private int ReadNumber() { + StringBuilder buf = new StringBuilder(); + int c; + + c = PeekChar(0); + while ('0' <= c && c <= '9') { + buf.Append(ReadChar()); + c = PeekChar(0); + } + if (buf.Length <= 0) { + throw new RegExpException( + RegExpException.ErrorType.UNEXPECTED_CHARACTER, + pos, + pattern); + } + return Int32.Parse(buf.ToString()); + } + + /** + * Reads the next character in the pattern. If no next character + * exists, an exception is thrown. + * + * @return the character read + * + * @throws RegExpException if no next character was available in + * the pattern string + */ + private char ReadChar() { + int c = PeekChar(0); + + if (c < 0) { + throw new RegExpException( + RegExpException.ErrorType.UNTERMINATED_PATTERN, + pos, + pattern); + } else { + pos++; + return (char) c; + } + } + + /** + * Reads the next character in the pattern. If the character + * wasn't the specified one, an exception is thrown. + * + * @param c the character to read + * + * @return the character read + * + * @throws RegExpException if the character read didn't match the + * specified one, or if no next character was + * available in the pattern string + */ + private char ReadChar(char c) { + if (c != ReadChar()) { + throw new RegExpException( + RegExpException.ErrorType.UNEXPECTED_CHARACTER, + pos - 1, + pattern); + } + return c; + } + + /** + * Returns a character that has not yet been read from the + * pattern. If the requested position is beyond the end of the + * pattern string, -1 is returned. + * + * @param count the preview position, from zero (0) + * + * @return the character found, or + * -1 if beyond the end of the pattern string + */ + private int PeekChar(int count) { + if (pos + count < pattern.Length) { + return pattern[pos + count]; + } else { + return -1; + } + } + } +} diff --git a/Core Library/Core Library/TokenStringDFA.cs b/Core Library/Core Library/TokenStringDFA.cs new file mode 100644 index 0000000..9678399 --- /dev/null +++ b/Core Library/Core Library/TokenStringDFA.cs @@ -0,0 +1,298 @@ +/* + * TokenStringDFA.cs + */ + +using System; +using System.Text; + +namespace Core.Library { + + /** + * A deterministic finite state automaton for matching exact strings. + * It uses a sorted binary tree representation of the state + * transitions in order to enable quick matches with a minimal memory + * footprint. It only supports a single character transition between + * states, but may be run in an all case-insensitive mode. + * + + * + * + */ + internal class TokenStringDFA { + + /** + * The lookup table for root states, indexed by the first ASCII + * character. This array is used to for speed optimizing the + * first step in the match. + */ + private DFAState[] ascii = new DFAState[128]; + + /** + * The automaton state transition tree for non-ASCII characters. + * Each transition from one state to another is added to the tree + * with the corresponding character. + */ + private DFAState nonAscii = new DFAState(); + + /** + * Creates a new empty string automaton. + */ + public TokenStringDFA() { + } + + /** + * Adds a string match to this automaton. New states and + * transitions will be added to extend this automaton to + * support the specified string. + * + * @param str the string to match + * @param caseInsensitive the case-insensitive flag + * @param value the match value + */ + public void AddMatch(string str, bool caseInsensitive, TokenPattern value) { + DFAState state; + DFAState next; + char c = str[0]; + int start = 0; + + if (caseInsensitive) { + c = Char.ToLower(c); + } + if (c < 128) { + state = ascii[c]; + if (state == null) { + state = ascii[c] = new DFAState(); + } + start++; + } else { + state = nonAscii; + } + for (int i = start; i < str.Length; i++) { + next = state.tree.Find(str[i], caseInsensitive); + if (next == null) { + next = new DFAState(); + state.tree.Add(str[i], caseInsensitive, next); + } + state = next; + } + state.value = value; + } + + /** + * Checks if the automaton matches an input stream. The + * matching will be performed from a specified position. This + * method will not read any characters from the stream, just + * peek ahead. The comparison can be done either in + * case-sensitive or case-insensitive mode. + * + * @param input the input stream to check + * @param pos the starting position + * @param caseInsensitive the case-insensitive flag + * + * @return the match value, or + * null if no match was found + * + * @throws IOException if an I/O error occurred + */ + public TokenPattern Match(ReaderBuffer buffer, bool caseInsensitive) { + TokenPattern result = null; + DFAState state; + int pos = 0; + int c; + + c = buffer.Peek(0); + if (c < 0) { + return null; + } + if (caseInsensitive) { + c = Char.ToLower((char) c); + } + if (c < 128) { + state = ascii[c]; + if (state == null) { + return null; + } else if (state.value != null) { + result = state.value; + } + pos++; + } else { + state = nonAscii; + } + while ((c = buffer.Peek(pos)) >= 0) { + state = state.tree.Find((char) c, caseInsensitive); + if (state == null) { + break; + } else if (state.value != null) { + result = state.value; + } + pos++; + } + return result; + } + + /** + * Returns a detailed string representation of this automaton. + * + * @return a detailed string representation of this automaton + */ + public override string ToString() { + StringBuilder buffer = new StringBuilder(); + + for (int i = 0; i < ascii.Length; i++) { + if (ascii[i] != null) { + buffer.Append((char) i); + if (ascii[i].value != null) { + buffer.Append(": "); + buffer.Append(ascii[i].value); + buffer.Append("\n"); + } + ascii[i].tree.PrintTo(buffer, " "); + } + } + nonAscii.tree.PrintTo(buffer, ""); + return buffer.ToString(); + } + } + + + /** + * An automaton state. This class represents a state in the DFA + * graph. + * + + * + * + */ + internal class DFAState { + + /** + * The token pattern matched at this state. + */ + internal TokenPattern value = null; + + /** + * The automaton state transition tree. Each transition from one + * state to another is added to the tree with the corresponding + * character. + */ + internal TransitionTree tree = new TransitionTree(); + } + + + /** + * An automaton state transition tree. This class contains a + * binary search tree for the automaton transitions from one + * state to another. All transitions are linked to a single + * character. + * + + * + * + */ + internal class TransitionTree { + + /** + * The transition character. If this value is set to the zero + * character ('\0'), this tree is empty. + */ + private char value = '\0'; + + /** + * The transition target state. + */ + private DFAState state = null; + + /** + * The left subtree. + */ + private TransitionTree left = null; + + /** + * The right subtree. + */ + private TransitionTree right = null; + + /** + * Creates a new empty automaton transition tree. + */ + public TransitionTree() { + } + + /** + * Finds an automaton state from the specified transition + * character. This method searches this transition tree for a + * matching transition. The comparison can optionally be done + * with a lower-case conversion of the character. + * + * @param c the character to search for + * @param lowerCase the lower-case conversion flag + * + * @return the automaton state found, or + * null if no transition exists + */ + public DFAState Find(char c, bool lowerCase) { + if (lowerCase) { + c = Char.ToLower(c); + } + if (value == '\0' || value == c) { + return state; + } else if (value > c) { + return left.Find(c, false); + } else { + return right.Find(c, false); + } + } + + /** + * Adds a transition to this tree. If the lower-case flag is + * set, the character will be converted to lower-case before + * being added. + * + * @param c the character to transition for + * @param lowerCase the lower-case conversion flag + * @param state the state to transition to + */ + public void Add(char c, bool lowerCase, DFAState state) { + if (lowerCase) { + c = Char.ToLower(c); + } + if (value == '\0') { + this.value = c; + this.state = state; + this.left = new TransitionTree(); + this.right = new TransitionTree(); + } else if (value > c) { + left.Add(c, false, state); + } else { + right.Add(c, false, state); + } + } + + /** + * Prints the automaton tree to the specified string buffer. + * + * @param buffer the string buffer + * @param indent the current indentation + */ + public void PrintTo(StringBuilder buffer, String indent) { + if (this.left != null) { + this.left.PrintTo(buffer, indent); + } + if (this.value != '\0') { + if (buffer.Length > 0 && buffer[buffer.Length - 1] == '\n') { + buffer.Append(indent); + } + buffer.Append(this.value); + if (this.state.value != null) { + buffer.Append(": "); + buffer.Append(this.state.value); + buffer.Append("\n"); + } + this.state.tree.PrintTo(buffer, indent + " "); + } + if (this.right != null) { + this.right.PrintTo(buffer, indent); + } + } + } +} diff --git a/Core Library/Core Library/Tokenizer.cs b/Core Library/Core Library/Tokenizer.cs new file mode 100644 index 0000000..ffc462c --- /dev/null +++ b/Core Library/Core Library/Tokenizer.cs @@ -0,0 +1,784 @@ +/* + * Tokenizer.cs + */ + +using System; +using System.Collections; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using Core.Library.RE; + +namespace Core.Library { + + /** + * A character stream tokenizer. This class groups the characters read + * from the stream together into tokens ("words"). The grouping is + * controlled by token patterns that contain either a fixed string to + * search for, or a regular expression. If the stream of characters + * don't match any of the token patterns, a parse exception is thrown. + * + + * + */ + public class Tokenizer { + + /** + * The token list feature flag. + */ + private bool useTokenList = false; + + /** + * The string DFA token matcher. This token matcher uses a + * deterministic finite automaton (DFA) implementation and is + * used for all string token patterns. It has a slight speed + * advantage to the NFA implementation, but should be equivalent + * on memory usage. + */ + private StringDFAMatcher stringDfaMatcher; + + /** + * The regular expression NFA token matcher. This token matcher + * uses a non-deterministic finite automaton (DFA) implementation + * and is used for most regular expression token patterns. It is + * somewhat faster than the other recursive regular expression + * implementations available, but doesn't support the full + * syntax. It conserves memory by using a fast queue instead of + * the stack during processing (no stack overflow). + */ + private NFAMatcher nfaMatcher; + + /** + * The regular expression token matcher. This token matcher is + * used for complex regular expressions, but should be avoided + * due to possibly degraded speed and memory usage compared to + * the automaton implementations. + */ + private RegExpMatcher regExpMatcher; + + /** + * The character stream reader buffer. + */ + private ReaderBuffer buffer = null; + + /** + * The last token match found. + */ + private TokenMatch lastMatch = new TokenMatch(); + + /** + * The previous token in the token list. + */ + private Token previousToken = null; + + /** + * Creates a new case-sensitive tokenizer for the specified + * input stream. + * + * @param input the input stream to read + */ + public Tokenizer(TextReader input) + : this(input, false) { + } + + /** + * Creates a new tokenizer for the specified input stream. The + * tokenizer can be set to process tokens either in + * case-sensitive or case-insensitive mode. + * + * @param input the input stream to read + * @param ignoreCase the character case ignore flag + * + * + */ + public Tokenizer(TextReader input, bool ignoreCase) { + this.stringDfaMatcher = new StringDFAMatcher(ignoreCase); + this.nfaMatcher = new NFAMatcher(ignoreCase); + this.regExpMatcher = new RegExpMatcher(ignoreCase); + this.buffer = new ReaderBuffer(input); + } + + /** + * The token list flag property. If the token list flag is + * set, all tokens (including ignored tokens) link to each + * other in a double-linked list. By default the token list + * flag is set to false. + * + * @see Token#Previous + * @see Token#Next + * + * + */ + public bool UseTokenList { + get { + return useTokenList; + } + set { + useTokenList = value; + } + } + + /** + * Checks if the token list feature is used. The token list + * feature makes all tokens (including ignored tokens) link to + * each other in a linked list. By default the token list feature + * is not used. + * + * @return true if the token list feature is used, or + * false otherwise + * + * @see #UseTokenList + * @see #SetUseTokenList + * @see Token#GetPreviousToken + * @see Token#GetNextToken + * + * + * + * @deprecated Use the UseTokenList property instead. + */ + public bool GetUseTokenList() { + return useTokenList; + } + + /** + * Sets the token list feature flag. The token list feature makes + * all tokens (including ignored tokens) link to each other in a + * linked list when active. By default the token list feature is + * not used. + * + * @param useTokenList the token list feature flag + * + * @see #UseTokenList + * @see #GetUseTokenList + * @see Token#GetPreviousToken + * @see Token#GetNextToken + * + * + * + * @deprecated Use the UseTokenList property instead. + */ + public void SetUseTokenList(bool useTokenList) { + this.useTokenList = useTokenList; + } + + /** + * Returns a description of the token pattern with the + * specified id. + * + * @param id the token pattern id + * + * @return the token pattern description, or + * null if not present + */ + public string GetPatternDescription(int id) { + TokenPattern pattern; + + pattern = stringDfaMatcher.GetPattern(id); + if (pattern == null) { + pattern = nfaMatcher.GetPattern(id); + } + if (pattern == null) { + pattern = regExpMatcher.GetPattern(id); + } + return (pattern == null) ? null : pattern.ToShortString(); + } + + /** + * Returns the current line number. This number will be the line + * number of the next token returned. + * + * @return the current line number + */ + public int GetCurrentLine() { + return buffer.LineNumber; + } + + /** + * Returns the current column number. This number will be the + * column number of the next token returned. + * + * @return the current column number + */ + public int GetCurrentColumn() { + return buffer.ColumnNumber; + } + + /** + * Adds a new token pattern to the tokenizer. The pattern will be + * added last in the list, choosing a previous token pattern in + * case two matches the same string. + * + * @param pattern the pattern to add + * + * @throws ParserCreationException if the pattern couldn't be + * added to the tokenizer + */ + public void AddPattern(TokenPattern pattern) { + switch (pattern.Type) { + case TokenPattern.PatternType.STRING: + try { + stringDfaMatcher.AddPattern(pattern); + } catch (Exception e) { + throw new ParserCreationException( + ParserCreationException.ErrorType.INVALID_TOKEN, + pattern.Name, + "error adding string token: " + + e.Message); + } + break; + case TokenPattern.PatternType.REGEXP: + try { + nfaMatcher.AddPattern(pattern); + } catch (Exception) { + try { + regExpMatcher.AddPattern(pattern); + } catch (Exception e) { + throw new ParserCreationException( + ParserCreationException.ErrorType.INVALID_TOKEN, + pattern.Name, + "regular expression contains error(s): " + + e.Message); + } + } + break; + default: + throw new ParserCreationException( + ParserCreationException.ErrorType.INVALID_TOKEN, + pattern.Name, + "pattern type " + pattern.Type + + " is undefined"); + } + } + + /** + * Resets this tokenizer for usage with another input stream. + * This method will clear all the internal state in the + * tokenizer as well as close the previous input stream. It + * is normally called in order to reuse a parser and + * tokenizer pair with multiple input streams, thereby + * avoiding the cost of re-analyzing the grammar structures. + * + * @param input the new input stream to read + * + * @see Parser#reset(Reader) + * + * + */ + public void Reset(TextReader input) { + this.buffer.Dispose(); + this.buffer = new ReaderBuffer(input); + this.previousToken = null; + this.lastMatch.Clear(); + } + + /** + * Finds the next token on the stream. This method will return + * null when end of file has been reached. It will return a + * parse exception if no token matched the input stream, or if + * a token pattern with the error flag set matched. Any tokens + * matching a token pattern with the ignore flag set will be + * silently ignored and the next token will be returned. + * + * @return the next token found, or + * null if end of file was encountered + * + * @throws ParseException if the input stream couldn't be read or + * parsed correctly + */ + public Token Next() { + Token token = null; + + do { + token = NextToken(); + if (token == null) { + previousToken = null; + return null; + } + if (useTokenList) { + token.Previous = previousToken; + previousToken = token; + } + if (token.Pattern.Ignore) { + token = null; + } else if (token.Pattern.Error) { + throw new ParseException( + ParseException.ErrorType.INVALID_TOKEN, + token.Pattern.ErrorMessage, + token.StartLine, + token.StartColumn); + } + } while (token == null); + return token; + } + + /** + * Finds the next token on the stream. This method will return + * null when end of file has been reached. It will return a + * parse exception if no token matched the input stream. + * + * @return the next token found, or + * null if end of file was encountered + * + * @throws ParseException if the input stream couldn't be read or + * parsed correctly + */ + private Token NextToken() { + string str; + int line; + int column; + + try { + lastMatch.Clear(); + stringDfaMatcher.Match(buffer, lastMatch); + nfaMatcher.Match(buffer, lastMatch); + regExpMatcher.Match(buffer, lastMatch); + if (lastMatch.Length > 0) { + line = buffer.LineNumber; + column = buffer.ColumnNumber; + str = buffer.Read(lastMatch.Length); + return NewToken(lastMatch.Pattern, str, line, column); + } else if (buffer.Peek(0) < 0) { + return null; + } else { + line = buffer.LineNumber; + column = buffer.ColumnNumber; + throw new ParseException( + ParseException.ErrorType.UNEXPECTED_CHAR, + buffer.Read(1), + line, + column); + } + } catch (IOException e) { + throw new ParseException(ParseException.ErrorType.IO, + e.Message, + -1, + -1); + } + } + + /** + * Factory method for creating a new token. This method can be + * overridden to provide other token implementations than the + * default one. + * + * @param pattern the token pattern + * @param image the token image (i.e. characters) + * @param line the line number of the first character + * @param column the column number of the first character + * + * @return the token created + * + * + */ + protected virtual Token NewToken(TokenPattern pattern, + string image, + int line, + int column) { + + return new Token(pattern, image, line, column); + } + + /** + * Returns a string representation of this object. The returned + * string will contain the details of all the token patterns + * contained in this tokenizer. + * + * @return a detailed string representation + */ + public override string ToString() { + StringBuilder buffer = new StringBuilder(); + + buffer.Append(stringDfaMatcher); + buffer.Append(nfaMatcher); + buffer.Append(regExpMatcher); + return buffer.ToString(); + } + } + + + /** + * A token pattern matcher. This class is the base class for the + * various types of token matchers that exist. The token matcher + * checks for matches with the tokenizer buffer, and maintains the + * state of the last match. + */ + internal abstract class TokenMatcher { + + /** + * The array of token patterns. + */ + protected TokenPattern[] patterns = new TokenPattern[0]; + + /** + * The ignore character case flag. + */ + protected bool ignoreCase = false; + + /** + * Creates a new token matcher. + * + * @param ignoreCase the character case ignore flag + */ + public TokenMatcher(bool ignoreCase) { + this.ignoreCase = ignoreCase; + } + + /** + * Searches for matching token patterns at the start of the + * input stream. If a match is found, the token match object + * is updated. + * + * @param buffer the input buffer to check + * @param match the token match to update + * + * @throws IOException if an I/O error occurred + */ + public abstract void Match(ReaderBuffer buffer, TokenMatch match); + + /** + * Returns the token pattern with the specified id. Only + * token patterns handled by this matcher can be returned. + * + * @param id the token pattern id + * + * @return the token pattern found, or + * null if not found + */ + public TokenPattern GetPattern(int id) { + for (int i = 0; i < patterns.Length; i++) { + if (patterns[i].Id == id) { + return patterns[i]; + } + } + return null; + } + + /** + * Adds a string token pattern to this matcher. + * + * @param pattern the pattern to add + * + * @throws Exception if the pattern couldn't be added to the matcher + */ + public virtual void AddPattern(TokenPattern pattern) { + Array.Resize(ref patterns, patterns.Length + 1); + patterns[patterns.Length - 1] = pattern; + } + + /** + * Returns a string representation of this matcher. This will + * contain all the token patterns. + * + * @return a detailed string representation of this matcher + */ + public override string ToString() { + StringBuilder buffer = new StringBuilder(); + + for (int i = 0; i < patterns.Length; i++) { + buffer.Append(patterns[i]); + buffer.Append("\n\n"); + } + return buffer.ToString(); + } + } + + + /** + * A token pattern matcher using a DFA for string tokens. This + * class only supports string tokens and must be complemented + * with another matcher for regular expressions. Internally it + * uses a DFA to provide high performance. + */ + internal class StringDFAMatcher : TokenMatcher { + + /** + * The deterministic finite state automaton used for + * matching. + */ + private TokenStringDFA automaton = new TokenStringDFA(); + + /** + * Creates a new string token matcher. + * + * @param ignoreCase the character case ignore flag + */ + public StringDFAMatcher(bool ignoreCase) : base(ignoreCase) { + } + + /** + * Adds a string token pattern to this matcher. + * + * @param pattern the pattern to add + */ + public override void AddPattern(TokenPattern pattern) { + automaton.AddMatch(pattern.Pattern, ignoreCase, pattern); + base.AddPattern(pattern); + } + + /** + * Searches for matching token patterns at the start of the + * input stream. If a match is found, the token match object + * is updated. + * + * @param buffer the input buffer to check + * @param match the token match to update + * + * @throws IOException if an I/O error occurred + */ + public override void Match(ReaderBuffer buffer, TokenMatch match) { + TokenPattern res = automaton.Match(buffer, ignoreCase); + + if (res != null) { + match.Update(res.Pattern.Length, res); + } + } + } + + + /** + * A token pattern matcher using a NFA for both string and + * regular expression tokens. This class has limited support for + * regular expressions and must be complemented with another + * matcher providing full regular expression support. Internally + * it uses a NFA to provide high performance and low memory + * usage. + */ + internal class NFAMatcher : TokenMatcher { + + /** + * The non-deterministic finite state automaton used for + * matching. + */ + private TokenNFA automaton = new TokenNFA(); + + /** + * Creates a new NFA token matcher. + * + * @param ignoreCase the character case ignore flag + */ + public NFAMatcher(bool ignoreCase) : base(ignoreCase) { + } + + /** + * Adds a token pattern to this matcher. + * + * @param pattern the pattern to add + * + * @throws Exception if the pattern couldn't be added to the matcher + */ + public override void AddPattern(TokenPattern pattern) { + if (pattern.Type == TokenPattern.PatternType.STRING) { + automaton.AddTextMatch(pattern.Pattern, ignoreCase, pattern); + } else { + automaton.AddRegExpMatch(pattern.Pattern, ignoreCase, pattern); + } + base.AddPattern(pattern); + } + + /** + * Searches for matching token patterns at the start of the + * input stream. If a match is found, the token match object + * is updated. + * + * @param buffer the input buffer to check + * @param match the token match to update + * + * @throws IOException if an I/O error occurred + */ + public override void Match(ReaderBuffer buffer, TokenMatch match) { + automaton.Match(buffer, match); + } + } + + + /** + * A token pattern matcher for complex regular expressions. This + * class only supports regular expression tokens and must be + * complemented with another matcher for string tokens. + * Internally it uses the Grammatica RE package for high + * performance or the native java.util.regex package for maximum + * compatibility. + */ + internal class RegExpMatcher : TokenMatcher { + + /** + * The regular expression handlers. + */ + private REHandler[] regExps = new REHandler[0]; + + /** + * Creates a new regular expression token matcher. + * + * @param ignoreCase the character case ignore flag + */ + public RegExpMatcher(bool ignoreCase) : base(ignoreCase) { + } + + /** + * Adds a regular expression token pattern to this matcher. + * + * @param pattern the pattern to add + * + * @throws Exception if the pattern couldn't be added to the matcher + */ + public override void AddPattern(TokenPattern pattern) { + REHandler re; + + try { + re = new GrammaticaRE(pattern.Pattern, ignoreCase); + pattern.DebugInfo = "Grammatica regexp\n" + re; + } catch (Exception) { + re = new SystemRE(pattern.Pattern, ignoreCase); + pattern.DebugInfo = "native .NET regexp"; + } + Array.Resize(ref regExps, regExps.Length + 1); + regExps[regExps.Length - 1] = re; + base.AddPattern(pattern); + } + + /** + * Searches for matching token patterns at the start of the + * input stream. If a match is found, the token match object + * is updated. + * + * @param buffer the input buffer to check + * @param match the token match to update + * + * @throws IOException if an I/O error occurred + */ + public override void Match(ReaderBuffer buffer, TokenMatch match) { + for (int i = 0; i < regExps.Length; i++) { + int length = regExps[i].Match(buffer); + if (length > 0) { + match.Update(length, patterns[i]); + } + } + } + } + + + /** + * The regular expression handler base class. + */ + internal abstract class REHandler { + + /** + * Checks if the start of the input stream matches this + * regular expression. + * + * @param buffer the input buffer to check + * + * @return the longest match found, or + * zero (0) if no match was found + * + * @throws IOException if an I/O error occurred + */ + public abstract int Match(ReaderBuffer buffer); + } + + + /** + * The Grammatica built-in regular expression handler. + */ + internal class GrammaticaRE : REHandler { + + /** + * The compiled regular expression. + */ + private RegExp regExp; + + /** + * The regular expression matcher to use. + */ + private Matcher matcher = null; + + /** + * Creates a new Grammatica regular expression handler. + * + * @param regex the regular expression text + * @param ignoreCase the character case ignore flag + * + * @throws Exception if the regular expression contained + * invalid syntax + */ + public GrammaticaRE(string regex, bool ignoreCase) { + regExp = new RegExp(regex, ignoreCase); + } + + /** + * Checks if the start of the input stream matches this + * regular expression. + * + * @param buffer the input buffer to check + * + * @return the longest match found, or + * zero (0) if no match was found + * + * @throws IOException if an I/O error occurred + */ + public override int Match(ReaderBuffer buffer) { + if (matcher == null) { + matcher = regExp.Matcher(buffer); + } else { + matcher.Reset(buffer); + } + return matcher.MatchFromBeginning() ? matcher.Length() : 0; + } + } + + + /** + * The .NET system regular expression handler. + */ + internal class SystemRE : REHandler { + + /** + * The parsed regular expression. + */ + private Regex reg; + + /** + * Creates a new .NET system regular expression handler. + * + * @param regex the regular expression text + * @param ignoreCase the character case ignore flag + * + * @throws Exception if the regular expression contained + * invalid syntax + */ + public SystemRE(string regex, bool ignoreCase) { + if (ignoreCase) { + reg = new Regex(regex, RegexOptions.IgnoreCase); + } else { + reg = new Regex(regex); + } + } + + /** + * Checks if the start of the input stream matches this + * regular expression. + * + * @param buffer the input buffer to check + * + * @return the longest match found, or + * zero (0) if no match was found + * + * @throws IOException if an I/O error occurred + */ + public override int Match(ReaderBuffer buffer) { + Match m; + + // Ugly hack since .NET doesn't have a flag for when the + // end of the input string was encountered... + buffer.Peek(1024 * 16); + // Also, there is no API to limit the search to the specified + // position, so we double-check the index afterwards instead. + m = reg.Match(buffer.ToString(), buffer.Position); + if (m.Success && m.Index == buffer.Position) { + return m.Length; + } else { + return 0; + } + } + } +} diff --git a/Core Library/Properties/AssemblyInfo.cs b/Core Library/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..f1b25fc --- /dev/null +++ b/Core Library/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Core Library")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Core Library")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("100bf7e7-b634-4e6b-948e-22d0566fb2af")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Semantics Analyzer/Properties/AssemblyInfo.cs b/Semantics Analyzer/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..df83228 --- /dev/null +++ b/Semantics Analyzer/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Semantics Analyzer")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Semantics Analyzer")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("5baad1b7-1a1b-41cd-aa2a-90d497685963")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Semantics Analyzer/Semantics Analyzer.csproj b/Semantics Analyzer/Semantics Analyzer.csproj new file mode 100644 index 0000000..401ecd0 --- /dev/null +++ b/Semantics Analyzer/Semantics Analyzer.csproj @@ -0,0 +1,69 @@ + + + + + Debug + AnyCPU + {5BAAD1B7-1A1B-41CD-AA2A-90D497685963} + Library + Properties + Semantics_Analyzer + Semantics Analyzer + v4.5.2 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + {100bf7e7-b634-4e6b-948e-22d0566fb2af} + Core Library + + + {51778AC8-5916-41D4-A647-E5E33A320F3E} + Syntax Analyzer + + + {B2A3CF3F-A100-4772-8190-781981B41EBF} + TokenLibrary + + + + + \ No newline at end of file diff --git a/Semantics Analyzer/SemanticsConstants.cs b/Semantics Analyzer/SemanticsConstants.cs new file mode 100644 index 0000000..930abc8 --- /dev/null +++ b/Semantics Analyzer/SemanticsConstants.cs @@ -0,0 +1,235 @@ +namespace Semantics_Analyzer +{ + public class SemanticsConstants + { + //Identifier Structure + public class Identifiers + { + string id; + int lines; + string attrib; + string dtype; + string scope; + string value; + string tokens; + + //SETS + public void setId(string id) + { + this.id = id; + } + public void setLines(int lines) + { + this.lines = lines; + } + public void setAttrib(string attrib) + { + this.attrib = attrib; + } + public void setDtype(string dtype) + { + this.dtype = dtype; + } + public void setScope(string scope) + { + this.scope = scope; + } + public void setValue(string value) + { + this.value = value; + } + public void setTokens(string tokens) + { + this.tokens = tokens; + } + //GETS + public string getId() + { + return this.id; + } + public int getLines() + { + return this.lines; + } + public string getAttrib() + { + return this.attrib; + } + public string getDtype() + { + return this.dtype; + } + public string getScope() + { + return this.scope; + } + public string getValue() + { + return this.value; + } + public string getTokens() + { + return this.tokens; + } + } + public class Objects + { + public string id; + public string dtype; + + //SETS + public void setId(string id) + { + this.id = id; + } + public void setDtype(string dtype) + { + this.dtype = dtype; + } + //GETS + public string getId() + { + return this.id; + } + public string getDtype() + { + return this.dtype; + } + } + public class Arrays + { + public string id; + public string dtype; + public bool isMulti; + public int size_1; + public int size_2 = -1; + + //SETS + public void setId(string id) + { + this.id = id; + } + public void setDtype(string dtype) + { + this.dtype = dtype; + } + public void setIsMulti(bool isMulti) + { + this.isMulti = isMulti; + } + public void setSize_1(int size_1) + { + this.size_1 = size_1; + } + public void setSize_2(int size_2) + { + this.size_2 = size_2; + } + //GETS + public string getId() + { + return this.id; + } + public string getDtype() + { + return this.dtype; + } + public bool getIsMulti() + { + return this.isMulti; + } + public int getSize_1() + { + return this.size_1; + } + public int getSize_2() + { + return this.size_2; + } + } + public class Index + { + public string id; + public string value; + public string datatype; + public int index_1; + public int index_2 = -1; + + //SETS + public void setId(string id) + { + this.id = id; + } + public void setValue(string value) + { + this.value = value; + } + public void setDatatype(string datatype) + { + this.datatype = datatype; + } + public void setIndex_1(int index_1) + { + this.index_1 = index_1; + } + public void setIndex_2(int index_2) + { + this.index_2 = index_2; + } + //GETS + public string getId() + { + return this.id; + } + public string getValue() + { + return this.value; + } + public string getDatatype() + { + return this.datatype; + } + public int getIndex_1() + { + return this.index_1; + } + public int getIndex_2() + { + return this.index_2; + } + } + public class Task + { + public string id; + public string dtype; + public int parameters; + + //SETS + public void setId(string id) + { + this.id = id; + } + public void setDtype(string dtype) + { + this.dtype = dtype; + } + public void setParameters(int parameters) + { + this.parameters = parameters; + } + //GETS + public string getId() + { + return this.id; + } + public string getDtype() + { + return this.dtype; + } + public int getParamters() + { + return this.parameters; + } + } + } +} diff --git a/Semantics Analyzer/SemanticsInitializer.cs b/Semantics Analyzer/SemanticsInitializer.cs new file mode 100644 index 0000000..4c19ff8 --- /dev/null +++ b/Semantics Analyzer/SemanticsInitializer.cs @@ -0,0 +1,2080 @@ +using System; +using System.Collections.Generic; +using Syntax_Analyzer; +using TokenLibrary; +using Core.Library; +using System.IO; + +namespace Semantics_Analyzer +{ + public class SemanticsInitializer : SyntaxAnalyzer + { + public class Tokens : TokensClass + { + public List attribute = new List(); + + public void addAttribute(string attribute) + { + this.attribute.Add(attribute); + } + + public List getAttribute() + { + return this.attribute; + } + } + + public string error = ""; + public List tokens; + //public List ID = new List(); + private List globalID = new List(); + + //List of Identifiers + private List identifiers = new List(); + private List arrays = new List(); + private List indexes = new List(); + private List objects = new List(); + private List tasks = new List(); + private string currscope = "Lead"; + public List Identifiers + { + get + { + return identifiers; + } + + set + { + identifiers = value; + } + } + + public List Arrays + { + get + { + return arrays; + } + + set + { + arrays = value; + } + } + + public List Indexes + { + get + { + return indexes; + } + + set + { + indexes = value; + } + } + + public List Objects + { + get + { + return objects; + } + + set + { + objects = value; + } + } + + public List Tasks + { + get + { + return tasks; + } + + set + { + tasks = value; + } + } + + public List GlobalID + { + get + { + return globalID; + } + + set + { + globalID = value; + } + } + + public SemanticsInitializer() + : this(new List()) { } + + public SemanticsInitializer(List tokens) + { + this.tokens = tokens; + + } + + public string Start() + { + + string tokenstream = ""; + string result = "Semantics Analyzer Failed...\n"; + int line = 1; + int linejump = 0; + foreach (var t in tokens) + { + if (t.getLines() != line) + { + linejump = t.getLines() - line; + line = t.getLines(); + for (int i = 0; i < linejump; i++) + { + tokenstream += "\n"; + } + } + tokenstream += t.getTokens() + " "; + } + tokenstream = tokenstream.TrimEnd(); + + Parser p; + p = CreateParser(tokenstream); + + try + { + p.Parse(); + if (error == "") + result = "Semantics Analyzer Succeeded..."; + } + catch (ParserCreationException) + { + result = "Semantics Analyzer Halted due to Syntax Analyzer Error..."; + } + catch (ParserLogException) + { + result = "Semantics Analyzer Halted due to Syntax Log Error..."; + } + return result; + } + + private Parser CreateParser(string input) + { + SyntaxParser parser = null; + try + { + parser = new SyntaxParser(new StringReader(input), this); + parser.Prepare(); + } + catch (ParserCreationException e) + { + throw new Exception(e.Message); + } + return parser; + } + + public Tokens GetTokens(int line, int column) + { + List t = new List(); + Tokens token = new Tokens(); + int endline = 0; + foreach (var item in tokens) + { + if (item.getLines() == line) + t.Add(item); + } + foreach (var item in t) + { + endline += item.getTokens().Length + 1; + if (column <= endline) + { + token = item; + break; + } + } + return token; + } + + private Boolean hasGlobalID(SemanticsConstants.Identifiers id) + { + Boolean isdeclared = false; + if (Identifiers.Count != 0) + { + foreach (var item in Identifiers) + { + if (item.getScope() == "Global") + { + if (item.getAttrib() == "Variable" || item.getAttrib() == "Let" || item.getAttrib() == "Array") + { + if (item.getId() == id.getId()) + { + error += "Semantics Error (Ln" + id.getLines() + "): " + id.getId() + " is already declared.\n"; + isdeclared = true; + break; + } + } + } + } + } + + if (!isdeclared) + { + Identifiers.Add(id); + } + return isdeclared; + } + + private void hasMULTIGLOBALID(Node node, string datatype, string scope, string attrib, string default_value) + { + SemanticsConstants.Identifiers id = new SemanticsConstants.Identifiers(); + int idline = node.GetChildAt(1).GetStartLine(); + int idcol = node.GetChildAt(1).GetStartColumn(); + Tokens token = GetTokens(idline, idcol); + string identifier = token.getLexemes(); + id = setIdentifier(identifier, attrib, datatype, scope, default_value, idline, token.getLexemes()); + hasGlobalID(id); + + if (node.GetChildCount() > 2) + { + //If no initialization but has vartail + if (node.GetChildAt(2).GetName() == ("Prod_vartail" + datatype.ToUpper())) + { + hasMULTIGLOBALID(node.GetChildAt(2), datatype, scope, attrib, default_value); + } + //If has initialization and vartail + else if (node.GetChildCount() == 4) + { + hasMULTIGLOBALID(node.GetChildAt(3), datatype, scope, attrib, default_value); + } + //If no vartail but has initialization + else + { + + } + + } + } + + private string getDtype(string dtype) + { + switch (dtype) + { + case "INT": + dtype = "Int"; + break; + case "DOUBLE": + dtype = "Double"; + break; + case "CHAR": + dtype = "Char"; + break; + case "STRING": + dtype = "String"; + break; + case "BOOLEAN": + dtype = "Boolean"; + break; + case "NULL": + dtype = "Null"; + break; + + } + return dtype; + } + + private void populateArray(string id, string datatype, Boolean isMulti, int size_1, int size_2) + { + string value = ""; + switch (datatype) + { + case "Int": + datatype = "Int"; + value = "0"; break; + case "Double": + datatype = "Double"; + value = "0.0"; break; + case "Char": + datatype = "Char"; + value = "''"; break; + case "String": + datatype = "String"; + value = "\"\""; break; + case "Boolean": + datatype = "Boolean"; + value = "Yes"; break; + } + if(isMulti) + { + for (int i = 0; i < size_1; i++) + { + for (int j = 0; j < size_2; j++) + { + SemanticsConstants.Index index = new SemanticsConstants.Index(); + index = setIndex(id, datatype, i, j, value); + Indexes.Add(index); + } + } + } + else + { + for (int k = 0; k < size_1; k++) + { + SemanticsConstants.Index index = new SemanticsConstants.Index(); + index = setIndex(id, datatype, k, 0, value); + Indexes.Add(index); + } + } + } + + private SemanticsConstants.Identifiers setIdentifier + (string identifier, string attrib, string dtype, string scope, string value, int lines, string token) + { + SemanticsConstants.Identifiers ID = new SemanticsConstants.Identifiers(); + ID.setAttrib(attrib); + ID.setDtype(dtype); + ID.setId(identifier); + ID.setLines(lines); + ID.setScope(scope); + ID.setTokens(token); + ID.setValue(value); + return ID; + } + + private SemanticsConstants.Arrays setArray + (string identifier, string dtype, bool isMulti, int size_1, int size_2) + { + SemanticsConstants.Arrays Array = new SemanticsConstants.Arrays(); + Array.setDtype(dtype); + Array.setId(identifier); + Array.setIsMulti(isMulti); + Array.setSize_1(size_1); + Array.setSize_2(size_2); + return Array; + } + + private SemanticsConstants.Objects setObject + (string identifier, string dtype) + { + SemanticsConstants.Objects Object = new SemanticsConstants.Objects(); + Object.setDtype(dtype); + Object.setId(identifier); + return Object; + } + + private SemanticsConstants.Task setTask + (string identifier, string dtype, int parameters) + { + SemanticsConstants.Task Task = new SemanticsConstants.Task(); + Task.setDtype(dtype); + Task.setId(identifier); + Task.setParameters(parameters); + return Task; + } + + private SemanticsConstants.Index setIndex + (string identifier, string datatype, int index_1, int index_2, string value) + { + SemanticsConstants.Index Index = new SemanticsConstants.Index(); + Index.setId(identifier); + Index.setDatatype(identifier + "." + datatype); + Index.setIndex_1(index_1); + Index.setIndex_2(index_2); + Index.setValue(value); + return Index; + } + + public override Node ExitProdStartProgram(Production node) + { + return node; + } + + public override void ChildProdStartProgram(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdProgram(Production node) + { + Console.Clear(); + } + + public override Node ExitProdProgram(Production node) + { + return node; + } + + public override void ChildProdProgram(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdGlobal(Production node) + { + currscope = "Global"; + } + + public override Node ExitProdGlobal(Production node) + { + currscope = "Lead"; + return node; + } + + public override void ChildProdGlobal(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdGlobalChoice(Production node) + { + } + + public override Node ExitProdGlobalChoice(Production node) + { + SemanticsConstants.Identifiers id = new SemanticsConstants.Identifiers(); + Node GlobalChoice = node; + + if (GlobalChoice.GetChildAt(0).GetName() == "Prod_let_global") + { + Node Let_Global = GlobalChoice.GetChildAt(0); + Node valueInfo = Let_Global.GetChildAt(3).GetChildAt(0); + int idline = Let_Global.GetChildAt(1).GetStartLine(); + int idcol = Let_Global.GetChildAt(1).GetStartColumn(); + Tokens token = GetTokens(idline, idcol); + string identifier = token.getLexemes(); + string scope = "Global"; + string attrib = "Let"; + string datatype = ""; + string value = valueInfo.GetName(); + switch (value) + { + case "INTLIT": + datatype = "Int"; break; + case "DOUBLELIT": + datatype = "Double"; break; + case "STRINGLIT": + datatype = "String"; break; + case "CHARLIT": + datatype = "Char"; break; + case "BOOLLIT": + datatype = "Boolean"; break; + } + + Tokens token_value = GetTokens(valueInfo.GetStartLine(), valueInfo.GetStartColumn()); + value = token_value.getLexemes(); + + id = setIdentifier(identifier, attrib, datatype, scope, value, idline, token.getLexemes()); + hasGlobalID(id); + string n = ""; + } + else if (GlobalChoice.GetChildAt(0).GetName() == "Prod_vardec") + { + Node vardtype = GlobalChoice.GetChildAt(0).GetChildAt(1); + int idline = vardtype.GetChildAt(1).GetStartLine(); + int idcol = vardtype.GetChildAt(1).GetStartColumn(); + Tokens token = GetTokens(idline, idcol); + string identifier = token.getLexemes(); + string datatype = vardtype.GetChildAt(0).GetName(); + string scope = "Global", value = "", attrib = "Variable"; + datatype = getDtype(datatype); + + switch (datatype) + { + case "Int": + value = "0"; break; + case "Double": + value = "0.0"; break; + case "String": + value = "\"\""; break; + case "Char": + value = "''"; break; + case "Boolean": + value = "Yes"; break; + } + + id = setIdentifier(identifier, attrib, datatype, scope, value, idline, token.getLexemes()); + hasGlobalID(id); + if(vardtype.GetChildCount() > 2) + { + //If no initialization but has vartail + if (vardtype.GetChildAt(2).GetName() == ("Prod_vartail" + datatype.ToUpper())) + { + hasMULTIGLOBALID(vardtype.GetChildAt(2), datatype, scope, attrib, value); + } + //If has initialization and vartail + else if (vardtype.GetChildCount() == 4) + { + hasMULTIGLOBALID(vardtype.GetChildAt(3), datatype, scope, attrib, value); + } + //If no vartail but has initialization + else + { + // Node varinitDTYPE = vardtype.GetChildAt(2); + // string initdtype = ""; + // switch (varinitDTYPE.GetName()) + // { + // case "Prod_varinitINT": + // initdtype = "Int"; + // break; + // case "Prod_varinitDOUBLE": + // initdtype = "Double"; + // break; + // case "Prod_varinitSTRING": + // initdtype = "String"; + // break; + // case "Prod_varinitCHAR": + // initdtype = "Char"; + // break; + // case "Prod_varinitBOOLEAN": + // initdtype = "Boolean"; + // break; + // } + // if(initdtype == "Int") + // { + // Node mathopINT = varinitDTYPE.GetChildAt(1); + // } + } + } + + string n = ""; + } + else if (GlobalChoice.GetChildAt(0).GetName() == "Prod_array") + { + SemanticsConstants.Arrays array = new SemanticsConstants.Arrays(); + Node Array = GlobalChoice.GetChildAt(0); + Node dataInfo = Array.GetChildAt(1); + string datatype = dataInfo.GetChildAt(0).GetName(); + datatype = getDtype(datatype); + int dtypeline = dataInfo.GetChildAt(0).GetStartLine(); + int dtypecol = dataInfo.GetChildAt(0).GetStartColumn(); + int idline = dataInfo.GetChildAt(1).GetStartLine(); + int idcol = dataInfo.GetChildAt(1).GetStartColumn(); + string scope = "Global"; + string attrib = "Array"; + Boolean isMulti = false; + Tokens id_token = GetTokens(idline, idcol); + Tokens dtype_token = GetTokens(dtypeline, dtypecol); + Tokens size_1_token = GetTokens(Array.GetChildAt(3).GetStartLine(), Array.GetChildAt(3).GetStartColumn()); + int size_1 = Int32.Parse(size_1_token.getLexemes()); + int size_2 = -1; + string identifier = id_token.getLexemes(); + if(Array.GetChildCount() > 4) + { + Node size_tail = Array.GetChildAt(4); + Tokens size_2_token = GetTokens(size_tail.GetChildAt(1).GetStartLine(), size_tail.GetChildAt(1).GetStartColumn()); + size_2 = Int32.Parse(size_2_token.getLexemes()); + isMulti = true; + } + id = setIdentifier(identifier, attrib, datatype, scope, "-", idline, id_token.getLexemes()); + Boolean array_add = hasGlobalID(id); + if(!array_add) + { + array = setArray(identifier, datatype, isMulti, size_1, size_2); + Arrays.Add(array); + populateArray(identifier, datatype, isMulti, size_1, size_2); + } + } + else if (GlobalChoice.GetChildAt(0).GetName() == "Prod_task") + { + + } + else + { + + } + return node; + } + + public override void ChildProdGlobalChoice(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdDatatype(Production node) + { + } + + public override Node ExitProdDatatype(Production node) + { + return node; + } + + public override void ChildProdDatatype(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdLetGlobal(Production node) + { + } + + public override Node ExitProdLetGlobal(Production node) + { + return node; + } + + public override void ChildProdLetGlobal(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdValues(Production node) + { + } + + public override Node ExitProdValues(Production node) + { + return node; + } + + public override void ChildProdValues(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdVardec(Production node) + { + } + + public override Node ExitProdVardec(Production node) + { + return node; + } + + public override void ChildProdVardec(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdVardtype(Production node) + { + } + + public override Node ExitProdVardtype(Production node) + { + return node; + } + + public override void ChildProdVardtype(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdVarinitInt(Production node) + { + } + + public override Node ExitProdVarinitInt(Production node) + { + return node; + } + + public override void ChildProdVarinitInt(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdVarinitDouble(Production node) + { + } + + public override Node ExitProdVarinitDouble(Production node) + { + return node; + } + + public override void ChildProdVarinitDouble(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdVarinitChar(Production node) + { + } + + public override Node ExitProdVarinitChar(Production node) + { + return node; + } + + public override void ChildProdVarinitChar(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdVarinitString(Production node) + { + } + + public override Node ExitProdVarinitString(Production node) + { + return node; + } + + public override void ChildProdVarinitString(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdVarinitBoolean(Production node) + { + } + + public override Node ExitProdVarinitBoolean(Production node) + { + return node; + } + + public override void ChildProdVarinitBoolean(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdVartailInt(Production node) + { + } + + public override Node ExitProdVartailInt(Production node) + { + return node; + } + + public override void ChildProdVartailInt(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdVartailDouble(Production node) + { + } + + public override Node ExitProdVartailDouble(Production node) + { + return node; + } + + public override void ChildProdVartailDouble(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdVartailChar(Production node) + { + } + + public override Node ExitProdVartailChar(Production node) + { + return node; + } + + public override void ChildProdVartailChar(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdVartailString(Production node) + { + } + + public override Node ExitProdVartailString(Production node) + { + return node; + } + + public override void ChildProdVartailString(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdVartailBoolean(Production node) + { + } + + public override Node ExitProdVartailBoolean(Production node) + { + return node; + } + + public override void ChildProdVartailBoolean(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdValueChar(Production node) + { + } + + public override Node ExitProdValueChar(Production node) + { + return node; + } + + public override void ChildProdValueChar(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdValueString(Production node) + { + } + + public override Node ExitProdValueString(Production node) + { + return node; + } + + public override void ChildProdValueString(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdValueBoolean(Production node) + { + } + + public override Node ExitProdValueBoolean(Production node) + { + return node; + } + + public override void ChildProdValueBoolean(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdIdTail(Production node) + { + } + + public override Node ExitProdIdTail(Production node) + { + return node; + } + + public override void ChildProdIdTail(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdIdsTail(Production node) + { + } + + public override Node ExitProdIdsTail(Production node) + { + return node; + } + + public override void ChildProdIdsTail(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdIdChoices(Production node) + { + } + + public override Node ExitProdIdChoices(Production node) + { + return node; + } + + public override void ChildProdIdChoices(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdTaskParam(Production node) + { + } + + public override Node ExitProdTaskParam(Production node) + { + return node; + } + + public override void ChildProdTaskParam(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdTaskParamTail(Production node) + { + } + + public override Node ExitProdTaskParamTail(Production node) + { + return node; + } + + public override void ChildProdTaskParamTail(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdValue(Production node) + { + } + + public override Node ExitProdValue(Production node) + { + return node; + } + + public override void ChildProdValue(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdIndex(Production node) + { + } + + public override Node ExitProdIndex(Production node) + { + return node; + } + + public override void ChildProdIndex(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdIndexop(Production node) + { + } + + public override Node ExitProdIndexop(Production node) + { + return node; + } + + public override void ChildProdIndexop(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdAddMin(Production node) + { + } + + public override Node ExitProdAddMin(Production node) + { + return node; + } + + public override void ChildProdAddMin(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdIndexValue(Production node) + { + } + + public override Node ExitProdIndexValue(Production node) + { + return node; + } + + public override void ChildProdIndexValue(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdIndexTail(Production node) + { + } + + public override Node ExitProdIndexTail(Production node) + { + return node; + } + + public override void ChildProdIndexTail(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdElements(Production node) + { + } + + public override Node ExitProdElements(Production node) + { + return node; + } + + public override void ChildProdElements(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdElementsTail(Production node) + { + } + + public override Node ExitProdElementsTail(Production node) + { + return node; + } + + public override void ChildProdElementsTail(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdArray(Production node) + { + } + + public override Node ExitProdArray(Production node) + { + return node; + } + + public override void ChildProdArray(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdSizeTail(Production node) + { + } + + public override Node ExitProdSizeTail(Production node) + { + return node; + } + + public override void ChildProdSizeTail(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdTask(Production node) + { + } + + public override Node ExitProdTask(Production node) + { + return node; + } + + public override void ChildProdTask(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdReturnType(Production node) + { + } + + public override Node ExitProdReturnType(Production node) + { + return node; + } + + public override void ChildProdReturnType(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdParameters(Production node) + { + } + + public override Node ExitProdParameters(Production node) + { + return node; + } + + public override void ChildProdParameters(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdParamTail(Production node) + { + } + + public override Node ExitProdParamTail(Production node) + { + return node; + } + + public override void ChildProdParamTail(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdObject(Production node) + { + } + + public override Node ExitProdObject(Production node) + { + return node; + } + + public override void ChildProdObject(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdObjectElem(Production node) + { + } + + public override Node ExitProdObjectElem(Production node) + { + return node; + } + + public override void ChildProdObjectElem(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdObjectElemTail(Production node) + { + } + + public override Node ExitProdObjectElemTail(Production node) + { + return node; + } + + public override void ChildProdObjectElemTail(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdObjectVar(Production node) + { + } + + public override Node ExitProdObjectVar(Production node) + { + return node; + } + + public override void ChildProdObjectVar(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdObjectVarTail(Production node) + { + } + + public override Node ExitProdObjectVarTail(Production node) + { + return node; + } + + public override void ChildProdObjectVarTail(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdStatements(Production node) + { + } + + public override Node ExitProdStatements(Production node) + { + return node; + } + + public override void ChildProdStatements(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdFunctions(Production node) + { + } + + public override Node ExitProdFunctions(Production node) + { + Node Functions = node; + string function = Functions.GetChildAt(0).GetName(); + SemanticsConstants.Identifiers id = new SemanticsConstants.Identifiers(); + if(function == "Prod_vardec") + { + Node vardtype = Functions.GetChildAt(0).GetChildAt(1); + int idline = vardtype.GetChildAt(1).GetStartLine(); + int idcol = vardtype.GetChildAt(1).GetStartColumn(); + Tokens token = GetTokens(idline, idcol); + string identifier = token.getLexemes(); + string datatype = vardtype.GetChildAt(0).GetName(); + string scope = currscope, value = "", attrib = "Variable"; + datatype = getDtype(datatype); + + switch (datatype) + { + case "Int": + value = "0"; break; + case "Double": + value = "0.0"; break; + case "String": + value = "\"\""; break; + case "Char": + value = "''"; break; + case "Boolean": + value = "Yes"; break; + } + + id = setIdentifier(identifier, attrib, datatype, scope, value, idline, token.getLexemes()); + hasGlobalID(id); + if (vardtype.GetChildCount() > 2) + { + //If no initialization but has vartail + if (vardtype.GetChildAt(2).GetName() == ("Prod_vartail" + datatype.ToUpper())) + { + hasMULTIGLOBALID(vardtype.GetChildAt(2), datatype, scope, attrib, value); + } + //If has initialization and vartail + else if (vardtype.GetChildCount() == 4) + { + hasMULTIGLOBALID(vardtype.GetChildAt(3), datatype, scope, attrib, value); + } + //If no vartail but has initialization + else + { + + } + } + } + return node; + } + + public override void ChildProdFunctions(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdIoStatement(Production node) + { + } + + public override Node ExitProdIoStatement(Production node) + { + + return node; + } + + public override void ChildProdIoStatement(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdOutputStatement(Production node) + { + } + + public override Node ExitProdOutputStatement(Production node) + { + Node Output = node; + Node Stringlit = Output.GetChildAt(0); + Tokens token; + int count = Output.GetChildCount(); + if(count == 1) + { + int idline = Stringlit.GetStartLine(); + int idcol = Stringlit.GetStartColumn(); + token = GetTokens(idline, idcol); + string outs = token.getLexemes(); + outs = outs.Remove(0, 1); + outs = outs.Remove(outs.Length - 1, 1); + Console.WriteLine(outs); + } + + return node; + } + + public override void ChildProdOutputStatement(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdConcat(Production node) + { + } + + public override Node ExitProdConcat(Production node) + { + return node; + } + + public override void ChildProdConcat(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdPreIncdec(Production node) + { + } + + public override Node ExitProdPreIncdec(Production node) + { + return node; + } + + public override void ChildProdPreIncdec(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdOption(Production node) + { + } + + public override Node ExitProdOption(Production node) + { + return node; + } + + public override void ChildProdOption(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdOptionChoices(Production node) + { + } + + public override Node ExitProdOptionChoices(Production node) + { + return node; + } + + public override void ChildProdOptionChoices(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdOptionInt(Production node) + { + } + + public override Node ExitProdOptionInt(Production node) + { + return node; + } + + public override void ChildProdOptionInt(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdOptionChar(Production node) + { + } + + public override Node ExitProdOptionChar(Production node) + { + return node; + } + + public override void ChildProdOptionChar(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdOptionString(Production node) + { + } + + public override Node ExitProdOptionString(Production node) + { + return node; + } + + public override void ChildProdOptionString(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdStateInt(Production node) + { + } + + public override Node ExitProdStateInt(Production node) + { + return node; + } + + public override void ChildProdStateInt(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdStateChar(Production node) + { + } + + public override Node ExitProdStateChar(Production node) + { + return node; + } + + public override void ChildProdStateChar(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdStateString(Production node) + { + } + + public override Node ExitProdStateString(Production node) + { + return node; + } + + public override void ChildProdStateString(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdDefault(Production node) + { + } + + public override Node ExitProdDefault(Production node) + { + return node; + } + + public override void ChildProdDefault(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdConditions(Production node) + { + } + + public override Node ExitProdConditions(Production node) + { + return node; + } + + public override void ChildProdConditions(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdConditionChoices(Production node) + { + } + + public override Node ExitProdConditionChoices(Production node) + { + return node; + } + + public override void ChildProdConditionChoices(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdConditionTail(Production node) + { + } + + public override Node ExitProdConditionTail(Production node) + { + return node; + } + + public override void ChildProdConditionTail(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdConditionIds(Production node) + { + } + + public override Node ExitProdConditionIds(Production node) + { + return node; + } + + public override void ChildProdConditionIds(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdLogOpTail(Production node) + { + } + + public override Node ExitProdLogOpTail(Production node) + { + return node; + } + + public override void ChildProdLogOpTail(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdLogOpChoices(Production node) + { + } + + public override Node ExitProdLogOpChoices(Production node) + { + return node; + } + + public override void ChildProdLogOpChoices(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdRelOp(Production node) + { + } + + public override Node ExitProdRelOp(Production node) + { + return node; + } + + public override void ChildProdRelOp(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdLogOp(Production node) + { + } + + public override Node ExitProdLogOp(Production node) + { + return node; + } + + public override void ChildProdLogOp(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdNegate(Production node) + { + } + + public override Node ExitProdNegate(Production node) + { + return node; + } + + public override void ChildProdNegate(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdIfOtherwise(Production node) + { + } + + public override Node ExitProdIfOtherwise(Production node) + { + return node; + } + + public override void ChildProdIfOtherwise(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdOr(Production node) + { + } + + public override Node ExitProdOr(Production node) + { + return node; + } + + public override void ChildProdOr(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdOtherwise(Production node) + { + } + + public override Node ExitProdOtherwise(Production node) + { + return node; + } + + public override void ChildProdOtherwise(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdCondLoop(Production node) + { + } + + public override Node ExitProdCondLoop(Production node) + { + return node; + } + + public override void ChildProdCondLoop(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdControl(Production node) + { + } + + public override Node ExitProdControl(Production node) + { + return node; + } + + public override void ChildProdControl(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdLoopstate(Production node) + { + } + + public override Node ExitProdLoopstate(Production node) + { + return node; + } + + public override void ChildProdLoopstate(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdInitialize(Production node) + { + } + + public override Node ExitProdInitialize(Production node) + { + return node; + } + + public override void ChildProdInitialize(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdInitChoices(Production node) + { + } + + public override Node ExitProdInitChoices(Production node) + { + return node; + } + + public override void ChildProdInitChoices(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdCond(Production node) + { + } + + public override Node ExitProdCond(Production node) + { + return node; + } + + public override void ChildProdCond(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdIncdecvar(Production node) + { + } + + public override Node ExitProdIncdecvar(Production node) + { + return node; + } + + public override void ChildProdIncdecvar(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdIdStmt(Production node) + { + } + + public override Node ExitProdIdStmt(Production node) + { + return node; + } + + public override void ChildProdIdStmt(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdIdStmtTail(Production node) + { + } + + public override Node ExitProdIdStmtTail(Production node) + { + return node; + } + + public override void ChildProdIdStmtTail(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdInitvalues(Production node) + { + } + + public override Node ExitProdInitvalues(Production node) + { + return node; + } + + public override void ChildProdInitvalues(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdMathopInt(Production node) + { + } + + public override Node ExitProdMathopInt(Production node) + { + return node; + } + + public override void ChildProdMathopInt(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdMathopDouble(Production node) + { + } + + public override Node ExitProdMathopDouble(Production node) + { + return node; + } + + public override void ChildProdMathopDouble(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdMathopNum(Production node) + { + } + + public override Node ExitProdMathopNum(Production node) + { + return node; + } + + public override void ChildProdMathopNum(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdIntvalue(Production node) + { + } + + public override Node ExitProdIntvalue(Production node) + { + return node; + } + + public override void ChildProdIntvalue(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdDoublevalue(Production node) + { + } + + public override Node ExitProdDoublevalue(Production node) + { + return node; + } + + public override void ChildProdDoublevalue(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdNumvalue(Production node) + { + } + + public override Node ExitProdNumvalue(Production node) + { + return node; + } + + public override void ChildProdNumvalue(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdExprId(Production node) + { + } + + public override Node ExitProdExprId(Production node) + { + return node; + } + + public override void ChildProdExprId(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdMathopIntTail(Production node) + { + } + + public override Node ExitProdMathopIntTail(Production node) + { + return node; + } + + public override void ChildProdMathopIntTail(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdMathopDoubleTail(Production node) + { + } + + public override Node ExitProdMathopDoubleTail(Production node) + { + return node; + } + + public override void ChildProdMathopDoubleTail(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdMathopNumTail(Production node) + { + } + + public override Node ExitProdMathopNumTail(Production node) + { + return node; + } + + public override void ChildProdMathopNumTail(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdOperators(Production node) + { + } + + public override Node ExitProdOperators(Production node) + { + return node; + } + + public override void ChildProdOperators(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdIncdec(Production node) + { + } + + public override Node ExitProdIncdec(Production node) + { + return node; + } + public override void ChildProdIncdec(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdIncdecNull(Production node) + { + } + + public override Node ExitProdIncdecNull(Production node) + { + return node; + } + + public override void ChildProdIncdecNull(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdTaskdef(Production node) + { + } + + public override Node ExitProdTaskdef(Production node) + { + return node; + } + + public override void ChildProdTaskdef(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdReturnId(Production node) + { + } + + public override Node ExitProdReturnId(Production node) + { + return node; + } + + public override void ChildProdReturnId(Production node, Node child) + { + node.AddChild(child); + if(child.GetName() == "ID") + { + int idline = child.GetStartLine(); + int idcol = child.GetStartColumn(); + Tokens token = GetTokens(idline, idcol); + currscope = "Task." + token.getLexemes(); + } + } + + public override void EnterProdTaskbody(Production node) + { + } + + public override Node ExitProdTaskbody(Production node) + { + return node; + } + + public override void ChildProdTaskbody(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdReturnInt(Production node) + { + } + + public override Node ExitProdReturnInt(Production node) + { + return node; + } + + public override void ChildProdReturnInt(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdReturnDouble(Production node) + { + } + + public override Node ExitProdReturnDouble(Production node) + { + return node; + } + + public override void ChildProdReturnDouble(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdReturnChar(Production node) + { + } + + public override Node ExitProdReturnChar(Production node) + { + return node; + } + + public override void ChildProdReturnChar(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdReturnString(Production node) + { + } + + public override Node ExitProdReturnString(Production node) + { + return node; + } + + public override void ChildProdReturnString(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdReturnBoolean(Production node) + { + } + + public override Node ExitProdReturnBoolean(Production node) + { + return node; + } + + public override void ChildProdReturnBoolean(Production node, Node child) + { + node.AddChild(child); + } + + public override void EnterProdReturntail(Production node) + { + } + + public override Node ExitProdReturntail(Production node) + { + return node; + } + + } +} diff --git a/SemanticsAnalyzer/Properties/AssemblyInfo.cs b/SemanticsAnalyzer/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..cb0b198 --- /dev/null +++ b/SemanticsAnalyzer/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SemanticsAnalyzer")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SemanticsAnalyzer")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("e187009e-0b2b-4569-b16c-c35ef06fdfe1")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SemanticsAnalyzer/SemanticsAnalyzer.csproj b/SemanticsAnalyzer/SemanticsAnalyzer.csproj new file mode 100644 index 0000000..17ce76e --- /dev/null +++ b/SemanticsAnalyzer/SemanticsAnalyzer.csproj @@ -0,0 +1,70 @@ + + + + + Debug + AnyCPU + {E187009E-0B2B-4569-B16C-C35EF06FDFE1} + Library + Properties + SemanticsAnalyzer + SemanticsAnalyzer + v4.5 + 512 + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + {100bf7e7-b634-4e6b-948e-22d0566fb2af} + Core Library + + + {c19858d3-1865-438d-afea-d2451a2ca503} + Syntax Analyzer + + + {17d6f07e-f7be-41de-8d3c-1881ee21f14a} + TokenLibrary + + + + + \ No newline at end of file diff --git a/SemanticsAnalyzer/SemanticsConstants.cs b/SemanticsAnalyzer/SemanticsConstants.cs new file mode 100644 index 0000000..930abc8 --- /dev/null +++ b/SemanticsAnalyzer/SemanticsConstants.cs @@ -0,0 +1,235 @@ +namespace Semantics_Analyzer +{ + public class SemanticsConstants + { + //Identifier Structure + public class Identifiers + { + string id; + int lines; + string attrib; + string dtype; + string scope; + string value; + string tokens; + + //SETS + public void setId(string id) + { + this.id = id; + } + public void setLines(int lines) + { + this.lines = lines; + } + public void setAttrib(string attrib) + { + this.attrib = attrib; + } + public void setDtype(string dtype) + { + this.dtype = dtype; + } + public void setScope(string scope) + { + this.scope = scope; + } + public void setValue(string value) + { + this.value = value; + } + public void setTokens(string tokens) + { + this.tokens = tokens; + } + //GETS + public string getId() + { + return this.id; + } + public int getLines() + { + return this.lines; + } + public string getAttrib() + { + return this.attrib; + } + public string getDtype() + { + return this.dtype; + } + public string getScope() + { + return this.scope; + } + public string getValue() + { + return this.value; + } + public string getTokens() + { + return this.tokens; + } + } + public class Objects + { + public string id; + public string dtype; + + //SETS + public void setId(string id) + { + this.id = id; + } + public void setDtype(string dtype) + { + this.dtype = dtype; + } + //GETS + public string getId() + { + return this.id; + } + public string getDtype() + { + return this.dtype; + } + } + public class Arrays + { + public string id; + public string dtype; + public bool isMulti; + public int size_1; + public int size_2 = -1; + + //SETS + public void setId(string id) + { + this.id = id; + } + public void setDtype(string dtype) + { + this.dtype = dtype; + } + public void setIsMulti(bool isMulti) + { + this.isMulti = isMulti; + } + public void setSize_1(int size_1) + { + this.size_1 = size_1; + } + public void setSize_2(int size_2) + { + this.size_2 = size_2; + } + //GETS + public string getId() + { + return this.id; + } + public string getDtype() + { + return this.dtype; + } + public bool getIsMulti() + { + return this.isMulti; + } + public int getSize_1() + { + return this.size_1; + } + public int getSize_2() + { + return this.size_2; + } + } + public class Index + { + public string id; + public string value; + public string datatype; + public int index_1; + public int index_2 = -1; + + //SETS + public void setId(string id) + { + this.id = id; + } + public void setValue(string value) + { + this.value = value; + } + public void setDatatype(string datatype) + { + this.datatype = datatype; + } + public void setIndex_1(int index_1) + { + this.index_1 = index_1; + } + public void setIndex_2(int index_2) + { + this.index_2 = index_2; + } + //GETS + public string getId() + { + return this.id; + } + public string getValue() + { + return this.value; + } + public string getDatatype() + { + return this.datatype; + } + public int getIndex_1() + { + return this.index_1; + } + public int getIndex_2() + { + return this.index_2; + } + } + public class Task + { + public string id; + public string dtype; + public int parameters; + + //SETS + public void setId(string id) + { + this.id = id; + } + public void setDtype(string dtype) + { + this.dtype = dtype; + } + public void setParameters(int parameters) + { + this.parameters = parameters; + } + //GETS + public string getId() + { + return this.id; + } + public string getDtype() + { + return this.dtype; + } + public int getParamters() + { + return this.parameters; + } + } + } +} diff --git a/SemanticsAnalyzer/SemanticsInitializer.cs b/SemanticsAnalyzer/SemanticsInitializer.cs new file mode 100644 index 0000000..d4f6cfa --- /dev/null +++ b/SemanticsAnalyzer/SemanticsInitializer.cs @@ -0,0 +1,4575 @@ +using System; +using System.Collections.Generic; +using Syntax_Analyzer; +using TokenLibrary.TokenLibrary; +using Core.Library; +using System.IO; + +namespace Semantics_Analyzer +{ + public class SemanticsInitializer : SyntaxAnalyzer + { + public class Tokens : TokenClass + { + public List attribute = new List(); + + public void addAttribute(string attribute) + { + this.attribute.Add(attribute); + } + + public List getAttribute() + { + return this.attribute; + } + } + + public string error = ""; + public List tokens; + //public List ID = new List(); + private List globalID = new List(); + + //List of Identifiers + public List identifiers = new List(); + public List arrays = new List(); + public List indexes = new List(); + public List objects = new List(); + public List tasks = new List(); + private string currscope = "Mane"; + public List Identifiers + { + get + { + return identifiers; + } + + set + { + identifiers = value; + } + } + + public List Arrays + { + get + { + return arrays; + } + + set + { + arrays = value; + } + } + + public List Indexes + { + get + { + return indexes; + } + + set + { + indexes = value; + } + } + + public List Objects + { + get + { + return objects; + } + + set + { + objects = value; + } + } + + public List Tasks + { + get + { + return tasks; + } + + set + { + tasks = value; + } + } + + public List GlobalID + { + get + { + return globalID; + } + + set + { + globalID = value; + } + } + + public SemanticsInitializer() + : this(new List()) { } + + public SemanticsInitializer(List tokens) + { + this.tokens = tokens; + } + + public string Start() + { + + string tokenstream = ""; + string result = "Semantics\n Analyzer Failed...\n"; + int line = 1; + int linejump = 0; + foreach (var t in tokens) + { + if (t.getLines() != line) + { + linejump = t.getLines() - line; + line = t.getLines(); + for (int i = 0; i < linejump; i++) + { + tokenstream += "\n"; + } + } + tokenstream += t.getTokens() + " "; + } + tokenstream = tokenstream.TrimEnd(); + + Parser p; + p = CreateParser(tokenstream); + + try + { + p.Parse(); + if (error == "") + result = "Semantics Analyzer Succeeded..."; + } + catch (ParserCreationException) + { + result = "Semantics Analyzer Halted due to Syntax Analyzer Error..."; + } + catch (ParserLogException) + { + result = "Semantics Analyzer Halted due to Syntax Log Error..."; + } + return result; + } + + private Parser CreateParser(string input) + { + SyntaxParser parser = null; + try + { + parser = new SyntaxParser(new StringReader(input), this); + parser.Prepare(); + } + catch (ParserCreationException e) + { + throw new Exception(e.Message); + } + return parser; + } + + public Tokens GetTokens(int line, int column) + { + List t = new List(); + Tokens token = new Tokens(); + int endline = 0; + foreach (var item in tokens) + { + if (item.getLines() == line) + t.Add(item); + } + foreach (var item in t) + { + endline += item.getTokens().Length + 1; + if (column <= endline) + { + token = item; + break; + } + } + return token; + } + + + private bool checkIdentifier(SemanticsConstants.Identifiers id) + { + bool isvalid = true; + if(Identifiers.Count != 0) + { + foreach (var item in Identifiers) + { + if(item.getId() == id.getId()) + { + if(item.getScope() == id.getScope() || item.getScope() == "Global" || item.getScope() == "Constant") + { + error += "Semantics Error (Ln" + id.getLines() + "): " + id.getId() + " is already declared.\n"; + isvalid = false; + } + } + } + } + + if(isvalid) + { + Identifiers.Add(id); + } + + return isvalid; + } + + private string getDtype(string dtype) + { + switch (dtype) + { + case "NEWT": + dtype = "Newt"; + break; + case "DUCK": + dtype = "Duck"; + break; + case "STARLING": + dtype = "Starling"; + break; + case "BULL": + dtype = "Bull"; + break; + case "NULL": + dtype = "Null"; + break; + + } + return dtype; + } + + private void populateArray(string id, string datatype, Boolean isMulti, int size_1, int size_2) + { + string value = ""; + switch (datatype) + { + case "Newt": + datatype = "Newt"; + value = "0"; break; + case "Duck": + datatype = "Duck"; + value = "0.00"; break; + case "Starling": + datatype = "Starling"; + value = "\"\""; break; + case "Bull": + datatype = "Bull"; + value = "Yes"; break; + } + if(isMulti) + { + for (int i = 0; i < size_1; i++) + { + for (int j = 0; j < size_2; j++) + { + SemanticsConstants.Index index = new SemanticsConstants.Index(); + index = setIndex(id, datatype, i, j, value); + Indexes.Add(index); + } + } + } + else + { + for (int k = 0; k < size_1; k++) + { + SemanticsConstants.Index index = new SemanticsConstants.Index(); + index = setIndex(id, datatype, k, 0, value); + Indexes.Add(index); + } + } + } + + private SemanticsConstants.Identifiers setIdentifier + (string identifier, string attrib, string dtype, string scope, string value, int lines, string token) + { + SemanticsConstants.Identifiers ID = new SemanticsConstants.Identifiers(); + ID.setAttrib(attrib); + ID.setDtype(dtype); + ID.setId(identifier); + ID.setLines(lines); + ID.setScope(scope); + ID.setTokens(token); + ID.setValue(value); + return ID; + } + + private SemanticsConstants.Arrays setArray + (string identifier, string dtype, bool isMulti, int size_1, int size_2) + { + SemanticsConstants.Arrays Array = new SemanticsConstants.Arrays(); + Array.setDtype(dtype); + Array.setId(identifier); + Array.setIsMulti(isMulti); + Array.setSize_1(size_1); + Array.setSize_2(size_2); + return Array; + } + + private SemanticsConstants.Objects setObject + (string identifier, string dtype) + { + SemanticsConstants.Objects Object = new SemanticsConstants.Objects(); + Object.setDtype(dtype); + Object.setId(identifier); + return Object; + } + + private SemanticsConstants.Task setTask + (string identifier, string dtype, int parameters) + { + SemanticsConstants.Task Task = new SemanticsConstants.Task(); + Task.setDtype(dtype); + Task.setId(identifier); + Task.setParameters(parameters); + return Task; + } + + private SemanticsConstants.Index setIndex + (string identifier, string datatype, int index_1, int index_2, string value) + { + SemanticsConstants.Index Index = new SemanticsConstants.Index(); + Index.setId(identifier); + Index.setDatatype(identifier + "." + datatype); + Index.setIndex_1(index_1); + Index.setIndex_2(index_2); + Index.setValue(value); + return Index; + } + /** +*

Called when entering a parse tree node. +* +* the node being entered +* +* if the node analysis +* discovered errors +*/ + public override void EnterProdProgram(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdProgram(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdProgram(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdComment(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdComment(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdComment(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdGlobalDec(Production node) + { + currscope = "Global"; + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdGlobalDec(Production node) + { + currscope = "Mane"; + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdGlobalDec(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdVarDec(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdVarDec(Production node) + { + string dtype = "", scope = currscope, id = ""; + Node ident_var = node.GetChildAt(0); + Node datatype = ident_var.GetChildAt(0).GetChildAt(0); + dtype = getDtype(datatype.GetName()); + bool isFunct = false; + bool isArray = false; + bool isSaved = false; + int idline, idcol; + idline = ident_var.GetChildAt(2).GetStartLine(); + idcol = ident_var.GetChildAt(2).GetStartColumn(); + Tokens token = new Tokens(); + token = GetTokens(idline,idcol); + id = token.getLexemes(); + SemanticsConstants.Identifiers identifier = new SemanticsConstants.Identifiers(); + identifier = setIdentifier(id,"",dtype,scope,"",idline,token.getTokens()); + isSaved = checkIdentifier(identifier); + if (node.GetChildCount() > 2) + { + if(node.GetChildAt(1).GetName() == "prod_func_var") + { + Node func_var = node.GetChildAt(1); + if(func_var.GetChildAt(0).GetName() == "prod_next2var") + { + Node next2var = node.GetChildAt(1); + //int idcount = 2; + if (next2var.GetChildAt(0).GetName() == "prod_array1D") + { + Node array1D = node.GetChildAt(1); + isArray = true; + } + else if (next2var.GetChildAt(0).GetName() == "=") + { + + } + else + { + //if (idcount == 1) + //{ + + //} + //else + //{ + // Node multiID = node.GetChildAt(1); + // idcount++; + + //} + + } + } + else + { + isFunct = true; + } + } + else + { + + } + } + + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdVarDec(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdFuncVar(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdFuncVar(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdFuncVar(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdIdentVar(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdIdentVar(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdIdentVar(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdDtype(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdDtype(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdDtype(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdNext2var(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdNext2var(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdNext2var(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdNext2varTail(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdNext2varTail(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdNext2varTail(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdVal(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdVal(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdVal(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdVal1(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdVal1(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdVal1(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdVal2(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdVal2(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdVal2(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdBulLit(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdBulLit(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdBulLit(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdArray1d(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdArray1d(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdArray1d(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdElem1dNext(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdElem1dNext(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdElem1dNext(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdElem1dList(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdElem1dList(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdElem1dList(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdElemlist1dTail(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdElemlist1dTail(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdElemlist1dTail(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdElem2dNext(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdElem2dNext(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdElem2dNext(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdElem2dList(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdElem2dList(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdElem2dList(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdElem2dListTail(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdElem2dListTail(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdElem2dListTail(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdSize(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdSize(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdSize(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdConstDec(Production node) + { + currscope = "Constant"; + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdConstDec(Production node) + { + string dtype = "", scope = currscope, id = ""; + Node ident_var = node.GetChildAt(1); + Node datatype = ident_var.GetChildAt(0).GetChildAt(0); + dtype = getDtype(datatype.GetName()); + bool isFunct = false; + bool isArray = false; + bool isSaved = false; + int idline, idcol; + idline = ident_var.GetChildAt(2).GetStartLine(); + idcol = ident_var.GetChildAt(2).GetStartColumn(); + Tokens token = new Tokens(); + token = GetTokens(idline, idcol); + id = token.getLexemes(); + SemanticsConstants.Identifiers identifier = new SemanticsConstants.Identifiers(); + identifier = setIdentifier(id, "", dtype, scope, "", idline, token.getTokens()); + isSaved = checkIdentifier(identifier); + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdConstDec(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdConstNext(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdConstNext(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdConstNext(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdFuncName(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdFuncName(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdFuncName(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdParam(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdParam(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdParam(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdParam2(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdParam2(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdParam2(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdStorkDec(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdStorkDec(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdStorkDec(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdStorkElem(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdStorkElem(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdStorkElem(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdMultiVardec(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdMultiVardec(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdMultiVardec(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdMultistorkElem(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdMultistorkElem(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdMultistorkElem(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdObjDec(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdObjDec(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdObjDec(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdMane(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdMane(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdMane(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdLocalDec(Production node) + { + currscope = "Local"; + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdLocalDec(Production node) + { + string dtype = "", scope = currscope, id = ""; + Node ident_var = node.GetChildAt(0); + Node datatype = ident_var.GetChildAt(0).GetChildAt(0); + dtype = getDtype(datatype.GetName()); + bool isFunct = false; + bool isArray = false; + bool isSaved = false; + int idline, idcol; + idline = ident_var.GetChildAt(2).GetStartLine(); + idcol = ident_var.GetChildAt(2).GetStartColumn(); + Tokens token = new Tokens(); + token = GetTokens(idline, idcol); + id = token.getLexemes(); + SemanticsConstants.Identifiers identifier = new SemanticsConstants.Identifiers(); + identifier = setIdentifier(id, "", dtype, scope, "", idline, token.getTokens()); + isSaved = checkIdentifier(identifier); + //if (node.GetChildCount() > 2) + //{ + // if (node.GetChildAt(1).GetName() == "prod_func_var") + // { + // Node func_var = node.GetChildAt(1); + // if (func_var.GetChildAt(0).GetName() == "prod_next2var") + // { + + // } + // else + // { + // isFunct = true; + // } + // } + // else + // { + + // } + //}; + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdLocalDec(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdStatement(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdStatement(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdStatement(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdStateNext(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdStateNext(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdStateNext(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdAssign1(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdAssign1(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdAssign1(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdAssignTail(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdAssignTail(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdAssignTail(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdNextFig(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdNextFig(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdNextFig(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdScanNext(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdScanNext(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdScanNext(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdArgs1(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdArgs1(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdArgs1(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdArgsTail(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdArgsTail(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdArgsTail(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdArgIn(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdArgIn(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdArgIn(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdMathEqtail1(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdMathEqtail1(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdMathEqtail1(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdMathEqtail2(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdMathEqtail2(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdMathEqtail2(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdMathTail(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdMathTail(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdMathTail(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdMathOp(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdMathOp(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdMathOp(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdMathFig(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdMathFig(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdMathFig(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdMathFig1(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdMathFig1(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdMathFig1(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdMatheqNext(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdMatheqNext(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdMatheqNext(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdFunctionCall(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdFunctionCall(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdFunctionCall(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdClrscr(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdClrscr(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdClrscr(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdInput(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdInput(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdInput(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdScanFig(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdScanFig(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdScanFig(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdMultiInput(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdMultiInput(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdMultiInput(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdArr1d(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdArr1d(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdArr1d(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdArr2d(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdArr2d(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdArr2d(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdStorkAccess1(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdStorkAccess1(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdStorkAccess1(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdOutput(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdOutput(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdOutput(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdOut(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdOut(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdOut(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdMultiOutput(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdMultiOutput(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdMultiOutput(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdConditional(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdConditional(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdConditional(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdCondi(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdCondi(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdCondi(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdNotFig(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdNotFig(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdNotFig(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdCondExpr(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdCondExpr(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdCondExpr(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdCondTail(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdCondTail(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdCondTail(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdRelExpr(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdRelExpr(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdRelExpr(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdRelexTail(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdRelexTail(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdRelexTail(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdExpression(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdExpression(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdExpression(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdRelOp1(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdRelOp1(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdRelOp1(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdRelOp2(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdRelOp2(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdRelOp2(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdRelFig(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdRelFig(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdRelFig(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdLogExpr(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdLogExpr(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdLogExpr(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdLogExprNext(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdLogExprNext(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdLogExprNext(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdLogOp(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdLogOp(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdLogOp(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdCondEelsif(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdCondEelsif(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdCondEelsif(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdCondEels(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdCondEels(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdCondEels(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdSwaspCase(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdSwaspCase(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdSwaspCase(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdSwaspCase1(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdSwaspCase1(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdSwaspCase1(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdTermExpr(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdTermExpr(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdTermExpr(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdDefault(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdDefault(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdDefault(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdIterative(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdIterative(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdIterative(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdLoopFig1(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdLoopFig1(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdLoopFig1(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdRelExpr1(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdRelExpr1(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdRelExpr1(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdLoopFig2(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdLoopFig2(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdLoopFig2(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdIncremDecrem(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdIncremDecrem(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdIncremDecrem(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdVar(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdVar(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdVar(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdUnaryOp(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdUnaryOp(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdUnaryOp(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdSubFunction(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdSubFunction(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdSubFunction(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdFuncInside(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdFuncInside(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdFuncInside(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdFuncArgs(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdFuncArgs(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdFuncArgs(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdMultifuncArgs(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdMultifuncArgs(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdMultifuncArgs(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdResult(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdResult(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdResult(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdFigTail(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdFigTail(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdFigTail(Production node, Node child) + { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void EnterProdResultTail(Production node) + { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node ExitProdResultTail(Production node) + { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void ChildProdResultTail(Production node, Node child) + { + node.AddChild(child); + } + + } +} diff --git a/Syntax Analyzer/Class1.cs b/Syntax Analyzer/Class1.cs new file mode 100644 index 0000000..9237242 --- /dev/null +++ b/Syntax Analyzer/Class1.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Syntax_Analyzer +{ + public class Class1 + { + } +} diff --git a/Syntax Analyzer/Properties/AssemblyInfo.cs b/Syntax Analyzer/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..c68f5b9 --- /dev/null +++ b/Syntax Analyzer/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Syntax Analyzer")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Syntax Analyzer")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("c19858d3-1865-438d-afea-d2451a2ca503")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Syntax Analyzer/Syntax Analyzer.csproj b/Syntax Analyzer/Syntax Analyzer.csproj new file mode 100644 index 0000000..342349b --- /dev/null +++ b/Syntax Analyzer/Syntax Analyzer.csproj @@ -0,0 +1,71 @@ + + + + + Debug + AnyCPU + {C19858D3-1865-438D-AFEA-D2451A2CA503} + Library + Properties + Syntax_Analyzer + Syntax Analyzer + v4.5 + 512 + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + {100bf7e7-b634-4e6b-948e-22d0566fb2af} + Core Library + + + {17d6f07e-f7be-41de-8d3c-1881ee21f14a} + TokenLibrary + + + + + \ No newline at end of file diff --git a/Syntax Analyzer/SyntaxAnalyzer.cs b/Syntax Analyzer/SyntaxAnalyzer.cs new file mode 100644 index 0000000..f115fce --- /dev/null +++ b/Syntax Analyzer/SyntaxAnalyzer.cs @@ -0,0 +1,6679 @@ +/* + * SyntaxAnalyzer.cs + * + * THIS FILE HAS BEEN GENERATED AUTOMATICALLY. DO NOT EDIT! + */ + +using Core.Library; + +/** + * A class providing callback methods for the + * parser. + */ +public abstract class SyntaxAnalyzer : Analyzer { + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public override void Enter(Node node) { + switch (node.Id) { + case (int) SyntaxConstants.ENTRANCE: + EnterEntrance((Token) node); + break; + case (int) SyntaxConstants.EXIT: + EnterExit((Token) node); + break; + case (int) SyntaxConstants.MANE: + EnterMane((Token) node); + break; + case (int) SyntaxConstants.LET: + EnterLet((Token) node); + break; + case (int) SyntaxConstants.WIPE: + EnterWipe((Token) node); + break; + case (int) SyntaxConstants.ZOOIN: + EnterZooin((Token) node); + break; + case (int) SyntaxConstants.ZOOUT: + EnterZoout((Token) node); + break; + case (int) SyntaxConstants.IF: + EnterIf((Token) node); + break; + case (int) SyntaxConstants.EELSIF: + EnterEelsif((Token) node); + break; + case (int) SyntaxConstants.EELS: + EnterEels((Token) node); + break; + case (int) SyntaxConstants.CHAMOIS: + EnterChamois((Token) node); + break; + case (int) SyntaxConstants.TERMITE: + EnterTermite((Token) node); + break; + case (int) SyntaxConstants.SEAL: + EnterSeal((Token) node); + break; + case (int) SyntaxConstants.WHALE: + EnterWhale((Token) node); + break; + case (int) SyntaxConstants.DO: + EnterDo((Token) node); + break; + case (int) SyntaxConstants.FUR: + EnterFur((Token) node); + break; + case (int) SyntaxConstants.HOP: + EnterHop((Token) node); + break; + case (int) SyntaxConstants.SWASP: + EnterSwasp((Token) node); + break; + case (int) SyntaxConstants.STORK: + EnterStork((Token) node); + break; + case (int) SyntaxConstants.AT: + EnterAt((Token) node); + break; + case (int) SyntaxConstants.NULL: + EnterNull((Token) node); + break; + case (int) SyntaxConstants.COMSYM: + EnterComsym((Token) node); + break; + case (int) SyntaxConstants.TERMI: + EnterTermi((Token) node); + break; + case (int) SyntaxConstants.SC: + EnterSc((Token) node); + break; + case (int) SyntaxConstants.COMMA: + EnterComma((Token) node); + break; + case (int) SyntaxConstants.EQUAL: + EnterEqual((Token) node); + break; + case (int) SyntaxConstants.OB: + EnterOb((Token) node); + break; + case (int) SyntaxConstants.CB: + EnterCb((Token) node); + break; + case (int) SyntaxConstants.OC: + EnterOc((Token) node); + break; + case (int) SyntaxConstants.CC: + EnterCc((Token) node); + break; + case (int) SyntaxConstants.OP: + EnterOp((Token) node); + break; + case (int) SyntaxConstants.CP: + EnterCp((Token) node); + break; + case (int) SyntaxConstants.ODC: + EnterOdc((Token) node); + break; + case (int) SyntaxConstants.CDC: + EnterCdc((Token) node); + break; + case (int) SyntaxConstants.CONC: + EnterConc((Token) node); + break; + case (int) SyntaxConstants.CON: + EnterCon((Token) node); + break; + case (int) SyntaxConstants.ODA: + EnterOda((Token) node); + break; + case (int) SyntaxConstants.CDA: + EnterCda((Token) node); + break; + case (int) SyntaxConstants.NEG: + EnterNeg((Token) node); + break; + case (int) SyntaxConstants.ADD: + EnterAdd((Token) node); + break; + case (int) SyntaxConstants.SUB: + EnterSub((Token) node); + break; + case (int) SyntaxConstants.MUL: + EnterMul((Token) node); + break; + case (int) SyntaxConstants.DIV: + EnterDiv((Token) node); + break; + case (int) SyntaxConstants.MOD: + EnterMod((Token) node); + break; + case (int) SyntaxConstants.EXP: + EnterExp((Token) node); + break; + case (int) SyntaxConstants.OA: + EnterOa((Token) node); + break; + case (int) SyntaxConstants.CA: + EnterCa((Token) node); + break; + case (int) SyntaxConstants.OAE: + EnterOae((Token) node); + break; + case (int) SyntaxConstants.CAE: + EnterCae((Token) node); + break; + case (int) SyntaxConstants.EE: + EnterEe((Token) node); + break; + case (int) SyntaxConstants.DE: + EnterDe((Token) node); + break; + case (int) SyntaxConstants.EXC: + EnterExc((Token) node); + break; + case (int) SyntaxConstants.DAND: + EnterDand((Token) node); + break; + case (int) SyntaxConstants.DOR: + EnterDor((Token) node); + break; + case (int) SyntaxConstants.INCRE: + EnterIncre((Token) node); + break; + case (int) SyntaxConstants.DECRE: + EnterDecre((Token) node); + break; + case (int) SyntaxConstants.NEWT: + EnterNewt((Token) node); + break; + case (int) SyntaxConstants.DUCK: + EnterDuck((Token) node); + break; + case (int) SyntaxConstants.BULL: + EnterBull((Token) node); + break; + case (int) SyntaxConstants.STARLING: + EnterStarling((Token) node); + break; + case (int) SyntaxConstants.VIPER: + EnterViper((Token) node); + break; + case (int) SyntaxConstants.NEWTLIT: + EnterNewtlit((Token) node); + break; + case (int) SyntaxConstants.DUCKLIT: + EnterDucklit((Token) node); + break; + case (int) SyntaxConstants.STARLIT: + EnterStarlit((Token) node); + break; + case (int) SyntaxConstants.TRUE: + EnterTrue((Token) node); + break; + case (int) SyntaxConstants.FALSE: + EnterFalse((Token) node); + break; + case (int) SyntaxConstants.ID: + EnterId((Token) node); + break; + case (int) SyntaxConstants.COMMENT: + EnterComment((Token) node); + break; + case (int) SyntaxConstants.PROD_PROGRAM: + EnterProdProgram((Production) node); + break; + case (int) SyntaxConstants.PROD_COMMENT: + EnterProdComment((Production) node); + break; + case (int) SyntaxConstants.PROD_GLOBAL_DEC: + EnterProdGlobalDec((Production) node); + break; + case (int) SyntaxConstants.PROD_VAR_DEC: + EnterProdVarDec((Production) node); + break; + case (int) SyntaxConstants.PROD_FUNC_VAR: + EnterProdFuncVar((Production) node); + break; + case (int) SyntaxConstants.PROD_IDENT_VAR: + EnterProdIdentVar((Production) node); + break; + case (int) SyntaxConstants.PROD_DTYPE: + EnterProdDtype((Production) node); + break; + case (int) SyntaxConstants.PROD_NEXT2VAR: + EnterProdNext2var((Production) node); + break; + case (int) SyntaxConstants.PROD_NEXT2VAR_TAIL: + EnterProdNext2varTail((Production) node); + break; + case (int) SyntaxConstants.PROD_VAL: + EnterProdVal((Production) node); + break; + case (int) SyntaxConstants.PROD_VAL1: + EnterProdVal1((Production) node); + break; + case (int) SyntaxConstants.PROD_VAL2: + EnterProdVal2((Production) node); + break; + case (int) SyntaxConstants.PROD_BUL_LIT: + EnterProdBulLit((Production) node); + break; + case (int) SyntaxConstants.PROD_ARRAY1D: + EnterProdArray1d((Production) node); + break; + case (int) SyntaxConstants.PROD_ELEM1D_NEXT: + EnterProdElem1dNext((Production) node); + break; + case (int) SyntaxConstants.PROD_ELEM1D_LIST: + EnterProdElem1dList((Production) node); + break; + case (int) SyntaxConstants.PROD_ELEMLIST1D_TAIL: + EnterProdElemlist1dTail((Production) node); + break; + case (int) SyntaxConstants.PROD_ELEM2D_NEXT: + EnterProdElem2dNext((Production) node); + break; + case (int) SyntaxConstants.PROD_ELEM2D_LIST: + EnterProdElem2dList((Production) node); + break; + case (int) SyntaxConstants.PROD_ELEM2D_LIST_TAIL: + EnterProdElem2dListTail((Production) node); + break; + case (int) SyntaxConstants.PROD_SIZE: + EnterProdSize((Production) node); + break; + case (int) SyntaxConstants.PROD_CONST_DEC: + EnterProdConstDec((Production) node); + break; + case (int) SyntaxConstants.PROD_CONST_NEXT: + EnterProdConstNext((Production) node); + break; + case (int) SyntaxConstants.PROD_FUNC_NAME: + EnterProdFuncName((Production) node); + break; + case (int) SyntaxConstants.PROD_PARAM: + EnterProdParam((Production) node); + break; + case (int) SyntaxConstants.PROD_PARAM2: + EnterProdParam2((Production) node); + break; + case (int) SyntaxConstants.PROD_STORK_DEC: + EnterProdStorkDec((Production) node); + break; + case (int) SyntaxConstants.PROD_STORK_ELEM: + EnterProdStorkElem((Production) node); + break; + case (int) SyntaxConstants.PROD_MULTI_VARDEC: + EnterProdMultiVardec((Production) node); + break; + case (int) SyntaxConstants.PROD_MULTISTORK_ELEM: + EnterProdMultistorkElem((Production) node); + break; + case (int) SyntaxConstants.PROD_OBJ_DEC: + EnterProdObjDec((Production) node); + break; + case (int) SyntaxConstants.PROD_MANE: + EnterProdMane((Production) node); + break; + case (int) SyntaxConstants.PROD_LOCAL_DEC: + EnterProdLocalDec((Production) node); + break; + case (int) SyntaxConstants.PROD_STATEMENT: + EnterProdStatement((Production) node); + break; + case (int) SyntaxConstants.PROD_STATE_NEXT: + EnterProdStateNext((Production) node); + break; + case (int) SyntaxConstants.PROD_ASSIGN1: + EnterProdAssign1((Production) node); + break; + case (int) SyntaxConstants.PROD_ASSIGN_TAIL: + EnterProdAssignTail((Production) node); + break; + case (int) SyntaxConstants.PROD_NEXT_FIG: + EnterProdNextFig((Production) node); + break; + case (int) SyntaxConstants.PROD_MATH_EQTAIL1: + EnterProdMathEqtail1((Production) node); + break; + case (int) SyntaxConstants.PROD_MATH_EQTAIL2: + EnterProdMathEqtail2((Production) node); + break; + case (int) SyntaxConstants.PROD_MATH_TAIL: + EnterProdMathTail((Production) node); + break; + case (int) SyntaxConstants.PROD_MATH_OP: + EnterProdMathOp((Production) node); + break; + case (int) SyntaxConstants.PROD_MATH_FIG: + EnterProdMathFig((Production) node); + break; + case (int) SyntaxConstants.PROD_MATH_FIG1: + EnterProdMathFig1((Production) node); + break; + case (int) SyntaxConstants.PROD_MATHEQ_NEXT: + EnterProdMatheqNext((Production) node); + break; + case (int) SyntaxConstants.PROD_FUNCTION_CALL: + EnterProdFunctionCall((Production) node); + break; + case (int) SyntaxConstants.PROD_SCAN_NEXT: + EnterProdScanNext((Production) node); + break; + case (int) SyntaxConstants.PROD_ARGS1: + EnterProdArgs1((Production) node); + break; + case (int) SyntaxConstants.PROD_ARGS_TAIL: + EnterProdArgsTail((Production) node); + break; + case (int) SyntaxConstants.PROD_ARG_IN: + EnterProdArgIn((Production) node); + break; + case (int) SyntaxConstants.PROD_CLRSCR: + EnterProdClrscr((Production) node); + break; + case (int) SyntaxConstants.PROD_INPUT: + EnterProdInput((Production) node); + break; + case (int) SyntaxConstants.PROD_SCAN_FIG: + EnterProdScanFig((Production) node); + break; + case (int) SyntaxConstants.PROD_MULTI_INPUT: + EnterProdMultiInput((Production) node); + break; + case (int) SyntaxConstants.PROD_ARR1D: + EnterProdArr1d((Production) node); + break; + case (int) SyntaxConstants.PROD_ARR2D: + EnterProdArr2d((Production) node); + break; + case (int) SyntaxConstants.PROD_STORK_ACCESS1: + EnterProdStorkAccess1((Production) node); + break; + case (int) SyntaxConstants.PROD_OUTPUT: + EnterProdOutput((Production) node); + break; + case (int) SyntaxConstants.PROD_OUT: + EnterProdOut((Production) node); + break; + case (int) SyntaxConstants.PROD_MULTI_OUTPUT: + EnterProdMultiOutput((Production) node); + break; + case (int) SyntaxConstants.PROD_CONDITIONAL: + EnterProdConditional((Production) node); + break; + case (int) SyntaxConstants.PROD_CONDI: + EnterProdCondi((Production) node); + break; + case (int) SyntaxConstants.PROD_NOT_FIG: + EnterProdNotFig((Production) node); + break; + case (int) SyntaxConstants.PROD_COND_EXPR: + EnterProdCondExpr((Production) node); + break; + case (int) SyntaxConstants.PROD_COND_TAIL: + EnterProdCondTail((Production) node); + break; + case (int) SyntaxConstants.PROD_REL_EXPR: + EnterProdRelExpr((Production) node); + break; + case (int) SyntaxConstants.PROD_RELEX_TAIL: + EnterProdRelexTail((Production) node); + break; + case (int) SyntaxConstants.PROD_EXPRESSION: + EnterProdExpression((Production) node); + break; + case (int) SyntaxConstants.PROD_REL_OP1: + EnterProdRelOp1((Production) node); + break; + case (int) SyntaxConstants.PROD_REL_OP2: + EnterProdRelOp2((Production) node); + break; + case (int) SyntaxConstants.PROD_REL_FIG: + EnterProdRelFig((Production) node); + break; + case (int) SyntaxConstants.PROD_LOG_EXPR: + EnterProdLogExpr((Production) node); + break; + case (int) SyntaxConstants.PROD_LOG_EXPR_NEXT: + EnterProdLogExprNext((Production) node); + break; + case (int) SyntaxConstants.PROD_LOG_OP: + EnterProdLogOp((Production) node); + break; + case (int) SyntaxConstants.PROD_COND_EELSIF: + EnterProdCondEelsif((Production) node); + break; + case (int) SyntaxConstants.PROD_COND_EELS: + EnterProdCondEels((Production) node); + break; + case (int) SyntaxConstants.PROD_SWASP_CASE: + EnterProdSwaspCase((Production) node); + break; + case (int) SyntaxConstants.PROD_SWASP_CASE1: + EnterProdSwaspCase1((Production) node); + break; + case (int) SyntaxConstants.PROD_TERM_EXPR: + EnterProdTermExpr((Production) node); + break; + case (int) SyntaxConstants.PROD_DEFAULT: + EnterProdDefault((Production) node); + break; + case (int) SyntaxConstants.PROD_ITERATIVE: + EnterProdIterative((Production) node); + break; + case (int) SyntaxConstants.PROD_LOOP_FIG1: + EnterProdLoopFig1((Production) node); + break; + case (int) SyntaxConstants.PROD_REL_EXPR1: + EnterProdRelExpr1((Production) node); + break; + case (int) SyntaxConstants.PROD_LOOP_FIG2: + EnterProdLoopFig2((Production) node); + break; + case (int) SyntaxConstants.PROD_INCREM_DECREM: + EnterProdIncremDecrem((Production) node); + break; + case (int) SyntaxConstants.PROD_VAR: + EnterProdVar((Production) node); + break; + case (int) SyntaxConstants.PROD_UNARY_OP: + EnterProdUnaryOp((Production) node); + break; + case (int) SyntaxConstants.PROD_SUB_FUNCTION: + EnterProdSubFunction((Production) node); + break; + case (int) SyntaxConstants.PROD_FUNC_INSIDE: + EnterProdFuncInside((Production) node); + break; + case (int) SyntaxConstants.PROD_FUNC_ARGS: + EnterProdFuncArgs((Production) node); + break; + case (int) SyntaxConstants.PROD_MULTIFUNC_ARGS: + EnterProdMultifuncArgs((Production) node); + break; + case (int) SyntaxConstants.PROD_RESULT: + EnterProdResult((Production) node); + break; + case (int) SyntaxConstants.PROD_FIG_TAIL: + EnterProdFigTail((Production) node); + break; + case (int) SyntaxConstants.PROD_RESULT_TAIL: + EnterProdResultTail((Production) node); + break; + } + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public override Node Exit(Node node) { + switch (node.Id) { + case (int) SyntaxConstants.ENTRANCE: + return ExitEntrance((Token) node); + case (int) SyntaxConstants.EXIT: + return ExitExit((Token) node); + case (int) SyntaxConstants.MANE: + return ExitMane((Token) node); + case (int) SyntaxConstants.LET: + return ExitLet((Token) node); + case (int) SyntaxConstants.WIPE: + return ExitWipe((Token) node); + case (int) SyntaxConstants.ZOOIN: + return ExitZooin((Token) node); + case (int) SyntaxConstants.ZOOUT: + return ExitZoout((Token) node); + case (int) SyntaxConstants.IF: + return ExitIf((Token) node); + case (int) SyntaxConstants.EELSIF: + return ExitEelsif((Token) node); + case (int) SyntaxConstants.EELS: + return ExitEels((Token) node); + case (int) SyntaxConstants.CHAMOIS: + return ExitChamois((Token) node); + case (int) SyntaxConstants.TERMITE: + return ExitTermite((Token) node); + case (int) SyntaxConstants.SEAL: + return ExitSeal((Token) node); + case (int) SyntaxConstants.WHALE: + return ExitWhale((Token) node); + case (int) SyntaxConstants.DO: + return ExitDo((Token) node); + case (int) SyntaxConstants.FUR: + return ExitFur((Token) node); + case (int) SyntaxConstants.HOP: + return ExitHop((Token) node); + case (int) SyntaxConstants.SWASP: + return ExitSwasp((Token) node); + case (int) SyntaxConstants.STORK: + return ExitStork((Token) node); + case (int) SyntaxConstants.AT: + return ExitAt((Token) node); + case (int) SyntaxConstants.NULL: + return ExitNull((Token) node); + case (int) SyntaxConstants.COMSYM: + return ExitComsym((Token) node); + case (int) SyntaxConstants.TERMI: + return ExitTermi((Token) node); + case (int) SyntaxConstants.SC: + return ExitSc((Token) node); + case (int) SyntaxConstants.COMMA: + return ExitComma((Token) node); + case (int) SyntaxConstants.EQUAL: + return ExitEqual((Token) node); + case (int) SyntaxConstants.OB: + return ExitOb((Token) node); + case (int) SyntaxConstants.CB: + return ExitCb((Token) node); + case (int) SyntaxConstants.OC: + return ExitOc((Token) node); + case (int) SyntaxConstants.CC: + return ExitCc((Token) node); + case (int) SyntaxConstants.OP: + return ExitOp((Token) node); + case (int) SyntaxConstants.CP: + return ExitCp((Token) node); + case (int) SyntaxConstants.ODC: + return ExitOdc((Token) node); + case (int) SyntaxConstants.CDC: + return ExitCdc((Token) node); + case (int) SyntaxConstants.CONC: + return ExitConc((Token) node); + case (int) SyntaxConstants.CON: + return ExitCon((Token) node); + case (int) SyntaxConstants.ODA: + return ExitOda((Token) node); + case (int) SyntaxConstants.CDA: + return ExitCda((Token) node); + case (int) SyntaxConstants.NEG: + return ExitNeg((Token) node); + case (int) SyntaxConstants.ADD: + return ExitAdd((Token) node); + case (int) SyntaxConstants.SUB: + return ExitSub((Token) node); + case (int) SyntaxConstants.MUL: + return ExitMul((Token) node); + case (int) SyntaxConstants.DIV: + return ExitDiv((Token) node); + case (int) SyntaxConstants.MOD: + return ExitMod((Token) node); + case (int) SyntaxConstants.EXP: + return ExitExp((Token) node); + case (int) SyntaxConstants.OA: + return ExitOa((Token) node); + case (int) SyntaxConstants.CA: + return ExitCa((Token) node); + case (int) SyntaxConstants.OAE: + return ExitOae((Token) node); + case (int) SyntaxConstants.CAE: + return ExitCae((Token) node); + case (int) SyntaxConstants.EE: + return ExitEe((Token) node); + case (int) SyntaxConstants.DE: + return ExitDe((Token) node); + case (int) SyntaxConstants.EXC: + return ExitExc((Token) node); + case (int) SyntaxConstants.DAND: + return ExitDand((Token) node); + case (int) SyntaxConstants.DOR: + return ExitDor((Token) node); + case (int) SyntaxConstants.INCRE: + return ExitIncre((Token) node); + case (int) SyntaxConstants.DECRE: + return ExitDecre((Token) node); + case (int) SyntaxConstants.NEWT: + return ExitNewt((Token) node); + case (int) SyntaxConstants.DUCK: + return ExitDuck((Token) node); + case (int) SyntaxConstants.BULL: + return ExitBull((Token) node); + case (int) SyntaxConstants.STARLING: + return ExitStarling((Token) node); + case (int) SyntaxConstants.VIPER: + return ExitViper((Token) node); + case (int) SyntaxConstants.NEWTLIT: + return ExitNewtlit((Token) node); + case (int) SyntaxConstants.DUCKLIT: + return ExitDucklit((Token) node); + case (int) SyntaxConstants.STARLIT: + return ExitStarlit((Token) node); + case (int) SyntaxConstants.TRUE: + return ExitTrue((Token) node); + case (int) SyntaxConstants.FALSE: + return ExitFalse((Token) node); + case (int) SyntaxConstants.ID: + return ExitId((Token) node); + case (int) SyntaxConstants.COMMENT: + return ExitComment((Token) node); + case (int) SyntaxConstants.PROD_PROGRAM: + return ExitProdProgram((Production) node); + case (int) SyntaxConstants.PROD_COMMENT: + return ExitProdComment((Production) node); + case (int) SyntaxConstants.PROD_GLOBAL_DEC: + return ExitProdGlobalDec((Production) node); + case (int) SyntaxConstants.PROD_VAR_DEC: + return ExitProdVarDec((Production) node); + case (int) SyntaxConstants.PROD_FUNC_VAR: + return ExitProdFuncVar((Production) node); + case (int) SyntaxConstants.PROD_IDENT_VAR: + return ExitProdIdentVar((Production) node); + case (int) SyntaxConstants.PROD_DTYPE: + return ExitProdDtype((Production) node); + case (int) SyntaxConstants.PROD_NEXT2VAR: + return ExitProdNext2var((Production) node); + case (int) SyntaxConstants.PROD_NEXT2VAR_TAIL: + return ExitProdNext2varTail((Production) node); + case (int) SyntaxConstants.PROD_VAL: + return ExitProdVal((Production) node); + case (int) SyntaxConstants.PROD_VAL1: + return ExitProdVal1((Production) node); + case (int) SyntaxConstants.PROD_VAL2: + return ExitProdVal2((Production) node); + case (int) SyntaxConstants.PROD_BUL_LIT: + return ExitProdBulLit((Production) node); + case (int) SyntaxConstants.PROD_ARRAY1D: + return ExitProdArray1d((Production) node); + case (int) SyntaxConstants.PROD_ELEM1D_NEXT: + return ExitProdElem1dNext((Production) node); + case (int) SyntaxConstants.PROD_ELEM1D_LIST: + return ExitProdElem1dList((Production) node); + case (int) SyntaxConstants.PROD_ELEMLIST1D_TAIL: + return ExitProdElemlist1dTail((Production) node); + case (int) SyntaxConstants.PROD_ELEM2D_NEXT: + return ExitProdElem2dNext((Production) node); + case (int) SyntaxConstants.PROD_ELEM2D_LIST: + return ExitProdElem2dList((Production) node); + case (int) SyntaxConstants.PROD_ELEM2D_LIST_TAIL: + return ExitProdElem2dListTail((Production) node); + case (int) SyntaxConstants.PROD_SIZE: + return ExitProdSize((Production) node); + case (int) SyntaxConstants.PROD_CONST_DEC: + return ExitProdConstDec((Production) node); + case (int) SyntaxConstants.PROD_CONST_NEXT: + return ExitProdConstNext((Production) node); + case (int) SyntaxConstants.PROD_FUNC_NAME: + return ExitProdFuncName((Production) node); + case (int) SyntaxConstants.PROD_PARAM: + return ExitProdParam((Production) node); + case (int) SyntaxConstants.PROD_PARAM2: + return ExitProdParam2((Production) node); + case (int) SyntaxConstants.PROD_STORK_DEC: + return ExitProdStorkDec((Production) node); + case (int) SyntaxConstants.PROD_STORK_ELEM: + return ExitProdStorkElem((Production) node); + case (int) SyntaxConstants.PROD_MULTI_VARDEC: + return ExitProdMultiVardec((Production) node); + case (int) SyntaxConstants.PROD_MULTISTORK_ELEM: + return ExitProdMultistorkElem((Production) node); + case (int) SyntaxConstants.PROD_OBJ_DEC: + return ExitProdObjDec((Production) node); + case (int) SyntaxConstants.PROD_MANE: + return ExitProdMane((Production) node); + case (int) SyntaxConstants.PROD_LOCAL_DEC: + return ExitProdLocalDec((Production) node); + case (int) SyntaxConstants.PROD_STATEMENT: + return ExitProdStatement((Production) node); + case (int) SyntaxConstants.PROD_STATE_NEXT: + return ExitProdStateNext((Production) node); + case (int) SyntaxConstants.PROD_ASSIGN1: + return ExitProdAssign1((Production) node); + case (int) SyntaxConstants.PROD_ASSIGN_TAIL: + return ExitProdAssignTail((Production) node); + case (int) SyntaxConstants.PROD_NEXT_FIG: + return ExitProdNextFig((Production) node); + case (int) SyntaxConstants.PROD_MATH_EQTAIL1: + return ExitProdMathEqtail1((Production) node); + case (int) SyntaxConstants.PROD_MATH_EQTAIL2: + return ExitProdMathEqtail2((Production) node); + case (int) SyntaxConstants.PROD_MATH_TAIL: + return ExitProdMathTail((Production) node); + case (int) SyntaxConstants.PROD_MATH_OP: + return ExitProdMathOp((Production) node); + case (int) SyntaxConstants.PROD_MATH_FIG: + return ExitProdMathFig((Production) node); + case (int) SyntaxConstants.PROD_MATH_FIG1: + return ExitProdMathFig1((Production) node); + case (int) SyntaxConstants.PROD_MATHEQ_NEXT: + return ExitProdMatheqNext((Production) node); + case (int) SyntaxConstants.PROD_FUNCTION_CALL: + return ExitProdFunctionCall((Production) node); + case (int) SyntaxConstants.PROD_SCAN_NEXT: + return ExitProdScanNext((Production) node); + case (int) SyntaxConstants.PROD_ARGS1: + return ExitProdArgs1((Production) node); + case (int) SyntaxConstants.PROD_ARGS_TAIL: + return ExitProdArgsTail((Production) node); + case (int) SyntaxConstants.PROD_ARG_IN: + return ExitProdArgIn((Production) node); + case (int) SyntaxConstants.PROD_CLRSCR: + return ExitProdClrscr((Production) node); + case (int) SyntaxConstants.PROD_INPUT: + return ExitProdInput((Production) node); + case (int) SyntaxConstants.PROD_SCAN_FIG: + return ExitProdScanFig((Production) node); + case (int) SyntaxConstants.PROD_MULTI_INPUT: + return ExitProdMultiInput((Production) node); + case (int) SyntaxConstants.PROD_ARR1D: + return ExitProdArr1d((Production) node); + case (int) SyntaxConstants.PROD_ARR2D: + return ExitProdArr2d((Production) node); + case (int) SyntaxConstants.PROD_STORK_ACCESS1: + return ExitProdStorkAccess1((Production) node); + case (int) SyntaxConstants.PROD_OUTPUT: + return ExitProdOutput((Production) node); + case (int) SyntaxConstants.PROD_OUT: + return ExitProdOut((Production) node); + case (int) SyntaxConstants.PROD_MULTI_OUTPUT: + return ExitProdMultiOutput((Production) node); + case (int) SyntaxConstants.PROD_CONDITIONAL: + return ExitProdConditional((Production) node); + case (int) SyntaxConstants.PROD_CONDI: + return ExitProdCondi((Production) node); + case (int) SyntaxConstants.PROD_NOT_FIG: + return ExitProdNotFig((Production) node); + case (int) SyntaxConstants.PROD_COND_EXPR: + return ExitProdCondExpr((Production) node); + case (int) SyntaxConstants.PROD_COND_TAIL: + return ExitProdCondTail((Production) node); + case (int) SyntaxConstants.PROD_REL_EXPR: + return ExitProdRelExpr((Production) node); + case (int) SyntaxConstants.PROD_RELEX_TAIL: + return ExitProdRelexTail((Production) node); + case (int) SyntaxConstants.PROD_EXPRESSION: + return ExitProdExpression((Production) node); + case (int) SyntaxConstants.PROD_REL_OP1: + return ExitProdRelOp1((Production) node); + case (int) SyntaxConstants.PROD_REL_OP2: + return ExitProdRelOp2((Production) node); + case (int) SyntaxConstants.PROD_REL_FIG: + return ExitProdRelFig((Production) node); + case (int) SyntaxConstants.PROD_LOG_EXPR: + return ExitProdLogExpr((Production) node); + case (int) SyntaxConstants.PROD_LOG_EXPR_NEXT: + return ExitProdLogExprNext((Production) node); + case (int) SyntaxConstants.PROD_LOG_OP: + return ExitProdLogOp((Production) node); + case (int) SyntaxConstants.PROD_COND_EELSIF: + return ExitProdCondEelsif((Production) node); + case (int) SyntaxConstants.PROD_COND_EELS: + return ExitProdCondEels((Production) node); + case (int) SyntaxConstants.PROD_SWASP_CASE: + return ExitProdSwaspCase((Production) node); + case (int) SyntaxConstants.PROD_SWASP_CASE1: + return ExitProdSwaspCase1((Production) node); + case (int) SyntaxConstants.PROD_TERM_EXPR: + return ExitProdTermExpr((Production) node); + case (int) SyntaxConstants.PROD_DEFAULT: + return ExitProdDefault((Production) node); + case (int) SyntaxConstants.PROD_ITERATIVE: + return ExitProdIterative((Production) node); + case (int) SyntaxConstants.PROD_LOOP_FIG1: + return ExitProdLoopFig1((Production) node); + case (int) SyntaxConstants.PROD_REL_EXPR1: + return ExitProdRelExpr1((Production) node); + case (int) SyntaxConstants.PROD_LOOP_FIG2: + return ExitProdLoopFig2((Production) node); + case (int) SyntaxConstants.PROD_INCREM_DECREM: + return ExitProdIncremDecrem((Production) node); + case (int) SyntaxConstants.PROD_VAR: + return ExitProdVar((Production) node); + case (int) SyntaxConstants.PROD_UNARY_OP: + return ExitProdUnaryOp((Production) node); + case (int) SyntaxConstants.PROD_SUB_FUNCTION: + return ExitProdSubFunction((Production) node); + case (int) SyntaxConstants.PROD_FUNC_INSIDE: + return ExitProdFuncInside((Production) node); + case (int) SyntaxConstants.PROD_FUNC_ARGS: + return ExitProdFuncArgs((Production) node); + case (int) SyntaxConstants.PROD_MULTIFUNC_ARGS: + return ExitProdMultifuncArgs((Production) node); + case (int) SyntaxConstants.PROD_RESULT: + return ExitProdResult((Production) node); + case (int) SyntaxConstants.PROD_FIG_TAIL: + return ExitProdFigTail((Production) node); + case (int) SyntaxConstants.PROD_RESULT_TAIL: + return ExitProdResultTail((Production) node); + } + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public override void Child(Production node, Node child) { + switch (node.Id) { + case (int) SyntaxConstants.PROD_PROGRAM: + ChildProdProgram(node, child); + break; + case (int) SyntaxConstants.PROD_COMMENT: + ChildProdComment(node, child); + break; + case (int) SyntaxConstants.PROD_GLOBAL_DEC: + ChildProdGlobalDec(node, child); + break; + case (int) SyntaxConstants.PROD_VAR_DEC: + ChildProdVarDec(node, child); + break; + case (int) SyntaxConstants.PROD_FUNC_VAR: + ChildProdFuncVar(node, child); + break; + case (int) SyntaxConstants.PROD_IDENT_VAR: + ChildProdIdentVar(node, child); + break; + case (int) SyntaxConstants.PROD_DTYPE: + ChildProdDtype(node, child); + break; + case (int) SyntaxConstants.PROD_NEXT2VAR: + ChildProdNext2var(node, child); + break; + case (int) SyntaxConstants.PROD_NEXT2VAR_TAIL: + ChildProdNext2varTail(node, child); + break; + case (int) SyntaxConstants.PROD_VAL: + ChildProdVal(node, child); + break; + case (int) SyntaxConstants.PROD_VAL1: + ChildProdVal1(node, child); + break; + case (int) SyntaxConstants.PROD_VAL2: + ChildProdVal2(node, child); + break; + case (int) SyntaxConstants.PROD_BUL_LIT: + ChildProdBulLit(node, child); + break; + case (int) SyntaxConstants.PROD_ARRAY1D: + ChildProdArray1d(node, child); + break; + case (int) SyntaxConstants.PROD_ELEM1D_NEXT: + ChildProdElem1dNext(node, child); + break; + case (int) SyntaxConstants.PROD_ELEM1D_LIST: + ChildProdElem1dList(node, child); + break; + case (int) SyntaxConstants.PROD_ELEMLIST1D_TAIL: + ChildProdElemlist1dTail(node, child); + break; + case (int) SyntaxConstants.PROD_ELEM2D_NEXT: + ChildProdElem2dNext(node, child); + break; + case (int) SyntaxConstants.PROD_ELEM2D_LIST: + ChildProdElem2dList(node, child); + break; + case (int) SyntaxConstants.PROD_ELEM2D_LIST_TAIL: + ChildProdElem2dListTail(node, child); + break; + case (int) SyntaxConstants.PROD_SIZE: + ChildProdSize(node, child); + break; + case (int) SyntaxConstants.PROD_CONST_DEC: + ChildProdConstDec(node, child); + break; + case (int) SyntaxConstants.PROD_CONST_NEXT: + ChildProdConstNext(node, child); + break; + case (int) SyntaxConstants.PROD_FUNC_NAME: + ChildProdFuncName(node, child); + break; + case (int) SyntaxConstants.PROD_PARAM: + ChildProdParam(node, child); + break; + case (int) SyntaxConstants.PROD_PARAM2: + ChildProdParam2(node, child); + break; + case (int) SyntaxConstants.PROD_STORK_DEC: + ChildProdStorkDec(node, child); + break; + case (int) SyntaxConstants.PROD_STORK_ELEM: + ChildProdStorkElem(node, child); + break; + case (int) SyntaxConstants.PROD_MULTI_VARDEC: + ChildProdMultiVardec(node, child); + break; + case (int) SyntaxConstants.PROD_MULTISTORK_ELEM: + ChildProdMultistorkElem(node, child); + break; + case (int) SyntaxConstants.PROD_OBJ_DEC: + ChildProdObjDec(node, child); + break; + case (int) SyntaxConstants.PROD_MANE: + ChildProdMane(node, child); + break; + case (int) SyntaxConstants.PROD_LOCAL_DEC: + ChildProdLocalDec(node, child); + break; + case (int) SyntaxConstants.PROD_STATEMENT: + ChildProdStatement(node, child); + break; + case (int) SyntaxConstants.PROD_STATE_NEXT: + ChildProdStateNext(node, child); + break; + case (int) SyntaxConstants.PROD_ASSIGN1: + ChildProdAssign1(node, child); + break; + case (int) SyntaxConstants.PROD_ASSIGN_TAIL: + ChildProdAssignTail(node, child); + break; + case (int) SyntaxConstants.PROD_NEXT_FIG: + ChildProdNextFig(node, child); + break; + case (int) SyntaxConstants.PROD_MATH_EQTAIL1: + ChildProdMathEqtail1(node, child); + break; + case (int) SyntaxConstants.PROD_MATH_EQTAIL2: + ChildProdMathEqtail2(node, child); + break; + case (int) SyntaxConstants.PROD_MATH_TAIL: + ChildProdMathTail(node, child); + break; + case (int) SyntaxConstants.PROD_MATH_OP: + ChildProdMathOp(node, child); + break; + case (int) SyntaxConstants.PROD_MATH_FIG: + ChildProdMathFig(node, child); + break; + case (int) SyntaxConstants.PROD_MATH_FIG1: + ChildProdMathFig1(node, child); + break; + case (int) SyntaxConstants.PROD_MATHEQ_NEXT: + ChildProdMatheqNext(node, child); + break; + case (int) SyntaxConstants.PROD_FUNCTION_CALL: + ChildProdFunctionCall(node, child); + break; + case (int) SyntaxConstants.PROD_SCAN_NEXT: + ChildProdScanNext(node, child); + break; + case (int) SyntaxConstants.PROD_ARGS1: + ChildProdArgs1(node, child); + break; + case (int) SyntaxConstants.PROD_ARGS_TAIL: + ChildProdArgsTail(node, child); + break; + case (int) SyntaxConstants.PROD_ARG_IN: + ChildProdArgIn(node, child); + break; + case (int) SyntaxConstants.PROD_CLRSCR: + ChildProdClrscr(node, child); + break; + case (int) SyntaxConstants.PROD_INPUT: + ChildProdInput(node, child); + break; + case (int) SyntaxConstants.PROD_SCAN_FIG: + ChildProdScanFig(node, child); + break; + case (int) SyntaxConstants.PROD_MULTI_INPUT: + ChildProdMultiInput(node, child); + break; + case (int) SyntaxConstants.PROD_ARR1D: + ChildProdArr1d(node, child); + break; + case (int) SyntaxConstants.PROD_ARR2D: + ChildProdArr2d(node, child); + break; + case (int) SyntaxConstants.PROD_STORK_ACCESS1: + ChildProdStorkAccess1(node, child); + break; + case (int) SyntaxConstants.PROD_OUTPUT: + ChildProdOutput(node, child); + break; + case (int) SyntaxConstants.PROD_OUT: + ChildProdOut(node, child); + break; + case (int) SyntaxConstants.PROD_MULTI_OUTPUT: + ChildProdMultiOutput(node, child); + break; + case (int) SyntaxConstants.PROD_CONDITIONAL: + ChildProdConditional(node, child); + break; + case (int) SyntaxConstants.PROD_CONDI: + ChildProdCondi(node, child); + break; + case (int) SyntaxConstants.PROD_NOT_FIG: + ChildProdNotFig(node, child); + break; + case (int) SyntaxConstants.PROD_COND_EXPR: + ChildProdCondExpr(node, child); + break; + case (int) SyntaxConstants.PROD_COND_TAIL: + ChildProdCondTail(node, child); + break; + case (int) SyntaxConstants.PROD_REL_EXPR: + ChildProdRelExpr(node, child); + break; + case (int) SyntaxConstants.PROD_RELEX_TAIL: + ChildProdRelexTail(node, child); + break; + case (int) SyntaxConstants.PROD_EXPRESSION: + ChildProdExpression(node, child); + break; + case (int) SyntaxConstants.PROD_REL_OP1: + ChildProdRelOp1(node, child); + break; + case (int) SyntaxConstants.PROD_REL_OP2: + ChildProdRelOp2(node, child); + break; + case (int) SyntaxConstants.PROD_REL_FIG: + ChildProdRelFig(node, child); + break; + case (int) SyntaxConstants.PROD_LOG_EXPR: + ChildProdLogExpr(node, child); + break; + case (int) SyntaxConstants.PROD_LOG_EXPR_NEXT: + ChildProdLogExprNext(node, child); + break; + case (int) SyntaxConstants.PROD_LOG_OP: + ChildProdLogOp(node, child); + break; + case (int) SyntaxConstants.PROD_COND_EELSIF: + ChildProdCondEelsif(node, child); + break; + case (int) SyntaxConstants.PROD_COND_EELS: + ChildProdCondEels(node, child); + break; + case (int) SyntaxConstants.PROD_SWASP_CASE: + ChildProdSwaspCase(node, child); + break; + case (int) SyntaxConstants.PROD_SWASP_CASE1: + ChildProdSwaspCase1(node, child); + break; + case (int) SyntaxConstants.PROD_TERM_EXPR: + ChildProdTermExpr(node, child); + break; + case (int) SyntaxConstants.PROD_DEFAULT: + ChildProdDefault(node, child); + break; + case (int) SyntaxConstants.PROD_ITERATIVE: + ChildProdIterative(node, child); + break; + case (int) SyntaxConstants.PROD_LOOP_FIG1: + ChildProdLoopFig1(node, child); + break; + case (int) SyntaxConstants.PROD_REL_EXPR1: + ChildProdRelExpr1(node, child); + break; + case (int) SyntaxConstants.PROD_LOOP_FIG2: + ChildProdLoopFig2(node, child); + break; + case (int) SyntaxConstants.PROD_INCREM_DECREM: + ChildProdIncremDecrem(node, child); + break; + case (int) SyntaxConstants.PROD_VAR: + ChildProdVar(node, child); + break; + case (int) SyntaxConstants.PROD_UNARY_OP: + ChildProdUnaryOp(node, child); + break; + case (int) SyntaxConstants.PROD_SUB_FUNCTION: + ChildProdSubFunction(node, child); + break; + case (int) SyntaxConstants.PROD_FUNC_INSIDE: + ChildProdFuncInside(node, child); + break; + case (int) SyntaxConstants.PROD_FUNC_ARGS: + ChildProdFuncArgs(node, child); + break; + case (int) SyntaxConstants.PROD_MULTIFUNC_ARGS: + ChildProdMultifuncArgs(node, child); + break; + case (int) SyntaxConstants.PROD_RESULT: + ChildProdResult(node, child); + break; + case (int) SyntaxConstants.PROD_FIG_TAIL: + ChildProdFigTail(node, child); + break; + case (int) SyntaxConstants.PROD_RESULT_TAIL: + ChildProdResultTail(node, child); + break; + } + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterEntrance(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitEntrance(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterExit(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitExit(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterMane(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitMane(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterLet(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitLet(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterWipe(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitWipe(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterZooin(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitZooin(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterZoout(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitZoout(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterIf(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitIf(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterEelsif(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitEelsif(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterEels(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitEels(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterChamois(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitChamois(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterTermite(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitTermite(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterSeal(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitSeal(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterWhale(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitWhale(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterDo(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitDo(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterFur(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitFur(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterHop(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitHop(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterSwasp(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitSwasp(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterStork(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitStork(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterAt(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitAt(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterNull(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitNull(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterComsym(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitComsym(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterTermi(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitTermi(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterSc(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitSc(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterComma(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitComma(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterEqual(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitEqual(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterOb(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitOb(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterCb(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitCb(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterOc(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitOc(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterCc(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitCc(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterOp(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitOp(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterCp(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitCp(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterOdc(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitOdc(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterCdc(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitCdc(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterConc(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitConc(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterCon(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitCon(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterOda(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitOda(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterCda(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitCda(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterNeg(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitNeg(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterAdd(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitAdd(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterSub(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitSub(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterMul(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitMul(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterDiv(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitDiv(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterMod(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitMod(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterExp(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitExp(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterOa(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitOa(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterCa(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitCa(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterOae(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitOae(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterCae(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitCae(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterEe(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitEe(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterDe(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitDe(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterExc(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitExc(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterDand(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitDand(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterDor(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitDor(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterIncre(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitIncre(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterDecre(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitDecre(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterNewt(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitNewt(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterDuck(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitDuck(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterBull(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitBull(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterStarling(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitStarling(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterViper(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitViper(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterNewtlit(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitNewtlit(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterDucklit(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitDucklit(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterStarlit(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitStarlit(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterTrue(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitTrue(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterFalse(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitFalse(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterId(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitId(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterComment(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitComment(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdProgram(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdProgram(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdProgram(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdComment(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdComment(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdComment(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdGlobalDec(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdGlobalDec(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdGlobalDec(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdVarDec(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdVarDec(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdVarDec(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdFuncVar(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdFuncVar(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdFuncVar(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdIdentVar(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdIdentVar(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdIdentVar(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdDtype(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdDtype(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdDtype(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdNext2var(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdNext2var(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdNext2var(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdNext2varTail(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdNext2varTail(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdNext2varTail(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdVal(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdVal(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdVal(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdVal1(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdVal1(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdVal1(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdVal2(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdVal2(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdVal2(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdBulLit(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdBulLit(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdBulLit(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdArray1d(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdArray1d(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdArray1d(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdElem1dNext(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdElem1dNext(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdElem1dNext(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdElem1dList(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdElem1dList(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdElem1dList(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdElemlist1dTail(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdElemlist1dTail(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdElemlist1dTail(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdElem2dNext(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdElem2dNext(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdElem2dNext(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdElem2dList(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdElem2dList(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdElem2dList(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdElem2dListTail(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdElem2dListTail(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdElem2dListTail(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdSize(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdSize(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdSize(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdConstDec(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdConstDec(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdConstDec(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdConstNext(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdConstNext(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdConstNext(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdFuncName(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdFuncName(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdFuncName(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdParam(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdParam(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdParam(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdParam2(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdParam2(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdParam2(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdStorkDec(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdStorkDec(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdStorkDec(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdStorkElem(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdStorkElem(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdStorkElem(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdMultiVardec(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdMultiVardec(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdMultiVardec(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdMultistorkElem(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdMultistorkElem(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdMultistorkElem(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdObjDec(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdObjDec(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdObjDec(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdMane(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdMane(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdMane(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdLocalDec(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdLocalDec(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdLocalDec(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdStatement(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdStatement(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdStatement(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdStateNext(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdStateNext(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdStateNext(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdAssign1(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdAssign1(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdAssign1(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdAssignTail(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdAssignTail(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdAssignTail(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdNextFig(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdNextFig(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdNextFig(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdMathEqtail1(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdMathEqtail1(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdMathEqtail1(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdMathEqtail2(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdMathEqtail2(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdMathEqtail2(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdMathTail(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdMathTail(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdMathTail(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdMathOp(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdMathOp(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdMathOp(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdMathFig(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdMathFig(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdMathFig(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdMathFig1(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdMathFig1(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdMathFig1(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdMatheqNext(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdMatheqNext(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdMatheqNext(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdFunctionCall(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdFunctionCall(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdFunctionCall(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdScanNext(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdScanNext(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdScanNext(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdArgs1(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdArgs1(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdArgs1(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdArgsTail(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdArgsTail(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdArgsTail(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdArgIn(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdArgIn(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdArgIn(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdClrscr(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdClrscr(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdClrscr(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdInput(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdInput(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdInput(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdScanFig(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdScanFig(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdScanFig(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdMultiInput(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdMultiInput(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdMultiInput(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdArr1d(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdArr1d(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdArr1d(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdArr2d(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdArr2d(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdArr2d(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdStorkAccess1(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdStorkAccess1(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdStorkAccess1(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdOutput(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdOutput(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdOutput(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdOut(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdOut(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdOut(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdMultiOutput(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdMultiOutput(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdMultiOutput(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdConditional(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdConditional(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdConditional(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdCondi(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdCondi(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdCondi(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdNotFig(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdNotFig(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdNotFig(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdCondExpr(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdCondExpr(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdCondExpr(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdCondTail(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdCondTail(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdCondTail(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdRelExpr(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdRelExpr(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdRelExpr(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdRelexTail(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdRelexTail(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdRelexTail(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdExpression(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdExpression(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdExpression(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdRelOp1(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdRelOp1(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdRelOp1(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdRelOp2(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdRelOp2(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdRelOp2(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdRelFig(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdRelFig(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdRelFig(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdLogExpr(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdLogExpr(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdLogExpr(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdLogExprNext(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdLogExprNext(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdLogExprNext(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdLogOp(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdLogOp(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdLogOp(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdCondEelsif(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdCondEelsif(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdCondEelsif(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdCondEels(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdCondEels(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdCondEels(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdSwaspCase(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdSwaspCase(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdSwaspCase(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdSwaspCase1(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdSwaspCase1(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdSwaspCase1(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdTermExpr(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdTermExpr(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdTermExpr(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdDefault(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdDefault(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdDefault(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdIterative(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdIterative(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdIterative(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdLoopFig1(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdLoopFig1(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdLoopFig1(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdRelExpr1(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdRelExpr1(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdRelExpr1(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdLoopFig2(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdLoopFig2(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdLoopFig2(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdIncremDecrem(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdIncremDecrem(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdIncremDecrem(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdVar(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdVar(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdVar(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdUnaryOp(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdUnaryOp(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdUnaryOp(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdSubFunction(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdSubFunction(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdSubFunction(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdFuncInside(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdFuncInside(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdFuncInside(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdFuncArgs(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdFuncArgs(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdFuncArgs(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdMultifuncArgs(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdMultifuncArgs(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdMultifuncArgs(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdResult(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdResult(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdResult(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdFigTail(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdFigTail(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdFigTail(Production node, Node child) { + node.AddChild(child); + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdResultTail(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdResultTail(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdResultTail(Production node, Node child) { + node.AddChild(child); + } +} diff --git a/Syntax Analyzer/SyntaxConstants.cs b/Syntax Analyzer/SyntaxConstants.cs new file mode 100644 index 0000000..fe8b683 --- /dev/null +++ b/Syntax Analyzer/SyntaxConstants.cs @@ -0,0 +1,175 @@ +/* + * SyntaxConstants.cs + * + * THIS FILE HAS BEEN GENERATED AUTOMATICALLY. DO NOT EDIT! + */ + +/** + * An enumeration with token and production node + * constants. + */ +public enum SyntaxConstants { + ENTRANCE = 1001, + EXIT = 1002, + MANE = 1003, + LET = 1004, + WIPE = 1005, + ZOOIN = 1006, + ZOOUT = 1007, + IF = 1008, + EELSIF = 1009, + EELS = 1010, + CHAMOIS = 1011, + TERMITE = 1012, + SEAL = 1013, + WHALE = 1014, + DO = 1015, + FUR = 1016, + HOP = 1017, + SWASP = 1018, + STORK = 1019, + AT = 1020, + NULL = 1021, + COMSYM = 1022, + TERMI = 1023, + SC = 1024, + COMMA = 1025, + EQUAL = 1026, + OB = 1027, + CB = 1028, + OC = 1029, + CC = 1030, + OP = 1031, + CP = 1032, + ODC = 1033, + CDC = 1034, + CONC = 1035, + CON = 1036, + ODA = 1037, + CDA = 1038, + NEG = 1039, + ADD = 1040, + SUB = 1041, + MUL = 1042, + DIV = 1043, + MOD = 1044, + EXP = 1045, + OA = 1046, + CA = 1047, + OAE = 1048, + CAE = 1049, + EE = 1050, + DE = 1051, + EXC = 1052, + DAND = 1053, + DOR = 1054, + INCRE = 1055, + DECRE = 1056, + NEWT = 1057, + DUCK = 1058, + BULL = 1059, + STARLING = 1060, + VIPER = 1061, + NEWTLIT = 1062, + DUCKLIT = 1063, + STARLIT = 1064, + TRUE = 1065, + FALSE = 1066, + ID = 1067, + COMMENT = 1068, + WHITESPACE = 1069, + PROD_PROGRAM = 2001, + PROD_COMMENT = 2002, + PROD_GLOBAL_DEC = 2003, + PROD_VAR_DEC = 2004, + PROD_FUNC_VAR = 2005, + PROD_IDENT_VAR = 2006, + PROD_DTYPE = 2007, + PROD_NEXT2VAR = 2008, + PROD_NEXT2VAR_TAIL = 2009, + PROD_VAL = 2010, + PROD_VAL1 = 2011, + PROD_VAL2 = 2012, + PROD_BUL_LIT = 2013, + PROD_ARRAY1D = 2014, + PROD_ELEM1D_NEXT = 2015, + PROD_ELEM1D_LIST = 2016, + PROD_ELEMLIST1D_TAIL = 2017, + PROD_ELEM2D_NEXT = 2018, + PROD_ELEM2D_LIST = 2019, + PROD_ELEM2D_LIST_TAIL = 2020, + PROD_SIZE = 2021, + PROD_CONST_DEC = 2022, + PROD_CONST_NEXT = 2023, + PROD_FUNC_NAME = 2024, + PROD_PARAM = 2025, + PROD_PARAM2 = 2026, + PROD_STORK_DEC = 2027, + PROD_STORK_ELEM = 2028, + PROD_MULTI_VARDEC = 2029, + PROD_MULTISTORK_ELEM = 2030, + PROD_OBJ_DEC = 2031, + PROD_MANE = 2032, + PROD_LOCAL_DEC = 2033, + PROD_STATEMENT = 2034, + PROD_STATE_NEXT = 2035, + PROD_ASSIGN1 = 2036, + PROD_ASSIGN_TAIL = 2037, + PROD_NEXT_FIG = 2038, + PROD_MATH_EQTAIL1 = 2039, + PROD_MATH_EQTAIL2 = 2040, + PROD_MATH_TAIL = 2041, + PROD_MATH_OP = 2042, + PROD_MATH_FIG = 2043, + PROD_MATH_FIG1 = 2044, + PROD_MATHEQ_NEXT = 2045, + PROD_FUNCTION_CALL = 2046, + PROD_SCAN_NEXT = 2047, + PROD_ARGS1 = 2048, + PROD_ARGS_TAIL = 2049, + PROD_ARG_IN = 2050, + PROD_CLRSCR = 2051, + PROD_INPUT = 2052, + PROD_SCAN_FIG = 2053, + PROD_MULTI_INPUT = 2054, + PROD_ARR1D = 2055, + PROD_ARR2D = 2056, + PROD_STORK_ACCESS1 = 2057, + PROD_OUTPUT = 2058, + PROD_OUT = 2059, + PROD_MULTI_OUTPUT = 2060, + PROD_CONDITIONAL = 2061, + PROD_CONDI = 2062, + PROD_NOT_FIG = 2063, + PROD_COND_EXPR = 2064, + PROD_COND_TAIL = 2065, + PROD_REL_EXPR = 2066, + PROD_RELEX_TAIL = 2067, + PROD_EXPRESSION = 2068, + PROD_REL_OP1 = 2069, + PROD_REL_OP2 = 2070, + PROD_REL_FIG = 2071, + PROD_LOG_EXPR = 2072, + PROD_LOG_EXPR_NEXT = 2073, + PROD_LOG_OP = 2074, + PROD_COND_EELSIF = 2075, + PROD_COND_EELS = 2076, + PROD_SWASP_CASE = 2077, + PROD_SWASP_CASE1 = 2078, + PROD_TERM_EXPR = 2079, + PROD_DEFAULT = 2080, + PROD_ITERATIVE = 2081, + PROD_LOOP_FIG1 = 2082, + PROD_REL_EXPR1 = 2083, + PROD_LOOP_FIG2 = 2084, + PROD_INCREM_DECREM = 2085, + PROD_VAR = 2086, + PROD_UNARY_OP = 2087, + PROD_SUB_FUNCTION = 2088, + PROD_FUNC_INSIDE = 2089, + PROD_FUNC_ARGS = 2090, + PROD_MULTIFUNC_ARGS = 2091, + PROD_RESULT = 2092, + PROD_FIG_TAIL = 2093, + PROD_RESULT_TAIL = 2094 +} diff --git a/Syntax Analyzer/SyntaxInitializer.cs b/Syntax Analyzer/SyntaxInitializer.cs new file mode 100644 index 0000000..3a7c0d2 --- /dev/null +++ b/Syntax Analyzer/SyntaxInitializer.cs @@ -0,0 +1,289 @@ +using System; +using System.IO; +using System.Collections.Generic; +using Core.Library; + +using TokenLibrary.TokenLibrary; + +namespace Syntax_Analyzer +{ + public class SyntaxInitializer : SyntaxAnalyzer + { + public string production = ""; + public string recursiveprod = ""; + Node currparent; + List prevparent = new List(); + List productions = new List(); + public List SET = new List(); + public List PRODUCTION = new List(); + + public override void Enter(Node node) + { + string name = node.GetName(); + if (name.Contains("prod_")) + { + node.SetParent(currparent); + name = name.Substring(5); + + if(currparent != null) + { + production += "Enter: <" + name + "> Parent: " + currparent.GetName() + "\n"; + productions.Add(node); + } + else + { + production += "Enter: <" + name + ">\n"; + productions.Add(node); + } + prevparent.Add(currparent); + currparent = node; + } + else + { + node.SetParent(currparent); + productions.Add(node); + production += "Enter: " + name + " Parent: " + currparent.GetName() + "\n"; + } + + } + public override Node Exit(Node node) + { + if(currparent == node) + { + currparent = prevparent[prevparent.Count-1]; + prevparent.RemoveAt(prevparent.Count - 1); + } + return node; + } + + public override Node Analyze(Node node) + { + return base.Analyze(node); + } + + public override Node Analyze(Node node, ParserLogException log) + { + return base.Analyze(node, log); + } + + public ErrorClass errors = new ErrorClass(); + public string Start(List tokens) + { + //Boolean isDone = false; + string tokenstream = ""; + string result; + int line = 1; + int linejump = 0; + foreach (var t in tokens) + { + if (t.getLines() != line) + { + linejump = t.getLines() - line; + line = t.getLines(); + for (int i = 0; i < linejump; i++) + { + tokenstream += "\n"; + } + } + tokenstream += t.getTokens() + " "; + } + tokenstream = tokenstream.TrimEnd(); + + Parser p; + p = CreateParser(tokenstream); + + try + { + Node parse = p.Parse(); + Fail("parsing succeeded"); + result = "Syntax Analyzer Succeeded..."; + } + catch (ParserCreationException e) + { + Fail(e.Message); + result = e.Message; + } + catch (ParserLogException e) + { + + List codes = p.GetAllProductionCode(); + PredictSet ps = new PredictSet(); + string message = "Expected: "; + errors.setColumn(e.GetError(0).Column); + errors.setLines(e.GetError(0).Line); + int ctr = GetSyntaxTable(codes); + //isDone = true; + + if(codes.Count - 1 >= ctr) + { + int code = codes[ctr]; + message += ps.GetPredictSet(code); + } + else + { + int code = codes[ctr - 1]; + message += ps.GetPredictSet(code); + } + //if (p.GetLastProductionState() == "NULL") + //{ + // int code = p.GetLastProductionCode(); + // message += ps.GetPredictSet(code); + //} + //else + //{ + // foreach (var item in e.GetError(0).Details) + // { + // message += item + ", "; + // } + //} + if (message == "Expected: ") + { + string errormessage = e.GetError(0).ErrorMessage; + if(errormessage.Contains("unexpected token")) + { + errormessage = ""; + foreach (var item in e.GetError(0).Details) + { + errormessage += item + ", "; + } + } + if (errormessage == "unexpected end of file") + errormessage = "\".\""; + + message += errormessage; + } + + //if (message == "Expected: @, (, &&, ||, >=, <=, <, >, ==, !=, )") + //{ + // message = "Expected: "; + // foreach (var item in e.GetError(0).Details) + // { + // message += item + ", "; + // } + //} + + message += "."; + + errors.setErrorMessage(message); + errors.setType(e.GetError(0).Type.ToString()); + result = e.Message; + + } + recursiveprod = p.GetRecursiveProduction(); + GetSyntaxTable(p.GetAllProductionCode()); + return result; + } + + private int GetSyntaxTable(List code) + { + SyntaxProductions prod = new SyntaxProductions(); + Boolean delete = true; + Node node = null; + string recprod = recursiveprod; + int ctr = -1, count = 1, prodcode = 0; + string currentparent = ""; + while (productions.Count != 0) + { + ctr++; + prodcode = code[ctr]; + node = productions[count]; + + + if (node.GetId() == prodcode) + { + + string nodename = node.GetName().ToLower(); + currentparent = node.GetParent().GetName(); + currentparent = currentparent.ToLower(); + currentparent = prod.GetProductionName(currentparent); + nodename = prod.GetProductionName(nodename); + delete = true; + if (currentparent.Contains("prod_")) + { + currentparent = "<" + currentparent.Substring(5) + ">"; + } + if(nodename.Contains("prod_")) + { + nodename = "<" + nodename.Substring(5) + ">"; + } + + PRODUCTION.Add(currentparent); + SET.Add(nodename); + } + else + { + + string name = Enum.GetName(typeof(SyntaxConstants), prodcode); + name = name.ToLower(); + name = prod.GetProductionName(name); + if (name.Contains("prod_")) + { + name = "<" + name.Substring(5) + ">"; + } + + if (PRODUCTION.Count != 1) + { + currentparent.ToLower(); + currentparent = prod.GetProductionName(currentparent); + if (currentparent.Contains("prod_")) + { + currentparent = "<" + currentparent.Substring(5) + ">"; + } + PRODUCTION.Add(currentparent); + SET.Add(name); + PRODUCTION.Add(name); + SET.Add("λ"); + delete = false; + } + else + { + PRODUCTION.Add(""); + SET.Add(name); + PRODUCTION.Add(name); + SET.Add("λ"); + delete = false; + } + } + + if (count != 1 && delete) + { + productions.RemoveAt(0); + } + else if(delete) + { + productions.RemoveAt(0); + productions.RemoveAt(0); + count = 0; + } + + + } + return (ctr + 1); + } + + private Parser CreateParser(string input) + { + Parser parser = null; + try + { + parser = new SyntaxParser(new StringReader(input), this); + parser.Prepare(); + + } + catch (ParserCreationException e) + { + Fail(e.Message); + } + return parser; + } + + protected void Fail(string message) + { + if (message != "parsing succeeded") + throw new Exception(message); + } + + + + } +} diff --git a/Syntax Analyzer/SyntaxParser.cs b/Syntax Analyzer/SyntaxParser.cs new file mode 100644 index 0000000..73e87e7 --- /dev/null +++ b/Syntax Analyzer/SyntaxParser.cs @@ -0,0 +1,1211 @@ +/* + * SyntaxParser.cs + * + * THIS FILE HAS BEEN GENERATED AUTOMATICALLY. DO NOT EDIT! + */ + +using System.IO; + +using Core.Library; + +/** + * A token stream parser. + */ +public class SyntaxParser : RecursiveDescentParser { + + /** + * An enumeration with the generated production node + * identity constants. + */ + private enum SynteticPatterns { + } + + /** + * Creates a new parser with a default analyzer. + * + * the input stream to read from + * + * if the parser + * couldn't be initialized correctly + */ + public SyntaxParser(TextReader input) + : base(input) { + + CreatePatterns(); + } + + /** + * Creates a new parser. + * + * the input stream to read from + * + * the analyzer to parse with + * + * if the parser + * couldn't be initialized correctly + */ + public SyntaxParser(TextReader input, SyntaxAnalyzer analyzer) + : base(input, analyzer) { + + CreatePatterns(); + } + + /** + * Creates a new tokenizer for this parser. Can be overridden + * by a subclass to provide a custom implementation. + * + * the input stream to read from + * + * the tokenizer created + * + * if the tokenizer + * couldn't be initialized correctly + */ + protected override Tokenizer NewTokenizer(TextReader input) { + return new SyntaxTokenizer(input); + } + + /** + * Initializes the parser by creating all the production + * patterns. + * + * if the parser + * couldn't be initialized correctly + */ + private void CreatePatterns() { + ProductionPattern pattern; + ProductionPatternAlternative alt; + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_PROGRAM, + "prod_program"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.ENTRANCE, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); + alt.AddProduction((int) SyntaxConstants.PROD_GLOBAL_DEC, 0, 1); + alt.AddToken((int) SyntaxConstants.MANE, 1, 1); + alt.AddToken((int) SyntaxConstants.OP, 1, 1); + alt.AddToken((int) SyntaxConstants.CP, 1, 1); + alt.AddToken((int) SyntaxConstants.ODC, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_MANE, 0, 1); + alt.AddToken((int) SyntaxConstants.CDC, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_SUB_FUNCTION, 0, 1); + alt.AddToken((int) SyntaxConstants.EXIT, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_COMMENT, + "prod_comment"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.COMSYM, 1, 1); + alt.AddToken((int) SyntaxConstants.COMMENT, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_GLOBAL_DEC, + "prod_global_dec"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_STORK_DEC, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_GLOBAL_DEC, 0, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_CONST_DEC, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_GLOBAL_DEC, 0, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_VAR_DEC, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_GLOBAL_DEC, 0, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.VIPER, 1, 1); + alt.AddToken((int) SyntaxConstants.AT, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_FUNC_NAME, 1, 1); + alt.AddToken((int) SyntaxConstants.OP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_PARAM, 0, 1); + alt.AddToken((int) SyntaxConstants.CP, 1, 1); + alt.AddToken((int) SyntaxConstants.TERMI, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_VAR_DEC, + "prod_var_dec"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_IDENT_VAR, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_FUNC_VAR, 0, 1); + alt.AddToken((int) SyntaxConstants.TERMI, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_FUNC_VAR, + "prod_func_var"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.OP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_PARAM, 0, 1); + alt.AddToken((int) SyntaxConstants.CP, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_NEXT2VAR, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_IDENT_VAR, + "prod_ident_var"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_DTYPE, 1, 1); + alt.AddToken((int) SyntaxConstants.AT, 1, 1); + alt.AddToken((int) SyntaxConstants.ID, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_DTYPE, + "prod_dtype"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.NEWT, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.DUCK, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.STARLING, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.BULL, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_NEXT2VAR, + "prod_next2var"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.COMMA, 1, 1); + alt.AddToken((int) SyntaxConstants.ID, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_NEXT2VAR, 0, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.EQUAL, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_VAL, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_NEXT2VAR_TAIL, 0, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_ARRAY1D, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_NEXT2VAR_TAIL, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_NEXT2VAR_TAIL, + "prod_next2var_tail"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.COMMA, 1, 1); + alt.AddToken((int) SyntaxConstants.ID, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_NEXT2VAR, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_VAL, + "prod_val"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_VAL1, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_VAL2, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_VAL1, + "prod_val1"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.NEWTLIT, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.DUCKLIT, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_VAL2, + "prod_val2"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.STARLIT, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_BUL_LIT, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_BUL_LIT, + "prod_bulLit"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.TRUE, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.FALSE, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_ARRAY1D, + "prod_array1D"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.OB, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_SIZE, 0, 1); + alt.AddToken((int) SyntaxConstants.CB, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_ELEM1D_NEXT, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_ELEM1D_NEXT, + "prod_elem1D_next"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.EQUAL, 1, 1); + alt.AddToken((int) SyntaxConstants.OC, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_ELEM1D_LIST, 1, 1); + alt.AddToken((int) SyntaxConstants.CC, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.OB, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_SIZE, 0, 1); + alt.AddToken((int) SyntaxConstants.CB, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_ELEM2D_NEXT, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_ELEM1D_LIST, + "prod_elem1D_list"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_VAL, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_ELEMLIST1D_TAIL, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_ELEMLIST1D_TAIL, + "prod_elemlist1D_tail"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.COMMA, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_VAL, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_ELEMLIST1D_TAIL, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_ELEM2D_NEXT, + "prod_elem2D_next"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.EQUAL, 1, 1); + alt.AddToken((int) SyntaxConstants.OC, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_ELEM2D_LIST, 1, 1); + alt.AddToken((int) SyntaxConstants.CC, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_ELEM2D_LIST, + "prod_elem2D_list"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.OP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_ELEM1D_LIST, 1, 1); + alt.AddToken((int) SyntaxConstants.CP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_ELEM2D_LIST_TAIL, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_ELEM2D_LIST_TAIL, + "prod_elem2D_list_tail"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.COMMA, 1, 1); + alt.AddToken((int) SyntaxConstants.OP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_ELEM1D_LIST, 1, 1); + alt.AddToken((int) SyntaxConstants.CP, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_SIZE, + "prod_size"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.NEWTLIT, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.ID, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_CONST_DEC, + "prod_const_dec"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.LET, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_IDENT_VAR, 1, 1); + alt.AddToken((int) SyntaxConstants.EQUAL, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_VAL, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_CONST_NEXT, 0, 1); + alt.AddToken((int) SyntaxConstants.TERMI, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_CONST_NEXT, + "prod_const_next"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.COMMA, 1, 1); + alt.AddToken((int) SyntaxConstants.ID, 1, 1); + alt.AddToken((int) SyntaxConstants.EQUAL, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_VAL, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_CONST_NEXT, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_FUNC_NAME, + "prod_func_name"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.ID, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_PARAM, + "prod_param"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_DTYPE, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_PARAM2, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_PARAM2, + "prod_param2"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.COMMA, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_DTYPE, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_PARAM2, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_STORK_DEC, + "prod_stork_dec"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.STORK, 1, 1); + alt.AddToken((int) SyntaxConstants.AT, 1, 1); + alt.AddToken((int) SyntaxConstants.ID, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); + alt.AddToken((int) SyntaxConstants.ODC, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_STORK_ELEM, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_MULTISTORK_ELEM, 0, 1); + alt.AddToken((int) SyntaxConstants.CDC, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_OBJ_DEC, 0, 1); + alt.AddToken((int) SyntaxConstants.TERMI, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_STORK_ELEM, + "prod_stork_elem"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_IDENT_VAR, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_MULTI_VARDEC, 0, 1); + alt.AddToken((int) SyntaxConstants.TERMI, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_MULTI_VARDEC, + "prod_multi_vardec"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.COMMA, 1, 1); + alt.AddToken((int) SyntaxConstants.ID, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_MULTI_VARDEC, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_MULTISTORK_ELEM, + "prod_multistork_elem"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_STORK_ELEM, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_OBJ_DEC, + "prod_obj_dec"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.ID, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_MULTI_VARDEC, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_MANE, + "prod_mane"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_LOCAL_DEC, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 0, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_LOCAL_DEC, + "prod_local_dec"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_IDENT_VAR, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_NEXT2VAR, 0, 1); + alt.AddToken((int) SyntaxConstants.TERMI, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_LOCAL_DEC, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_STATEMENT, + "prod_statement"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_INPUT, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 0, 1); + alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_OUTPUT, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 0, 1); + alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_CONDITIONAL, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 0, 1); + alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_ITERATIVE, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 0, 1); + alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.ID, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_STATE_NEXT, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 0, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_CLRSCR, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_STATE_NEXT, + "prod_state_next"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_ASSIGN1, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_FUNCTION_CALL, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_ASSIGN1, + "prod_assign1"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_ASSIGN_TAIL, 0, 1); + alt.AddToken((int) SyntaxConstants.EQUAL, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_NEXT_FIG, 1, 1); + alt.AddToken((int) SyntaxConstants.TERMI, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_ASSIGN_TAIL, + "prod_assign_tail"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_SCAN_FIG, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_NEXT_FIG, + "prod_next_fig"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_MATH_EQTAIL2, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_MATH_EQTAIL1, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.EQUAL, 1, 1); + alt.AddToken((int) SyntaxConstants.ID, 1, 1); + alt.AddToken((int) SyntaxConstants.CON, 1, 1); + alt.AddToken((int) SyntaxConstants.ID, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_MATH_EQTAIL1, + "prod_math_eqtail1"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.OP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_MATH_FIG, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_MATH_OP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_MATH_FIG, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_MATHEQ_NEXT, 0, 1); + alt.AddToken((int) SyntaxConstants.CP, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_MATH_EQTAIL2, + "prod_math_eqtail2"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_MATH_FIG1, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_MATH_OP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_MATH_FIG1, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_MATH_TAIL, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_MATH_TAIL, + "prod_math_tail"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_MATH_OP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_MATH_FIG1, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_MATH_TAIL, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_MATH_OP, + "prod_math_op"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.ADD, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.SUB, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.MUL, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.DIV, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.MOD, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_MATH_FIG, + "prod_math_fig"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.ID, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_ASSIGN_TAIL, 0, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_VAL1, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_MATH_EQTAIL1, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_MATH_FIG1, + "prod_math_fig1"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.ID, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_ASSIGN_TAIL, 0, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_VAL1, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_MATHEQ_NEXT, + "prod_matheq_next"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_MATH_OP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_MATH_FIG, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_MATHEQ_NEXT, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_FUNCTION_CALL, + "prod_function_call"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.OP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_ARGS1, 1, 1); + alt.AddToken((int) SyntaxConstants.CP, 1, 1); + alt.AddToken((int) SyntaxConstants.TERMI, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_SCAN_NEXT, + "prod_scan_next"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_MATH_OP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_MATH_FIG1, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_MATH_TAIL, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_ARGS1, + "prod_args1"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_ARG_IN, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_ARGS_TAIL, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_ARGS_TAIL, + "prod_args_tail"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.COMMA, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_ARG_IN, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_ARGS_TAIL, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_ARG_IN, + "prod_arg_in"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.ID, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_ARR1D, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_VAL, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_CLRSCR, + "prod_clrscr"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.WIPE, 1, 1); + alt.AddToken((int) SyntaxConstants.TERMI, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_INPUT, + "prod_input"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.ZOOIN, 1, 1); + alt.AddToken((int) SyntaxConstants.CDA, 1, 1); + alt.AddToken((int) SyntaxConstants.ID, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_ASSIGN_TAIL, 0, 1); + alt.AddProduction((int) SyntaxConstants.PROD_MULTI_INPUT, 0, 1); + alt.AddToken((int) SyntaxConstants.TERMI, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_SCAN_FIG, + "prod_scan_fig"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_ARR1D, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_STORK_ACCESS1, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_MULTI_INPUT, + "prod_multi_input"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.CDA, 1, 1); + alt.AddToken((int) SyntaxConstants.ID, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_ASSIGN_TAIL, 0, 1); + alt.AddProduction((int) SyntaxConstants.PROD_MULTI_INPUT, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_ARR1D, + "prod_arr1D"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.OB, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_SIZE, 0, 1); + alt.AddToken((int) SyntaxConstants.CB, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_ARR2D, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_ARR2D, + "prod_arr2D"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.OB, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_SIZE, 0, 1); + alt.AddToken((int) SyntaxConstants.CB, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_STORK_ACCESS1, + "prod_stork_access1"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.CONC, 1, 1); + alt.AddToken((int) SyntaxConstants.ID, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_OUTPUT, + "prod_output"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.ZOOUT, 1, 1); + alt.AddToken((int) SyntaxConstants.ODA, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_OUT, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_MULTI_OUTPUT, 0, 1); + alt.AddToken((int) SyntaxConstants.TERMI, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_OUT, + "prod_out"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.ID, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_ASSIGN_TAIL, 0, 1); + alt.AddProduction((int) SyntaxConstants.PROD_SCAN_NEXT, 0, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.STARLIT, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_MULTI_OUTPUT, + "prod_multi_output"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.ODA, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_OUT, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_MULTI_OUTPUT, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_CONDITIONAL, + "prod_conditional"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.IF, 1, 1); + alt.AddToken((int) SyntaxConstants.OP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_CONDI, 1, 1); + alt.AddToken((int) SyntaxConstants.CP, 1, 1); + alt.AddToken((int) SyntaxConstants.ODC, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 1, 1); + alt.AddToken((int) SyntaxConstants.CDC, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_COND_EELSIF, 0, 1); + alt.AddProduction((int) SyntaxConstants.PROD_COND_EELS, 0, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.SWASP, 1, 1); + alt.AddToken((int) SyntaxConstants.OP, 1, 1); + alt.AddToken((int) SyntaxConstants.ID, 1, 1); + alt.AddToken((int) SyntaxConstants.CP, 1, 1); + alt.AddToken((int) SyntaxConstants.ODC, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_SWASP_CASE, 0, 1); + alt.AddProduction((int) SyntaxConstants.PROD_DEFAULT, 1, 1); + alt.AddToken((int) SyntaxConstants.CDC, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_CONDI, + "prod_condi"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.OP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_COND_EXPR, 1, 1); + alt.AddToken((int) SyntaxConstants.CP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_COND_TAIL, 0, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.EXC, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_NOT_FIG, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_NOT_FIG, + "prod_not_fig"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.ID, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_BUL_LIT, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.OP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_COND_EXPR, 1, 1); + alt.AddToken((int) SyntaxConstants.CP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_COND_TAIL, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_COND_EXPR, + "prod_cond_expr"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_REL_EXPR, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_COND_TAIL, + "prod_cond_tail"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_LOG_EXPR, 1, 1); + alt.AddToken((int) SyntaxConstants.OP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_COND_EXPR, 1, 1); + alt.AddToken((int) SyntaxConstants.CP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_COND_TAIL, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_REL_EXPR, + "prod_rel_expr"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_EXPRESSION, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_RELEX_TAIL, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_RELEX_TAIL, + "prod_relex_tail"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_REL_OP1, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_EXPRESSION, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_REL_OP2, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_REL_FIG, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_EXPRESSION, + "prod_expression"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_VAL1, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.OP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_MATH_FIG, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_MATH_OP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_MATH_FIG, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_MATH_TAIL, 0, 1); + alt.AddToken((int) SyntaxConstants.CP, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.ID, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_ASSIGN_TAIL, 0, 1); + alt.AddProduction((int) SyntaxConstants.PROD_SCAN_NEXT, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_REL_OP1, + "prod_rel_op1"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.OA, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.CA, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.OAE, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.CAE, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_REL_OP2, + "prod_rel_op2"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.EE, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.DE, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_REL_FIG, + "prod_rel_fig"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_VAL, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.NULL, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.ID, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_ASSIGN_TAIL, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_LOG_EXPR, + "prod_log_expr"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_LOG_OP, 1, 1); + alt.AddToken((int) SyntaxConstants.OP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_REL_EXPR, 1, 1); + alt.AddToken((int) SyntaxConstants.CP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_LOG_EXPR_NEXT, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_LOG_EXPR_NEXT, + "prod_log_expr_next"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_LOG_OP, 1, 1); + alt.AddToken((int) SyntaxConstants.OP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_REL_EXPR, 1, 1); + alt.AddToken((int) SyntaxConstants.CP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_LOG_EXPR_NEXT, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_LOG_OP, + "prod_log_op"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.DAND, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.DOR, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_COND_EELSIF, + "prod_cond_eelsif"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.EELSIF, 1, 1); + alt.AddToken((int) SyntaxConstants.OP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_CONDI, 1, 1); + alt.AddToken((int) SyntaxConstants.CP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); + alt.AddToken((int) SyntaxConstants.ODC, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 0, 1); + alt.AddToken((int) SyntaxConstants.CDC, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); + alt.AddProduction((int) SyntaxConstants.PROD_COND_EELSIF, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_COND_EELS, + "prod_cond_eels"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.EELS, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); + alt.AddToken((int) SyntaxConstants.ODC, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 0, 1); + alt.AddToken((int) SyntaxConstants.CDC, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_SWASP_CASE, + "prod_swasp_case"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.CHAMOIS, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_TERM_EXPR, 1, 1); + alt.AddToken((int) SyntaxConstants.SC, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 0, 1); + alt.AddToken((int) SyntaxConstants.TERMITE, 1, 1); + alt.AddToken((int) SyntaxConstants.TERMI, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_SWASP_CASE1, 0, 1); + alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_SWASP_CASE1, + "prod_swasp_case1"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_SWASP_CASE, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_TERM_EXPR, + "prod_term_expr"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.NEWTLIT, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.STARLIT, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_DEFAULT, + "prod_default"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.SEAL, 1, 1); + alt.AddToken((int) SyntaxConstants.TERMI, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_ITERATIVE, + "prod_iterative"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.WHALE, 1, 1); + alt.AddToken((int) SyntaxConstants.OP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_CONDI, 1, 1); + alt.AddToken((int) SyntaxConstants.CP, 1, 1); + alt.AddToken((int) SyntaxConstants.ODC, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 0, 1); + alt.AddProduction((int) SyntaxConstants.PROD_LOOP_FIG2, 1, 1); + alt.AddToken((int) SyntaxConstants.TERMI, 1, 1); + alt.AddToken((int) SyntaxConstants.CDC, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.DO, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); + alt.AddToken((int) SyntaxConstants.ODC, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 0, 1); + alt.AddToken((int) SyntaxConstants.CDC, 1, 1); + alt.AddToken((int) SyntaxConstants.WHALE, 1, 1); + alt.AddToken((int) SyntaxConstants.OP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_CONDI, 1, 1); + alt.AddToken((int) SyntaxConstants.CP, 1, 1); + alt.AddToken((int) SyntaxConstants.TERMI, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.FUR, 1, 1); + alt.AddToken((int) SyntaxConstants.OP, 1, 1); + alt.AddToken((int) SyntaxConstants.ID, 1, 1); + alt.AddToken((int) SyntaxConstants.EQUAL, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_LOOP_FIG1, 1, 1); + alt.AddToken((int) SyntaxConstants.TERMI, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_REL_EXPR1, 1, 1); + alt.AddToken((int) SyntaxConstants.TERMI, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_LOOP_FIG2, 1, 1); + alt.AddToken((int) SyntaxConstants.CP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); + alt.AddToken((int) SyntaxConstants.ODC, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 0, 1); + alt.AddToken((int) SyntaxConstants.CDC, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_LOOP_FIG1, + "prod_loop_fig1"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.NEWTLIT, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.ID, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_REL_EXPR1, + "prod_rel_expr1"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.ID, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_REL_OP1, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_ARG_IN, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_LOOP_FIG2, + "prod_loop_fig2"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_INCREM_DECREM, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_INCREM_DECREM, + "prod_increm_decrem"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_UNARY_OP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_VAR, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_VAR, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_UNARY_OP, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_VAR, + "prod_var"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_LOOP_FIG1, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_UNARY_OP, + "prod_unary_op"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.INCRE, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.DECRE, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_SUB_FUNCTION, + "prod_sub_function"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_DTYPE, 1, 1); + alt.AddToken((int) SyntaxConstants.AT, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_FUNC_NAME, 1, 1); + alt.AddToken((int) SyntaxConstants.OP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_FUNC_ARGS, 0, 1); + alt.AddToken((int) SyntaxConstants.CP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); + alt.AddToken((int) SyntaxConstants.ODC, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_FUNC_INSIDE, 1, 1); + alt.AddToken((int) SyntaxConstants.HOP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_RESULT, 0, 1); + alt.AddToken((int) SyntaxConstants.TERMI, 1, 1); + alt.AddToken((int) SyntaxConstants.CDC, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); + alt.AddProduction((int) SyntaxConstants.PROD_SUB_FUNCTION, 0, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.VIPER, 1, 1); + alt.AddToken((int) SyntaxConstants.AT, 1, 1); + alt.AddToken((int) SyntaxConstants.ID, 1, 1); + alt.AddToken((int) SyntaxConstants.OP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_FUNC_ARGS, 0, 1); + alt.AddToken((int) SyntaxConstants.CP, 1, 1); + alt.AddToken((int) SyntaxConstants.ODC, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_FUNC_INSIDE, 0, 1); + alt.AddToken((int) SyntaxConstants.CDC, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_SUB_FUNCTION, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_FUNC_INSIDE, + "prod_func_inside"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_LOCAL_DEC, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_FUNC_ARGS, + "prod_func_args"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_IDENT_VAR, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_MULTIFUNC_ARGS, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_MULTIFUNC_ARGS, + "prod_multifunc_args"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.COMMA, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_FUNC_ARGS, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_RESULT, + "prod_result"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_VAL2, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.ID, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_RESULT_TAIL, 0, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.DUCKLIT, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.NEWTLIT, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_MATH_OP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_LOOP_FIG1, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_FIG_TAIL, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_FIG_TAIL, + "prod_fig_tail"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_MATH_OP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_LOOP_FIG1, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_FIG_TAIL, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_RESULT_TAIL, + "prod_result_tail"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.OP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_ARGS1, 0, 1); + alt.AddToken((int) SyntaxConstants.CP, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_MATH_OP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_LOOP_FIG1, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_FIG_TAIL, 0, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_ARR1D, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + } +} diff --git a/Syntax Analyzer/SyntaxProductions.cs b/Syntax Analyzer/SyntaxProductions.cs new file mode 100644 index 0000000..cd9224a --- /dev/null +++ b/Syntax Analyzer/SyntaxProductions.cs @@ -0,0 +1,239 @@ +namespace Syntax_Analyzer +{ + public class SyntaxProductions + { + public string GetProductionName(string prod) + { + string production = prod; + if (production.Contains("prod_")) + { + switch (prod) + { + // Productions + case "prod_startprogram": + production = "prod_Start_Program"; break; + case "prod_varinit_int": + production = "prod_varinitINT"; break; + case "prod_varinit_double": + production = "prod_varinitDOUBLE"; break; + case "prod_varinit_char": + production = "prod_varinitCHAR"; break; + case "prod_varinit_string": + production = "prod_varinitSTRING"; break; + case "prod_varinit_boolean": + production = "prod_varinitBOOLEAN"; break; + case "prod_vartail_int": + production = "prod_vartailINT"; break; + case "prod_vartail_double": + production = "prod_vartailDOUBLE"; break; + case "prod_vartail_char": + production = "prod_vartailCHAR"; break; + case "prod_vartail_string": + production = "prod_vartailSTRING"; break; + case "prod_vartail_boolean": + production = "prod_vartailBOOLEAN"; break; + case "prod_value_char": + production = "prod_valueCHAR"; break; + case "prod_value_string": + production = "prod_valueSTRING"; break; + case "prod_value_boolean": + production = "prod_valueBOOLEAN"; break; + case "prod_option_int": + production = "prod_optionINT"; break; + case "prod_option_string": + production = "prod_optionSTRING"; break; + case "prod_option_char": + production = "prod_optionCHAR"; break; + case "prod_state_int": + production = "prod_stateINT"; break; + case "prod_state_string": + production = "prod_stateSTRING"; break; + case "prod_state_char": + production = "prod_stateCHAR"; break; + case "prod_log_op": + production = "prod_logOp"; break; + case "prod_log_op_tail": + production = "prod_logOp_tail"; break; + case "prod_log_op_choices": + production = "prod_logOp_choices"; break; + case "prod_rel_op": + production = "prod_relOp"; break; + case "prod_if_otherwise": + production = "prod_IfOtherwise"; break; + case "prod_mathop_int": + production = "prod_mathopINT"; break; + case "prod_mathop_double": + production = "prod_mathopDOUBLE"; break; + case "prod_mathop_num": + production = "prod_mathopNUM"; break; + case "prod_mathop_int_tail": + production = "prod_mathopINT_tail"; break; + case "prod_mathop_double_tail": + production = "prod_mathopDOUBLE_tail"; break; + case "prod_mathop_num_tail": + production = "prod_mathopNUM_tail"; break; + case "prod_return_int": + production = "prod_returnINT"; break; + case "prod_return_double": + production = "prod_returnDOUBLE"; break; + case "prod_return_string": + production = "prod_returnSTRING"; break; + case "prod_return_char": + production = "prod_returnCHAR"; break; + case "prod_return_boolean": + production = "prod_returnBOOLEAN"; break; + } + } + else + { + switch (prod) + { + + // Tokens + case "task": + production = "Task"; break; + case "lead": + production = "Lead"; break; + case "start": + production = "Start"; break; + case "end": + production = "End"; break; + case "var": + production = "Var"; break; + case "id": + production = "id"; break; + case "as": + production = "as"; break; + case "let": + production = "Let"; break; + case "object": + production = "Object"; break; + case "of": + production = "of"; break; + case "by": + production = "by"; break; + case "is": + production = "is"; break; + case "clear": + production = "Clear"; break; + case "read": + production = "Read"; break; + case "say": + production = "Say"; break; + case "skip": + production = "Skip"; break; + case "stop": + production = "Stop"; break; + case "if": + production = "If"; break; + case "or": + production = "Or"; break; + case "otherwise": + production = "Otherwise"; break; + case "option": + production = "Option"; break; + case "state": + production = "State"; break; + case "default": + production = "Default"; break; + case "until": + production = "Until"; break; + case "loop": + production = "Loop"; break; + case "loopif": + production = "LoopIf"; break; + case "do": + production = "Do"; break; + case "for": + production = "For"; break; + case "response": + production = "Response"; break; + case "endif": + production = "EndIf"; break; + case "int": + production = "Int"; break; + case "double": + production = "Double"; break; + case "char": + production = "Char"; break; + case "string": + production = "String"; break; + case "null": + production = "Null"; break; + case "array": + production = "Array"; break; + case "boolean": + production = "Boolean"; break; + case "intlit": + production = "intlit"; break; + case "charlit": + production = "charlit"; break; + case "doublelit": + production = "doublelit"; break; + case "stringlit": + production = "stringlit"; break; + case "boollit": + production = "boollit"; break; + case "col": + production = ":"; break; + case "sem": + production = ";"; break; + case "die": + production = "#"; break; + case "per": + production = "."; break; + case "op": + production = "("; break; + case "cp": + production = ")"; break; + case "ob": + production = "["; break; + case "cb": + production = "]"; break; + case "add": + production = "+"; break; + case "min": + production = "-"; break; + case "mul": + production = "*"; break; + case "div": + production = "/"; break; + case "mod": + production = "%"; break; + case "inc": + production = "++"; break; + case "dec": + production = "--"; break; + case "iseq": + production = "=="; break; + case "noteq": + production = "!="; break; + case "great": + production = ">"; break; + case "less": + production = "<"; break; + case "logand": + production = "&&"; break; + case "logor": + production = "||"; break; + case "not": + production = "!"; break; + case "eq": + production = "="; break; + case "comma": + production = ","; break; + case "at": + production = "@"; break; + case "geq": + production = ">="; break; + case "leq": + production = "<="; break; + case "whitespace": + break; + } + } + + return production; + } + } +} diff --git a/Syntax Analyzer/SyntaxTokenizer.cs b/Syntax Analyzer/SyntaxTokenizer.cs new file mode 100644 index 0000000..22da25a --- /dev/null +++ b/Syntax Analyzer/SyntaxTokenizer.cs @@ -0,0 +1,456 @@ +/* + * SyntaxTokenizer.cs + * + * THIS FILE HAS BEEN GENERATED AUTOMATICALLY. DO NOT EDIT! + */ + +using System.IO; + +using Core.Library; + +/** + * A character stream tokenizer. + */ +public class SyntaxTokenizer : Tokenizer { + + /** + * Creates a new tokenizer for the specified input + * stream. + * + * the input stream to read + * + * if the tokenizer + * couldn't be initialized correctly + */ + public SyntaxTokenizer(TextReader input) + : base(input, false) { + + CreatePatterns(); + } + + /** + * Initializes the tokenizer by creating all the token + * patterns. + * + * if the tokenizer + * couldn't be initialized correctly + */ + private void CreatePatterns() { + TokenPattern pattern; + + pattern = new TokenPattern((int) SyntaxConstants.ENTRANCE, + "ENTRANCE", + TokenPattern.PatternType.STRING, + "entrance"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.EXIT, + "EXIT", + TokenPattern.PatternType.STRING, + "exit"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.MANE, + "MANE", + TokenPattern.PatternType.STRING, + "mane"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.LET, + "LET", + TokenPattern.PatternType.STRING, + "let"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.WIPE, + "WIPE", + TokenPattern.PatternType.STRING, + "wipe"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.ZOOIN, + "ZOOIN", + TokenPattern.PatternType.STRING, + "zooin"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.ZOOUT, + "ZOOUT", + TokenPattern.PatternType.STRING, + "zoout"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.IF, + "IF", + TokenPattern.PatternType.STRING, + "if"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.EELSIF, + "EELSIF", + TokenPattern.PatternType.STRING, + "eelsif"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.EELS, + "EELS", + TokenPattern.PatternType.STRING, + "eels"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.CHAMOIS, + "CHAMOIS", + TokenPattern.PatternType.STRING, + "chamois"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.TERMITE, + "TERMITE", + TokenPattern.PatternType.STRING, + "termite"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.SEAL, + "SEAL", + TokenPattern.PatternType.STRING, + "seal"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.WHALE, + "WHALE", + TokenPattern.PatternType.STRING, + "whale"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.DO, + "DO", + TokenPattern.PatternType.STRING, + "do"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.FUR, + "FUR", + TokenPattern.PatternType.STRING, + "fur"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.HOP, + "HOP", + TokenPattern.PatternType.STRING, + "hop"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.SWASP, + "SWASP", + TokenPattern.PatternType.STRING, + "swasp"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.STORK, + "STORK", + TokenPattern.PatternType.STRING, + "stork"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.AT, + "AT", + TokenPattern.PatternType.STRING, + "at"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.NULL, + "NULL", + TokenPattern.PatternType.STRING, + "null"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.COMSYM, + "COMSYM", + TokenPattern.PatternType.STRING, + "'"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.TERMI, + "TERMI", + TokenPattern.PatternType.STRING, + ":"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.SC, + "SC", + TokenPattern.PatternType.STRING, + ";"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.COMMA, + "COMMA", + TokenPattern.PatternType.STRING, + ","); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.EQUAL, + "EQUAL", + TokenPattern.PatternType.STRING, + "="); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.OB, + "OB", + TokenPattern.PatternType.STRING, + "["); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.CB, + "CB", + TokenPattern.PatternType.STRING, + "]"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.OC, + "OC", + TokenPattern.PatternType.STRING, + "{"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.CC, + "CC", + TokenPattern.PatternType.STRING, + "}"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.OP, + "OP", + TokenPattern.PatternType.STRING, + "("); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.CP, + "CP", + TokenPattern.PatternType.STRING, + ")"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.ODC, + "ODC", + TokenPattern.PatternType.STRING, + "{{"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.CDC, + "CDC", + TokenPattern.PatternType.STRING, + "}}"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.CONC, + "CONC", + TokenPattern.PatternType.STRING, + ".+"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.CON, + "CON", + TokenPattern.PatternType.STRING, + "?"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.ODA, + "ODA", + TokenPattern.PatternType.STRING, + "<<"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.CDA, + "CDA", + TokenPattern.PatternType.STRING, + ">>"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.NEG, + "NEG", + TokenPattern.PatternType.STRING, + "~"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.ADD, + "ADD", + TokenPattern.PatternType.STRING, + "+"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.SUB, + "SUB", + TokenPattern.PatternType.STRING, + "-"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.MUL, + "MUL", + TokenPattern.PatternType.STRING, + "*"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.DIV, + "DIV", + TokenPattern.PatternType.STRING, + "/"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.MOD, + "MOD", + TokenPattern.PatternType.STRING, + "%"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.EXP, + "EXP", + TokenPattern.PatternType.STRING, + "^"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.OA, + "OA", + TokenPattern.PatternType.STRING, + "<"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.CA, + "CA", + TokenPattern.PatternType.STRING, + ">"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.OAE, + "OAE", + TokenPattern.PatternType.STRING, + "<="); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.CAE, + "CAE", + TokenPattern.PatternType.STRING, + ">="); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.EE, + "EE", + TokenPattern.PatternType.STRING, + "!="); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.DE, + "DE", + TokenPattern.PatternType.STRING, + "=="); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.EXC, + "EXC", + TokenPattern.PatternType.STRING, + "!"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.DAND, + "DAND", + TokenPattern.PatternType.STRING, + "&&"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.DOR, + "DOR", + TokenPattern.PatternType.STRING, + "||"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.INCRE, + "INCRE", + TokenPattern.PatternType.STRING, + "++"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.DECRE, + "DECRE", + TokenPattern.PatternType.STRING, + "--"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.NEWT, + "NEWT", + TokenPattern.PatternType.STRING, + "newt"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.DUCK, + "DUCK", + TokenPattern.PatternType.STRING, + "duck"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.BULL, + "BULL", + TokenPattern.PatternType.STRING, + "bull"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.STARLING, + "STARLING", + TokenPattern.PatternType.STRING, + "starling"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.VIPER, + "VIPER", + TokenPattern.PatternType.STRING, + "viper"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.NEWTLIT, + "NEWTLIT", + TokenPattern.PatternType.STRING, + "newt literals"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.DUCKLIT, + "DUCKLIT", + TokenPattern.PatternType.STRING, + "duck literals"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.STARLIT, + "STARLIT", + TokenPattern.PatternType.STRING, + "starling literals"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.TRUE, + "TRUE", + TokenPattern.PatternType.STRING, + "true"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.FALSE, + "FALSE", + TokenPattern.PatternType.STRING, + "false"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.ID, + "ID", + TokenPattern.PatternType.STRING, + "id"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.COMMENT, + "COMMENT", + TokenPattern.PatternType.STRING, + "comment"); + AddPattern(pattern); + + pattern = new TokenPattern((int) SyntaxConstants.WHITESPACE, + "WHITESPACE", + TokenPattern.PatternType.REGEXP, + "[ \\t\\n\\r\\s]+"); + pattern.Ignore = true; + AddPattern(pattern); + } +} diff --git a/Token/Class1.vb b/Token/Class1.vb new file mode 100644 index 0000000..875798b --- /dev/null +++ b/Token/Class1.vb @@ -0,0 +1,3 @@ +Public Class Class1 + +End Class diff --git a/Token/ErrorClass.vb b/Token/ErrorClass.vb new file mode 100644 index 0000000..1dac919 --- /dev/null +++ b/Token/ErrorClass.vb @@ -0,0 +1,39 @@ +Namespace TokenLibrary + + Public Class ErrorClass + Dim lines As Integer + Dim column As Integer + Dim type As String + Dim ErrorMessage As String + + Public Sub setErrorMessage(ErrorMessage) + Me.ErrorMessage = ErrorMessage + End Sub + Public Function getErrorMessage() As String + Return Me.ErrorMessage + End Function + Public Sub setLines(line) + + Me.lines = line + End Sub + Public Function getLines() + Return Me.lines + End Function + Public Sub setColumn(column) + Me.column = column + End Sub + Public Function getColumn() As String + + Return Me.column + + End Function + Public Sub setType(type) + + Me.type = type + End Sub + Public Function gitType() As String + Return Me.type + End Function + End Class + +End Namespace \ No newline at end of file diff --git a/Token/My Project/Application.Designer.vb b/Token/My Project/Application.Designer.vb new file mode 100644 index 0000000..88dd01c --- /dev/null +++ b/Token/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + diff --git a/Token/My Project/Application.myapp b/Token/My Project/Application.myapp new file mode 100644 index 0000000..758895d --- /dev/null +++ b/Token/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 1 + true + diff --git a/Token/My Project/AssemblyInfo.vb b/Token/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..fed6122 --- /dev/null +++ b/Token/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: +' + + + diff --git a/Token/My Project/Resources.Designer.vb b/Token/My Project/Resources.Designer.vb new file mode 100644 index 0000000..846808c --- /dev/null +++ b/Token/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + +Imports System + +Namespace My.Resources + + 'This class was auto-generated by the StronglyTypedResourceBuilder + 'class via a tool like ResGen or Visual Studio. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + ''' + ''' A strongly-typed resource class, for looking up localized strings, etc. + ''' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ''' + ''' Returns the cached ResourceManager instance used by this class. + ''' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("TokenLibrary.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Overrides the current thread's CurrentUICulture property for all + ''' resource lookups using this strongly typed resource class. + ''' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/Token/My Project/Resources.resx b/Token/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Token/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Token/My Project/Settings.Designer.vb b/Token/My Project/Settings.Designer.vb new file mode 100644 index 0000000..839c841 --- /dev/null +++ b/Token/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) + +#Region "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.TokenLibrary.My.MySettings + Get + Return Global.TokenLibrary.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Token/My Project/Settings.settings b/Token/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Token/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Token/TokenClass.vb b/Token/TokenClass.vb new file mode 100644 index 0000000..39ce2a8 --- /dev/null +++ b/Token/TokenClass.vb @@ -0,0 +1,37 @@ +Namespace TokenLibrary + Public Class TokenClass + Dim lines As Integer + Dim tokens As String + Dim lexemes As String + Dim attributes As String + + Sub setTokens(ByVal token As String) + Me.tokens = token + End Sub + + Sub setLexemes(ByVal lexemes As String) + Me.lexemes = lexemes + End Sub + Sub setLines(ByVal lines As Integer) + Me.lines = lines + End Sub + Sub setAttributes(ByVal attributes As String) + Me.attributes = attributes + End Sub + + Function getTokens() As String + Return Me.tokens + End Function + Function getLexemes() As String + Return Me.lexemes + End Function + Function getLines() As Integer + Return Me.lines + End Function + Function getAttributes() As String + Return Me.attributes + End Function + + + End Class +End Namespace diff --git a/Token/TokenLibrary.vbproj b/Token/TokenLibrary.vbproj new file mode 100644 index 0000000..412e698 --- /dev/null +++ b/Token/TokenLibrary.vbproj @@ -0,0 +1,113 @@ + + + + + Debug + AnyCPU + {17D6F07E-F7BE-41DE-8D3C-1881EE21F14A} + Library + TokenLibrary + TokenLibrary + 512 + Windows + v4.5 + + + + true + full + true + true + bin\Debug\ + TokenLibrary.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + TokenLibrary.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + On + + + Binary + + + Off + + + On + + + + + + + + + + + + + + + + + + + + + + + + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + \ No newline at end of file diff --git a/Zootopia_Compiler.sln b/Zootopia_Compiler.sln index e8c9c9f..291eb14 100644 --- a/Zootopia_Compiler.sln +++ b/Zootopia_Compiler.sln @@ -5,6 +5,16 @@ VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Zootopia_Compiler", "Zootopia_Compiler\Zootopia_Compiler.vbproj", "{E5EC999D-71D4-4FD6-B6E0-D1D6AB111463}" EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "TokenLibrary", "Token\TokenLibrary.vbproj", "{17D6F07E-F7BE-41DE-8D3C-1881EE21F14A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Core Library", "Core Library\Core Library.csproj", "{100BF7E7-B634-4E6B-948E-22D0566FB2AF}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Syntax Analyzer", "Syntax Analyzer\Syntax Analyzer.csproj", "{C19858D3-1865-438D-AFEA-D2451A2CA503}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SemanticsAnalyzer", "SemanticsAnalyzer\SemanticsAnalyzer.csproj", "{E187009E-0B2B-4569-B16C-C35EF06FDFE1}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Code Generation", "CodeGeneration\Code Generation.csproj", "{A371B79E-2C88-40A3-8AA5-3C5731FF607F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +25,26 @@ Global {E5EC999D-71D4-4FD6-B6E0-D1D6AB111463}.Debug|Any CPU.Build.0 = Debug|Any CPU {E5EC999D-71D4-4FD6-B6E0-D1D6AB111463}.Release|Any CPU.ActiveCfg = Release|Any CPU {E5EC999D-71D4-4FD6-B6E0-D1D6AB111463}.Release|Any CPU.Build.0 = Release|Any CPU + {17D6F07E-F7BE-41DE-8D3C-1881EE21F14A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {17D6F07E-F7BE-41DE-8D3C-1881EE21F14A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {17D6F07E-F7BE-41DE-8D3C-1881EE21F14A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {17D6F07E-F7BE-41DE-8D3C-1881EE21F14A}.Release|Any CPU.Build.0 = Release|Any CPU + {100BF7E7-B634-4E6B-948E-22D0566FB2AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {100BF7E7-B634-4E6B-948E-22D0566FB2AF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {100BF7E7-B634-4E6B-948E-22D0566FB2AF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {100BF7E7-B634-4E6B-948E-22D0566FB2AF}.Release|Any CPU.Build.0 = Release|Any CPU + {C19858D3-1865-438D-AFEA-D2451A2CA503}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C19858D3-1865-438D-AFEA-D2451A2CA503}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C19858D3-1865-438D-AFEA-D2451A2CA503}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C19858D3-1865-438D-AFEA-D2451A2CA503}.Release|Any CPU.Build.0 = Release|Any CPU + {E187009E-0B2B-4569-B16C-C35EF06FDFE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E187009E-0B2B-4569-B16C-C35EF06FDFE1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E187009E-0B2B-4569-B16C-C35EF06FDFE1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E187009E-0B2B-4569-B16C-C35EF06FDFE1}.Release|Any CPU.Build.0 = Release|Any CPU + {A371B79E-2C88-40A3-8AA5-3C5731FF607F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A371B79E-2C88-40A3-8AA5-3C5731FF607F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A371B79E-2C88-40A3-8AA5-3C5731FF607F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A371B79E-2C88-40A3-8AA5-3C5731FF607F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Zootopia_Compiler/App.config b/Zootopia_Compiler/App.config index 2ae8254..1729194 100644 --- a/Zootopia_Compiler/App.config +++ b/Zootopia_Compiler/App.config @@ -1,6 +1,6 @@ - + - + - \ No newline at end of file + diff --git a/Zootopia_Compiler/Form1.Designer.vb b/Zootopia_Compiler/Form1.Designer.vb index 9c89b57..852ac54 100644 --- a/Zootopia_Compiler/Form1.Designer.vb +++ b/Zootopia_Compiler/Form1.Designer.vb @@ -1,9 +1,9 @@ - _ + Partial Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. - _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) Try If disposing AndAlso components IsNot Nothing Then @@ -20,54 +20,71 @@ Partial Class Form1 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. - _ + Private Sub InitializeComponent() Me.rTBCode = New System.Windows.Forms.RichTextBox() - Me.btnAna = New System.Windows.Forms.Button() Me.dGridLexi = New System.Windows.Forms.ListView() Me.Number = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) Me.Line = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) Me.Lexeme = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) Me.Token = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) - Me.Attribute = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) + Me.ColumnHeader19 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) Me.dGridError = New System.Windows.Forms.ListView() - Me.ColumnHeader1 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) Me.ColumnHeader2 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) Me.ColumnHeader3 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) - Me.dGridIden = New System.Windows.Forms.ListView() + Me.ColumnHeader1 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) + Me.Panel1 = New System.Windows.Forms.Panel() + Me.Panel3 = New System.Windows.Forms.Panel() + Me.Label1 = New System.Windows.Forms.Label() + Me.PictureBox1 = New System.Windows.Forms.PictureBox() Me.dGridBoard = New System.Windows.Forms.ListView() + Me.ColumnHeader = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) + Me.ColumnHeader17 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) Me.lineNum = New System.Windows.Forms.PictureBox() + Me.btnAna = New System.Windows.Forms.Button() + Me.dGridIden = New System.Windows.Forms.ListView() + Me.ColumnHeader7 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) + Me.ColumnHeader8 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) + Me.ColumnHeader9 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) + Me.ColumnHeader10 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) + Me.ColumnHeader11 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) + Me.ColumnHeader12 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) + Me.ColumnHeader13 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) + Me.ColumnHeader14 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) + Me.ColumnHeader15 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) + Me.ColumnHeader16 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) + Me.ColumnHeader18 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) + Me.ErrorText = New System.Windows.Forms.TextBox() + Me.ColumnHeader4 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) + Me.ColumnHeader5 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) + Me.ColumnHeader6 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) + Me.dGridSemantic = New System.Windows.Forms.ListView() + Me.btnClr = New System.Windows.Forms.Button() + Me.Panel1.SuspendLayout() + CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.lineNum, System.ComponentModel.ISupportInitialize).BeginInit() Me.SuspendLayout() ' 'rTBCode ' - Me.rTBCode.Location = New System.Drawing.Point(44, 13) + Me.rTBCode.Font = New System.Drawing.Font("Segoe UI", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.rTBCode.Location = New System.Drawing.Point(226, 13) Me.rTBCode.Name = "rTBCode" - Me.rTBCode.Size = New System.Drawing.Size(362, 381) + Me.rTBCode.Size = New System.Drawing.Size(362, 446) Me.rTBCode.TabIndex = 2 Me.rTBCode.Text = "" ' - 'btnAna - ' - Me.btnAna.Location = New System.Drawing.Point(511, 339) - Me.btnAna.Name = "btnAna" - Me.btnAna.Size = New System.Drawing.Size(180, 57) - Me.btnAna.TabIndex = 3 - Me.btnAna.Text = "Analyze" - Me.btnAna.UseVisualStyleBackColor = True - ' 'dGridLexi ' - Me.dGridLexi.BackColor = System.Drawing.Color.SaddleBrown + Me.dGridLexi.BackColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(108, Byte), Integer), CType(CType(162, Byte), Integer)) Me.dGridLexi.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle - Me.dGridLexi.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.Number, Me.Line, Me.Lexeme, Me.Token, Me.Attribute}) - Me.dGridLexi.Font = New System.Drawing.Font("Segoe UI", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) - Me.dGridLexi.ForeColor = System.Drawing.SystemColors.Window + Me.dGridLexi.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.Number, Me.Line, Me.Lexeme, Me.Token, Me.ColumnHeader19}) + Me.dGridLexi.Font = New System.Drawing.Font("Segoe UI", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.dGridLexi.ForeColor = System.Drawing.Color.White Me.dGridLexi.GridLines = True - Me.dGridLexi.Location = New System.Drawing.Point(412, 12) + Me.dGridLexi.Location = New System.Drawing.Point(604, 13) Me.dGridLexi.Name = "dGridLexi" - Me.dGridLexi.Size = New System.Drawing.Size(368, 178) + Me.dGridLexi.Size = New System.Drawing.Size(484, 137) Me.dGridLexi.TabIndex = 4 Me.dGridLexi.UseCompatibleStateImageBehavior = False Me.dGridLexi.View = System.Windows.Forms.View.Details @@ -75,117 +92,348 @@ Partial Class Form1 'Number ' Me.Number.Text = "No." - Me.Number.Width = 41 + Me.Number.Width = 0 ' 'Line ' Me.Line.Text = "Line" Me.Line.TextAlign = System.Windows.Forms.HorizontalAlignment.Center - Me.Line.Width = 45 + Me.Line.Width = 62 ' 'Lexeme ' Me.Lexeme.Text = "Lexeme" Me.Lexeme.TextAlign = System.Windows.Forms.HorizontalAlignment.Center - Me.Lexeme.Width = 133 + Me.Lexeme.Width = 137 ' 'Token ' Me.Token.Text = "Token" Me.Token.TextAlign = System.Windows.Forms.HorizontalAlignment.Center - Me.Token.Width = 151 + Me.Token.Width = 139 ' - 'Attribute + 'ColumnHeader19 ' - Me.Attribute.Text = "Attribute" - Me.Attribute.TextAlign = System.Windows.Forms.HorizontalAlignment.Center - Me.Attribute.Width = 117 + Me.ColumnHeader19.Text = "Attibutes" + Me.ColumnHeader19.Width = 144 ' 'dGridError ' - Me.dGridError.BackColor = System.Drawing.Color.SaddleBrown - Me.dGridError.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle - Me.dGridError.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.ColumnHeader1, Me.ColumnHeader2, Me.ColumnHeader3}) + Me.dGridError.BackColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(108, Byte), Integer), CType(CType(162, Byte), Integer)) + Me.dGridError.BorderStyle = System.Windows.Forms.BorderStyle.None + Me.dGridError.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.ColumnHeader2, Me.ColumnHeader3, Me.ColumnHeader1}) + Me.dGridError.Font = New System.Drawing.Font("Segoe UI", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.dGridError.ForeColor = System.Drawing.Color.White Me.dGridError.GridLines = True - Me.dGridError.Location = New System.Drawing.Point(412, 199) + Me.dGridError.Location = New System.Drawing.Point(604, 156) Me.dGridError.Name = "dGridError" - Me.dGridError.Size = New System.Drawing.Size(372, 128) + Me.dGridError.Size = New System.Drawing.Size(484, 127) Me.dGridError.TabIndex = 5 Me.dGridError.UseCompatibleStateImageBehavior = False Me.dGridError.View = System.Windows.Forms.View.Details ' - 'ColumnHeader1 - ' - Me.ColumnHeader1.Text = "Error no." - ' 'ColumnHeader2 ' - Me.ColumnHeader2.Text = "Line" + Me.ColumnHeader2.Text = "No." Me.ColumnHeader2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center + Me.ColumnHeader2.Width = 0 ' 'ColumnHeader3 ' - Me.ColumnHeader3.Text = "Error Message" + Me.ColumnHeader3.Text = "Line" Me.ColumnHeader3.TextAlign = System.Windows.Forms.HorizontalAlignment.Center - Me.ColumnHeader3.Width = 249 + Me.ColumnHeader3.Width = 64 ' - 'dGridIden + 'ColumnHeader1 ' - Me.dGridIden.Location = New System.Drawing.Point(12, 422) - Me.dGridIden.Name = "dGridIden" - Me.dGridIden.Size = New System.Drawing.Size(381, 97) - Me.dGridIden.TabIndex = 6 - Me.dGridIden.UseCompatibleStateImageBehavior = False + Me.ColumnHeader1.Text = "Error Message" + Me.ColumnHeader1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center + Me.ColumnHeader1.Width = 423 + ' + 'Panel1 + ' + Me.Panel1.BackColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(108, Byte), Integer), CType(CType(162, Byte), Integer)) + Me.Panel1.Controls.Add(Me.Panel3) + Me.Panel1.Controls.Add(Me.Label1) + Me.Panel1.Controls.Add(Me.PictureBox1) + Me.Panel1.Location = New System.Drawing.Point(1, -1) + Me.Panel1.Name = "Panel1" + Me.Panel1.Size = New System.Drawing.Size(165, 458) + Me.Panel1.TabIndex = 9 + ' + 'Panel3 + ' + Me.Panel3.BackgroundImage = Global.Zootopia_Compiler.My.Resources.Resources.analyzer + Me.Panel3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom + Me.Panel3.Location = New System.Drawing.Point(58, 170) + Me.Panel3.Name = "Panel3" + Me.Panel3.Size = New System.Drawing.Size(49, 198) + Me.Panel3.TabIndex = 10 + ' + 'Label1 + ' + Me.Label1.AutoSize = True + Me.Label1.Location = New System.Drawing.Point(76, 196) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(0, 13) + Me.Label1.TabIndex = 10 + ' + 'PictureBox1 + ' + Me.PictureBox1.BackgroundImage = Global.Zootopia_Compiler.My.Resources.Resources.Zoo_whale + Me.PictureBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom + Me.PictureBox1.Location = New System.Drawing.Point(10, 12) + Me.PictureBox1.Name = "PictureBox1" + Me.PictureBox1.Size = New System.Drawing.Size(142, 139) + Me.PictureBox1.TabIndex = 10 + Me.PictureBox1.TabStop = False ' 'dGridBoard ' - Me.dGridBoard.Location = New System.Drawing.Point(422, 422) + Me.dGridBoard.BackColor = System.Drawing.SystemColors.ControlLightLight + Me.dGridBoard.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle + Me.dGridBoard.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.ColumnHeader, Me.ColumnHeader17}) + Me.dGridBoard.Font = New System.Drawing.Font("Corbel", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.dGridBoard.ForeColor = System.Drawing.SystemColors.ControlText + Me.dGridBoard.GridLines = True + Me.dGridBoard.Location = New System.Drawing.Point(44, 586) Me.dGridBoard.Name = "dGridBoard" - Me.dGridBoard.Size = New System.Drawing.Size(157, 97) - Me.dGridBoard.TabIndex = 7 + Me.dGridBoard.Size = New System.Drawing.Size(176, 136) + Me.dGridBoard.TabIndex = 36 Me.dGridBoard.UseCompatibleStateImageBehavior = False + Me.dGridBoard.View = System.Windows.Forms.View.Details + Me.dGridBoard.Visible = False + ' + 'ColumnHeader + ' + Me.ColumnHeader.Text = "object_name" + Me.ColumnHeader.Width = 88 + ' + 'ColumnHeader17 + ' + Me.ColumnHeader17.Text = "board_name" + Me.ColumnHeader17.Width = 84 ' 'lineNum ' - Me.lineNum.BackColor = System.Drawing.Color.Transparent - Me.lineNum.Location = New System.Drawing.Point(12, 13) + Me.lineNum.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(191, Byte), Integer), CType(CType(79, Byte), Integer)) + Me.lineNum.Location = New System.Drawing.Point(190, 11) Me.lineNum.Name = "lineNum" - Me.lineNum.Size = New System.Drawing.Size(30, 378) + Me.lineNum.Size = New System.Drawing.Size(30, 446) Me.lineNum.TabIndex = 8 Me.lineNum.TabStop = False ' + 'btnAna + ' + Me.btnAna.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(191, Byte), Integer), CType(CType(79, Byte), Integer)) + Me.btnAna.FlatAppearance.MouseDownBackColor = System.Drawing.Color.DarkOrange + Me.btnAna.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Orange + Me.btnAna.FlatStyle = System.Windows.Forms.FlatStyle.Flat + Me.btnAna.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.btnAna.ForeColor = System.Drawing.Color.White + Me.btnAna.Image = Global.Zootopia_Compiler.My.Resources.Resources.analyze + Me.btnAna.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft + Me.btnAna.Location = New System.Drawing.Point(1, 463) + Me.btnAna.Name = "btnAna" + Me.btnAna.Size = New System.Drawing.Size(360, 57) + Me.btnAna.TabIndex = 3 + Me.btnAna.Text = "Analyze" + Me.btnAna.UseVisualStyleBackColor = False + ' + 'dGridIden + ' + Me.dGridIden.BackColor = System.Drawing.SystemColors.ControlLightLight + Me.dGridIden.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle + Me.dGridIden.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.ColumnHeader7, Me.ColumnHeader8, Me.ColumnHeader9, Me.ColumnHeader10, Me.ColumnHeader11, Me.ColumnHeader12, Me.ColumnHeader13, Me.ColumnHeader14, Me.ColumnHeader15, Me.ColumnHeader16, Me.ColumnHeader18}) + Me.dGridIden.Font = New System.Drawing.Font("Corbel", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.dGridIden.ForeColor = System.Drawing.SystemColors.ControlText + Me.dGridIden.GridLines = True + Me.dGridIden.Location = New System.Drawing.Point(334, 586) + Me.dGridIden.Name = "dGridIden" + Me.dGridIden.Size = New System.Drawing.Size(714, 136) + Me.dGridIden.TabIndex = 35 + Me.dGridIden.UseCompatibleStateImageBehavior = False + Me.dGridIden.View = System.Windows.Forms.View.Details + Me.dGridIden.Visible = False + ' + 'ColumnHeader7 + ' + Me.ColumnHeader7.Text = "ID No." + Me.ColumnHeader7.Width = 42 + ' + 'ColumnHeader8 + ' + Me.ColumnHeader8.Text = "ID" + Me.ColumnHeader8.Width = 101 + ' + 'ColumnHeader9 + ' + Me.ColumnHeader9.Text = "Data Type" + Me.ColumnHeader9.Width = 61 + ' + 'ColumnHeader10 + ' + Me.ColumnHeader10.Text = "Value" + Me.ColumnHeader10.Width = 102 + ' + 'ColumnHeader11 + ' + Me.ColumnHeader11.Text = "Val_Dtype" + Me.ColumnHeader11.Width = 71 + ' + 'ColumnHeader12 + ' + Me.ColumnHeader12.Text = "Type" + Me.ColumnHeader12.Width = 76 + ' + 'ColumnHeader13 + ' + Me.ColumnHeader13.Text = "Used" + Me.ColumnHeader13.Width = 38 + ' + 'ColumnHeader14 + ' + Me.ColumnHeader14.Text = "Size" + Me.ColumnHeader14.Width = 36 + ' + 'ColumnHeader15 + ' + Me.ColumnHeader15.Text = "Parameter" + Me.ColumnHeader15.Width = 42 + ' + 'ColumnHeader16 + ' + Me.ColumnHeader16.Text = "Function" + Me.ColumnHeader16.Width = 75 + ' + 'ColumnHeader18 + ' + Me.ColumnHeader18.Text = "Size2" + Me.ColumnHeader18.Width = 68 + ' + 'ErrorText + ' + Me.ErrorText.BackColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(108, Byte), Integer), CType(CType(162, Byte), Integer)) + Me.ErrorText.ForeColor = System.Drawing.Color.White + Me.ErrorText.Location = New System.Drawing.Point(604, 289) + Me.ErrorText.Multiline = True + Me.ErrorText.Name = "ErrorText" + Me.ErrorText.ReadOnly = True + Me.ErrorText.Size = New System.Drawing.Size(484, 108) + Me.ErrorText.TabIndex = 41 + ' + 'ColumnHeader4 + ' + Me.ColumnHeader4.Text = "Error no." + Me.ColumnHeader4.Width = 0 + ' + 'ColumnHeader5 + ' + Me.ColumnHeader5.Text = "Line" + Me.ColumnHeader5.TextAlign = System.Windows.Forms.HorizontalAlignment.Center + Me.ColumnHeader5.Width = 64 + ' + 'ColumnHeader6 + ' + Me.ColumnHeader6.Text = "Semantic Error" + Me.ColumnHeader6.TextAlign = System.Windows.Forms.HorizontalAlignment.Center + Me.ColumnHeader6.Width = 423 + ' + 'dGridSemantic + ' + Me.dGridSemantic.BackColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(108, Byte), Integer), CType(CType(162, Byte), Integer)) + Me.dGridSemantic.BorderStyle = System.Windows.Forms.BorderStyle.None + Me.dGridSemantic.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.ColumnHeader4, Me.ColumnHeader5, Me.ColumnHeader6}) + Me.dGridSemantic.Font = New System.Drawing.Font("Segoe UI", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.dGridSemantic.ForeColor = System.Drawing.Color.White + Me.dGridSemantic.GridLines = True + Me.dGridSemantic.Location = New System.Drawing.Point(604, 408) + Me.dGridSemantic.Name = "dGridSemantic" + Me.dGridSemantic.Size = New System.Drawing.Size(484, 126) + Me.dGridSemantic.TabIndex = 37 + Me.dGridSemantic.UseCompatibleStateImageBehavior = False + Me.dGridSemantic.View = System.Windows.Forms.View.Details + ' + 'btnClr + ' + Me.btnClr.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(191, Byte), Integer), CType(CType(79, Byte), Integer)) + Me.btnClr.FlatAppearance.MouseDownBackColor = System.Drawing.Color.DarkOrange + Me.btnClr.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Orange + Me.btnClr.FlatStyle = System.Windows.Forms.FlatStyle.Flat + Me.btnClr.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.btnClr.ForeColor = System.Drawing.Color.White + Me.btnClr.Image = Global.Zootopia_Compiler.My.Resources.Resources.analyze + Me.btnClr.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft + Me.btnClr.Location = New System.Drawing.Point(367, 463) + Me.btnClr.Name = "btnClr" + Me.btnClr.Size = New System.Drawing.Size(221, 57) + Me.btnClr.TabIndex = 42 + Me.btnClr.Text = "Clear" + Me.btnClr.UseVisualStyleBackColor = False + ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.ClientSize = New System.Drawing.Size(792, 408) - Me.Controls.Add(Me.lineNum) + Me.BackColor = System.Drawing.Color.White + Me.ClientSize = New System.Drawing.Size(1100, 541) + Me.Controls.Add(Me.btnClr) + Me.Controls.Add(Me.ErrorText) + Me.Controls.Add(Me.dGridSemantic) Me.Controls.Add(Me.dGridBoard) Me.Controls.Add(Me.dGridIden) + Me.Controls.Add(Me.Panel1) + Me.Controls.Add(Me.lineNum) Me.Controls.Add(Me.dGridError) Me.Controls.Add(Me.dGridLexi) Me.Controls.Add(Me.btnAna) Me.Controls.Add(Me.rTBCode) Me.Name = "Form1" Me.Text = "Form1" + Me.Panel1.ResumeLayout(False) + Me.Panel1.PerformLayout() + CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.lineNum, System.ComponentModel.ISupportInitialize).EndInit() Me.ResumeLayout(False) + Me.PerformLayout() End Sub Friend WithEvents rTBCode As RichTextBox Friend WithEvents btnAna As Button Friend WithEvents dGridLexi As ListView Friend WithEvents dGridError As ListView - Friend WithEvents dGridIden As ListView - Friend WithEvents dGridBoard As ListView Friend WithEvents lineNum As PictureBox Friend WithEvents Number As ColumnHeader Friend WithEvents Line As ColumnHeader Friend WithEvents Lexeme As ColumnHeader Friend WithEvents Token As ColumnHeader - Friend WithEvents Attribute As ColumnHeader - Friend WithEvents ColumnHeader1 As ColumnHeader Friend WithEvents ColumnHeader2 As ColumnHeader Friend WithEvents ColumnHeader3 As ColumnHeader + Friend WithEvents Panel1 As System.Windows.Forms.Panel + Friend WithEvents Label1 As System.Windows.Forms.Label + Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox + Friend WithEvents Panel3 As System.Windows.Forms.Panel + Friend WithEvents dGridIden As ListView + Friend WithEvents ColumnHeader7 As ColumnHeader + Friend WithEvents ColumnHeader8 As ColumnHeader + Friend WithEvents ColumnHeader9 As ColumnHeader + Friend WithEvents ColumnHeader10 As ColumnHeader + Friend WithEvents ColumnHeader11 As ColumnHeader + Friend WithEvents ColumnHeader12 As ColumnHeader + Friend WithEvents ColumnHeader13 As ColumnHeader + Friend WithEvents ColumnHeader14 As ColumnHeader + Friend WithEvents ColumnHeader15 As ColumnHeader + Friend WithEvents ColumnHeader16 As ColumnHeader + Friend WithEvents ColumnHeader18 As ColumnHeader + Friend WithEvents dGridBoard As ListView + Friend WithEvents ColumnHeader As ColumnHeader + Friend WithEvents ColumnHeader17 As ColumnHeader + Friend WithEvents ColumnHeader19 As ColumnHeader + Friend WithEvents ErrorText As TextBox + Friend WithEvents ColumnHeader1 As ColumnHeader + Friend WithEvents ColumnHeader4 As ColumnHeader + Friend WithEvents ColumnHeader5 As ColumnHeader + Friend WithEvents ColumnHeader6 As ColumnHeader + Friend WithEvents dGridSemantic As ListView + Friend WithEvents btnClr As Button End Class diff --git a/Zootopia_Compiler/Form1.vb b/Zootopia_Compiler/Form1.vb index 3a04772..08a6942 100644 --- a/Zootopia_Compiler/Form1.vb +++ b/Zootopia_Compiler/Form1.vb @@ -4,6 +4,10 @@ Imports System.Reflection Imports System.CodeDom Imports System.CodeDom.Compiler Imports Microsoft.VisualBasic +Imports Syntax_Analyzer +Imports Core.Library +Imports Code_Generation + Public Class Form1 Public objList As ListViewItem @@ -15,18 +19,122 @@ Public Class Form1 Dim ismane As Boolean = False Dim errorCtr As Integer = 0 + Dim tokenstream As New List(Of TokenLibrary.TokenLibrary.TokenClass) Dim brccount As Integer Dim paracount As Integer + Public Sub New() + + ' This call is required by the designer. + InitializeComponent() + + ' Add any initialization after the InitializeComponent() call. + + End Sub + Public Class Tokens + Dim line As Integer + Dim token As String + Dim lexeme As String + Dim attribute As String + Public Sub setLine(ByVal line As Integer) + Me.line = line + End Sub + Public Sub setToken(ByVal token As String) + Me.token = token + End Sub + Public Sub setLexeme(ByVal lexeme As String) + Me.lexeme = lexeme + End Sub + Public Sub setAttrib(ByVal attribute As String) + Me.attribute = attribute + End Sub + Public Function getLine() As Integer + Return Me.line + End Function + Public Function getToken() As String + Return Me.token + End Function + Public Function getLexeme() As String + Return Me.lexeme + End Function + Public Function getAttrib() As String + Return Me.attribute + End Function + End Class + + Private Sub lexinew() + + Dim newcode As String = "" + Dim tempcode As String = rTBCode.Text + Dim currcode As String = rTBCode.Text + Dim isLimit As Boolean = False + Dim noExit As Boolean = False + While currcode <> "" + Dim isEnd As Boolean = True + Dim limit As Integer = rTBCode.Text.Length - 1 + currcode = rTBCode.Text + Dim currctr As Integer = 0 + + If currcode.Contains("exit") = False Then + noExit = True + End If + + If noExit Then + currcode = "" + End If + + If currcode <> "" Then + While currcode.ElementAt(currctr) <> "e" + currctr = currctr + 1 + If currctr = limit Then + isEnd = False + isLimit = True + Stop + End If + End While + If (isEnd And ((currctr + 1) <> limit) And currcode.ElementAt(currctr + 1) = "x") Then + currctr = currctr + 1 + Else + isEnd = False + End If + If (isEnd And ((currctr + 1) <> limit) And currcode.ElementAt(currctr + 1) = "i") Then + currctr = currctr + 1 + Else + isEnd = False + End If + If (isEnd And ((currctr + 1) <= limit) And currcode.ElementAt(currctr + 1) = "t") Then + currctr = currctr + 1 + Else + isEnd = False + End If - Private Sub lexi() + If isEnd Then + currcode = "" + End If + If isLimit Then + newcode += rTBCode.Text.Substring(0, currctr) + rTBCode.Text = rTBCode.Text.Substring(currctr) + Else + newcode += rTBCode.Text.Substring(0, currctr + 1) + rTBCode.Text = rTBCode.Text.Substring(currctr + 1) + End If + End If + End While + If noExit Then + rTBCode.Text = tempcode + Else + rTBCode.Text = newcode + End If + + tokenstream.Clear() + Dim tokens As New TokenLibrary.TokenLibrary.TokenClass dGridLexi.Items.Clear() dGridError.Items.Clear() dGridIden.Items.Clear() - 'semant_table.Items.Clear() + dGridSemantic.Items.Clear() dGridBoard.Items.Clear() - Dim sourcecode As String = rTBCode.Text + " " + rTBCode.Text = tempcode Dim sc() As Char = sourcecode.ToCharArray() Dim i As Integer = 0 Dim line As Integer = 1 @@ -34,6 +142,7 @@ Public Class Form1 Dim errorCtr As Integer = 0 Dim symbolCtr As Integer = 0 Dim idCtr As Integer = 0 + Dim idnum As Integer = 1 Dim delimStr As String = "Invalid lexeme " Dim id As String = "" @@ -42,127 +151,167 @@ Public Class Form1 Dim comment As String = "" Dim num As String = "" - Dim allsym(95) As String - allsym(0) = "`" - allsym(1) = "~" - allsym(2) = "1" - allsym(3) = "!" - allsym(4) = "2" - allsym(5) = "$" - allsym(6) = "3" - allsym(7) = "//" - allsym(8) = "4" - allsym(9) = "$" - allsym(10) = "5" - allsym(11) = "%" - allsym(12) = "6" - allsym(13) = "^" - allsym(14) = "7" - allsym(15) = "&" - allsym(16) = "8" - allsym(17) = "*" - allsym(18) = "9" - allsym(19) = "(" - allsym(20) = "0" - allsym(21) = ")" - allsym(22) = "-" - allsym(23) = "_" - allsym(24) = "=" - allsym(25) = "+" - allsym(26) = ":" - allsym(27) = "|" - allsym(28) = "]" - allsym(29) = "}" - allsym(30) = "[" - allsym(31) = "{" - allsym(32) = "'" - allsym(33) = """" - allsym(34) = ";" - allsym(35) = ":" - allsym(36) = "/" - allsym(37) = "?" - allsym(38) = "." - allsym(39) = ">" - allsym(40) = "," - allsym(41) = "<" - allsym(42) = " " - allsym(43) = "q" - allsym(44) = "w" - allsym(45) = "e" - allsym(46) = "r" - allsym(47) = "t" - allsym(48) = "y" - allsym(49) = "u" - allsym(50) = "i" - allsym(51) = "o" - allsym(52) = "p" - allsym(53) = "a" - allsym(54) = "s" - allsym(55) = "d" - allsym(56) = "f" - allsym(57) = "g" - allsym(58) = "h" - allsym(59) = "j" - allsym(60) = "k" - allsym(61) = "l" - allsym(62) = "z" - allsym(63) = "x" - allsym(64) = "c" - allsym(65) = "v" - allsym(66) = "b" - allsym(67) = "n" - allsym(68) = "m" - allsym(69) = "Q" - allsym(70) = "W" - allsym(71) = "E" - allsym(72) = "R" - allsym(73) = "T" - allsym(74) = "Y" - allsym(75) = "U" - allsym(76) = "I" - allsym(77) = "O" - allsym(78) = "P" - allsym(79) = "A" - allsym(80) = "S" - allsym(81) = "D" - allsym(82) = "F" - allsym(83) = "G" - allsym(84) = "H" - allsym(85) = "J" - allsym(86) = "K" - allsym(87) = "L" - allsym(88) = "Z" - allsym(89) = "X" - allsym(90) = "C" - allsym(91) = "V" - allsym(92) = "B" - allsym(93) = "N" - allsym(94) = "M" + Dim delimsymbol(95) As String + delimsymbol(0) = "`" + delimsymbol(1) = "~" + delimsymbol(2) = "1" + delimsymbol(3) = "!" + delimsymbol(4) = "2" + delimsymbol(5) = "@" + delimsymbol(6) = "3" + delimsymbol(7) = "#" + delimsymbol(8) = "4" + delimsymbol(9) = "$" + delimsymbol(10) = "5" + delimsymbol(11) = "%" + delimsymbol(12) = "6" + delimsymbol(13) = "^" + delimsymbol(14) = "7" + delimsymbol(15) = "&" + delimsymbol(16) = "8" + delimsymbol(17) = "*" + delimsymbol(18) = "9" + delimsymbol(19) = "(" + delimsymbol(20) = "0" + delimsymbol(21) = ")" + delimsymbol(22) = "-" + delimsymbol(23) = "_" + delimsymbol(24) = "=" + delimsymbol(25) = "+" + delimsymbol(26) = "\" + delimsymbol(27) = "|" + delimsymbol(28) = "]" + delimsymbol(29) = "}" + delimsymbol(30) = "[" + delimsymbol(31) = "{" + delimsymbol(32) = "'" + delimsymbol(33) = """" + delimsymbol(34) = ";" + delimsymbol(35) = ":" + delimsymbol(36) = "/" + delimsymbol(37) = "?" + delimsymbol(38) = "." + delimsymbol(39) = ">" + delimsymbol(40) = "," + delimsymbol(41) = "<" + delimsymbol(42) = " " + delimsymbol(43) = "q" + delimsymbol(44) = "w" + delimsymbol(45) = "e" + delimsymbol(46) = "r" + delimsymbol(47) = "t" + delimsymbol(48) = "y" + delimsymbol(49) = "u" + delimsymbol(50) = "i" + delimsymbol(51) = "o" + delimsymbol(52) = "p" + delimsymbol(53) = "a" + delimsymbol(54) = "s" + delimsymbol(55) = "d" + delimsymbol(56) = "f" + delimsymbol(57) = "g" + delimsymbol(58) = "h" + delimsymbol(59) = "j" + delimsymbol(60) = "k" + delimsymbol(61) = "l" + delimsymbol(62) = "z" + delimsymbol(63) = "x" + delimsymbol(64) = "c" + delimsymbol(65) = "v" + delimsymbol(66) = "b" + delimsymbol(67) = "n" + delimsymbol(68) = "m" + delimsymbol(69) = "Q" + delimsymbol(70) = "W" + delimsymbol(71) = "E" + delimsymbol(72) = "R" + delimsymbol(73) = "T" + delimsymbol(74) = "Y" + delimsymbol(75) = "U" + delimsymbol(76) = "I" + delimsymbol(77) = "O" + delimsymbol(78) = "P" + delimsymbol(79) = "A" + delimsymbol(80) = "S" + delimsymbol(81) = "D" + delimsymbol(82) = "F" + delimsymbol(83) = "G" + delimsymbol(84) = "H" + delimsymbol(85) = "J" + delimsymbol(86) = "K" + delimsymbol(87) = "L" + delimsymbol(88) = "Z" + delimsymbol(89) = "X" + delimsymbol(90) = "C" + delimsymbol(91) = "V" + delimsymbol(92) = "B" + delimsymbol(93) = "N" + delimsymbol(94) = "M" Dim neg As Boolean = False While i < sourcecode.Length Dim read As Boolean = False - If sc(i) = "b" Then + If sc(i) = "a" Then + If sc(i + 1) = "t" Then + If sc(i + 2) = " " Then + symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("at") + tokens.setLexemes("at") + tokens.setAttributes("at") + tokens.setLines(line) + tokenstream.Add(tokens) + objList = dGridLexi.Items.Add(symbolCtr) + objList.SubItems.Add(line) + objList.SubItems.Add("at") + objList.SubItems.Add("at") + objList.SubItems.Add(" ") + read = True + i += 1 + Else + errorCtr += 1 + objList = dGridError.Items.Add(errorCtr) + objList.SubItems.Add(line) + objList.SubItems.Add(delimStr & "'at'") + read = True + i += 1 + End If + Else + errorCtr += 1 + objList = dGridError.Items.Add(errorCtr) + objList.SubItems.Add(line) + objList.SubItems.Add(delimStr & "'a'") + read = True + End If + + + ElseIf sc(i) = "b" Then If sc(i + 1) = "u" Then If sc(i + 1) = "u" And sc(i + 2) = "l" Then If sc(i + 1) = "u" And sc(i + 2) = "l" And sc(i + 3) = "l" Then - If sc(i + 4) = " " Or sc(i + 4) = "newline" Or Not inArray(sc(i + 4), allsym, 95) Then + If sc(i + 4) = " " Or sc(i + 4) = "," Or sc(i + 4) = ")" Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("bull") + tokens.setLexemes("bull") + tokens.setAttributes("data type") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("bull") objList.SubItems.Add("bull") - objList.SubItems.Add(" ") + objList.SubItems.Add("bull") read = True - i += 4 + i += 3 Else errorCtr += 1 - objList = dGridError.Items.Add(errorCtr) objList.SubItems.Add(line) + objList = dGridError.Items.Add(errorCtr) objList.SubItems.Add(delimStr & "'bull'") read = True - i += 4 + i += 3 End If Else errorCtr += 1 @@ -170,7 +319,7 @@ Public Class Form1 objList.SubItems.Add(line) objList.SubItems.Add(delimStr & "'bul'") read = True - i += 3 + i += 2 End If Else errorCtr += 1 @@ -178,7 +327,7 @@ Public Class Form1 objList.SubItems.Add(line) objList.SubItems.Add(delimStr & "'bu'") read = True - i += 2 + i += 1 End If Else errorCtr += 1 @@ -195,15 +344,21 @@ Public Class Form1 If sc(i + 1) = "h" And sc(i + 2) = "a" And sc(i + 3) = "m" And sc(i + 4) = "o" Then If sc(i + 1) = "h" And sc(i + 2) = "a" And sc(i + 3) = "m" And sc(i + 4) = "o" And sc(i + 5) = "i" Then If sc(i + 1) = "h" And sc(i + 2) = "a" And sc(i + 3) = "m" And sc(i + 4) = "o" And sc(i + 5) = "i" And sc(i + 6) = "s" Then - If sc(i + 7) = " " Or Not inArray(sc(i + 8), allsym, 95) Then + If sc(i + 7) = " " Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("chamois") + tokens.setLexemes("chamois") + tokens.setAttributes("chamois") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("chamois") objList.SubItems.Add("chamois") - objList.SubItems.Add(" ") + objList.SubItems.Add("chamois") read = True - i += 7 + i += 6 Else errorCtr += 1 objList = dGridError.Items.Add(errorCtr) @@ -261,35 +416,47 @@ Public Class Form1 End If ElseIf sc(i) = "d" Then If sc(i + 1) = "o" Then - If sc(i + 2) = " " Or sc(i + 2) = "(" Or sc(i + 2) = "{" Or Not inArray(sc(i + 8), allsym, 95) Then + If sc(i + 2) = " " Or sc(i + 2) = "{" Or sc(i + 2) = "newline" Or Not inArray(sc(i + 2), delimsymbol, 95) Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("do") + tokens.setLexemes("do") + tokens.setAttributes("do") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("do") objList.SubItems.Add("do") - objList.SubItems.Add(" ") + objList.SubItems.Add("do") read = True - i += 3 + i += 1 Else errorCtr += 1 objList = dGridError.Items.Add(errorCtr) objList.SubItems.Add(line) objList.SubItems.Add(delimStr & "'do'") read = True - i += 2 + i += 1 End If ElseIf sc(i + 1) = "u" Then If sc(i + 1) = "u" And sc(i + 2) = "c" Then If sc(i + 1) = "u" And sc(i + 2) = "c" And sc(i + 3) = "k" Then - If sc(i + 4) = " " Or Not inArray(sc(i + 4), allsym, 95) Then + If sc(i + 4) = " " Or sc(i + 4) = ")" Or sc(i + 4) = "," Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("duck") + tokens.setLexemes("duck") + tokens.setAttributes("data type") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("duck") objList.SubItems.Add("duck") - objList.SubItems.Add(" ") + objList.SubItems.Add("data type") read = True - i += 4 + i += 3 Else errorCtr += 1 objList = dGridError.Items.Add(errorCtr) @@ -328,13 +495,19 @@ Public Class Form1 If sc(i + 1) = "e" And sc(i + 2) = "l" And sc(i + 3) = "s" Then If sc(i + 1) = "e" And sc(i + 2) = "l" And sc(i + 3) = "s" And sc(i + 4) = "i" Then If sc(i + 1) = "e" And sc(i + 2) = "l" And sc(i + 3) = "s" And sc(i + 4) = "i" And sc(i + 5) = "f" Then - If sc(i + 6) = "(" Or sc(i + 6) = " " Then + If sc(i + 6) = "(" Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("eelsif") + tokens.setLexemes("eelsif") + tokens.setAttributes("eelsif") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("eelsif") objList.SubItems.Add("eelsif") - objList.SubItems.Add(" ") + objList.SubItems.Add("eelsif") read = True i += 5 Else @@ -354,13 +527,19 @@ Public Class Form1 i += 4 End If ElseIf sc(i + 1) = "e" And sc(i + 2) = "l" And sc(i + 3) = "s" _ - And (sc(i + 4) = " " Or sc(i + 4) = "//" Or sc(i + 4) = "<" Or sc(i + 4) = "newline" Or Not inArray(sc(i + 4), allsym, 95)) Then + And (sc(i + 4) = " " Or sc(i + 4) = "newline" Or Not inArray(sc(i + 4), delimsymbol, 95)) Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("eels") + tokens.setLexemes("eels") + tokens.setAttributes("eels") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("eels") objList.SubItems.Add("eels") - objList.SubItems.Add(" ") + objList.SubItems.Add("eels") read = True i += 3 Else @@ -395,15 +574,21 @@ Public Class Form1 If sc(i + 1) = "n" And sc(i + 2) = "t" And sc(i + 3) = "r" And sc(i + 4) = "a" And sc(i + 5) = "n" Then If sc(i + 1) = "n" And sc(i + 2) = "t" And sc(i + 3) = "r" And sc(i + 4) = "a" And sc(i + 5) = "n" And sc(i + 6) = "c" Then If sc(i + 1) = "n" And sc(i + 2) = "t" And sc(i + 3) = "r" And sc(i + 4) = "a" And sc(i + 5) = "n" And sc(i + 6) = "c" And sc(i + 7) = "e" Then - If sc(i + 8) = " " Or sc(i + 8) = "(" Or sc(i + 8) = "newline" Or Not inArray(sc(i + 8), allsym, 95) Then + If sc(i + 8) = " " Or sc(i + 8) = "'" Or sc(i + 8) = "newline" Or Not inArray(sc(i + 8), delimsymbol, 95) Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("entrance") + tokens.setLexemes("entrance") + tokens.setAttributes("entrance") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("entrance") objList.SubItems.Add("entrance") - objList.SubItems.Add(" ") + objList.SubItems.Add("entrance") read = True - i += 8 + i += 7 Else errorCtr += 1 objList = dGridError.Items.Add(errorCtr) @@ -464,15 +649,21 @@ Public Class Form1 ElseIf sc(i + 1) = "x" Then If sc(i + 1) = "x" And sc(i + 2) = "i" Then If sc(i + 1) = "x" And sc(i + 2) = "i" And sc(i + 3) = "t" Then - If sc(i + 4) = " " Or sc(i + 4) = "(" Or sc(i + 4) = "newline" Or Not inArray(sc(i + 4), allsym, 95) Then + If sc(i + 4) = " " Or Not inArray(sc(i + 4), delimsymbol, 95) Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("exit") + tokens.setLexemes("exit") + tokens.setAttributes("exit") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("exit") objList.SubItems.Add("exit") - objList.SubItems.Add(" ") + objList.SubItems.Add("exit") read = True - i += 4 + i += 3 Else errorCtr += 1 objList = dGridError.Items.Add(errorCtr) @@ -511,15 +702,21 @@ Public Class Form1 If sc(i + 1) = "a" And sc(i + 2) = "l" Then If sc(i + 1) = "a" And sc(i + 2) = "l" And sc(i + 3) = "s" Then If sc(i + 1) = "a" And sc(i + 2) = "l" And sc(i + 3) = "s" And sc(i + 4) = "e" Then - If sc(i + 5) = " " Or sc(i + 5) = ":" Or sc(i + 5) = ")" Or sc(i + 5) = "," Or sc(i + 5) = "}" Or Not inArray(sc(i + 5), allsym, 95) Then + If sc(i + 5) = " " Or sc(i + 5) = ":" Or sc(i + 5) = ")" Or sc(i + 5) = "," Or sc(i + 5) = "}" Or Not inArray(sc(i + 5), delimsymbol, 95) Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("false") + tokens.setLexemes("bullLit") + tokens.setAttributes("bullLit, false") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("false") - objList.SubItems.Add("Bull Literals") - objList.SubItems.Add(" ") + objList.SubItems.Add("bullLit") + objList.SubItems.Add("bullLit, false") read = True - i += 5 + i += 4 Else errorCtr += 1 objList = dGridError.Items.Add(errorCtr) @@ -558,13 +755,19 @@ Public Class Form1 If sc(i + 1) = "u" And sc(i + 2) = "r" Then If sc(i + 3) = "(" Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("fur") + tokens.setLexemes("fur") + tokens.setAttributes("fur") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("fur") objList.SubItems.Add("fur") - objList.SubItems.Add(" ") + objList.SubItems.Add("fur") read = True - i += 3 + i += 2 Else errorCtr += 1 objList = dGridError.Items.Add(errorCtr) @@ -594,13 +797,19 @@ Public Class Form1 If sc(i + 1) = "o" And sc(i + 2) = "p" Then If sc(i + 3) = " " Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("hop") + tokens.setLexemes("hop") + tokens.setAttributes("hop") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("hop") objList.SubItems.Add("hop") - objList.SubItems.Add(" ") + objList.SubItems.Add("hop") read = True - i += 3 + i += 2 Else errorCtr += 1 objList = dGridError.Items.Add(errorCtr) @@ -627,13 +836,19 @@ Public Class Form1 ElseIf sc(i) = "i" Then If sc(i + 1) = "f" Then - If sc(i + 2) = "(" Or sc(i + 2) = " " Then + If sc(i + 2) = "(" Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("if") + tokens.setLexemes("if") + tokens.setAttributes("if") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("if") objList.SubItems.Add("if") - objList.SubItems.Add(" ") + objList.SubItems.Add("if") read = True i += 1 Else @@ -658,16 +873,22 @@ Public Class Form1 If sc(i + 1) = "e" And sc(i + 2) = "t" Then If sc(i + 3) = " " Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("let") + tokens.setLexemes("let") + tokens.setAttributes("let") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("let") objList.SubItems.Add("let") - objList.SubItems.Add(" ") + objList.SubItems.Add("let") read = True i += 2 Else errorCtr += 1 - objList = dGridLexi.Items.Add(errorCtr) + objList = dGridError.Items.Add(errorCtr) objList.SubItems.Add(line) objList.SubItems.Add(delimStr & "'let'") read = True @@ -694,11 +915,17 @@ Public Class Form1 If sc(i + 1) = "a" And sc(i + 2) = "n" And sc(i + 3) = "e" Then If sc(i + 4) = "(" Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("mane") + tokens.setLexemes("mane") + tokens.setAttributes("mane") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("mane") objList.SubItems.Add("mane") - objList.SubItems.Add(" ") + objList.SubItems.Add("mane") read = True i += 3 Else @@ -739,6 +966,12 @@ Public Class Form1 If sc(i + 1) = "e" And sc(i + 2) = "w" And sc(i + 3) = "t" Then If sc(i + 4) = " " Or sc(i + 4) = "," Or sc(i + 4) = ")" Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("newt") + tokens.setLexemes("newt") + tokens.setAttributes("data type") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("newt") @@ -776,6 +1009,12 @@ Public Class Form1 If sc(i + 1) = "u" And sc(i + 2) = "l" And sc(i + 3) = "l" Then If sc(i + 4) = ")" Or sc(i + 4) = " " Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("") + tokens.setLexemes("") + tokens.setAttributes(" ") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("null") @@ -824,13 +1063,19 @@ Public Class Form1 If sc(i + 1) = "t" And sc(i + 2) = "a" And sc(i + 3) = "r" And sc(i + 4) = "l" And sc(i + 5) = "i" Then If sc(i + 1) = "t" And sc(i + 2) = "a" And sc(i + 3) = "r" And sc(i + 4) = "l" And sc(i + 5) = "i" And sc(i + 6) = "n" Then If sc(i + 1) = "t" And sc(i + 2) = "a" And sc(i + 3) = "r" And sc(i + 4) = "l" And sc(i + 5) = "i" And sc(i + 6) = "n" And sc(i + 7) = "g" Then - If sc(i + 8) = " " Or sc(i + 8) = "," Then + If sc(i + 8) = " " Or sc(i + 8) = "," Or sc(i + 8) = ")" Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("starling") + tokens.setLexemes("starling") + tokens.setAttributes("data type") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("starling") objList.SubItems.Add("starling") - objList.SubItems.Add(" ") + objList.SubItems.Add("data type") read = True i += 7 Else @@ -888,11 +1133,17 @@ Public Class Form1 If sc(i + 1) = "t" And sc(i + 2) = "o" And sc(i + 3) = "r" And sc(i + 4) = "k" Then If sc(i + 5) = " " Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("stork") + tokens.setLexemes("stork") + tokens.setAttributes("stork") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("stork") objList.SubItems.Add("stork") - objList.SubItems.Add(" ") + objList.SubItems.Add("stork") read = True i += 4 Else @@ -931,13 +1182,19 @@ Public Class Form1 ElseIf sc(i + 1) = "e" Then If sc(i + 1) = "e" And sc(i + 2) = "a" Then If sc(i + 1) = "e" And sc(i + 2) = "a" And sc(i + 3) = "l" Then - If sc(i + 4) = " " Then + If sc(i + 4) = " " Or sc(i + 4) = ";" Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("seal") + tokens.setLexemes("seal") + tokens.setAttributes("seal") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("seal") objList.SubItems.Add("seal") - objList.SubItems.Add(" ") + objList.SubItems.Add("seal") read = True i += 3 Else @@ -971,11 +1228,17 @@ Public Class Form1 If sc(i + 1) = "w" And sc(i + 2) = "a" And sc(i + 3) = "s" And sc(i + 4) = "p" Then If sc(i + 5) = "(" Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("swasp") + tokens.setLexemes("swasp") + tokens.setAttributes("swasp") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("swasp") objList.SubItems.Add("swasp") - objList.SubItems.Add(" ") + objList.SubItems.Add("swasp") read = True i += 4 Else @@ -1027,14 +1290,20 @@ Public Class Form1 If sc(i + 1) = "e" And sc(i + 2) = "r" And sc(i + 3) = "m" And sc(i + 4) = "i" Then If sc(i + 1) = "e" And sc(i + 2) = "r" And sc(i + 3) = "m" And sc(i + 4) = "i" And sc(i + 5) = "t" Then If sc(i + 1) = "e" And sc(i + 2) = "r" And sc(i + 3) = "m" And sc(i + 4) = "i" And sc(i + 5) = "t" _ - And sc(i + 6) = "e" Then + And sc(i + 6) = "e" Then If sc(i + 7) = " " Or sc(i + 7) = ":" Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("termite") + tokens.setLexemes("termite") + tokens.setAttributes("termite") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("termite") objList.SubItems.Add("termite") - objList.SubItems.Add(" ") + objList.SubItems.Add("termite") read = True i += 6 Else @@ -1085,6 +1354,50 @@ Public Class Form1 read = True i += 1 End If + + ElseIf sc(i + 1) = "r" Then + If sc(i + 1) = "r" And sc(i + 2) = "u" Then + If sc(i + 1) = "r" And sc(i + 2) = "u" And sc(i + 3) = "e" Then + If sc(i + 4) = " " Or sc(i + 4) = ":" Or sc(i + 4) = ")" Or sc(i + 4) = "," Or sc(i + 4) = "}" Or Not inArray(sc(i + 4), delimsymbol, 95) Then + symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("true") + tokens.setLexemes("bullLit") + tokens.setAttributes("bullLit, true") + tokens.setLines(line) + tokenstream.Add(tokens) + objList = dGridLexi.Items.Add(symbolCtr) + objList.SubItems.Add(line) + objList.SubItems.Add("true") + objList.SubItems.Add("bullLit") + objList.SubItems.Add("bullLite, true") + read = True + i += 3 + Else + errorCtr += 1 + objList = dGridError.Items.Add(errorCtr) + objList.SubItems.Add(line) + objList.SubItems.Add(delimStr & "'true'") + read = True + i += 3 + End If + Else + errorCtr += 1 + objList = dGridError.Items.Add(errorCtr) + objList.SubItems.Add(line) + objList.SubItems.Add(delimStr & "'tru'") + read = True + i += 2 + End If + Else + errorCtr += 1 + objList = dGridError.Items.Add(errorCtr) + objList.SubItems.Add(line) + objList.SubItems.Add(delimStr & "'tr'") + read = True + i += 1 + End If + Else errorCtr += 1 objList = dGridError.Items.Add(errorCtr) @@ -1093,20 +1406,24 @@ Public Class Form1 read = True End If - ElseIf sc(i) = "v" Then If sc(i + 1) = "i" Then If sc(i + 1) = "i" And sc(i + 2) = "p" Then If sc(i + 1) = "i" And sc(i + 2) = "p" And sc(i + 3) = "e" Then If sc(i + 1) = "i" And sc(i + 2) = "p" And sc(i + 3) = "e" And sc(i + 4) = "r" Then If sc(i + 5) = " " Then - symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("viper") + tokens.setLexemes("viper") + tokens.setAttributes("data type") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("viper") objList.SubItems.Add("viper") - objList.SubItems.Add("Data Type") + objList.SubItems.Add("data type") read = True i += 4 Else @@ -1156,11 +1473,17 @@ Public Class Form1 If sc(i + 1) = "h" And sc(i + 2) = "a" And sc(i + 3) = "l" And sc(i + 4) = "e" Then If sc(i + 5) = "(" Or sc(i + 5) = " " Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("whale") + tokens.setLexemes("whale") + tokens.setAttributes("whale") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("whale") objList.SubItems.Add("whale") - objList.SubItems.Add(" ") + objList.SubItems.Add("whale") read = True i += 4 Else @@ -1198,42 +1521,48 @@ Public Class Form1 ElseIf sc(i + 1) = "i" Then If sc(i + 1) = "i" And sc(i + 2) = "p" Then - If sc(i + 1) = "i" And sc(i + 2) = "p" And sc(i + 3) = "e" Then - If sc(i + 4) = " " Or sc(i + 4) = ":" Then - symbolCtr += 1 - objList = dGridLexi.Items.Add(symbolCtr) - objList.SubItems.Add(line) - objList.SubItems.Add("wipe") - objList.SubItems.Add("wipe") - objList.SubItems.Add(" ") - read = True - i += 3 - Else - errorCtr += 1 - objList = dGridError.Items.Add(errorCtr) - objList.SubItems.Add(line) - objList.SubItems.Add(delimStr & "'wipe'") - read = True - i += 3 - End If + If sc(i + 1) = "i" And sc(i + 2) = "p" And sc(i + 3) = "e" Then + If sc(i + 4) = " " Or sc(i + 4) = ":" Then + symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("wipe") + tokens.setLexemes("wipe") + tokens.setAttributes("wipe") + tokens.setLines(line) + tokenstream.Add(tokens) + objList = dGridLexi.Items.Add(symbolCtr) + objList.SubItems.Add(line) + objList.SubItems.Add("wipe") + objList.SubItems.Add("wipe") + objList.SubItems.Add("wipe") + read = True + i += 3 Else errorCtr += 1 objList = dGridError.Items.Add(errorCtr) objList.SubItems.Add(line) - objList.SubItems.Add(delimStr & "'wip'") + objList.SubItems.Add(delimStr & "'wipe'") read = True - i += 2 + i += 3 End If Else errorCtr += 1 objList = dGridError.Items.Add(errorCtr) objList.SubItems.Add(line) - objList.SubItems.Add(delimStr & "'wi'") + objList.SubItems.Add(delimStr & "'wip'") read = True - i += 1 + i += 2 End If Else errorCtr += 1 + objList = dGridError.Items.Add(errorCtr) + objList.SubItems.Add(line) + objList.SubItems.Add(delimStr & "'wi'") + read = True + i += 1 + End If + Else + errorCtr += 1 objList = dGridError.Items.Add(errorCtr) objList.SubItems.Add(line) objList.SubItems.Add(delimStr & "'w'") @@ -1245,13 +1574,19 @@ Public Class Form1 If sc(i + 1) = "o" And sc(i + 2) = "o" Then If sc(i + 1) = "o" And sc(i + 2) = "o" And sc(i + 3) = "u" Then If sc(i + 1) = "o" And sc(i + 2) = "o" And sc(i + 3) = "u" And sc(i + 4) = "t" Then - If sc(i + 5) = "(" Then + If sc(i + 5) = "<" Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("zoout") + tokens.setLexemes("zoout") + tokens.setAttributes("zoout") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("zoout") objList.SubItems.Add("zoout") - objList.SubItems.Add(" ") + objList.SubItems.Add("zoout") read = True i += 4 Else @@ -1273,13 +1608,19 @@ Public Class Form1 ElseIf sc(i + 1) = "o" And sc(i + 2) = "o" And sc(i + 3) = "i" Then If sc(i + 1) = "o" And sc(i + 2) = "o" And sc(i + 3) = "i" And sc(i + 4) = "n" Then - If sc(i + 5) = ")" Or sc(i + 5) = " " Then + If sc(i + 5) = ">" Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("zooin") + tokens.setLexemes("zooin") + tokens.setAttributes("zooin") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("zooin") objList.SubItems.Add("zooin") - objList.SubItems.Add(" ") + objList.SubItems.Add("zooin") read = True i += 4 Else @@ -1464,10 +1805,16 @@ Public Class Form1 If sc(i + 1) = "=" Then If sc(i + 2) = " " Or sc(i + 2) = "$" Or sc(i + 2) = "(" Or sc(i + 2) = "~" Or sc(i + 2) = """" Or Char.IsDigit(sc(i + 2)) Or sc(i + 2) = "t" Or sc(i + 2) = "f" Or sc(i + 2) = "n" Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("==") + tokens.setLexemes("relOp2") + tokens.setAttributes("relOp, ==") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("==") - objList.SubItems.Add("relational Operator") + objList.SubItems.Add("relOp2") objList.SubItems.Add("relOp, ==") i += 1 read = True @@ -1481,10 +1828,16 @@ Public Class Form1 End If ElseIf sc(i + 1) = " " Or sc(i + 1) = "$" Or sc(i + 1) = "(" Or sc(i + 1) = "~" Or sc(i + 1) = "{" Or sc(i + 1) = """" Or Char.IsDigit(sc(i + 1)) Or sc(i + 1) = "t" Or sc(i + 1) = "f" Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("=") + tokens.setLexemes("assgnOp") + tokens.setAttributes("assgnOp, =") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("=") - objList.SubItems.Add("Assignment Operator") + objList.SubItems.Add("assgnOp") objList.SubItems.Add("assgnOp, =") read = True Else @@ -1499,12 +1852,18 @@ Public Class Form1 If sc(i) = "+" Then If sc(i + 1) = "+" Then - If sc(i + 2) = " " Or sc(i + 2) = "$" Or sc(i + 2) = "~" Or sc(i + 2) = "\" Or sc(i + 2) = ")" Or Char.IsDigit(sc(i + 2)) Then + If sc(i + 2) = " " Or sc(i + 2) = """" Or sc(i + 2) = "$" Or sc(i + 2) = ":" Or sc(i + 2) = ")" Or Char.IsDigit(sc(i + 2)) Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("++") + tokens.setLexemes("increOp") + tokens.setAttributes("increOp, ++") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("++") - objList.SubItems.Add("increment Operator") + objList.SubItems.Add("increOp") objList.SubItems.Add("increOp, ++") i += 1 read = True @@ -1536,10 +1895,16 @@ Public Class Form1 ' End If ElseIf sc(i + 1) = " " Or sc(i + 1) = "$" Or sc(i + 1) = "(" Or sc(i + 1) = "~" Or Char.IsDigit(sc(i + 1)) Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("+") + tokens.setLexemes("mathOp") + tokens.setAttributes("addOp, +") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("+") - objList.SubItems.Add("Math Operator") + objList.SubItems.Add("mathOp") objList.SubItems.Add("addOp, +") read = True Else @@ -1554,12 +1919,18 @@ Public Class Form1 If sc(i) = "-" Then If sc(i + 1) = "-" Then - If sc(i + 2) = " " Or sc(i + 2) = "$" Or sc(i + 2) = "~" Or sc(i + 2) = ":" Or sc(i + 2) = ")" Or Char.IsDigit(sc(i + 2)) Then + If sc(i + 2) = " " Or sc(i + 2) = """" Or sc(i + 2) = "$" Or sc(i + 2) = ":" Or sc(i + 2) = ")" Or Char.IsDigit(sc(i + 2)) Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("--") + tokens.setLexemes("decreOp") + tokens.setAttributes("decreOp, --") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("--") - objList.SubItems.Add("decrement Operator") + objList.SubItems.Add("decreOp") objList.SubItems.Add("decreOp, --") i += 1 read = True @@ -1591,10 +1962,16 @@ Public Class Form1 ' End If ElseIf sc(i + 1) = " " Or sc(i + 1) = "$" Or sc(i + 1) = "(" Or sc(i + 1) = "~" Or Char.IsDigit(sc(i + 1)) Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("-") + tokens.setLexemes("mathOp") + tokens.setAttributes("subOp, -") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("-") - objList.SubItems.Add("Math Operator") + objList.SubItems.Add("mathOp") objList.SubItems.Add("subOp, -") read = True Else @@ -1608,30 +1985,18 @@ Public Class Form1 'END NG - If sc(i) = "*" Then - 'If sc(i + 1) = "=" Then - ' If sc(i + 2) = " " Or sc(i + 2) = "$" Or sc(i + 2) = "(" Or sc(i + 2) = "~" Or Char.IsDigit(sc(i + 2)) Then - ' symbolCtr += 1 - ' objList = dGridLexi.Items.Add(symbolCtr) - ' objList.SubItems.Add(line) - ' objList.SubItems.Add("*=") - ' objList.SubItems.Add("assgnOp2") - ' objList.SubItems.Add("assgnOp, *=") - ' i += 1 - ' read = True - ' Else - ' errorCtr += 1 - ' objList = dGridError.Items.Add(errorCtr) - ' objList.SubItems.Add(line) - ' objList.SubItems.Add(delimStr & "'*='") - ' i += 1 - ' read = True - ' End If If sc(i + 1) = " " Or sc(i + 1) = "$" Or sc(i + 1) = "(" Or sc(i + 1) = "~" Or Char.IsDigit(sc(i + 1)) Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("*") + tokens.setLexemes("mathOp") + tokens.setAttributes("mulOp, *") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("*") - objList.SubItems.Add("Math Operator") + objList.SubItems.Add("mathOp") objList.SubItems.Add("mulOp, *") read = True Else @@ -1665,11 +2030,17 @@ Public Class Form1 ' End If If sc(i + 1) = " " Or sc(i + 1) = "$" Or sc(i + 1) = "(" Or sc(i + 1) = "~" Or Char.IsDigit(sc(i + 1)) Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("/") + tokens.setLexemes("mathOp") + tokens.setAttributes("divOp, /") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("/") - objList.SubItems.Add("Math Operator") - objList.SubItems.Add("mulOp, /") + objList.SubItems.Add("mathOp") + objList.SubItems.Add("divOp, /") 'mulOp read = True Else errorCtr += 1 @@ -1702,11 +2073,17 @@ Public Class Form1 ' End If If sc(i + 1) = " " Or sc(i + 1) = "$" Or sc(i + 1) = "(" Or sc(i + 1) = "~" Or Char.IsDigit(sc(i + 1)) Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("%") + tokens.setLexemes("modOp") + tokens.setAttributes("modOp, %") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("%") - objList.SubItems.Add("Math Operator") - objList.SubItems.Add("mulOp, %") + objList.SubItems.Add("mathOp") + objList.SubItems.Add("modOp, %") read = True Else errorCtr += 1 @@ -1718,33 +2095,44 @@ Public Class Form1 End If 'END NG % - If sc(i) = "." Then - If sc(i + 1) = "+" Then - If sc(i + 2) = " " Or sc(i + 2) = "$" Or Char.IsLetter(sc(1 + 2)) Then - symbolCtr += 1 - objList = dGridLexi.Items.Add(symbolCtr) - objList.SubItems.Add(line) - objList.SubItems.Add(".+") - objList.SubItems.Add(".+") - objList.SubItems.Add("structOp, .+") - i += 1 - read = True - Else - errorCtr += 1 - objList = dGridError.Items.Add(errorCtr) - objList.SubItems.Add(line) - objList.SubItems.Add(delimStr & "'.+'") - i += 1 - read = True - End If + If sc(i) = "?" Then + If sc(i + 2) = " " Or sc(i + 2) = "$" Or Not inArray(sc(i + 2), delimsymbol, 95) Then + symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("?") + tokens.setLexemes("?") + tokens.setAttributes("strOp, ?, binary") + tokens.setLines(line) + tokenstream.Add(tokens) + objList = dGridLexi.Items.Add(symbolCtr) + objList.SubItems.Add(line) + objList.SubItems.Add("?") + objList.SubItems.Add("?") + objList.SubItems.Add("strOp, ?, binary") + i += 1 + read = True + Else + errorCtr += 1 + objList = dGridError.Items.Add(errorCtr) + objList.SubItems.Add(line) + objList.SubItems.Add(delimStr & "'?'") + i += 1 + read = True End If End If - ' END NG . + + ' END NG ? If sc(i) = "!" Then If sc(i + 1) = "=" Then If sc(i + 2) = " " Or sc(i + 2) = "$" Or sc(i + 2) = "(" Or sc(i + 2) = "~" Or sc(i + 2) = """" Or sc(i + 2) = "f" Or sc(i + 2) = "t" Or sc(i + 2) = "n" Or Char.IsDigit(sc(i + 2)) Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("!=") + tokens.setLexemes("relOp2") + tokens.setAttributes("relOp, !=") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("!=") @@ -1760,8 +2148,14 @@ Public Class Form1 i += 1 read = True End If - ElseIf sc(i + 1) = " " Or sc(i + 1) = "(" Or sc(i + 1) = "$" Or sc(i + 1) = "t" Or sc(i + 1) = "f" Then + ElseIf sc(i + 1) = " " Or sc(i + 1) = "(" Or sc(i + 1) = "$" Or sc(i + 1) = "t" Or sc(i + 1) = "f" Or Not inArray(sc(i + 1), delimsymbol, 95) Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("!") + tokens.setLexemes("!") + tokens.setAttributes("logOp, !") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("!") @@ -1780,8 +2174,14 @@ Public Class Form1 If sc(i) = "<" Then If sc(i + 1) = "=" Then - If sc(i + 2) = " " Or sc(i + 2) = "$" Or sc(i + 2) = "(" Or sc(i + 2) = "~" Or Char.IsDigit(sc(i + 2)) Then + If sc(i + 2) = " " Or sc(i + 2) = "$" Or sc(i + 2) = "(" Or sc(i + 2) = "~" Or sc(i + 2) = "{" Or Char.IsDigit(sc(i + 2)) Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("<=") + tokens.setLexemes("relOp1") + tokens.setAttributes("relOp, <=") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("<=") @@ -1789,6 +2189,7 @@ Public Class Form1 objList.SubItems.Add("relOp, <=") i += 1 read = True + Else errorCtr += 1 objList = dGridError.Items.Add(errorCtr) @@ -1797,8 +2198,29 @@ Public Class Form1 i += 1 read = True End If + ElseIf sc(i + 1) = "<" Then + symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("<<") + tokens.setLexemes("<<") + tokens.setAttributes("output symbol") + tokens.setLines(line) + tokenstream.Add(tokens) + objList = dGridLexi.Items.Add(symbolCtr) + objList.SubItems.Add(line) + objList.SubItems.Add("<<") + objList.SubItems.Add("<<") + objList.SubItems.Add("output symbol") + i += 1 + read = True ElseIf sc(i + 1) = " " Or sc(i + 1) = "$" Or sc(i + 1) = "(" Or sc(i + 1) = "~" Or Char.IsDigit(sc(i + 1)) Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("<") + tokens.setLexemes("relOp1") + tokens.setAttributes("relOp, <") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("<") @@ -1821,10 +2243,16 @@ Public Class Form1 If sc(i + 1) = "=" Then If sc(i + 2) = " " Or sc(i + 2) = "$" Or sc(i + 2) = "(" Or sc(i + 2) = "~" Or Char.IsDigit(sc(i + 2)) Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens(">=") + tokens.setLexemes("relOp1") + tokens.setAttributes("relOp, >=") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add(">=") - objList.SubItems.Add("relational Operator") + objList.SubItems.Add("relOp1") objList.SubItems.Add("relOp, >=") i += 1 read = True @@ -1836,13 +2264,34 @@ Public Class Form1 i += 1 read = True End If + ElseIf sc(i + 1) = ">" Then + symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens(">>") + tokens.setLexemes(">>") + tokens.setAttributes("input symbol") + tokens.setLines(line) + tokenstream.Add(tokens) + objList = dGridLexi.Items.Add(symbolCtr) + objList.SubItems.Add(line) + objList.SubItems.Add(">>") + objList.SubItems.Add(">>") + objList.SubItems.Add("input symbol") + i += 1 + read = True ElseIf sc(i + 1) = " " Or sc(i + 1) = "$" Or sc(i + 1) = "(" Or sc(i + 1) = "~" Or Char.IsDigit(sc(i + 1)) Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens(">") + tokens.setLexemes("relOp1") + tokens.setAttributes("relOp, >") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add(">") - objList.SubItems.Add("relational Operator") - objList.SubItems.Add("relOp, <") + objList.SubItems.Add("relOp1") + objList.SubItems.Add("relOp, >") read = True Else errorCtr += 1 @@ -1854,58 +2303,17 @@ Public Class Form1 End If 'END NG > - If sc(i) = ")" Then - If sc(i + 1) = ")" Then - If sc(i + 2) = " " Or sc(i + 2) = "$" Then - symbolCtr += 1 - objList = dGridLexi.Items.Add(symbolCtr) - objList.SubItems.Add(line) - objList.SubItems.Add("))") - objList.SubItems.Add("))") - objList.SubItems.Add("input symbol") - i += 1 - read = True - Else - errorCtr += 1 - objList = dGridError.Items.Add(errorCtr) - objList.SubItems.Add(line) - objList.SubItems.Add(delimStr & "'))'") - i += 1 - read = True - End If - End If - End If - 'End ng )) - - - If sc(i) = "(" Then - If sc(i + 1) = "(" Then - If sc(i + 2) = " " Or sc(i + 2) = "$" Or sc(i + 2) = ":" _ - Or sc(i + 2) = "(" Or sc(i + 2) = """" Or Char.IsDigit(sc(i + 2)) Then - symbolCtr += 1 - objList = dGridLexi.Items.Add(symbolCtr) - objList.SubItems.Add(line) - objList.SubItems.Add("((") - objList.SubItems.Add("((") - objList.SubItems.Add("Output symbol") - i += 1 - read = True - Else - errorCtr += 1 - objList = dGridError.Items.Add(errorCtr) - objList.SubItems.Add(line) - objList.SubItems.Add(delimStr & "'(('") - i += 1 - read = True - End If - End If - End If - 'END ng (( If sc(i) = "\" Then If sc(i + 1) = "n" Then - If sc(i + 2) = " " Or sc(i + 2) = ":" Then + If sc(i + 2) = " " Or sc(i + 2) = ":" Or sc(i + 2) = "\" Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("\n") + tokens.setLexemes("\n") + tokens.setAttributes("newline symbol") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("\n") @@ -1925,6 +2333,12 @@ Public Class Form1 ElseIf sc(i + 1) = "t" Then If sc(i + 2) = " " Or sc(i + 2) = ":" Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("\t") + tokens.setLexemes("\t") + tokens.setAttributes("tab symbol") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("\t") @@ -1951,12 +2365,18 @@ Public Class Form1 'END NG \ If sc(i) = "^" Then - If sc(i + 1) = " " Or sc(i + 1) = "$" Or sc(i + 1) = "(" Or sc(i + 1) = "~" Or Char.IsDigit(sc(i + 1)) Then + If sc(i + 1) = "$" Or sc(i + 1) = "(" Or sc(i + 1) = "~" Or Char.IsDigit(sc(i + 1)) Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("^") + tokens.setLexemes("mathop") + tokens.setAttributes("powerOp, ^") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("^") - objList.SubItems.Add("math Operator") + objList.SubItems.Add("mathOp") objList.SubItems.Add("powerOp, ^") read = True Else @@ -1973,17 +2393,25 @@ Public Class Form1 If sc(i + 1) = "&" Then If sc(i + 2) = " " Or sc(i + 2) = "(" Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("&&") + tokens.setLexemes("&&") + tokens.setAttributes("logOp, &&") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("&&") - objList.SubItems.Add("logical Operator") - objList.SubItems.Add("logOp, &") + objList.SubItems.Add("&&") + objList.SubItems.Add("logOp, &&") + i += 1 read = True Else errorCtr += 1 objList = dGridError.Items.Add(errorCtr) objList.SubItems.Add(line) objList.SubItems.Add(delimStr & "'&&'") + i += 1 read = True End If End If @@ -1994,17 +2422,25 @@ Public Class Form1 If sc(i + 1) = "|" Then If sc(i + 2) = " " Or sc(i + 2) = "(" Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("||") + tokens.setLexemes("||") + tokens.setAttributes("logOp, ||") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("||") - objList.SubItems.Add("logical Operator") + objList.SubItems.Add("||") objList.SubItems.Add("logOp, ||") + i += 1 read = True Else errorCtr += 1 objList = dGridError.Items.Add(errorCtr) objList.SubItems.Add(line) objList.SubItems.Add(delimStr & "'||'") + i += 1 read = True End If End If @@ -2012,40 +2448,107 @@ Public Class Form1 'END NG || + + If sc(i) = "(" Then - If sc(i + 1) = " " Or sc(i + 1) = "$" Or sc(i + 1) = "(" Or sc(i + 1) = ")" Or sc(i + 1) = "~" _ - Or sc(i + 1) = "+" Or sc(i + 1) = "-" Or sc(i + 1) = "f" Or sc(i + 1) = "t" Or sc(i + 1) = "w" _ - Or sc(i + 1) = """" Or sc(i + 1) = "!" Or sc(i + 1) = "'" Or Char.IsDigit(sc(i + 1)) Then - symbolCtr += 1 - objList = dGridLexi.Items.Add(symbolCtr) - objList.SubItems.Add(line) - objList.SubItems.Add("(") - objList.SubItems.Add("openpar") - objList.SubItems.Add("openpar") - read = True - Else - errorCtr += 1 - objList = dGridError.Items.Add(errorCtr) - objList.SubItems.Add(line) + 'If sc(i + 1) = "(" Then + ' If sc(i + 2) = " " Or sc(i + 2) = "$" _ + ' Or sc(i + 2) = """" Or Char.IsDigit(sc(i + 2)) Then + ' symbolCtr += 1 + ' tokens = New TokenLibrary.TokenLibrary.TokenClass + ' tokens.setTokens("((") + ' tokens.setLexemes("((") + ' tokens.setAttributes("output symbol") + ' tokens.setLines(line) + ' tokenstream.Add(tokens) + ' objList = dGridLexi.Items.Add(symbolCtr) + ' objList.SubItems.Add(line) + ' objList.SubItems.Add("((") + ' objList.SubItems.Add("((") + ' objList.SubItems.Add("output symbol") + ' i += 1 + ' read = True + ' Else + ' errorCtr += 1 + ' objList = dGridError.Items.Add(errorCtr) + ' objList.SubItems.Add(line) + ' objList.SubItems.Add(delimStr & "'(('") + ' i += 1 + ' read = True + ' End If + + If sc(i + 1) = " " Or sc(i + 1) = "$" Or sc(i + 1) = ")" Or sc(i + 1) = "~" Or sc(i + 1) = "(" _ + Or sc(i + 1) = "+" Or sc(i + 1) = "-" Or sc(i + 1) = "n" Or sc(i + 1) = "d" Or sc(i + 1) = "s" _ + Or sc(i + 1) = "b" Or sc(i + 1) = """" Or sc(i + 1) = "!" Or sc(i + 1) = "'" Or Char.IsDigit(sc(i + 1)) _ + Or Not inArray(sc(i + 1), delimsymbol, 95) Then + symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("(") + tokens.setLexemes("(") + tokens.setAttributes("oppar") + tokens.setLines(line) + tokenstream.Add(tokens) + objList = dGridLexi.Items.Add(symbolCtr) + objList.SubItems.Add(line) + objList.SubItems.Add("(") + objList.SubItems.Add("oppar") + objList.SubItems.Add("oppar") + read = True + Else + errorCtr += 1 + objList = dGridError.Items.Add(errorCtr) + objList.SubItems.Add(line) objList.SubItems.Add(delimStr & "'('") read = True End If End If 'END NG ( + If sc(i) = ")" Then - If sc(i + 1) = " " Or sc(i + 1) = ")" Or sc(i + 1) = "," Or sc(i + 1) = ":" _ - Or sc(i + 1) = "\" Or sc(i + 1) = "+" Or sc(i + 1) = "-" Or sc(i + 1) = "*" _ - Or sc(i + 1) = "/" Or sc(i + 1) = "%" Or sc(i + 1) = "^" Or sc(i + 1) = "&" _ - Or sc(i + 1) = "|" Or sc(i + 1) = "<" Or sc(i + 1) = ">" Or sc(i + 1) = "=" _ - Or sc(i + 1) = "!" Or sc(i + 1) = "//" Or sc(i + 1) = "}" Or sc(i + 1) = "newline" _ - Or Not inArray(sc(i + 1), allsym, 95) Then + 'If sc(i + 1) = ")" Then + 'If sc(i + 2) = " " Or sc(i + 2) = "$" Then + ' symbolCtr += 1 + ' tokens = New TokenLibrary.TokenLibrary.TokenClass + ' tokens.setTokens("))") + ' tokens.setLexemes("))") + ' tokens.setAttributes("input symbol") + ' tokens.setLines(line) + ' tokenstream.Add(tokens) + ' objList = dGridLexi.Items.Add(symbolCtr) + ' objList.SubItems.Add(line) + ' objList.SubItems.Add("))") + ' objList.SubItems.Add("))") + ' objList.SubItems.Add("input symbol") + ' i += 1 + ' read = True + 'Else + ' errorCtr += 1 + ' objList = dGridError.Items.Add(errorCtr) + ' objList.SubItems.Add(line) + ' objList.SubItems.Add(delimStr & "'))'") + ' i += 1 + ' read = True + 'End If + + If sc(i + 1) = " " Or sc(i + 1) = "," Or sc(i + 1) = ":" _ + Or sc(i + 1) = "+" Or sc(i + 1) = "-" Or sc(i + 1) = "*" _ + Or sc(i + 1) = "/" Or sc(i + 1) = "%" Or sc(i + 1) = "^" Or sc(i + 1) = "&" _ + Or sc(i + 1) = "|" Or sc(i + 1) = "<" Or sc(i + 1) = ">" Or sc(i + 1) = "=" _ + Or sc(i + 1) = "!" Or sc(i + 1) = " ' " Or sc(i + 1) = "}" Or sc(i + 1) = "newline" _ + Or sc(i + 1) = ")" Or Not inArray(sc(i + 1), delimsymbol, 95) Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens(")") + tokens.setLexemes("clpar") + tokens.setAttributes("clpar") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add(")") - objList.SubItems.Add("closepar") - objList.SubItems.Add("closepar") + objList.SubItems.Add("clpar") + objList.SubItems.Add("clpar") read = True Else errorCtr += 1 @@ -2060,11 +2563,17 @@ Public Class Form1 If sc(i) = "[" Then If sc(i + 1) = " " Or sc(i + 1) = "$" Or sc(i + 1) = "]" Or Char.IsDigit(sc(i + 1)) Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("[") + tokens.setLexemes("opsquare") + tokens.setAttributes("opsquare") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("[") - objList.SubItems.Add("openarray") - objList.SubItems.Add("openarray") + objList.SubItems.Add("opsquare") + objList.SubItems.Add("opsquare") read = True Else errorCtr += 1 @@ -2084,11 +2593,17 @@ Public Class Form1 Or sc(i + 1) = "|" Or sc(i + 1) = "<" Or sc(i + 1) = ">" _ Or sc(i + 1) = "=" Or sc(i + 1) = "!" Or sc(i + 1) = "[" Or sc(i + 1) = ")" Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("]") + tokens.setLexemes("clsquare") + tokens.setAttributes("clsquare") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("]") - objList.SubItems.Add("closearray") - objList.SubItems.Add("closearray") + objList.SubItems.Add("clsquare") + objList.SubItems.Add("clsquare") read = True Else errorCtr += 1 @@ -2102,13 +2617,19 @@ Public Class Form1 If sc(i) = "{" Then If sc(i + 1) = "{" Then - If sc(i + 2) = " " Or sc(i + 2) = "//" Or sc(i + 2) = "$" Or sc(i + 2) = "~" Or sc(i + 2) = "(" Or sc(i + 2) = "w" Or sc(i + 2) = "t" Or sc(i + 2) = "f" Or sc(i + 2) = "c" Or sc(i + 2) = "r" Or sc(i + 2) = "d" Or sc(i + 2) = "newline" Or Not inArray(sc(i + 2), allsym, 95) Then + If sc(i + 2) = " " Or sc(i + 2) = "'" Or sc(i + 2) = "$" Or sc(i + 2) = "~" Or sc(i + 2) = "(" Or sc(i + 2) = "w" Or sc(i + 2) = "t" Or sc(i + 2) = "f" Or sc(i + 2) = "c" Or sc(i + 2) = "r" Or sc(i + 2) = "d" Or sc(i + 2) = "newline" Or Not inArray(sc(i + 2), delimsymbol, 95) Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("{{") + tokens.setLexemes("opsymbol") + tokens.setAttributes("opsymbol") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("{{") - objList.SubItems.Add("Open Symbol") - objList.SubItems.Add("Open Symbol") + objList.SubItems.Add("opsymbol") + objList.SubItems.Add("opsymbol") i += 1 read = True Else @@ -2120,14 +2641,20 @@ Public Class Form1 read = True End If - ElseIf sc(i + 1) = " " Or sc(i + 1) = "(" Or sc(i + 1) = "~" Or sc(i + 1) = """" Or sc(i + 1) = "f" _ - Or sc(i + 1) = "t" Or sc(i + 1) = "$" Or Char.IsDigit(sc(i + 1)) Then + ElseIf sc(i + 1) = " " Or sc(i + 1) = "(" Or sc(i + 1) = "~" Or sc(i + 1) = """" Or sc(i + 1) = "d" _ + Or sc(i + 1) = "s" Or sc(i + 1) = "$" Or Char.IsDigit(sc(i + 1)) Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("{") + tokens.setLexemes("opcurly") + tokens.setAttributes("opcurly") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("{") - objList.SubItems.Add("openElem") - objList.SubItems.Add("openElem") + objList.SubItems.Add("opcurly") + objList.SubItems.Add("opcurly") read = True Else errorCtr += 1 @@ -2142,13 +2669,19 @@ Public Class Form1 If sc(i) = "}" Then If sc(i + 1) = "}" Then - If sc(i + 2) = " " Or sc(i + 2) = "//" Or sc(i + 2) = "$" Or sc(i + 2) = ":" Or sc(i + 2) = "d" Or sc(i + 2) = "newline" Or Not inArray(sc(i + 2), allsym, 95) Then 'pending nl + If sc(i + 2) = " " Or sc(i + 2) = "'" Or sc(i + 2) = "$" Or sc(i + 2) = ":" Or sc(i + 2) = "d" Or sc(i + 2) = "newline" Or Not inArray(sc(i + 2), delimsymbol, 95) Then 'pending nl symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("}}") + tokens.setLexemes("clsymbol") + tokens.setAttributes("clsymbol") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("}}") - objList.SubItems.Add("Close Symbol") - objList.SubItems.Add("Close Symbol") + objList.SubItems.Add("clsymbol") + objList.SubItems.Add("clsymbol") i += 1 read = True Else @@ -2160,35 +2693,47 @@ Public Class Form1 read = True End If - ElseIf sc(i + 1) = " " Or sc(i + 1) = "\" Or sc(i + 1) = "," Then + ElseIf sc(i + 1) = " " Or sc(i + 1) = ":" Or sc(i + 1) = "," Then symbolCtr += 1 - objList = dGridLexi.Items.Add(symbolCtr) - objList.SubItems.Add(line) - objList.SubItems.Add("}") - objList.SubItems.Add("clcurly") - objList.SubItems.Add("clcurly") - read = True - Else - errorCtr += 1 - objList = dGridError.Items.Add(errorCtr) - objList.SubItems.Add(line) - objList.SubItems.Add(delimStr & "'}'") - read = True - End If - + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("}") + tokens.setLexemes("clcurly") + tokens.setAttributes("clcurly") + tokens.setLines(line) + tokenstream.Add(tokens) + objList = dGridLexi.Items.Add(symbolCtr) + objList.SubItems.Add(line) + objList.SubItems.Add("}") + objList.SubItems.Add("clcurly") + objList.SubItems.Add("clcurly") + read = True + Else + errorCtr += 1 + objList = dGridError.Items.Add(errorCtr) + objList.SubItems.Add(line) + objList.SubItems.Add(delimStr & "'}'") + read = True End If - 'END NG } + End If + + 'END NG } - If sc(i) = ";" Then + If sc(i) = ";" Then If i + 1 < sourcecode.Length Then - If sc(i + 1) = " " Or sc(i + 1) = "<" Or sc(i + 1) = "//" Or sc(i + 1) = "t" Or sc(i + 1) = "newline" Or Not inArray(sc(i + 1), allsym, 95) Then + If sc(i + 1) = " " Or sc(i + 1) = "<" Or sc(i + 1) = "'" Or sc(i + 1) = "newline" Or Not inArray(sc(i + 1), delimsymbol, 95) Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens(";") + tokens.setLexemes(";") + tokens.setAttributes("switch terminal symbol") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add(";") objList.SubItems.Add(";") - objList.SubItems.Add("swasp terminal symbol") + objList.SubItems.Add("switch terminal symbol") read = True Else errorCtr += 1 @@ -2341,7 +2886,7 @@ Public Class Form1 'End If 'END NG ' - If sc(i) = "//" Then + If sc(i) = "'" Then comment = "" read = True Dim x As Integer = 1 @@ -2363,19 +2908,25 @@ Public Class Form1 symbolCtr += 1 objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) - objList.SubItems.Add("//" & comment) + objList.SubItems.Add("'" & comment) objList.SubItems.Add("comment") objList.SubItems.Add("comment") read = True i += x End If - 'END NG // + 'END NG ' If sc(i) = ":" Then If i + 1 < sourcecode.Length Then - If sc(i + 1) = " " Or sc(i + 1) = "//" Or sc(i + 1) = "(" Or sc(i + 1) = ">" Or sc(i + 1) = "$" _ - Or sc(i + 1) = "newline" Or Not inArray(sc(i + 1), allsym, 95) Then 'pending nl + If sc(i + 1) = " " Or sc(i + 1) = "'" Or sc(i + 1) = "(" Or sc(i + 1) = ">" Or sc(i + 1) = "$" _ + Or sc(i + 1) = "newline" Or Not inArray(sc(i + 1), delimsymbol, 95) Then 'pending nl symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens(":") + tokens.setLexemes(":") + tokens.setAttributes("statement terminator") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add(":") @@ -2396,13 +2947,20 @@ Public Class Form1 If sc(i) = "," Then If i + 1 < sourcecode.Length Then If sc(i + 1) = " " Or sc(i + 1) = "$" Or sc(i + 1) = """" Or sc(i + 1) = "(" Or sc(i + 1) = "~" _ - Or sc(i + 1) = "f" Or sc(i + 1) = "t" Or sc(i + 1) = "w" Or Char.IsDigit(sc(i + 1)) Then + Or sc(i + 1) = "b" Or sc(i + 1) = "d" Or sc(i + 1) = "n" Or sc(i + 1) = "s" Or Char.IsDigit(sc(i + 1)) _ + Or Not inArray(sc(i + 1), delimsymbol, 95) Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens(",") + tokens.setLexemes(",") + tokens.setAttributes("separator symbol") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add(",") objList.SubItems.Add(",") - objList.SubItems.Add("separator") + objList.SubItems.Add("separator symbol") read = True Else errorCtr += 1 @@ -2417,13 +2975,19 @@ Public Class Form1 If sc(i) = "~" Then If i + 1 < sourcecode.Length Then - If sc(i + 1) = "$" Or sc(i + 1) = "(" Or sc(i + 1) = " " Then + If sc(i + 1) = "$" Or sc(i + 1) = "(" Or sc(i + 1) = " " Or Char.IsDigit(sc(i + 1)) Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("~") + tokens.setLexemes("~") + tokens.setAttributes("negOp, ~, unary") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("~") objList.SubItems.Add("~") - objList.SubItems.Add("negate, ~, unary") + objList.SubItems.Add("negOp, ~, unary") read = True ElseIf Char.IsDigit(sc(i + 1)) Then 'leading neg = True @@ -2443,11 +3007,17 @@ Public Class Form1 If sc(i + 1) = "+" Then If sc(i + 2) = " " Or sc(i + 2) = "$" Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens(".+") + tokens.setLexemes(".+") + tokens.setAttributes("structOp, .+") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add(".+") objList.SubItems.Add(".+") - objList.SubItems.Add("strOp, .+, binary") + objList.SubItems.Add("structOp, .+") i += 1 read = True Else @@ -2460,6 +3030,12 @@ Public Class Form1 End If ElseIf sc(i + 1) = " " Or sc(i + 1) = "i" Or sc(i + 1) = "l" Or sc(i + 1) = "z" Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens(".") + tokens.setLexemes(".") + tokens.setAttributes(" ") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add(".") @@ -2476,14 +3052,14 @@ Public Class Form1 End If 'END NG . - '-----------------textlit + '-----------------stringlit If sc(i) = """" Then str = "" read = True Dim x As Integer = 1 Dim start As Integer = x Dim point As Integer = line - While Not (sc(i + x) = """" Or Not inArray(sc(i + x), allsym, 95)) And i + x + 1 < sourcecode.Length 'outer " + While Not (sc(i + x) = """" Or Not inArray(sc(i + x), delimsymbol, 95)) And i + x + 1 < sourcecode.Length 'outer " x += 1 End While @@ -2493,15 +3069,21 @@ Public Class Form1 End While If sc(i + x) = """" Then - If str.Length <= 500 Then - If sc(i + x + 1) = " " Or sc(i + x + 1) = ":" Or sc(i + x + 1) = ";" Or sc(i + x + 1) = "\" _ - Or sc(i + x + 1) = ")" Or sc(i + x + 1) = "," Or sc(i + x + 1) = "}" Or sc(i + x + 1) = "!" Then + If str.Length <= 200 Then + If sc(i + x + 1) = " " Or sc(i + x + 1) = ":" Or sc(i + x + 1) = ";" _ + Or sc(i + x + 1) = ")" Or sc(i + x + 1) = "," Or sc(i + x + 1) = "}" Or sc(i + x + 1) = "!" Or sc(i + x + 1) = "<" Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("starling literals") + tokens.setLexemes(str) + tokens.setAttributes(" ") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("""" & str & """") - objList.SubItems.Add("textlit") - objList.SubItems.Add("textlit, " & """" & str & """") + objList.SubItems.Add("starlingliteral") + objList.SubItems.Add("starlingliteral, " & """" & str & """") Else errorCtr += 1 objList = dGridError.Items.Add(errorCtr) @@ -2509,12 +3091,12 @@ Public Class Form1 objList.SubItems.Add(delimStr & """" & str & """") End If Else - If sc(i + x + 1) = " " Or sc(i + x + 1) = ":" Or sc(i + x + 1) = ";" Or sc(i + x + 1) = "\" _ + If sc(i + x + 1) = " " Or sc(i + x + 1) = ":" Or sc(i + x + 1) = ";" _ Or sc(i + x + 1) = ")" Or sc(i + x + 1) = "," Or sc(i + x + 1) = "}" Or sc(i + x + 1) = "!" Then errorCtr += 1 objList = dGridError.Items.Add(errorCtr) objList.SubItems.Add(line) - objList.SubItems.Add("Invalid textlit. Exceed max. no of character in string") + objList.SubItems.Add("Invalid stringliteral. Exceed max. no of character in string") Else errorCtr += 1 objList = dGridError.Items.Add(errorCtr) @@ -2526,7 +3108,7 @@ Public Class Form1 errorCtr += 1 objList = dGridError.Items.Add(errorCtr) objList.SubItems.Add(line) - objList.SubItems.Add("""" & str & " , Unterminated string") + objList.SubItems.Add("Invalid Lexeme " & """" & str) End If read = True i += x @@ -2539,7 +3121,7 @@ Public Class Form1 Dim ctr1 As Integer = i + 1 Dim length As Integer = 0 While ctr1 < sourcecode.Length - If Char.IsDigit(sc(ctr1)) And length < 10 Then + If Char.IsDigit(sc(ctr1)) And length < 9 Then number = number + sc(ctr1) ctr1 += 1 length += 1 @@ -2548,21 +3130,27 @@ Public Class Form1 End If End While - If sc(ctr1) = " " Or sc(ctr1) = "," Or sc(ctr1) = "\" _ + If sc(ctr1) = " " Or sc(ctr1) = "," Or sc(ctr1) = ":" _ Or sc(ctr1) = "]" Or sc(ctr1) = "+" Or sc(ctr1) = "-" Or sc(ctr1) = "}" _ Or sc(ctr1) = "*" Or sc(ctr1) = "/" Or sc(ctr1) = "%" Or sc(ctr1) = "^" _ - Or sc(ctr1) = "<" Or sc(ctr1) = ";" Or sc(ctr1) = ">" Or sc(ctr1) = "'" Or sc(ctr1) = "=" Or sc(ctr1) = ":" Or sc(ctr1) = ")" Then + Or sc(ctr1) = "<" Or sc(ctr1) = ";" Or sc(ctr1) = ">" Or sc(ctr1) = "=" Or sc(ctr1) = ")" Or Not inArray(sc(ctr1), delimsymbol, 95) Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("newt literals") + tokens.setLexemes("newtlit") + tokens.setAttributes("newtlit") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) If neg = True Then objList.SubItems.Add("~" & number) - objList.SubItems.Add("wholelit") - objList.SubItems.Add("wholelit, ~" & number) + objList.SubItems.Add("newtlit") + objList.SubItems.Add("newtlit, ~" & number) Else objList.SubItems.Add(number) - objList.SubItems.Add("wholelit") - objList.SubItems.Add("wholelit, " & number) + objList.SubItems.Add("newtlit") + objList.SubItems.Add("newtlit, " & number) End If read = True i = ctr1 - 1 @@ -2573,7 +3161,7 @@ Public Class Form1 Dim ctr2 As Integer = ctr1 + 1 Dim length1 As Integer = 0 While ctr2 < sourcecode.Length - If Char.IsDigit(sc(ctr2)) And length1 < 5 Then + If Char.IsDigit(sc(ctr2)) And length1 < 4 Then number = number + sc(ctr2) ctr2 += 1 length1 += 1 @@ -2582,21 +3170,27 @@ Public Class Form1 End If End While - If sc(ctr2) = " " Or sc(ctr2) = "," Or sc(ctr2) = "\" _ - Or sc(ctr2) = "]" Or sc(ctr2) = "+" Or sc(ctr2) = "-" Or sc(ctr2) = "}" _ + If sc(ctr2) = " " Or sc(ctr2) = ":" _ + Or sc(ctr2) = "]" Or sc(ctr2) = "+" Or sc(ctr2) = "-" _ Or sc(ctr2) = "*" Or sc(ctr2) = "/" Or sc(ctr2) = "%" Or sc(ctr2) = "^" _ - Or sc(ctr2) = "<" Or sc(ctr2) = ";" Or sc(ctr2) = ">" Or sc(ctr2) = "'" Or sc(ctr2) = "=" Or sc(ctr2) = ":" Or sc(ctr2) = ")" Then + Or sc(ctr2) = "<" Or sc(ctr2) = ";" Or sc(ctr2) = ">" Or sc(ctr2) = "'" Or sc(ctr2) = "=" Or sc(ctr2) = ")" Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("duck literals") + tokens.setLexemes("ducklit") + tokens.setAttributes("ducklit") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) If neg = True Then objList.SubItems.Add("~" & number) - objList.SubItems.Add("fraclit") - objList.SubItems.Add("fraclit, ~" & number) + objList.SubItems.Add("ducklit") + objList.SubItems.Add("ducklit, ~" & number) Else objList.SubItems.Add(number) - objList.SubItems.Add("wholelit") - objList.SubItems.Add("wholelit, " & number) + objList.SubItems.Add("ducklit") + objList.SubItems.Add("ducklit, " & number) End If read = True i = ctr2 - 1 @@ -2638,7 +3232,7 @@ Public Class Form1 Dim ctr1 As Integer = i + 2 Dim length As Integer = 1 While ctr1 < sourcecode.Length - If (Char.IsLower(sc(ctr1)) Or Char.IsDigit(sc(ctr1)) Or sc(ctr1) = "_") And length < 9 Then + If (Char.IsLower(sc(ctr1)) Or Char.IsDigit(sc(ctr1))) And length < 9 Then ident = ident + sc(ctr1) ctr1 += 1 length += 1 @@ -2647,16 +3241,23 @@ Public Class Form1 End If End While - If sc(ctr1) = " " Or sc(ctr1) = "," Or sc(ctr1) = "\" _ + If sc(ctr1) = " " Or sc(ctr1) = "," Or sc(ctr1) = ":" _ Or sc(ctr1) = "]" Or sc(ctr1) = "[" Or sc(ctr1) = "+" Or sc(ctr1) = "-" Or sc(ctr1) = "^" _ Or sc(ctr1) = "*" Or sc(ctr1) = "/" Or sc(ctr1) = "%" Or sc(ctr1) = "(" _ - Or sc(ctr1) = "<" Or sc(ctr1) = ")" Or sc(ctr1) = ">" Or sc(ctr1) = "=" Or sc(ctr1) = "!" Or sc(ctr1) = ":" Or Not inArray(sc(ctr1), allsym, 95) Then + Or sc(ctr1) = "<" Or sc(ctr1) = ")" Or sc(ctr1) = ">" Or sc(ctr1) = "=" Or sc(ctr1) = "!" Or sc(ctr1) = ";" Or Not inArray(sc(ctr1), delimsymbol, 95) Then symbolCtr += 1 + tokens = New TokenLibrary.TokenLibrary.TokenClass + tokens.setTokens("id") + tokens.setLexemes(ident) + tokens.setAttributes("identifier") + tokens.setLines(line) + tokenstream.Add(tokens) objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add(ident) objList.SubItems.Add("identifier") - objList.SubItems.Add("identifier") + objList.SubItems.Add("identifier" & idnum) + idnum += 1 read = True i = ctr1 - 1 Else @@ -2680,6 +3281,7 @@ Public Class Form1 If Microsoft.VisualBasic.AscW(sc(i)) = 10 Then symbolCtr += 1 + 'tokens.Add("") objList = dGridLexi.Items.Add(symbolCtr) objList.SubItems.Add(line) objList.SubItems.Add("newline") @@ -2709,553 +3311,2841 @@ Public Class Form1 errorCtr += 1 objList = dGridError.Items.Add(errorCtr) objList.SubItems.Add(line) - objList.SubItems.Add(unid & " -- Unidentified lexeme") + objList.SubItems.Add("Undefined lexeme -->" & unid) i = x - 1 Else errorCtr += 1 objList = dGridError.Items.Add(errorCtr) objList.SubItems.Add(line) - objList.SubItems.Add(sc(i) & " -- Unidentified character") + objList.SubItems.Add("Undefined character -->" & sc(i)) End If End If + i += 1 'LAGING NAGMOMOVE NG 1 CHAR 'MessageBox.Show("sc(i)= " & sc & " i= " & i) End While + ' END NG LEXICAL End Sub + Private Sub Button2_Click(sender As Object, e As EventArgs) Handles btnAna.Click - dGridError.BackColor = Color.SaddleBrown - dGridLexi.BackColor = Color.SaddleBrown - 'semant_table.BackColor = Color.SaddleBrown - lexi() - 'syntaxana() - 'identifierList() - 'semantic() - 'If dGridError.Items.Count = 0 Then - ' translate() - ' output() - 'End If + ErrorText.Clear() + ErrorText.BackColor = Color.SteelBlue + dGridError.BackColor = Color.SteelBlue + dGridLexi.BackColor = Color.SteelBlue + dGridSemantic.BackColor = Color.SteelBlue - End Sub + lexinew() + identifierList() + Dim semantics As New Semantics_Analyzer.SemanticsInitializer + 'semantic() - 'Public Sub translate() - ' 'MessageBox.Show(dGridLexi.Items.Count) - ' Dim s As Integer = 0 - ' Dim t As Integer = 0 - ' Dim str As String = "" - ' RichTextBox1.Text = "" - ' RichTextBox1.Text = RichTextBox1.Text + "//include" + vbNewLine - ' RichTextBox1.Text = RichTextBox1.Text + "//include" + vbNewLine - ' RichTextBox1.Text = RichTextBox1.Text + "//include" + vbNewLine - ' RichTextBox1.Text = RichTextBox1.Text + "//include" + vbNewLine - ' RichTextBox1.Text = RichTextBox1.Text + "//include" + vbNewLine - ' RichTextBox1.Text = RichTextBox1.Text + "//include" + vbNewLine + vbNewLine - ' RichTextBox1.Text = RichTextBox1.Text + "using namespace std;" + vbNewLine + vbNewLine - ' 'RichTextBox1.Text = RichTextBox1.Text + "int main()" - - ' For i As Integer = 0 To dGridLexi.Items.Count - 1 - ' tokee(i) = dGridLexi.Items.Item(i).SubItems(3).Text() 'TOKEN - ' Next - - ' While s < dGridLexi.Items.Count - ' If tokee(s) = "newline" Then - ' RichTextBox1.Text = RichTextBox1.Text + vbNewLine - ' End If - - ' If tokee(s) = "valuu" Then - ' str = dGridLexi.Items.Item(s).SubItems(2).Text - ' RichTextBox1.Text = RichTextBox1.Text + str + " " - ' End If - - ' If tokee(s) = "comment" Then - ' str = dGridLexi.Items.Item(s).SubItems(2).Text - ' str = str.Replace("//", "//") - ' RichTextBox1.Text = RichTextBox1.Text + str - ' End If - - ' If tokee(s) = "id" And tokee(s + 1) <> ".+" Then - ' str = dGridLexi.Items.Item(s).SubItems(2).Text - ' str = str.Replace("$", "") - ' RichTextBox1.Text = RichTextBox1.Text + str - ' End If - - ' If tokee(s) = "board" Then - ' RichTextBox1.Text = RichTextBox1.Text + "struct " - ' End If - - ' If tokee(s) = "xlear" Then - ' RichTextBox1.Text = RichTextBox1.Text + "clear" - ' End If - - ' If tokee(s) = "xnore" Then - ' RichTextBox1.Text = RichTextBox1.Text + "ignore" - ' End If - - ' If tokee(s) = "xfail" Then - ' RichTextBox1.Text = RichTextBox1.Text + "fail" - ' End If - - ' If tokee(s) = "vr" Then - ' RichTextBox1.Text = RichTextBox1.Text + "break" - ' End If - - ' If tokee(s) = "ind" Then - ' RichTextBox1.Text = RichTextBox1.Text + "char " - ' End If - - ' If tokee(s) = "indi" Then - ' RichTextBox1.Text = RichTextBox1.Text + "getch();" - ' End If - - ' If tokee(s) = "'\0'" Then - ' RichTextBox1.Text = RichTextBox1.Text + "'\0'" - ' End If - - ' If tokee(s) = "''" Then - ' RichTextBox1.Text = RichTextBox1.Text + "' '" - ' End If - - ' If tokee(s) = "'*'" Then - ' RichTextBox1.Text = RichTextBox1.Text + "'*'" - ' End If - - ' If tokee(s) = "deport" Then - ' 'str = dGridLexi.Items.Item(s + 1).SubItems(2).Text - ' 'If str <> "0" Then - ' RichTextBox1.Text = RichTextBox1.Text + "return " - ' 'Else - ' ' RichTextBox1.Text = RichTextBox1.Text + "getch(); return " - ' 'End If - ' End If - - ' If tokee(s) = "during" Then - ' RichTextBox1.Text = RichTextBox1.Text + "while " - ' End If - - ' If tokee(s) = "gate" Then - ' RichTextBox1.Text = RichTextBox1.Text + "default " - ' End If - - ' If tokee(s) = "halt" Then - ' RichTextBox1.Text = RichTextBox1.Text + "break" - ' End If - - ' If tokee(s) = "mane" Then - ' RichTextBox1.Text = RichTextBox1.Text + "int main" - ' End If - - ' If tokee(s) = "ztr" Then - ' RichTextBox1.Text = RichTextBox1.Text + "strlen" - ' End If - - ' If tokee(s) = "zcat" Then - ' RichTextBox1.Text = RichTextBox1.Text + "strcat" - ' End If - - ' If tokee(s) = "null" Then - ' RichTextBox1.Text = RichTextBox1.Text + "0" - ' End If - - ' If tokee(s) = "otherwise" Then - ' RichTextBox1.Text = RichTextBox1.Text + "else " - ' End If - - ' If tokee(s) = "otherwisewhen" Then - ' RichTextBox1.Text = RichTextBox1.Text + "else if " - ' End If - - ' If tokee(s) = "run" Then - ' RichTextBox1.Text = RichTextBox1.Text + "do " - ' End If - - ' If tokee(s) = "set" Then - ' RichTextBox1.Text = RichTextBox1.Text + "const " - ' End If - - ' If tokee(s) = "terminal" Then - ' RichTextBox1.Text = RichTextBox1.Text + "case " - ' End If - - ' If tokee(s) = "take" Then - ' RichTextBox1.Text = RichTextBox1.Text + "switch " - ' End If - - ' If tokee(s) = "till" Then - ' RichTextBox1.Text = RichTextBox1.Text + "for" - ' End If - - ' If tokee(s) = "vacant" Then - ' RichTextBox1.Text = RichTextBox1.Text + "void " - ' End If - - ' If tokee(s) = "when" Then - ' RichTextBox1.Text = RichTextBox1.Text + "if " - ' End If - - ' If tokee(s) = "checkin" Then - ' RichTextBox1.Text = RichTextBox1.Text + "cin" - ' End If - - ' If tokee(s) = "checkout" Then - ' RichTextBox1.Text = RichTextBox1.Text + "cout" - ' End If - - ' If tokee(s) = "clearfield" Then - ' RichTextBox1.Text = RichTextBox1.Text + "system(""cls"")" - ' End If - - ' If tokee(s) = "assgnOp" Then - ' RichTextBox1.Text = RichTextBox1.Text + "=" - ' End If - - ' If tokee(s) = "\" Then - ' RichTextBox1.Text = RichTextBox1.Text + ";" - ' End If - - ' If tokee(s) = "opsymbol" Then - ' RichTextBox1.Text = RichTextBox1.Text + "{" - ' End If - - ' If tokee(s) = "clsymbol" Then - ' RichTextBox1.Text = RichTextBox1.Text + "}" - ' End If - - ' If tokee(s) = "oppar" Then - ' RichTextBox1.Text = RichTextBox1.Text + "(" - ' End If - - ' If tokee(s) = "clpar" Then - ' RichTextBox1.Text = RichTextBox1.Text + ")" - ' End If - - ' If tokee(s) = "opsquare" Then - ' RichTextBox1.Text = RichTextBox1.Text + "[" - ' End If - - ' If tokee(s) = "clsquare" Then - ' RichTextBox1.Text = RichTextBox1.Text + "]" - ' End If - - ' If tokee(s) = "opcurly" Then - ' RichTextBox1.Text = RichTextBox1.Text + "{" - ' End If - - ' If tokee(s) = "clcurly" Then - ' RichTextBox1.Text = RichTextBox1.Text + "}" - ' End If - - ' If tokee(s) = "!+" Then - ' RichTextBox1.Text = RichTextBox1.Text + "." - ' End If - - ' If tokee(s) = "!" Then - ' RichTextBox1.Text = RichTextBox1.Text + " ! " - ' End If - - ' If tokee(s) = ":<" Then - ' RichTextBox1.Text = RichTextBox1.Text + "<<" - ' End If - - ' If tokee(s) = ":>" Then - ' RichTextBox1.Text = RichTextBox1.Text + ">>" - ' End If - - ' If tokee(s) = ":n" Then - ' RichTextBox1.Text = RichTextBox1.Text + "endl" - ' End If - - ' If tokee(s) = ":t" Then - ' RichTextBox1.Text = RichTextBox1.Text + """ """ - ' End If - - ' If tokee(s) = ";" Then - ' RichTextBox1.Text = RichTextBox1.Text + ": " - ' End If - - ' If tokee(s) = "," Then - ' RichTextBox1.Text = RichTextBox1.Text + ", " - ' End If - - ' If tokee(s) = "?" Then - ' RichTextBox1.Text = RichTextBox1.Text + "? " - ' End If - - ' If tokee(s) = ".+" Then - ' Dim id1 As String = dGridLexi.Items.Item(s - 1).SubItems(2).Text - ' id1 = id1.Replace("$", " ") - ' Dim id2 As String = dGridLexi.Items.Item(s + 1).SubItems(2).Text - ' id2 = id2.Replace("$", " ") - ' str = tokee(s - 1) + tokee(s) + tokee(s + 1) - ' str = "strcat(" + id1 + "," + id2 + ")" - ' RichTextBox1.Text = RichTextBox1.Text + str - ' s += 1 - ' End If - - ' If tokee(s) = "increOp" Or tokee(s) = "decreOp" Or tokee(s) = "relOp2" Or tokee(s) = "relOp1" Or tokee(s) = "assgnOp2" _ - ' Or tokee(s) = "mathOp" Then - ' str = dGridLexi.Items.Item(s).SubItems(2).Text - ' RichTextBox1.Text = RichTextBox1.Text + str + " " - ' End If - - ' If tokee(s) = "logOp" Then - ' str = dGridLexi.Items.Item(s).SubItems(2).Text - ' RichTextBox1.Text = RichTextBox1.Text + str + str - ' End If - - ' If tokee(s) = "wholelit" Then - ' str = dGridLexi.Items.Item(s).SubItems(2).Text - ' If str.Contains("~") Then - ' str = str.Replace("~", "-") - ' RichTextBox1.Text = RichTextBox1.Text + " (" + str + ") " - ' Else - ' RichTextBox1.Text = RichTextBox1.Text + str - ' End If - ' End If - - ' If tokee(s) = "fraclit" Then - ' str = dGridLexi.Items.Item(s).SubItems(2).Text - ' If str.Contains("~") Then - ' str = str.Replace("~", "-") - ' RichTextBox1.Text = RichTextBox1.Text + " (" + str + ") " - ' Else - ' RichTextBox1.Text = RichTextBox1.Text + str + " " - ' End If - ' End If - - ' If tokee(s) = "flaglit" Then - ' str = dGridLexi.Items.Item(s).SubItems(2).Text - ' RichTextBox1.Text = RichTextBox1.Text + str + " " - ' End If - - ' If tokee(s) = "textlit" Then - ' str = dGridLexi.Items.Item(s).SubItems(2).Text - ' RichTextBox1.Text = RichTextBox1.Text + str + " " - ' End If - - ' If tokee(s) = "whole" Then - ' RichTextBox1.Text = RichTextBox1.Text + "int " - ' End If - - ' If tokee(s) = "text" Then - ' Dim strln As Integer - ' If tokee(s + 3) = "opsquare" Then - ' strln = dGridLexi.Items.Item(s + 8).SubItems(2).Text.Length - ' If strln > 3 Then - ' RichTextBox1.Text = RichTextBox1.Text + "string " - ' Else - ' RichTextBox1.Text = RichTextBox1.Text + "char " - ' End If - ' Else - ' RichTextBox1.Text = RichTextBox1.Text + "string " - ' End If - ' End If - - ' If tokee(s) = "frac" Then - ' RichTextBox1.Text = RichTextBox1.Text + "float " - ' End If - - ' If tokee(s) = "flag" Then - ' RichTextBox1.Text = RichTextBox1.Text + "bool " - ' End If - ' s += 1 - ' End While - 'End Sub - - 'Public Sub output() - ' If Not My.Computer.FileSystem.DirectoryExists("C:\Users\sarah\Documents") Then - ' My.Computer.FileSystem.CreateDirectory("C:\Users\sarah\Documents") - ' End If - ' '<><>CHECK FOR OLD FILES<><> - ' If My.Computer.FileSystem.FileExists("C:\Users\sarah\Documents\compiler.cpp") Then - ' My.Computer.FileSystem.DeleteFile("C:\Users\sarah\Documents\compiler.cpp") - ' End If - ' If My.Computer.FileSystem.FileExists("C:\Users\sarah\Documents\compiler.exe") Then - ' My.Computer.FileSystem.DeleteFile("C:\Users\sarah\Documents\compiler.exe") - ' End If - ' '<><>WRITING<><> - ' Using sw As New System.IO.StreamWriter("C:\Users\sarah\Documents\compiler.cpp") - ' sw.WriteLine(RichTextBox1.Text) - ' sw.Close() - ' End Using - ' '<><>COMPILING<><> - ' Dim CPath As String = "C:\MinGW\bin" - ' Process.Start("cmd", "/c g++ C:\Users\sarah\Documents\compiler.cpp -o C:\Users\sarah\Documents\compiler.exe").WaitForExit() - ' If Not My.Computer.FileSystem.FileExists("C:\Users\sarah\Documents\compiler.exe") Then - ' MsgBox("Unsuccessful Build. Please check your code.") - ' Else - ' Process.Start("C:\Users\sarah\Documents\compiler").WaitForExit() - ' End If - 'End Sub - - 'Private Sub CutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CutToolStripMenuItem.Click - ' Clipboard.SetDataObject(rTBCode.SelectedText) - ' Dim S As String = rTBCode.Text - ' Dim SelStart As Integer = rTBCode.SelectionStart - ' Dim SelLen As Integer = rTBCode.SelectionLength - - ' S = S.Remove(SelStart, SelLen) - - ' rTBCode.Text = S - - ' rTBCode.Focus() - 'End Sub - - 'Private Sub CopyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyToolStripMenuItem.Click - ' Clipboard.SetDataObject(rTBCode.SelectedText) - ' rTBCode.Focus() - 'End Sub - - 'Private Sub PasteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PasteToolStripMenuItem.Click - ' Dim oDataObject As IDataObject - ' oDataObject = Clipboard.GetDataObject() - ' If oDataObject.GetDataPresent(DataFormats.Text) Then - ' rTBCode.SelectedText = CType(oDataObject.GetData(DataFormats.Text), String) - ' End If - ' rTBCode.Focus() - 'End Sub + ' Syntax + If dGridError.Items.Count = 0 Then + Dim ctr = dGridLexi.Items.Count - 1 + Dim result As String = "" - Public Sub RowCol() - Dim index As Integer - Dim line As Integer - Dim col As Integer - Dim pt As Point + Dim syntaxana As New Syntax_Analyzer.SyntaxInitializer + semantics = SemanticStart(tokensDump(tokenstream)) + result = syntaxana.Start(tokenstream) + vbCrLf + semantics.Start() + vbCrLf + semantics.error + ' MessageBox.Show(result, "Result") - ' get the current line - index = Me.rTBCode.SelectionStart - line = Me.rTBCode.GetLineFromCharIndex(index) + 1 - ' get the caret position in pixel coordinates - pt = Me.rTBCode.GetPositionFromCharIndex(index) - ' now get the character index at the start of the line, and subtract from the current index to get the column - pt.X = 0 - col = index - Me.rTBCode.GetCharIndexFromPosition(pt) + 1 - ' finally, update the display in the status bar, incrementing the line and column values so that the first line & first character position is shown as "1, 1" - 'Me.ToolStripStatusLabel1.Text = "Ln " + (++line).ToString() + ", Col " + (++col).ToString() - End Sub + ErrorText.Text = "Syntax Result: " & vbCrLf & result + 'MessageBox.Show(syntaxana.production) + 'MessageBox.Show(syntaxana.recursiveprod) + 'MessageBox.Show(result, "Result") - Private Sub rTBCode_SelectionChanged(sender As Object, e As EventArgs) Handles rTBCode.SelectionChanged - RowCol() + End If + + Dim generate As New CodeGenInitialize + generate = codeGenStart(tokenDump(tokenstream), semantics) + generate.Start() End Sub - Public Function inArray(ByVal input As String, ByVal array() As String, ByVal lim As Integer) - Dim bool As Boolean = True - For x As Integer = 0 To lim - If input = array(x) Then - bool = True - Exit For - Else - bool = False - End If + Function SemanticStart(ByVal tokens As List(Of Semantics_Analyzer.SemanticsInitializer.Tokens)) As Semantics_Analyzer.SemanticsInitializer + Dim sem As New Semantics_Analyzer.SemanticsInitializer + Try + sem = New Semantics_Analyzer.SemanticsInitializer(tokens) + Catch ex As Exception + MessageBox.Show(ex.Message) + End Try + Return sem + End Function + + Function codeGenStart(ByVal tokens As List(Of CodeGenInitialize.Tokens), ByVal semantics As Semantics_Analyzer.SemanticsInitializer) As CodeGenInitialize + Dim gen As New CodeGenInitialize + Try + gen = New CodeGenInitialize(tokens, semantics) + Catch ex As Exception + MessageBox.Show(ex.Message) + End Try + Return gen + End Function + + Function tokensDump(ByVal tokens As List(Of TokenLibrary.TokenLibrary.TokenClass)) As List(Of Semantics_Analyzer.SemanticsInitializer.Tokens) + Dim token As New List(Of Semantics_Analyzer.SemanticsInitializer.Tokens) + Dim t As New Semantics_Analyzer.SemanticsInitializer.Tokens + + For Each item In tokens + t = New Semantics_Analyzer.SemanticsInitializer.Tokens + t.setAttributes(item.getAttributes) + t.setLexemes(item.getLexemes) + t.setLines(item.getLines) + t.setTokens(item.getTokens) + token.Add(t) Next - Return bool + Return token End Function - Private Sub DrawRichTextBoxLineNumbers(ByRef g As Graphics) - 'Calculate font heigth as the difference in Y coordinate - 'between line 2 and line 1 - 'Note that the RichTextBox text must have at least two lines. - ' So the initial Text property of the RichTextBox - ' should not be an empty string. It could be something - ' like vbcrlf & vbcrlf & vbcrlf - With rTBCode - Dim font_height As Single - font_height = .GetPositionFromCharIndex(.GetFirstCharIndexFromLine(2)).Y _ - - .GetPositionFromCharIndex(.GetFirstCharIndexFromLine(1)).Y - If font_height = 0 Then Exit Sub + Function tokenDump(ByVal tokens As List(Of TokenLibrary.TokenLibrary.TokenClass)) As List(Of CodeGenInitialize.Tokens) + Dim token As New List(Of CodeGenInitialize.Tokens) + Dim t As New CodeGenInitialize.Tokens + + For Each item In tokens + t = New CodeGenInitialize.Tokens + t.setAttributes(item.getAttributes) + t.setLexemes(item.getLexemes) + t.setLines(item.getLines) + t.setTokens(item.getTokens) + token.Add(t) + Next + Return token + End Function - 'Get the first line index and location - Dim first_index As Integer - Dim first_line As Integer - Dim first_line_y As Integer - first_index = .GetCharIndexFromPosition(New _ - Point(0, g.VisibleClipBounds.Y + font_height / 3)) - first_line = .GetLineFromCharIndex(first_index) - first_line_y = .GetPositionFromCharIndex(first_index).Y + Private Sub semantic() + Dim dtype(4) As String + dtype(0) = "newt" + dtype(1) = "duck" + dtype(2) = "bull" + dtype(3) = "starling" - 'Print on the PictureBox the visible line numbers of the RichTextBox - 'g.Clear(Control.DefaultBackColor) - Dim i As Integer = first_line - Dim y As Single - Do While y < g.VisibleClipBounds.Y + g.VisibleClipBounds.Height - y = first_line_y + 2 + font_height * (i - first_line - 1) - g.DrawString((i).ToString, .Font, Brushes.Black, lineNum.Width _ - - g.MeasureString((i).ToString, .Font).Width, y) - i += 1 - Loop - 'Debug.WriteLine("Finished: " & firstLine + 1 & " " & i - 1) - End With - End Sub + Dim k As Integer = 0 + Dim isMane As Boolean = False + Dim errCtr As Integer = 0 + Dim symbolCtr As Integer = 0 + Dim isStork As Boolean = False + Dim isFunction As Boolean = False - Private Sub r_Resize(ByVal sender As Object, ByVal e As System.EventArgs) _ - Handles rTBCode.Resize - lineNum.Invalidate() - End Sub + While k < dGridLexi.Items.Count + If setokee(k) = "stork" Then + isStork = True + End If - Private Sub r_VScroll(ByVal sender As Object, ByVal e As System.EventArgs) _ - Handles rTBCode.VScroll - lineNum.Invalidate() - End Sub + If setokee(k) = "mane" Then + isStork = False + isMane = True + End If - Private Sub p_Paint(ByVal sender As Object, - ByVal e As System.Windows.Forms.PaintEventArgs) _ - Handles lineNum.Paint - DrawRichTextBoxLineNumbers(e.Graphics) - End Sub + If setokee(k) = "opsymbol" Then + symbolCtr += 1 + End If - Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _ - Handles MyBase.Load - rTBCode.Text = vbCrLf & vbCrLf & vbCrLf - End Sub + If setokee(k) = "clsymbol" Then + symbolCtr -= 1 + End If - 'Private Sub open_but_Click(sender As Object, e As EventArgs) Handles open_but.Click - ' OpenFileDialog1.Filter = "(*.txt) | *.txt" - ' If (OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK) Then - ' rTBCode.Text = My.Computer.FileSystem.ReadAllText(OpenFileDialog1.FileName) - ' End If - - 'End Sub - - 'Private Sub save_but_Click(sender As Object, e As EventArgs) Handles save_but.Click - ' SaveFileDialog1.Title = "Save File As..." - ' SaveFileDialog1.Filter = "(*.txt) | *.txt" - ' If (SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK) Then - ' rTBCode.SaveFile(SaveFileDialog1.FileName, RichTextBoxStreamType.PlainText) - ' End If - 'End Sub - - 'Private Sub close_but_Click(sender As Object, e As EventArgs) Handles close_but.Click - ' Me.Close() - 'End Sub - - 'Private Sub min_but_Click(sender As Object, e As EventArgs) Handles min_but.Click - ' Me.WindowState = System.Windows.Forms.FormWindowState.Minimized - 'End Sub - - 'Private Sub new_but_Click(sender As Object, e As EventArgs) Handles new_but.Click - ' rTBCode.Clear() - ' dGridLexi.Items.Clear() - ' dGridError.Items.Clear() - ' dGridIden.Items.Clear() - ' semant_table.Items.Clear() - ' dGridBoard.Items.Clear() - 'End Sub - - Private Sub lineNum_Click(sender As Object, e As EventArgs) Handles lineNum.Click + If setokee(k) = "identifier" Then + Dim kawntctr As Integer = 0 + Dim identifier As String = dGridLexi.Items.Item(k).SubItems(2).Text() 'name ng id sa lextable @zootopia + Dim ctr As Integer = 0 + Dim curind As Integer + + If dGridIden.Items.Count > 1 Then + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = identifier Then 'kung nasa dGridIden yung @zootopia + curind = index + Exit For + End If + Next - End Sub + For index As Integer = curind + 1 To dGridIden.Items.Count - 1 + If identifier = dGridIden.Items.Item(index).SubItems(1).Text() Then 'kung nasa dGridIden yung @zootopia + ctr += 1 + End If + If ctr >= 1 Then + Exit For + End If + Next + + If ctr >= 1 Then + Dim x As Integer + x = k + While setokee(x) <> "newline" + x -= 1 + End While + + If setokee(x + 1) = "newt" Or setokee(x + 1) = "starling" Or setokee(x + 1) = "duck" Or setokee(x + 1) = "bull" Then + kawntctr += 1 + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(identifier + " -Multiple declaration of variable") + End If + End If - Private Sub rTBCode_TextChanged(sender As Object, e As EventArgs) Handles rTBCode.TextChanged + End If - End Sub + '======================================================================== + Dim identifier2 As String = dGridLexi.Items.Item(k).SubItems(2).Text() 'name ng id sa lextable @zootopia + Dim ctr2 As Integer = 0 + For index As Integer = 0 To dGridIden.Items.Count - 1 + If identifier2 = dGridIden.Items.Item(index).SubItems(1).Text Then 'kung nasa dGridIden yung @zootopia + ctr2 += 1 + End If + Next + + If dGridBoard.Items.Count > 0 Then + For index As Integer = 0 To dGridBoard.Items.Count - 1 + If identifier2 = dGridBoard.Items.Item(index).SubItems(0).Text Then 'kung nasa dGridIden yung @zootopia + ctr2 += 1 + End If + Next + End If + + If ctr2 < 1 Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(identifier2 + " -Undeclared variable or stork(structure)") + End If + 'GoTo boarde + '========================================================================= + Dim identifier3 As String = dGridLexi.Items.Item(k).SubItems(2).Text() 'name ng id sa lextable @zootopia + Dim ctr3 As Integer = 0 + Dim cur As Integer + + For index As Integer = 0 To dGridIden.Items.Count - 1 + If identifier3 = dGridIden.Items.Item(index).SubItems(1).Text Then 'kung nasa dGridIden yung @zootopia + ctr3 += 1 + End If + Next + + For index As Integer = 0 To dGridIden.Items.Count - 1 + If identifier3 = dGridIden.Items.Item(index).SubItems(1).Text Then 'kung nasa dGridIden yung @zootopia + cur = index + End If + Next + + If ctr3 > 0 Then + Dim ctr4 As Integer = 0 + For index As Integer = 0 To dGridLexi.Items.Count - 1 + If identifier3 = dGridLexi.Items.Item(index).SubItems(2).Text Then 'kung nasa dGridIden yung @zootopia + ctr4 += 1 + End If + Next + + If dGridBoard.Items.Count > 0 Then + For index As Integer = 0 To dGridBoard.Items.Count - 1 + If identifier3 = dGridBoard.Items.Item(index).SubItems(0).Text Then 'kung nasa dGridIden yung @zootopia + ctr4 += 2 + End If + Next + End If + + If ctr4 < 2 And dGridIden.Items.Item(cur).SubItems(9).Text <> "stork" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(identifier3 + " -Unused variable") + End If + End If + '============================================================================== + Dim identifier4 As String = dGridLexi.Items.Item(k).SubItems(2).Text() 'name ng id sa lextable @zootopia + + Dim declCount As Integer = 0 + Dim declCtr As Integer = k + While Not (setokee(declCtr) = ":" Or setokee(declCtr) = "newline" Or inArray(setokee(k), dtype, 4)) + If setokee(declCtr) = "at" Then + declCount += 1 + End If + declCtr -= 1 + End While + + If declCount > 0 Then 'if declaration + Dim c As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = identifier4 Then + c = index + End If + Next + + Dim curType = dGridIden.Items.Item(c).SubItems(5).Text() + If setokee(k + 1) = "assgnOp" Then 'para sa variable + Dim datatype As String = dGridIden.Items.Item(c).SubItems(2).Text() + Dim val_data As String = dGridIden.Items.Item(c).SubItems(4).Text() + Dim value As String = dGridIden.Items.Item(c).SubItems(3).Text() + If datatype = "newt" Then + If Not (val_data = "newtlit" Or val_data = "null") Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(value + " -Invalid value for data type " + datatype) + End If + ElseIf datatype = "starling" Then + If Not (val_data = "starlinglit" Or val_data = "null") Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(value + " -Invalid value for data type " + datatype) + End If + ElseIf datatype = "bull" Then + If Not (val_data = "bullLit" Or val_data = "null") Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(value + " -Invalid value for data type " + datatype) + End If + ElseIf datatype = "duck" Then + If Not (val_data = "ducklit" Or val_data = "newtlit" Or val_data = "null") Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(value + " -Invalid value for data type " + datatype) + End If + End If + ElseIf setokee(k + 1) = "oppar" Then 'para sa function + 'MessageBox.Show("line= " & selinee(k)) + Dim kawnt As Integer = k + 1 + While setokee(kawnt) <> "newline" + If setokee(kawnt) = "clpar" Then + Exit While + End If + kawnt += 1 + End While + + If setokee(kawnt + 1) = ":" Then + Dim datatype2 As String = dGridIden.Items.Item(c).SubItems(2).Text() + Dim count As Integer = k + 1 + Dim counter As Integer = 0 + While Not setokee(count) = ":" + If Not (setokee(count) = datatype2 Or setokee(count) = "," Or setokee(count) = "oppar" Or setokee(count) = "clpar") Then + counter += 1 + End If + count += 1 + End While + If counter >= 1 Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("Data Type of parameter must be same with the data type of the function used.") + End If + Else 'PANG FUNCTION DEFINITION + Dim datatype2 As String = dGridIden.Items.Item(c).SubItems(2).Text() + 'MessageBox.Show(datatype2 & "Sa Else") + Dim count As Integer = k + 1 + Dim counter As Integer = 0 + Dim counter2 As Integer = 0 + While Not setokee(count) = "clpar" + 'MessageBox.Show(setokee(count)) + If Not (setokee(count) = datatype2 Or setokee(count) = "," Or setokee(count) = "at" Or setokee(count) = "identifier" Or setokee(count) = "opsquare" Or setokee(count) = "clsquare" Or setokee(count) = "oppar" Or setokee(count) = "clpar") Then + counter += 1 + End If + count += 1 + End While + If counter >= 1 Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("Data Type of parameter must be the same with the function content.") + End If + + count = k + 1 + If setokee(k + 2) <> "clpar" Then + While setokee(count) <> "clpar" + If setokee(count) = "," Then + counter2 += 1 + End If + count += 1 + End While + + counter2 += 1 + 'MessageBox.Show(cou) + If dGridIden.Items.Count > 0 Then + Dim param As String = dGridIden.Items.Item(c).SubItems(8).Text() + If Int(param) <> counter2 Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("No. of parameter in written function is not equal with function declaration.") + End If + End If + End If + End If + + ElseIf setokee(k + 1) = "opsquare" Then + Dim currType As String = dGridIden.Items.Item(c).SubItems(5).Text() 'array1/array2 + If currType = "array1" Then + Dim arrSize As String = dGridIden.Items.Item(c).SubItems(7).Text + If Char.IsDigit(arrSize) Then + If Int(arrSize) < 1 Or Int(arrSize) > 10 Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("Size should be greater than 0 or less than 100") + End If + Else + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("Size must be a newtlit or identifier with data type of 'newt'") + End If + ElseIf currType = "array2" Then + Dim arrSize As String = dGridIden.Items.Item(c).SubItems(7).Text + Dim arrSize2 As String = dGridIden.Items.Item(c).SubItems(10).Text + If Char.IsDigit(arrSize) Then + If Int(arrSize) < 1 Or Int(arrSize) > 10 Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("Size must be greater than 0 or less than 10") + End If + Else + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("Size must be a newtlit or identifier with data type of 'newt'") + End If + + If Char.IsDigit(arrSize2) Then + If Int(arrSize2) < 1 Or Int(arrSize2) > 10 Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("Size must be greater than 0 or less than 10") + End If + Else + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("Size must be a newtlit or identifier with data type of 'newt'") + End If + End If + + + + If setokee(k + 3) = "assgnOp" Or setokee(k + 4) = "assgnOp" Or setokee(k + 5) = "assgnOp" Or setokee(k + 6) = "assgnOp" Or setokee(k + 7) = "assgnOp" Then + Dim arrdtype As String = dGridIden.Items.Item(c).SubItems(4).Text() + Dim arrType As String = dGridIden.Items.Item(c).SubItems(5).Text() + Dim arrcount As Integer = k + Dim arrctr As Integer = 0 + Dim elemCtr As Integer = k + 4 + Dim commaCtr As Integer = 0 + Dim parCtr As Integer = 0 + + While setokee(arrcount) <> "assgnOp" + arrcount += 1 + End While + + While Not (setokee(arrcount) = ":" Or setokee(arrcount) = "clcurly") + If Not (setokee(arrcount) = "assgnOp" Or setokee(arrcount) = "opcurly" Or setokee(arrcount) = "clcurly" Or setokee(arrcount) = "oppar" _ + Or setokee(arrcount) = "," Or setokee(arrcount) = "clpar" Or setokee(arrcount) = arrdtype) Then + arrctr += 1 + End If + arrcount += 1 + End While + + If arrctr > 0 Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("Data Type of an element should be the same with the array content.") + End If + + If arrType = "array1" Then + While Not (setokee(elemCtr) = ":" Or setokee(elemCtr) = "clcurly") + If setokee(elemCtr) = "," Then + commaCtr += 1 + End If + elemCtr += 1 + End While + + Dim arrSize1 As String = "" + If Not dGridIden.Items.Item(c).SubItems(7).Text() = "null" Then + arrSize1 = dGridIden.Items.Item(c).SubItems(7).Text() + End If + + If commaCtr >= Int(arrSize1) Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("#no. of elem(s) is not within the size of an array.") + End If + + ElseIf arrType = "array2" Then + While Not (setokee(elemCtr) = ":" Or setokee(elemCtr) = "clcurly") + If setokee(elemCtr) = "," Then + commaCtr += 1 + ElseIf setokee(elemCtr) = "oppar" Then + parCtr += 1 + End If + elemCtr += 1 + End While + + Dim arrSize1 As String = dGridIden.Items.Item(c).SubItems(7).Text() + Dim arrSize2 As String = dGridIden.Items.Item(c).SubItems(10).Text() + Dim totalSize As String = Int(arrSize1) * Int(arrSize2) + + If commaCtr >= totalSize Or commaCtr > 100 Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("#no. of column(s) is not within the size of an array.") + End If + + If parCtr > arrSize1 Or parCtr > 10 Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("#no. of row(s) is not around the size of an array.") + End If + + End If + + End If + End If + + ElseIf declCount = 0 Then 'di declaration + + If setokee(k) = "identifier" Then + 'INDEX out of bounds + If dGridIden.Items.Count > 0 Then + Dim setID As String = dGridLexi.Items.Item(k).SubItems(2).Text() + Dim d1 As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = setID Then + d1 = index + End If + Next + + Dim setType As String = dGridIden.Items.Item(d1).SubItems(5).Text + If setType = "array1" Then + Dim getSize As String = dGridIden.Items.Item(d1).SubItems(7).Text + If setokee(k + 1) = "newtlit" Then + Dim curIndex As String = dGridLexi.Items.Item(k).SubItems(2).Text + ' MessageBox.Show(curIndex & " " & getSize) + If curIndex >= getSize Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("Index is out of bounds") + End If + End If + '------------------------------------------------------------------- + 'No. of parameter + ElseIf setType = "function" Then + Dim getParam As String = dGridIden.Items.Item(d1).SubItems(8).Text + Dim getDtype As String = dGridIden.Items.Item(d1).SubItems(2).Text + Dim counta As Integer = k + 1 + Dim paramCtr As Integer = 0 + + If setokee(k + 1) = "oppar" Then + While Not setokee(counta) = "clpar" + If setokee(counta) = "," Then + paramCtr += 1 + End If + counta += 1 + End While + + paramCtr += 1 + + If getDtype <> "viper" Then + If paramCtr < Int(getParam) Or paramCtr > Int(getParam) Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("No. of param is not equal to the declared param") + End If + End If + + 'MessageBox.Show("paramCtr= " & paramCtr) + '------------------------------------------------------------------ + Dim counta2 As Integer = k + 1 + + While Not setokee(counta2) = "clpar" + If getDtype = "newt" Then + If setokee(counta2) = "identifier" Then + Dim currID As String = dGridLexi.Items.Item(counta2).SubItems(2).Text() 'c + Dim counta3 As Integer 'c + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = currID Then 'c + counta3 = index 'c + End If + Next + + Dim currDType As String = dGridIden.Items.Item(counta3).SubItems(2).Text() 'c + If currDType = "duck" Or currDType = "bull" Or currDType = "starling" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(counta2).SubItems(2).Text() & " - Invalid data type for param") + End If + ElseIf setokee(counta2) = "ducklit" Or setokee(counta2) = "bullLit" Or setokee(counta2) = "starlinglit" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(counta2).SubItems(2).Text() & " - Invalid data type for param") + End If + + ElseIf getDtype = "duck" Then + If setokee(counta2) = "identifier" Then + Dim currID As String = dGridLexi.Items.Item(counta2).SubItems(2).Text() 'c + Dim counta3 As Integer 'c + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = currID Then 'c + counta3 = index 'c + End If + Next + + Dim currDType As String = dGridIden.Items.Item(counta3).SubItems(2).Text() 'c + If currDType = "newt" Or currDType = "bull" Or currDType = "starling" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(counta2).SubItems(2).Text() & " - Invalid data type for param") + End If + ElseIf setokee(counta2) = "newtlit" Or setokee(counta2) = "bullLit" Or setokee(counta2) = "starlinglit" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(counta2).SubItems(2).Text() & " - Invalid data type for param") + End If + + ElseIf getDtype = "bull" Then + If setokee(counta2) = "identifier" Then + Dim currID As String = dGridLexi.Items.Item(counta2).SubItems(2).Text() 'c + Dim counta3 As Integer 'c + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = currID Then 'c + counta3 = index 'c + End If + Next + + Dim currDType As String = dGridIden.Items.Item(counta3).SubItems(2).Text() 'c + If currDType = "duck" Or currDType = "newt" Or currDType = "starling" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(counta2).SubItems(2).Text() & " - Invalid data type for param") + End If + ElseIf setokee(counta2) = "ducklit" Or setokee(counta2) = "newtlit" Or setokee(counta2) = "starlinglit" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(counta2).SubItems(2).Text() & " - Invalid data type for param") + End If + ElseIf getDtype = "starling" Then + If setokee(counta2) = "identifier" Then + Dim currID As String = dGridLexi.Items.Item(counta2).SubItems(2).Text() 'c + Dim counta3 As Integer 'c + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = currID Then 'c + counta3 = index 'c + End If + Next + + Dim currDType As String = dGridIden.Items.Item(counta3).SubItems(2).Text() 'c + If currDType = "duck" Or currDType = "bull" Or currDType = "newt" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(counta2).SubItems(2).Text() & " - Invalid data type for param") + End If + ElseIf setokee(counta2) = "ducklit" Or setokee(counta2) = "bullLit" Or setokee(counta2) = "newtlit" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(counta2).SubItems(2).Text() & " - Invalid data type for param") + End If + End If + counta2 += 1 + End While + Else + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(setID & " - is used not as a function") + + Dim x As Integer = k + 1 + While setokee(x) <> "newline" + x += 1 + End While + k = x + End If + + 'wawalain yung to + '------------------------------------------------------------------ + ElseIf setokee(k + 1) = "at" Then + If dGridIden.Items.Count > 0 Then + Dim boaId As String = dGridLexi.Items.Item(k).SubItems(2).Text() + Dim match As Integer + Dim isMember As Boolean = False + Dim isStor As Boolean = False + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = boaId Then 'c + match = index 'c + End If + Next + + Dim typee As String = dGridIden.Items.Item(match).SubItems(5).Text + + If typee <> "stork" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(boaId & " - is not stork_name") + Else + isStor = True + End If + + If isStor = True Then + Dim boaObj As String = dGridLexi.Items.Item(k + 2).SubItems(2).Text() + For index As Integer = 0 To dGridBoard.Items.Count - 1 + If dGridBoard.Items.Item(index).SubItems(0).Text() = boaObj Then 'c + isMember = True + End If + Next + + If isMember = True Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(boaObj & " - identifier is already used a stork_name") + Else + objList = dGridBoard.Items.Add(boaObj) + objList.SubItems.Add(boaId) + End If + End If + + + End If + + End If + 'END SA IF-FUNCTION + End If + 'END IF MAY LAMAN YUNG dGridIden + End If + 'END IF ID YUNG SETOKEE(K) PARA SA DECLARATION + Dim identifier5 As String = dGridLexi.Items.Item(k).SubItems(2).Text() + + Dim d As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = identifier5 Then + d = index + End If + Next + + Dim curIDType As String = dGridIden.Items.Item(d).SubItems(5).Text() + + If setokee(k + 1) = "assgnOp" And (setokee(k + 3) = "," Or setokee(k + 3) = ":") Then 'para sa variable + If Not curIDType = "constant" Then + Dim idDType As String = "" + Dim idType As String = "" + Dim curID As String = "" + + If setokee(k + 2) = "identifier" Then + curID = dGridLexi.Items.Item(k + 2).SubItems(2).Text() '@zootopia + Dim e As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = curID Then + e = index + End If + Next + If dGridIden.Items.Item(e).SubItems(4).Text() = "null" Then + idDType = dGridIden.Items.Item(e).SubItems(2).Text() + If idDType = "newt" Then + idType = "newtlit" + ElseIf idDType = "bull" Then + idType = "bullLit" + ElseIf idDType = "duck" Then + idType = "ducklit" + ElseIf idDType = "starling" Then + idType = "starlinglit" + End If + Else + idType = dGridIden.Items.Item(e).SubItems(4).Text() + End If + Else + idType = dGridLexi.Items.Item(k + 2).SubItems(3).Text() + End If + + Dim curDType As String = "" + Dim curType As String = "" + If dGridIden.Items.Item(d).SubItems(4).Text() = "null" Then + curDType = dGridIden.Items.Item(d).SubItems(2).Text() + If curDType = "newt" Then + curType = "newtlit" + ElseIf curDType = "bull" Then + curType = "bullLit" + ElseIf curDType = "duck" Then + curType = "ducklit" + ElseIf curDType = "starling" Then + curType = "starlinglit" + End If + Else + curType = dGridIden.Items.Item(d).SubItems(4).Text() + End If + '------------------------------------- + 'TYPE MISMATCH SA ASSIGNMENT NG VALUE SA VARIABLE + If Not curType = idType Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("Type mismatch.") 'assigning ng value sa var + End If + + If setokee(k + 2) = "identifier" Then + Dim se1Type As String = dGridIden.Items.Item(d).SubItems(5).Text 'if variable talaga yung 1st + Dim fDType As String = dGridIden.Items.Item(d).SubItems(2).Text + Dim sID As String = dGridLexi.Items.Item(k + 2).SubItems(2).Text() '@zootopia + Dim sDType As String = "" + Dim f As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = sID Then + f = index + End If + Next + Dim se2Type As String = dGridIden.Items.Item(f).SubItems(5).Text 'if variable talaga yung 2nd + sDType = dGridIden.Items.Item(f).SubItems(2).Text + + 'MessageBox.Show("Type1= " & se1Type & " ,Type2= " & se2Type) + + If se1Type <> "variable" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(se1Type & " " & dGridIden.Items.Item(d).SubItems(1).Text & " is used as a variable") + End If + + If se2Type <> "variable" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(se2Type & " " & dGridIden.Items.Item(f).SubItems(1).Text & " is used as a variable") + End If + End If + + + '-------------------------------------------------------------------- + Else + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("Cannot change value for set") + End If + ElseIf setokee(k + 1) = "assgnOp" And setokee(k + 2) = "identifier" Then + 'MessageBox.Show("assign tayo") + Dim fDType As String = dGridIden.Items.Item(d).SubItems(2).Text + Dim sID As String = dGridLexi.Items.Item(k + 2).SubItems(2).Text() '@zootopia + Dim sDType As String = "" + Dim f As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = sID Then + f = index + End If + Next + sDType = dGridIden.Items.Item(f).SubItems(2).Text + + 'MessageBox.Show("Type1= " & se1Type & " ,Type2= " & se2Type) + If fDType <> sDType Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("Type mismatch for assigning value to " & dGridIden.Items.Item(d).SubItems(1).Text) + End If + '------------ + + '----------------------------------------------------------------- + 'MATH EXP SA TEXT OR FLAG + ElseIf setokee(k + 2) = "increOp" Or setokee(k + 2) = "decreOp" Or setokee(k + 3) = "mathOp" _ + Or setokee(k + 3) = "decreOp" Or setokee(k + 3) = "increOp" Then + + Dim curDType = dGridIden.Items.Item(d).SubItems(2).Text() + If curDType = "starling" Or curDType = "bull" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("Type mismatch. Cannot assign math Op to the variable with '" & curDType & "' data type.") + End If + '-------------------------------------------------------------------- + 'PARA SA ARRAY + ElseIf curIDType = "array1" Then + If setokee(k + 2) = "newtlit" Or setokee(k + 2) = "identifier" Then + Dim setID As String = dGridLexi.Items.Item(k).SubItems(2).Text() + Dim d1 As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = setID Then + d1 = index + End If + Next + 'INDEX OUT OF BOUNDS + If dGridIden.Items.Count > 0 Then + Dim setType As String = dGridIden.Items.Item(d1).SubItems(5).Text + Dim getSize As String = dGridIden.Items.Item(d1).SubItems(7).Text + If setType = "array1" Then + If setokee(k + 2) = "newtlit" Then + Dim curIndex As String = dGridLexi.Items.Item(k + 2).SubItems(2).Text + If Int(curIndex) >= Int(getSize) Or Int(curIndex) < 0 Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("Index is out of bounds ") + End If + ElseIf setokee(k + 2) = "identifier" Then + Dim sizeID As String = dGridLexi.Items.Item(k + 2).SubItems(2).Text() + Dim d2 As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = sizeID Then + d2 = index + End If + Next + + Dim sizeDType As String = dGridIden.Items.Item(d2).SubItems(2).Text + If Not sizeDType = "newt" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("Can't assign variable " & sizeID & " as size of an array") + Else + Dim sizeVal As String = dGridIden.Items.Item(d2).SubItems(3).Text + If sizeVal = "null" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(sizeID & " - No value is assigned before using as size of an array") + Else + If Int(sizeVal) >= Int(getSize) Or Int(sizeVal) < 0 Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("Index is out of bounds.") + End If + End If + End If + End If + End If + End If + 'END IF MAY LAMAN YUNG dGridIden + End If + + If setokee(k + 4) = "assgnOp" Then + Dim daType As String = dGridIden.Items.Item(d).SubItems(2).Text + If daType = "newt" Then + If setokee(k + 5) = "ducklit" Or setokee(k + 5) = "bullLit" Or setokee(k + 5) = "starlinglit" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("Type mismatch for assigning value to " & dGridIden.Items.Item(d).SubItems(1).Text) + ElseIf setokee(k + 5) = "identifier" Then + Dim cureID = dGridLexi.Items.Item(k + 5).SubItems(2).Text() '@zootopia + Dim e As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = cureID Then + e = index + End If + Next + + Dim getDT As String = dGridIden.Items.Item(e).SubItems(2).Text() + If getDT <> daType Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("Type mismatch for assigning value to " & dGridIden.Items.Item(d).SubItems(1).Text) + End If + End If + ElseIf daType = "duck" Then + If setokee(k + 5) = "newtlit" Or setokee(k + 5) = "bullLit" Or setokee(k + 5) = "starlinglit" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("Type mismatch for assigning value to " & dGridIden.Items.Item(d).SubItems(1).Text) + ElseIf setokee(k + 5) = "identifier" Then + Dim cureID = dGridLexi.Items.Item(k + 5).SubItems(2).Text() '@zootopia + Dim e As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = cureID Then + e = index + End If + Next + + Dim getDT As String = dGridIden.Items.Item(e).SubItems(2).Text() + If getDT <> daType Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("Type mismatch for assigning value to " & dGridIden.Items.Item(d).SubItems(1).Text) + End If + End If + ElseIf daType = "bull" Then + If setokee(k + 5) = "ducklit" Or setokee(k + 5) = "newtlit" Or setokee(k + 5) = "starlinglit" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("Type mismatch for assigning value to " & dGridIden.Items.Item(d).SubItems(1).Text) + ElseIf setokee(k + 5) = "identifier" Then + Dim cureID = dGridLexi.Items.Item(k + 5).SubItems(2).Text() '@zootopia + Dim e As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = cureID Then + e = index + End If + Next + + Dim getDT As String = dGridIden.Items.Item(e).SubItems(2).Text() + If getDT <> daType Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("Type mismatch for assigning value to " & dGridIden.Items.Item(d).SubItems(1).Text) + End If + End If + ElseIf daType = "starling" Then + If setokee(k + 5) = "ducklit" Or setokee(k + 5) = "bullLit" Or setokee(k + 5) = "newtlit" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("Type mismatch for assigning value to " & dGridIden.Items.Item(d).SubItems(1).Text) + ElseIf setokee(k + 5) = "identifier" Then + Dim cureID = dGridLexi.Items.Item(k + 5).SubItems(2).Text() '@zootopia + Dim e As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = cureID Then + e = index + End If + Next + + Dim getDT As String = dGridIden.Items.Item(e).SubItems(2).Text() + If getDT <> daType Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("Type mismatch for assigning value to " & dGridIden.Items.Item(d).SubItems(1).Text) + End If + End If + End If + End If + ElseIf curIDType = "array2" Then + If setokee(k + 2) = "newtlit" Or setokee(k + 2) = "identifier" Then + Dim setID As String = dGridLexi.Items.Item(k).SubItems(2).Text() + Dim d1 As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = setID Then + d1 = index + End If + Next + 'INDEX OUT OF BOUNDS + If dGridIden.Items.Count > 0 Then + Dim setType As String = dGridIden.Items.Item(d1).SubItems(5).Text + Dim getSize1 As String = dGridIden.Items.Item(d1).SubItems(7).Text + Dim getSize2 As String = dGridIden.Items.Item(d1).SubItems(10).Text + If setType = "array2" Then + If setokee(k + 2) = "newtlit" Then + Dim curIndex As String = dGridLexi.Items.Item(k + 2).SubItems(2).Text + If Int(curIndex) >= Int(getSize1) Or Int(curIndex) < 0 Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("1st Index is out of bounds") + End If + ElseIf setokee(k + 2) = "identifier" Then + Dim sizeID As String = dGridLexi.Items.Item(k + 2).SubItems(2).Text() + Dim d2 As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = sizeID Then + d2 = index + End If + Next + + Dim sizeDType As String = dGridIden.Items.Item(d2).SubItems(2).Text + If Not sizeDType = "newt" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("Can't assign variable " & sizeID & " as 1st index of array") + Else + Dim sizeVal As String = dGridIden.Items.Item(d2).SubItems(3).Text + If sizeVal = "null" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(sizeID & " - No value is assigned before using as 1st index of array") + Else + If Int(sizeVal) >= Int(getSize1) Or Int(sizeVal) < 0 Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("1st Index is out of bounds.") + End If + End If + End If + End If + + If setokee(k + 5) = "newtlit" Then + Dim curIndex As String = dGridLexi.Items.Item(k + 5).SubItems(2).Text + If Int(curIndex) >= Int(getSize2) Or Int(curIndex) < 0 Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("2nd Index is out of bounds ") + End If + ElseIf setokee(k + 5) = "identifier" Then + Dim sizeID As String = dGridLexi.Items.Item(k + 5).SubItems(2).Text() + Dim d2 As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = sizeID Then + d2 = index + End If + Next + + Dim sizeDType As String = dGridIden.Items.Item(d2).SubItems(2).Text + If Not sizeDType = "newt" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("Can't assign var " & sizeID & " as 2nd index of array") + Else + Dim sizeVal As String = dGridIden.Items.Item(d2).SubItems(3).Text + If sizeVal = "null" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(sizeID & " - No value is assigned before using as 2nd index of array") + Else + If Int(sizeVal) >= Int(getSize2) Or Int(sizeVal) < 0 Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(" 2nd Index is out of bounds.") + End If + End If + End If + End If + End If + End If + 'END IF MAY LAMAN YUNG identlist/table + End If + + If setokee(k + 7) = "assgnOp" Then + Dim daType As String = dGridIden.Items.Item(d).SubItems(2).Text + If daType = "newt" Then + If setokee(k + 8) = "ducklit" Or setokee(k + 8) = "bullLit" Or setokee(k + 8) = "starlinglit" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("Type mismatch for assigning value to " & dGridIden.Items.Item(d).SubItems(1).Text) + ElseIf setokee(k + 8) = "identifier" Then + Dim cureID = dGridLexi.Items.Item(k + 8).SubItems(2).Text() '@zootopia + Dim e As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = cureID Then + e = index + End If + Next + + Dim getDT As String = dGridIden.Items.Item(e).SubItems(2).Text() + If getDT <> daType Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("Type mismatch for assigning value to " & dGridIden.Items.Item(d).SubItems(1).Text) + End If + End If + ElseIf daType = "duck" Then + If setokee(k + 8) = "newtlit" Or setokee(k + 8) = "bullLit" Or setokee(k + 8) = "starlinglit" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("Type mismatch for assigning value to " & dGridIden.Items.Item(d).SubItems(1).Text) + ElseIf setokee(k + 8) = "identifier" Then + Dim cureID = dGridLexi.Items.Item(k + 8).SubItems(2).Text() '@zootopia + Dim e As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = cureID Then + e = index + End If + Next + + Dim getDT As String = dGridIden.Items.Item(e).SubItems(2).Text() + If getDT <> daType Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("Type mismatch for assigning value to " & dGridIden.Items.Item(d).SubItems(1).Text) + End If + End If + ElseIf daType = "bull" Then + If setokee(k + 8) = "ducklit" Or setokee(k + 8) = "newtlit" Or setokee(k + 8) = "starlinglit" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("Type mismatch for assigning value to " & dGridIden.Items.Item(d).SubItems(1).Text) + ElseIf setokee(k + 8) = "identifier" Then + Dim cureID = dGridLexi.Items.Item(k + 8).SubItems(2).Text() '@zootopia + Dim e As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = cureID Then + e = index + End If + Next + + Dim getDT As String = dGridIden.Items.Item(e).SubItems(2).Text() + If getDT <> daType Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("Type mismatch for assigning value to " & dGridIden.Items.Item(d).SubItems(1).Text) + End If + End If + ElseIf daType = "starling" Then + If setokee(k + 8) = "ducklit" Or setokee(k + 8) = "bullLit" Or setokee(k + 8) = "newtlit" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("Type mismatch for assigning value to " & dGridIden.Items.Item(d).SubItems(1).Text) + ElseIf setokee(k + 8) = "identifier" Then + Dim cureID = dGridLexi.Items.Item(k + 8).SubItems(2).Text() '@zootopia + Dim e As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = cureID Then + e = index + End If + Next + + Dim getDT As String = dGridIden.Items.Item(e).SubItems(2).Text() + If getDT <> daType Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("Type mismatch for assigning value to " & dGridIden.Items.Item(d).SubItems(1).Text) + End If + End If + End If + End If + + End If + End If + End If + If setokee(k) = "mathOp" Then + If setokee(k - 1) = "identifier" Then 'c + If dGridIden.Items.Count > 0 Then + Dim currID As String = dGridLexi.Items.Item(k - 1).SubItems(2).Text() 'c + Dim counta As Integer 'c + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = currID Then 'c + counta = index 'c + End If + Next + + Dim currDType As String = dGridIden.Items.Item(counta).SubItems(2).Text() 'c + If currDType = "starling" Or currDType = "bull" Then 'c + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k - 1).SubItems(2).Text() & " - Invalid for math expression") 'c + ElseIf currDType = "newt" Or currDType = "duck" Then + Dim currVal As String = dGridIden.Items.Item(counta).SubItems(3).Text() + If currVal = "null" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k - 1).SubItems(2).Text() & " - No value is assigned before using in math expression") + End If + + End If + End If + ElseIf setokee(k - 1) = "starlinglit" Or setokee(k - 1) = "bullLit" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k - 1).SubItems(2).Text() & " - Invalid for math expression") 'c + End If + + If setokee(k + 1) = "identifier" Then 'c + If dGridIden.Items.Count > 0 Then + Dim currID As String = dGridLexi.Items.Item(k + 1).SubItems(2).Text() 'c + Dim counta As Integer 'c + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = currID Then 'c + counta = index 'c + End If + Next + + Dim currDType As String = dGridIden.Items.Item(counta).SubItems(2).Text() 'c + If currDType = "starling" Or currDType = "bull" Then 'c + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Invalid for math expression") 'c + ElseIf currDType = "newt" Or currDType = "duck" Then + Dim currVal As String = dGridIden.Items.Item(counta).SubItems(3).Text() + If currVal = "null" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k - 1).SubItems(2).Text() & " - No value is assigned before using in math expression") + End If + End If + End If + ElseIf setokee(k + 1) = "starlinglit" Or setokee(k + 1) = "bullLit" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Invalid for math expression") 'c + End If + End If + + If setokee(k) = "increOp" Or setokee(k) = "decreOp" Then + If setokee(k - 1) = "identifier" Then 'c + If dGridIden.Items.Count > 0 Then + Dim currID As String = dGridLexi.Items.Item(k - 1).SubItems(2).Text() 'c + Dim counta As Integer 'c + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = currID Then 'c + counta = index 'c + End If + Next + + Dim currDType As String = dGridIden.Items.Item(counta).SubItems(2).Text() 'c + If currDType = "starling" Or currDType = "bull" Or currDType = "duck" Then 'c + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k - 1).SubItems(2).Text() & " (" & currDType & ") - Invalid for increment/ decrement operation") 'c + ElseIf currDType = "newt" Then + Dim currVal As String = dGridIden.Items.Item(counta).SubItems(3).Text() + If currVal = "null" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k - 1).SubItems(2).Text() & " - No value is assigned before using in increment/decrement operation") + End If + End If + End If + ElseIf setokee(k - 1) = "starlinglit" Or setokee(k - 1) = "bullLit" Or setokee(k - 1) = "ducklit" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k - 1).SubItems(2).Text() & " - Invalid for increment/ decrement operation") 'c + End If + + If setokee(k + 1) = "identifier" Then 'c + If dGridIden.Items.Count > 0 Then + Dim currID As String = dGridLexi.Items.Item(k + 1).SubItems(2).Text() 'c + Dim counta As Integer 'c + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = currID Then 'c + counta = index 'c + End If + Next + + Dim currDType As String = dGridIden.Items.Item(counta).SubItems(2).Text() 'c + If currDType = "starling" Or currDType = "bull" Or currDType = "duck" Then 'c + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " (" & currDType & ") - Invalid for increment/ decrement operation") 'c + ElseIf currDType = "newt" Then + Dim currVal As String = dGridIden.Items.Item(counta).SubItems(3).Text() + If currVal = "null" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k - 1).SubItems(2).Text() & " - No value is assigned before using in increment/decrement operation") + End If + End If + End If + ElseIf setokee(k + 1) = "starlinglit" Or setokee(k + 1) = "bullLit" Or setokee(k - 1) = "ducklit" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Invalid for increment/ decrement operation") 'c + End If + End If + If setokee(k) = ".+" Then + If dGridIden.Items.Count > 1 Then + Dim fId As String = dGridLexi.Items.Item(k - 1).SubItems(2).Text + Dim sId As String = dGridLexi.Items.Item(k + 1).SubItems(2).Text + Dim fDtype As String = "" + Dim sDtype As String = "" + Dim cF, cS As Integer + + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = fId Then 'c + cF = index 'c + End If + Next + + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = sId Then 'c + cS = index 'c + End If + Next + + fDtype = dGridIden.Items.Item(cF).SubItems(2).Text + If fDtype <> "starling" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("Data type of " & fId & " should be 'starling(string)' for string operator") + End If + + sDtype = dGridIden.Items.Item(cS).SubItems(2).Text + If sDtype <> "starling" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("Data type of " & sId & " should be 'starling(string)' for string operator") + End If + End If + 'end ng if may laman yung dGridIden + End If + If setokee(k) = "relOp2" Then + If setokee(k - 1) = "identifier" Then 'VARIABLE + If dGridIden.Items.Count > 0 Then + Dim currID As String = dGridLexi.Items.Item(k - 1).SubItems(2).Text() 'CHANGE + Dim counta As Integer 'c + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = currID Then 'c + counta = index 'c + End If + Next + Dim currDType As String = dGridIden.Items.Item(counta).SubItems(2).Text() 'datatype ng k-? + 'MessageBox.Show(currDType) + + If currDType = "newt" Then 'newt== + If setokee(k + 1) = "identifier" Then + If dGridIden.Items.Count > 0 Then + Dim setID As String = dGridLexi.Items.Item(k + 1).SubItems(2).Text() + Dim setCtr As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = setID Then 'c + setCtr = index 'c + End If + Next + + Dim setDType As String = dGridIden.Items.Item(setCtr).SubItems(2).Text() + If setDType = "duck" Or setDType = "bull" Or setDType = "starling" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for arguements should be the same for condition") + End If + End If + ElseIf setokee(k + 1) = "ducklit" Or setokee(k + 1) = "bullLit" Or setokee(k + 1) = "starlinglit" Then 'CHANGE + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for arguements should be the same for condition") + End If + ElseIf currDType = "duck" Then + If setokee(k + 1) = "identifier" Then + If dGridIden.Items.Count > 0 Then + Dim setID As String = dGridLexi.Items.Item(k + 1).SubItems(2).Text() + Dim setCtr As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = setID Then 'c + setCtr = index 'c + End If + Next + + Dim setDType As String = dGridIden.Items.Item(setCtr).SubItems(2).Text() + If setDType = "newt" Or setDType = "bull" Or setDType = "starling" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for arguements should be the same for condition") + End If + End If + ElseIf setokee(k + 1) = "newtlit" Or setokee(k + 1) = "bullLit" Or setokee(k + 1) = "starlinglit" Then 'CHANGE + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for arguements should be the same for condition") + End If + ElseIf currDType = "bull" Then + If setokee(k + 1) = "identifier" Then + If dGridIden.Items.Count > 0 Then + Dim setID As String = dGridLexi.Items.Item(k + 1).SubItems(2).Text() + Dim setCtr As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = setID Then 'c + setCtr = index 'c + End If + Next + + Dim setDType As String = dGridIden.Items.Item(setCtr).SubItems(2).Text() + If setDType = "duck" Or setDType = "newt" Or setDType = "starling" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for arguements should be the same for condition") + End If + End If + ElseIf setokee(k + 1) = "ducklit" Or setokee(k + 1) = "newtlit" Or setokee(k + 1) = "starlinglit" Then 'CHANGE + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for arguements should be the same for condition") + End If + ElseIf currDType = "starling" Then + If setokee(k + 1) = "identifier" Then + If dGridIden.Items.Count > 0 Then + Dim setID As String = dGridLexi.Items.Item(k + 1).SubItems(2).Text() + Dim setCtr As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = setID Then 'c + setCtr = index 'c + End If + Next + + Dim setDType As String = dGridIden.Items.Item(setCtr).SubItems(2).Text() + If setDType = "duck" Or setDType = "bull" Or setDType = "newt" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for arguements should be the same for condition") + End If + End If + ElseIf setokee(k + 1) = "ducklit" Or setokee(k + 1) = "bullLit" Or setokee(k + 1) = "newtlit" Then 'CHANGE + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for arguements should be the same for condition") + End If + End If + + End If + ElseIf setokee(k - 1) = "clsquare" And setokee(k - 4) = "identifier" Then + '1d array + If dGridIden.Items.Count > 0 Then + Dim currID As String = dGridLexi.Items.Item(k - 4).SubItems(2).Text() 'CHANGE + Dim counta As Integer 'c + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = currID Then 'c + counta = index 'c + End If + Next + Dim currDType As String = dGridIden.Items.Item(counta).SubItems(2).Text() 'datatype ng k-? + 'MessageBox.Show(currDType) + + If currDType = "newt" Then 'newt== + If setokee(k + 1) = "identifier" Then + If dGridIden.Items.Count > 0 Then + Dim setID As String = dGridLexi.Items.Item(k + 1).SubItems(2).Text() + Dim setCtr As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = setID Then 'c + setCtr = index 'c + End If + Next + + Dim setDType As String = dGridIden.Items.Item(setCtr).SubItems(2).Text() + If setDType = "duck" Or setDType = "bull" Or setDType = "starling" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for arguements should be the same for condition") + End If + End If + ElseIf setokee(k + 1) = "ducklit" Or setokee(k + 1) = "bullLit" Or setokee(k + 1) = "starlinglit" Then 'CHANGE + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for arguements should be the same for condition") + End If + ElseIf currDType = "duck" Then + If setokee(k + 1) = "identifier" Then + If dGridIden.Items.Count > 0 Then + Dim setID As String = dGridLexi.Items.Item(k + 1).SubItems(2).Text() + Dim setCtr As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = setID Then 'c + setCtr = index 'c + End If + Next + + Dim setDType As String = dGridIden.Items.Item(setCtr).SubItems(2).Text() + If setDType = "newt" Or setDType = "bull" Or setDType = "starling" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for arguements should be the same for condition") + End If + End If + ElseIf setokee(k + 1) = "newtlit" Or setokee(k + 1) = "bullLit" Or setokee(k + 1) = "starlinglit" Then 'CHANGE + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for arguements should be the same for condition") + End If + ElseIf currDType = "bull" Then + If setokee(k + 1) = "identifier" Then + If dGridIden.Items.Count > 0 Then + Dim setID As String = dGridLexi.Items.Item(k + 1).SubItems(2).Text() + Dim setCtr As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = setID Then 'c + setCtr = index 'c + End If + Next + + Dim setDType As String = dGridIden.Items.Item(setCtr).SubItems(2).Text() + If setDType = "duck" Or setDType = "newt" Or setDType = "starling" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for arguements should be the same for condition") + End If + End If + ElseIf setokee(k + 1) = "ducklit" Or setokee(k + 1) = "newtlit" Or setokee(k + 1) = "starlinglit" Then 'CHANGE + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for arguements should be the same for condition") + End If + ElseIf currDType = "starling" Then + If setokee(k + 1) = "identifier" Then + If dGridIden.Items.Count > 0 Then + Dim setID As String = dGridLexi.Items.Item(k + 1).SubItems(2).Text() + Dim setCtr As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = setID Then 'c + setCtr = index 'c + End If + Next + + Dim setDType As String = dGridIden.Items.Item(setCtr).SubItems(2).Text() + If setDType = "duck" Or setDType = "bull" Or setDType = "newt" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for arguements should be the same for condition") + End If + End If + ElseIf setokee(k + 1) = "ducklit" Or setokee(k + 1) = "bullLit" Or setokee(k + 1) = "newtlit" Then 'CHANGE + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for arguements should be the same for condition") + End If + End If + + End If + ElseIf setokee(k - 1) = "clsquare" And setokee(k - 4) = "clsquare" And setokee(k - 7) = "identifier" Then + '2d array + If dGridIden.Items.Count > 0 Then + Dim currID As String = dGridLexi.Items.Item(k - 7).SubItems(2).Text() 'CHANGE + Dim counta As Integer 'c + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = currID Then 'c + counta = index 'c + End If + Next + Dim currDType As String = dGridIden.Items.Item(counta).SubItems(2).Text() 'datatype ng k-? + 'MessageBox.Show(currDType) + + If currDType = "newt" Then 'newt== + If setokee(k + 1) = "identifier" Then + If dGridIden.Items.Count > 0 Then + Dim setID As String = dGridLexi.Items.Item(k + 1).SubItems(2).Text() + Dim setCtr As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = setID Then 'c + setCtr = index 'c + End If + Next + + Dim setDType As String = dGridIden.Items.Item(setCtr).SubItems(2).Text() + If setDType = "duck" Or setDType = "bull" Or setDType = "starling" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for arguements should be the same for condition") + End If + End If + ElseIf setokee(k + 1) = "ducklit" Or setokee(k + 1) = "bullLit" Or setokee(k + 1) = "starlinglit" Then 'CHANGE + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for arguements should be the same for condition") + End If + ElseIf currDType = "duck" Then + If setokee(k + 1) = "identifier" Then + If dGridIden.Items.Count > 0 Then + Dim setID As String = dGridLexi.Items.Item(k + 1).SubItems(2).Text() + Dim setCtr As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = setID Then 'c + setCtr = index 'c + End If + Next + + Dim setDType As String = dGridIden.Items.Item(setCtr).SubItems(2).Text() + If setDType = "newt" Or setDType = "bull" Or setDType = "starling" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for arguements should be the same for condition") + End If + End If + ElseIf setokee(k + 1) = "newtlit" Or setokee(k + 1) = "bullLit" Or setokee(k + 1) = "starlinglit" Then 'CHANGE + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for arguements should be the same for condition") + End If + ElseIf currDType = "bull" Then + If setokee(k + 1) = "identifier" Then + If dGridIden.Items.Count > 0 Then + Dim setID As String = dGridLexi.Items.Item(k + 1).SubItems(2).Text() + Dim setCtr As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = setID Then 'c + setCtr = index 'c + End If + Next + + Dim setDType As String = dGridIden.Items.Item(setCtr).SubItems(2).Text() + If setDType = "duck" Or setDType = "newt" Or setDType = "starling" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for arguements should be the same for condition") + End If + End If + ElseIf setokee(k + 1) = "ducklit" Or setokee(k + 1) = "newtlit" Or setokee(k + 1) = "starlinglit" Then 'CHANGE + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for arguements should be the same for condition") + End If + ElseIf currDType = "starling" Then + If setokee(k + 1) = "identifier" Then + If dGridIden.Items.Count > 0 Then + Dim setID As String = dGridLexi.Items.Item(k + 1).SubItems(2).Text() + Dim setCtr As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = setID Then 'c + setCtr = index 'c + End If + Next + + Dim setDType As String = dGridIden.Items.Item(setCtr).SubItems(2).Text() + If setDType = "duck" Or setDType = "bull" Or setDType = "newt" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for arguements should be the same for condition") + End If + End If + ElseIf setokee(k + 1) = "ducklit" Or setokee(k + 1) = "bullLit" Or setokee(k + 1) = "newtlit" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for arguements should be the same for condition") + End If + End If + + End If + End If + End If + If setokee(k) = "relOp1" Then + If setokee(k - 1) = "identifier" Then 'VARIABLE + If dGridIden.Items.Count > 0 Then + Dim currID As String = dGridLexi.Items.Item(k - 1).SubItems(2).Text() 'CHANGE + Dim counta As Integer 'c + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = currID Then 'c + counta = index 'c + End If + Next + Dim currDType As String = dGridIden.Items.Item(counta).SubItems(2).Text() + 'MessageBox.Show(currDType) + + If currDType = "newt" Then 'newt== + If setokee(k + 1) = "identifier" Then + If dGridIden.Items.Count > 0 Then + Dim setID As String = dGridLexi.Items.Item(k + 1).SubItems(2).Text() + Dim setCtr As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = setID Then 'c + setCtr = index 'c + End If + Next + + Dim setDType As String = dGridIden.Items.Item(setCtr).SubItems(2).Text() + If setDType = "bull" Or setDType = "starling" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for relational operation is invalid") + End If + End If + ElseIf setokee(k + 1) = "bullLit" Or setokee(k + 1) = "starlinglit" Then 'CHANGE + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for relational operation is invalid") + End If + ElseIf currDType = "duck" Then + If setokee(k + 1) = "identifier" Then + If dGridIden.Items.Count > 0 Then + Dim setID As String = dGridLexi.Items.Item(k + 1).SubItems(2).Text() + Dim setCtr As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = setID Then 'c + setCtr = index 'c + End If + Next + + Dim setDType As String = dGridIden.Items.Item(setCtr).SubItems(2).Text() + If setDType = "bull" Or setDType = "starling" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for relational operation is invalid") + End If + End If + ElseIf setokee(k + 1) = "bullLit" Or setokee(k + 1) = "starlinglit" Then 'CHANGE + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for relational operation is invalid") + End If + ElseIf currDType = "bull" Or currDType = "starling" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridIden.Items.Item(counta).SubItems(1).Text() & " - Data type for relational operation is invalid") + If setokee(k + 1) = "identifier" Then + If dGridIden.Items.Count > 0 Then + Dim setID As String = dGridLexi.Items.Item(k + 1).SubItems(2).Text() + Dim setCtr As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = setID Then 'c + setCtr = index 'c + End If + Next + + Dim setDType As String = dGridIden.Items.Item(setCtr).SubItems(2).Text() + If setDType = "bull" Or setDType = "starling" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for relational operation is invalid") + End If + End If + ElseIf setokee(k + 1) = "bullLit" Or setokee(k + 1) = "starlinglit" Then 'CHANGE + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for relational operation is invalid") + End If + + End If + + End If + ElseIf setokee(k - 1) = "clsquare" And setokee(k - 4) = "identifier" Then + '1d array + If dGridIden.Items.Count > 0 Then + Dim currID As String = dGridLexi.Items.Item(k - 4).SubItems(2).Text() 'CHANGE + Dim counta As Integer 'c + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = currID Then 'c + counta = index 'c + End If + Next + Dim currDType As String = dGridIden.Items.Item(counta).SubItems(2).Text() + 'MessageBox.Show(currDType) + + If currDType = "newt" Then 'newt== + If setokee(k + 1) = "identifier" Then + If dGridIden.Items.Count > 0 Then + Dim setID As String = dGridLexi.Items.Item(k + 1).SubItems(2).Text() + Dim setCtr As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = setID Then 'c + setCtr = index 'c + End If + Next + + Dim setDType As String = dGridIden.Items.Item(setCtr).SubItems(2).Text() + If setDType = "bull" Or setDType = "starling" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for relational operation is invalid") + End If + End If + ElseIf setokee(k + 1) = "bullLit" Or setokee(k + 1) = "starlinglit" Then 'CHANGE + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for relational operation is invalid") + End If + ElseIf currDType = "duck" Then + If setokee(k + 1) = "identifier" Then + If dGridIden.Items.Count > 0 Then + Dim setID As String = dGridLexi.Items.Item(k + 1).SubItems(2).Text() + Dim setCtr As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = setID Then 'c + setCtr = index 'c + End If + Next + + Dim setDType As String = dGridIden.Items.Item(setCtr).SubItems(2).Text() + If setDType = "bull" Or setDType = "starling" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for relational operation is invalid") + End If + End If + ElseIf setokee(k + 1) = "bullLit" Or setokee(k + 1) = "starlinglit" Then 'CHANGE + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for relational operation is invalid") + End If + ElseIf currDType = "bull" Or currDType = "starling" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridIden.Items.Item(counta).SubItems(1).Text() & " - Data type for relational operation is invalid") + If setokee(k + 1) = "identifier" Then + If dGridIden.Items.Count > 0 Then + Dim setID As String = dGridLexi.Items.Item(k + 1).SubItems(2).Text() + Dim setCtr As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = setID Then 'c + setCtr = index 'c + End If + Next + + Dim setDType As String = dGridIden.Items.Item(setCtr).SubItems(2).Text() + If setDType = "bull" Or setDType = "starling" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for relational operation is invalid") + End If + End If + ElseIf setokee(k + 1) = "bullLit" Or setokee(k + 1) = "starlinglit" Then 'CHANGE + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for relational operation is invalid") + End If + End If + End If + ElseIf setokee(k - 1) = "clsquare" And setokee(k - 4) = "clsquare" And setokee(k - 7) = "identifier" Then + '2dimen arr + If dGridIden.Items.Count > 0 Then + Dim currID As String = dGridLexi.Items.Item(k - 7).SubItems(2).Text() + Dim counta As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = currID Then 'c + counta = index 'c + End If + Next + Dim currDType As String = dGridIden.Items.Item(counta).SubItems(2).Text() + 'MessageBox.Show(currDType) + + If currDType = "newt" Then 'newt== + If setokee(k + 1) = "identifier" Then + If dGridIden.Items.Count > 0 Then + Dim setID As String = dGridLexi.Items.Item(k + 1).SubItems(2).Text() + Dim setCtr As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = setID Then + setCtr = index 'c + End If + Next + + Dim setDType As String = dGridIden.Items.Item(setCtr).SubItems(2).Text() + If setDType = "bull" Or setDType = "starling" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for relational operation is invalid") + End If + End If + ElseIf setokee(k + 1) = "bullLit" Or setokee(k + 1) = "starlinglit" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for relational operation is invalid") + End If + ElseIf currDType = "duck" Then + If setokee(k + 1) = "identifier" Then + If dGridIden.Items.Count > 0 Then + Dim setID As String = dGridLexi.Items.Item(k + 1).SubItems(2).Text() + Dim setCtr As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = setID Then 'c + setCtr = index 'c + End If + Next + + Dim setDType As String = dGridIden.Items.Item(setCtr).SubItems(2).Text() + If setDType = "bull" Or setDType = "starling" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for relational operation is invalid") + End If + End If + ElseIf setokee(k + 1) = "bullLit" Or setokee(k + 1) = "starlinglit" Then 'CHANGE + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for relational operation is invalid") + End If + ElseIf currDType = "bull" Or currDType = "starling" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridIden.Items.Item(counta).SubItems(1).Text() & " - Data type for relational operation is invalid") + If setokee(k + 1) = "identifier" Then + If dGridIden.Items.Count > 0 Then + Dim setID As String = dGridLexi.Items.Item(k + 1).SubItems(2).Text() + Dim setCtr As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = setID Then 'c + setCtr = index 'c + End If + Next + + Dim setDType As String = dGridIden.Items.Item(setCtr).SubItems(2).Text() + If setDType = "bull" Or setDType = "starling" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for relational operation is invalid") + End If + End If + ElseIf setokee(k + 1) = "bullLit" Or setokee(k + 1) = "starlinglit" Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add(dGridLexi.Items.Item(k + 1).SubItems(2).Text() & " - Data type for relational operation is invalid.") + End If + End If + + End If + End If + End If + + If setokee(k) = "hop" Then + 'MessageBox.Show("deport") + Dim depDtype As String = "" + Dim funcDtype As String = "" + If setokee(k + 1) = "identifier" Then + Dim seId As String = dGridLexi.Items.Item(k + 1).SubItems(2).Text + Dim getID As Integer + + If dGridIden.Items.Count > 0 Then + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text() = seId Then + getID = index + End If + Next + End If + + depDtype = dGridIden.Items.Item(getID).SubItems(2).Text + ElseIf setokee(k + 1) = "newtlit" Then + depDtype = "newt" + ElseIf setokee(k + 1) = "ducklit" Then + depDtype = "duck" + ElseIf setokee(k + 1) = "bullLit" Then + depDtype = "bull" + ElseIf setokee(k + 1) = "starlinglit" Then + depDtype = "starling" + End If + + 'MessageBox.Show(depDtype) + Dim dep As Integer = k + While dep >= 0 + If setokee(dep) = "clpar" And setokee(dep + 1) = "newline" Then + Exit While + Else + dep -= 1 + End If + End While + + Dim les As Integer = dep + 'MessageBox.Show(dep) + While setokee(les) <> "oppar" + If setokee(les) = "newt" Or setokee(les) = "duck" Or setokee(les) = "bull" Or setokee(les) = "starling" Then + funcDtype = setokee(les) + Exit While + Else + les -= 1 + End If + End While + + 'MessageBox.Show(funcDtype) + + If depDtype <> funcDtype Then + errCtr += 1 + objList = dGridSemantic.Items.Add(errCtr) + objList.SubItems.Add(selinee(k)) + objList.SubItems.Add("Data type of hop(return) value is not match.") + End If + End If + + + + k += 1 + End While + + 'para sa errors + Dim err As String = "" + Dim err1 As String = "" + Dim err2 As String = "" + Dim err21 As String = "" + Dim er1 As ListViewItem + Dim er2 As ListViewItem + If dGridSemantic.Items.Count > 1 Then + For i As Integer = 0 To dGridSemantic.Items.Count - 1 + er1 = dGridSemantic.Items(i) + err = dGridSemantic.Items.Item(i).SubItems(1).Text() + err1 = dGridSemantic.Items.Item(i).SubItems(2).Text() + + For j As Integer = i + 1 To dGridSemantic.Items.Count - 1 + er2 = dGridSemantic.Items(j) + err2 = dGridSemantic.Items.Item(j).SubItems(1).Text() + err21 = dGridSemantic.Items.Item(j).SubItems(2).Text() + + If err = err2 And err1 = err21 Then + dGridSemantic.Items.Remove(er2) + End If + Next + Next + End If + + End Sub + + + Private Sub identifierList() + Dim x As Integer = 0 + Dim isMane As Boolean = False + Dim isStork As Boolean = False + Dim isFunction As Boolean = False + Dim Ctr As Integer = 0 + Dim bCtr As Integer = 0 + Dim erCtr As Integer = 0 + Dim valDType As String = "" + Dim value As String = "" + Dim curDtype As String = "" + Dim type As String = "" + Dim used As String = "No" + Dim arraySize As String = "" + Dim arraySize2 As String = "" + Dim parameter As String = "" + Dim constAns As String = "" + + Dim dtype(4) As String + dtype(0) = "newt" + dtype(1) = "duck" + dtype(2) = "bull" + dtype(3) = "starling" + + For i As Integer = 0 To dGridLexi.Items.Count - 1 + selinee(i) = dGridLexi.Items.Item(i).SubItems(1).Text() 'LINE + Next + + For i As Integer = 0 To dGridLexi.Items.Count - 1 + setokee(i) = dGridLexi.Items.Item(i).SubItems(3).Text() 'TOKEN + Next + + While x < dGridLexi.Items.Count + If setokee(x) = "mane" Then + isStork = False + isMane = True + End If + + If setokee(x) = "stork" Then + isStork = True + 'MessageBox.Show(isStork) + Ctr += 1 + objList = dGridIden.Items.Add(Ctr) + objList.SubItems.Add(dGridLexi.Items.Item(x + 2).SubItems(2).Text()) + objList.SubItems.Add("-") + objList.SubItems.Add("-") + objList.SubItems.Add("-") + objList.SubItems.Add("stork") + objList.SubItems.Add("-") + objList.SubItems.Add("-") + objList.SubItems.Add("-") + objList.SubItems.Add("stork/global") + objList.SubItems.Add("-") + End If + + If setokee(x) = "clsymbol" Then + Dim termi As Integer = x + Dim termi2 As Integer = x + Dim iden As String = "" + If setokee(x + 1) = "identifier" Then + While termi2 >= 0 + If setokee(termi2) = "stork" Then + Exit While + End If + termi2 -= 1 + End While + + iden = dGridLexi.Items.Item(x).SubItems(2).Text + While setokee(termi) <> ":" + If setokee(termi) = "identifier" Then + bCtr += 1 + objList = dGridBoard.Items.Add(dGridLexi.Items.Item(termi).SubItems(2).Text()) + objList.SubItems.Add(dGridLexi.Items.Item(termi2 + 2).SubItems(2).Text()) + End If + termi += 1 + End While + isStork = False + ElseIf setokee(x + 1) = ":" Then + isStork = False + End If + End If + + If setokee(x) = "viper" Then + Dim kawnter As Integer = x + While setokee(kawnter) <> "clpar" + kawnter += 1 + End While + + If setokee(kawnter + 1) = ":" Then + Ctr += 1 + objList = dGridIden.Items.Add(Ctr) + objList.SubItems.Add(dGridLexi.Items.Item(x + 2).SubItems(2).Text()) + objList.SubItems.Add(setokee(x)) + objList.SubItems.Add("-") + objList.SubItems.Add("-") + objList.SubItems.Add("function") + objList.SubItems.Add("No") + objList.SubItems.Add("-") + objList.SubItems.Add("0") + objList.SubItems.Add("global") + objList.SubItems.Add("-") + End If + End If + + If inArray(setokee(x), dtype, 4) Then + Dim kownt As Integer = x + While setokee(kownt) <> "newline" + If setokee(kownt) = "newline" Then + Exit While + End If + kownt += 1 + End While + + If setokee(kownt - 1) = "clpar" Or setokee(kownt - 1) = "opsymbol" Then + isMane = False + isStork = False + isFunction = True + End If + + End If + + If inArray(setokee(x), dtype, 4) Then + curDtype = setokee(x) + + Dim declCount As Integer = 0 + Dim declCtr As Integer = x + While Not (setokee(declCtr) = ":" Or setokee(declCtr) = "newline") + If setokee(declCtr) = "at" Then + declCount += 1 + End If + declCtr += 1 + End While + + If declCount = 1 Then + While Not (setokee(x) = ":" Or setokee(x) = "newline") + + 'MessageBox.Show("x= " & x & ", " & setokee(x) & ", " & setokee(x + 1) & ", " & setokee(x + 2) & ", " & setokee(x + 3)) + + If setokee(x) = "identifier" And setokee(x + 1) <> "clsquare" And Not (setokee(x) = "identifier" And setokee(x + 1) = "oppar" And setokee(x + 2) = "clpar" And (setokee(x + 3) = "newline" Or setokee(x + 3) = "opsymbol")) Then + If setokee(x + 1) = "assgnOp" Then + valDType = setokee(x + 2).ToString + value = dGridLexi.Items.Item(x + 2).SubItems(2).Text() + If setokee(x - 3) = "let" Then + type = "constant" + Else + type = "variable" + End If + + ElseIf setokee(x + 1) = "opsquare" Then + value = "-" + If curDtype = "newt" Then + valDType = "newtlit" + ElseIf curDtype = "duck" Then + valDType = "ducklit" + ElseIf curDtype = "bull" Then + valDType = "bullLit" + ElseIf curDtype = "starling" Then + valDType = "starlinglit" + End If + If setokee(x + 3) = "opsquare" Or setokee(x + 4) = "opsquare" Then + type = "array2" + Else + type = "array1" + End If + ElseIf setokee(x + 1) = "oppar" Then + Dim lol As Integer = x + 1 + While setokee(lol) <> "newline" + If setokee(lol) = ":" Then + Exit While + End If + lol += 1 + End While + + If Not (setokee(x + 1) = "oppar" And setokee(x + 2) = "clpar" And (setokee(x + 3) = "newline" Or setokee(x + 3) = "opsymbol")) Then + value = "-" + If curDtype = "newt" Then + valDType = "newtlit" + ElseIf curDtype = "duck" Then + valDType = "ducklit" + ElseIf curDtype = "bull" Then + valDType = "bullLit" + ElseIf curDtype = "starling" Then + valDType = "starlinglit" + End If + type = "function" + End If + Else + If Not (setokee(x) = "identifier" And setokee(x + 1) = "oppar" And setokee(x + 2) = "clpar" And (setokee(x + 3) = "newline" Or setokee(x + 3) = "opsymbol")) Then + If curDtype = "newt" Then + value = "0" + valDType = "newtlit" + ElseIf curDtype = "duck" Then + value = "true" + valDType = "bullLit" + ElseIf curDtype = "duck" Then + value = "0.0" + valDType = "ducklit" + ElseIf curDtype = "starling" Then + value = "" + valDType = "starlinglit" + End If + type = "variable" + End If + End If + + Ctr += 1 + objList = dGridIden.Items.Add(Ctr) + objList.SubItems.Add(dGridLexi.Items.Item(x).SubItems(2).Text()) + objList.SubItems.Add(curDtype) + objList.SubItems.Add(value) + objList.SubItems.Add(valDType) + objList.SubItems.Add(type) + objList.SubItems.Add(used) + + If dGridIden.Items.Item(Ctr - 1).SubItems(5).Text() = "array1" Then + If setokee(x + 2) = "newtlit" Then + arraySize = dGridLexi.Items.Item(x + 2).SubItems(2).Text() + arraySize2 = "-" + ElseIf setokee(x + 2) = "identifier" Then + Dim arrID As String = dGridLexi.Items.Item(x + 2).SubItems(2).Text + Dim a As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text = arrID Then + a = index + End If + Next + + Dim val As String = dGridIden.Items.Item(a).SubItems(3).Text + arraySize = val + arraySize2 = "-" + ElseIf setokee(x + 2) = "clsquare" Then + arraySize = "100" + arraySize2 = "-" + End If + ElseIf dGridIden.Items.Item(Ctr - 1).SubItems(5).Text() = "array2" Then + If setokee(x + 2) = "newtlit" Then + arraySize = dGridLexi.Items.Item(x + 2).SubItems(2).Text() + If setokee(x + 5) = "newtlit" Then + arraySize = arraySize + arraySize2 = dGridLexi.Items.Item(x + 5).SubItems(2).Text() + ElseIf setokee(x + 5) = "identifier" Then + Dim arrayID As String = dGridLexi.Items.Item(x + 5).SubItems(2).Text + Dim b As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text = arrayID Then + b = index + End If + Next + Dim value1 As String = dGridIden.Items.Item(b).SubItems(3).Text + arraySize = arraySize + arraySize2 = value1 + ElseIf setokee(x + 5) = "clsquare" Then + arraySize = arraySize + arraySize2 = "10" + End If + ElseIf setokee(x + 2) = "identifier" Then + Dim arrID As String = dGridLexi.Items.Item(x + 2).SubItems(2).Text + Dim a As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text = arrID Then + a = index + End If + Next + + Dim val As String = dGridIden.Items.Item(a).SubItems(3).Text + arraySize = val + + If setokee(x + 5) = "newtlit" Then '[@s][2] + arraySize = arraySize + arraySize2 = dGridLexi.Items.Item(x + 5).SubItems(2).Text() + ElseIf setokee(x + 5) = "identifier" Then '[@s][@a] + Dim arrayID As String = dGridLexi.Items.Item(x + 5).SubItems(2).Text + Dim b As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text = arrayID Then + b = index + End If + Next + Dim value1 As String = dGridIden.Items.Item(b).SubItems(3).Text + arraySize = arraySize + arraySize2 = value1 + ElseIf setokee(x + 5) = "clsquare" Then '[@s][] + arraySize = arraySize + arraySize2 = "10" + End If + + ElseIf setokee(x + 2) = "clsquare" Then + arraySize = "10" + If setokee(x + 4) = "newtlit" Then + arraySize = arraySize + arraySize2 = dGridLexi.Items.Item(x + 4).SubItems(2).Text() + ElseIf setokee(x + 4) = "identifier" Then + Dim arrayID As String = dGridLexi.Items.Item(x + 4).SubItems(2).Text + Dim b As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text = arrayID Then + b = index + End If + Next + Dim value1 As String = dGridIden.Items.Item(b).SubItems(3).Text + arraySize = arraySize + arraySize2 = value1 + ElseIf setokee(x + 4) = "clsquare" Then + arraySize = arraySize + arraySize2 = "10" + End If + End If + Else + arraySize = "-" + arraySize2 = "-" + End If + + objList.SubItems.Add(arraySize) + + + If dGridIden.Items.Item(Ctr - 1).SubItems(5).Text() = "function" Then + Dim paramCtr As Integer = x + Dim paramCount As Integer = 0 + While Not setokee(paramCtr) = "clpar" + If inArray(setokee(paramCtr), dtype, 4) Then + paramCount += 1 + End If + paramCtr += 1 + End While + parameter = paramCount.ToString + Else + parameter = "-" + End If + + objList.SubItems.Add(parameter) + + If isMane = True Then + objList.SubItems.Add("mane") + ElseIf isStork = True Then + Dim kaw As Integer = x + While kaw >= 0 + If setokee(kaw) = "opsymbol" Then + Exit While + Else + kaw -= 1 + End If + End While + If setokee(kaw - 1) = "newline" Then + objList.SubItems.Add(dGridLexi.Items.Item(kaw - 2).SubItems(2).Text) + Else + objList.SubItems.Add(dGridLexi.Items.Item(kaw - 1).SubItems(2).Text) + End If + ElseIf isFunction = True Then + objList.SubItems.Add("subfunction") + Else + objList.SubItems.Add("global") + End If + + objList.SubItems.Add(arraySize2) + End If + x += 1 + End While + ElseIf declCount >= 1 Then + Dim kawnt As Integer = x + While setokee(kawnt) <> "newline" + If setokee(kawnt) = "newline" Then + Exit While + End If + kawnt += 1 + End While + + While setokee(x) <> "," + If setokee(x) = "identifier" And setokee(x + 1) <> "clsquare" And Not (setokee(x) = "identifier" And setokee(x + 1) = "oppar" And (setokee(kawnt - 1) = "clpar" Or setokee(kawnt - 1) = "opsymbol")) Then + If setokee(x + 1) = "assgnOp" Then + valDType = setokee(x + 2).ToString + value = dGridLexi.Items.Item(x + 2).SubItems(2).Text() + If setokee(x - 3) = "let" Then + type = "constant" + Else + type = "variable" + End If + + ElseIf setokee(x + 1) = "opsquare" Then + value = "-" + If curDtype = "newt" Then + valDType = "newtlit" + ElseIf curDtype = "duck" Then + valDType = "ducklit" + ElseIf curDtype = "bull" Then + valDType = "bullLit" + ElseIf curDtype = "starling" Then + valDType = "starlinglit" + End If + If setokee(x + 3) = "opsquare" Or setokee(x + 4) = "opsquare" Then + type = "array2" + Else + type = "array1" + End If + ElseIf setokee(x + 1) = "oppar" Then + Dim lol As Integer = x + 1 + While setokee(lol) <> "newline" + If setokee(lol) = ":" Then + Exit While + End If + lol += 1 + End While + + If Not (setokee(x + 1) = "oppar" And setokee(x + 2) = "clpar" And (setokee(x + 3) = "newline" Or setokee(x + 3) = "opsymbol")) Then + value = "-" + If curDtype = "newt" Then + valDType = "newtlit" + ElseIf curDtype = "duck" Then + valDType = "ducklit" + ElseIf curDtype = "bull" Then + valDType = "bullLit" + ElseIf curDtype = "starling" Then + valDType = "starlinglit" + End If + type = "function" + End If + Else + If Not (setokee(x) = "identifier" And setokee(x + 1) = "oppar" And setokee(x + 2) = "clpar" And (setokee(x + 3) = "newline" Or setokee(x + 3) = "opsymbol")) Then + If curDtype = "newt" Then + value = "0" + valDType = "newtlit" + ElseIf curDtype = "bull" Then + value = "true" + valDType = "bullLit" + ElseIf curDtype = "duck" Then + value = "0.0" + valDType = "ducklit" + ElseIf curDtype = "starling" Then + value = "" + valDType = "starlinglit" + End If + type = "variable" + End If + End If + + Ctr += 1 + objList = dGridIden.Items.Add(Ctr) + objList.SubItems.Add(dGridLexi.Items.Item(x).SubItems(2).Text()) + objList.SubItems.Add(curDtype) + objList.SubItems.Add(value) + objList.SubItems.Add(valDType) + objList.SubItems.Add(type) + objList.SubItems.Add(used) + + If dGridIden.Items.Item(Ctr - 1).SubItems(5).Text() = "array1" Then 'size ng array + If setokee(x + 2) = "newtlit" Then + arraySize = dGridLexi.Items.Item(x + 2).SubItems(2).Text() + arraySize2 = "-" + ElseIf setokee(x + 2) = "identifier" Then + Dim arrID As String = dGridLexi.Items.Item(x + 2).SubItems(2).Text + Dim a As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text = arrID Then + a = index + End If + Next + + Dim val As String = dGridIden.Items.Item(a).SubItems(3).Text + arraySize = val + arraySize2 = "-" + ElseIf setokee(x + 2) = "clsquare" Then + arraySize = "100" + arraySize2 = "-" + End If + ElseIf dGridIden.Items.Item(Ctr - 1).SubItems(5).Text() = "array2" Then + If setokee(x + 2) = "newtlit" Then + arraySize = dGridLexi.Items.Item(x + 2).SubItems(2).Text() + If setokee(x + 5) = "newtlit" Then + arraySize = arraySize + arraySize2 = dGridLexi.Items.Item(x + 5).SubItems(2).Text() + ElseIf setokee(x + 5) = "identifier" Then + Dim arrayID As String = dGridLexi.Items.Item(x + 5).SubItems(2).Text + Dim b As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text = arrayID Then + b = index + End If + Next + Dim value1 As String = dGridIden.Items.Item(b).SubItems(3).Text + arraySize = arraySize + arraySize2 = value1 + ElseIf setokee(x + 5) = "clsquare" Then + arraySize = arraySize + arraySize2 = "10" + End If + ElseIf setokee(x + 2) = "identifier" Then + Dim arrID As String = dGridLexi.Items.Item(x + 2).SubItems(2).Text + Dim a As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text = arrID Then + a = index + End If + Next + + Dim val As String = dGridIden.Items.Item(a).SubItems(3).Text + arraySize = val + + If setokee(x + 5) = "newtlit" Then + arraySize = arraySize + arraySize2 = dGridLexi.Items.Item(x + 5).SubItems(2).Text() + ElseIf setokee(x + 5) = "identifier" Then + Dim arrayID As String = dGridLexi.Items.Item(x + 5).SubItems(2).Text + Dim b As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text = arrayID Then + b = index + End If + Next + Dim value1 As String = dGridIden.Items.Item(b).SubItems(3).Text + arraySize = arraySize + arraySize2 = value1 + ElseIf setokee(x + 5) = "clsquare" Then + arraySize = arraySize + arraySize2 = "10" + End If + + ElseIf setokee(x + 2) = "clsquare" Then + arraySize = "10" + If setokee(x + 4) = "newtlit" Then + arraySize = arraySize + arraySize2 = dGridLexi.Items.Item(x + 4).SubItems(2).Text() + ElseIf setokee(x + 4) = "identifier" Then + Dim arrayID As String = dGridLexi.Items.Item(x + 4).SubItems(2).Text + Dim b As Integer + For index As Integer = 0 To dGridIden.Items.Count - 1 + If dGridIden.Items.Item(index).SubItems(1).Text = arrayID Then + b = index + End If + Next + Dim value1 As String = dGridIden.Items.Item(b).SubItems(3).Text + arraySize = arraySize + arraySize2 = value1 + ElseIf setokee(x + 4) = "clsquare" Then + arraySize = arraySize + arraySize2 = "10" + End If + End If + Else + arraySize = "-" + arraySize2 = "-" + End If + + objList.SubItems.Add(arraySize) + + If dGridIden.Items.Item(Ctr - 1).SubItems(5).Text() = "function" Then + Dim paramCtr As Integer = x + Dim paramCount As Integer = 0 + While Not setokee(paramCtr) = "clpar" + If inArray(setokee(paramCtr), dtype, 4) Then + paramCount += 1 + End If + paramCtr += 1 + End While + parameter = paramCount.ToString + Else + parameter = "-" + End If + + objList.SubItems.Add(parameter) + + If isMane = True Then + objList.SubItems.Add("mane") + ElseIf isStork = True Then + Dim kaw As Integer = x + While kaw >= 0 + If setokee(kaw) = "opsymbol" Then + Exit While + Else + kaw -= 1 + End If + End While + If setokee(kaw - 1) = "newline" Then + objList.SubItems.Add(dGridLexi.Items.Item(kaw - 2).SubItems(2).Text) + Else + objList.SubItems.Add(dGridLexi.Items.Item(kaw - 1).SubItems(2).Text) + End If + + ElseIf isFunction = True Then + objList.SubItems.Add("subfunction") + Else + objList.SubItems.Add("global") + End If + + objList.SubItems.Add(arraySize2) + + End If + x += 1 + End While + End If + End If + + + x += 1 + End While + End Sub + + + + + + + + Public Sub RowCol() + + Dim index As Integer + Dim line As Integer + Dim col As Integer + Dim pt As Point + + ' get the current line + index = Me.rTBCode.SelectionStart + line = Me.rTBCode.GetLineFromCharIndex(index) + 1 + ' get the caret position in pixel coordinates + pt = Me.rTBCode.GetPositionFromCharIndex(index) + ' now get the character index at the start of the line, and subtract from the current index to get the column + pt.X = 0 + col = index - Me.rTBCode.GetCharIndexFromPosition(pt) + 1 + + ' finally, update the display in the status bar, incrementing the line and column values so that the first line & first character position is shown as "1, 1" + 'Me.ToolStripStatusLabel1.Text = "Ln " + (++line).ToString() + ", Col " + (++col).ToString() + + End Sub + + Private Sub rTBCode_SelectionChanged(sender As Object, e As EventArgs) Handles rTBCode.SelectionChanged + RowCol() + End Sub + + Public Function inArray(ByVal input As String, ByVal array() As String, ByVal lim As Integer) + Dim bool As Boolean = True + For x As Integer = 0 To lim + If input = array(x) Then + bool = True + Exit For + Else + bool = False + End If + Next + Return bool + End Function + + Private Sub DrawRichTextBoxLineNumbers(ByRef g As Graphics) + 'Calculate font heigth as the difference in Y coordinate + 'between line 2 and line 1 + 'Note that the RichTextBox text must have at least two lines. + ' So the initial Text property of the RichTextBox + ' should not be an empty string. It could be something + ' like vbcrlf & vbcrlf & vbcrlf + With rTBCode + Dim font_height As Single + font_height = .GetPositionFromCharIndex(.GetFirstCharIndexFromLine(2)).Y _ + - .GetPositionFromCharIndex(.GetFirstCharIndexFromLine(1)).Y + If font_height = 0 Then Exit Sub + + 'Get the first line index and location + Dim first_index As Integer + Dim first_line As Integer + Dim first_line_y As Integer + first_index = .GetCharIndexFromPosition(New _ + Point(0, g.VisibleClipBounds.Y + font_height / 3)) + first_line = .GetLineFromCharIndex(first_index) + first_line_y = .GetPositionFromCharIndex(first_index).Y + + 'Print on the PictureBox the visible line numbers of the RichTextBox + 'g.Clear(Control.DefaultBackColor) + Dim i As Integer = first_line + Dim y As Single + Do While y < g.VisibleClipBounds.Y + g.VisibleClipBounds.Height + y = first_line_y + 2 + font_height * (i - first_line - 1) + g.DrawString((i).ToString, .Font, Brushes.Black, lineNum.Width _ + - g.MeasureString((i).ToString, .Font).Width, y) + i += 1 + Loop + 'Debug.WriteLine("Finished: " & firstLine + 1 & " " & i - 1) + End With + End Sub + + Private Sub r_Resize(ByVal sender As Object, ByVal e As System.EventArgs) _ + Handles rTBCode.Resize + lineNum.Invalidate() + End Sub + + Private Sub r_VScroll(ByVal sender As Object, ByVal e As System.EventArgs) _ + Handles rTBCode.VScroll + lineNum.Invalidate() + End Sub + + Private Sub p_Paint(ByVal sender As Object, + ByVal e As System.Windows.Forms.PaintEventArgs) _ + Handles lineNum.Paint + DrawRichTextBoxLineNumbers(e.Graphics) + End Sub + + Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _ + Handles MyBase.Load + rTBCode.Text = vbCrLf & vbCrLf & vbCrLf + End Sub + + Private Sub rTBCode_TextChanged(sender As Object, e As EventArgs) Handles rTBCode.TextChanged + + End Sub + + Private Sub btnClr_Click(sender As Object, e As EventArgs) Handles btnClr.Click + clear() + End Sub + + Private Sub clear() + rTBCode.Clear() + End Sub + + Private Sub dGridIden_SelectedIndexChanged(sender As Object, e As EventArgs) Handles dGridIden.SelectedIndexChanged + + End Sub +End Class - Private Sub dGridLexi_SelectedIndexChanged(sender As Object, e As EventArgs) Handles dGridLexi.SelectedIndexChanged - End Sub -End Class diff --git a/Zootopia_Compiler/My Project/Application.Designer.vb b/Zootopia_Compiler/My Project/Application.Designer.vb index b0bd106..88dd01c 100644 --- a/Zootopia_Compiler/My Project/Application.Designer.vb +++ b/Zootopia_Compiler/My Project/Application.Designer.vb @@ -11,28 +11,3 @@ Option Strict On Option Explicit On - -Namespace My - - 'NOTE: This file is auto-generated; do not modify it directly. To make changes, - ' or if you encounter build errors in this file, go to the Project Designer - ' (go to Project Properties or double-click the My Project node in - ' Solution Explorer), and make changes on the Application tab. - ' - Partial Friend Class MyApplication - - _ - Public Sub New() - MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows) - Me.IsSingleInstance = false - Me.EnableVisualStyles = true - Me.SaveMySettingsOnExit = true - Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses - End Sub - - _ - Protected Overrides Sub OnCreateMainForm() - Me.MainForm = Global.Zootopia_Compiler.Form1 - End Sub - End Class -End Namespace diff --git a/Zootopia_Compiler/My Project/Resources.Designer.vb b/Zootopia_Compiler/My Project/Resources.Designer.vb index 86efd1b..69b84a5 100644 --- a/Zootopia_Compiler/My Project/Resources.Designer.vb +++ b/Zootopia_Compiler/My Project/Resources.Designer.vb @@ -11,9 +11,10 @@ Option Strict On Option Explicit On +Imports System Namespace My.Resources - + 'This class was auto-generated by the StronglyTypedResourceBuilder 'class via a tool like ResGen or Visual Studio. 'To add or remove a member, edit your .ResX file then rerun ResGen @@ -21,20 +22,20 @@ Namespace My.Resources ''' ''' A strongly-typed resource class, for looking up localized strings, etc. ''' - _ + _ Friend Module Resources - + Private resourceMan As Global.System.Resources.ResourceManager - + Private resourceCulture As Global.System.Globalization.CultureInfo - + ''' ''' Returns the cached ResourceManager instance used by this class. ''' - _ + _ Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager Get If Object.ReferenceEquals(resourceMan, Nothing) Then @@ -44,19 +45,69 @@ Namespace My.Resources Return resourceMan End Get End Property - + ''' ''' Overrides the current thread's CurrentUICulture property for all ''' resource lookups using this strongly typed resource class. ''' - _ + _ Friend Property Culture() As Global.System.Globalization.CultureInfo Get Return resourceCulture End Get - Set(ByVal value As Global.System.Globalization.CultureInfo) + Set resourceCulture = value End Set End Property + + ''' + ''' Looks up a localized resource of type System.Drawing.Bitmap. + ''' + Friend ReadOnly Property analyze() As System.Drawing.Bitmap + Get + Dim obj As Object = ResourceManager.GetObject("analyze", resourceCulture) + Return CType(obj,System.Drawing.Bitmap) + End Get + End Property + + ''' + ''' Looks up a localized resource of type System.Drawing.Bitmap. + ''' + Friend ReadOnly Property analyzer() As System.Drawing.Bitmap + Get + Dim obj As Object = ResourceManager.GetObject("analyzer", resourceCulture) + Return CType(obj,System.Drawing.Bitmap) + End Get + End Property + + ''' + ''' Looks up a localized resource of type System.Drawing.Bitmap. + ''' + Friend ReadOnly Property lexi() As System.Drawing.Bitmap + Get + Dim obj As Object = ResourceManager.GetObject("lexi", resourceCulture) + Return CType(obj,System.Drawing.Bitmap) + End Get + End Property + + ''' + ''' Looks up a localized resource of type System.Drawing.Bitmap. + ''' + Friend ReadOnly Property lexical() As System.Drawing.Bitmap + Get + Dim obj As Object = ResourceManager.GetObject("lexical", resourceCulture) + Return CType(obj,System.Drawing.Bitmap) + End Get + End Property + + ''' + ''' Looks up a localized resource of type System.Drawing.Bitmap. + ''' + Friend ReadOnly Property Zoo_whale() As System.Drawing.Bitmap + Get + Dim obj As Object = ResourceManager.GetObject("Zoo_whale", resourceCulture) + Return CType(obj,System.Drawing.Bitmap) + End Get + End Property End Module End Namespace diff --git a/Zootopia_Compiler/My Project/Resources.resx b/Zootopia_Compiler/My Project/Resources.resx index af7dbeb..2fc4da9 100644 --- a/Zootopia_Compiler/My Project/Resources.resx +++ b/Zootopia_Compiler/My Project/Resources.resx @@ -46,7 +46,7 @@ mimetype: application/x-microsoft.net.object.binary.base64 value : The object must be serialized with - : System.Serialization.Formatters.Binary.BinaryFormatter + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : and then encoded with base64 encoding. mimetype: application/x-microsoft.net.object.soap.base64 @@ -60,6 +60,7 @@ : and then encoded with base64 encoding. --> + @@ -68,9 +69,10 @@ - + + @@ -85,9 +87,10 @@ - + + @@ -109,9 +112,25 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\Zoo_whale.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\analyzer.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\lexical.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\lexi.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\analyze.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/Zootopia_Compiler/My Project/Settings.Designer.vb b/Zootopia_Compiler/My Project/Settings.Designer.vb index 665b9de..682135a 100644 --- a/Zootopia_Compiler/My Project/Settings.Designer.vb +++ b/Zootopia_Compiler/My Project/Settings.Designer.vb @@ -13,42 +13,42 @@ Option Explicit On Namespace My - - _ + + _ Partial Friend NotInheritable Class MySettings Inherits Global.System.Configuration.ApplicationSettingsBase - - Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) - + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) + #Region "My.Settings Auto-Save Functionality" #If _MyType = "WindowsForms" Then - Private Shared addedHandler As Boolean + Private Shared addedHandler As Boolean - Private Shared addedHandlerLockObject As New Object + Private Shared addedHandlerLockObject As New Object - _ - Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) - If My.Application.SaveMySettingsOnExit Then - My.Settings.Save() - End If - End Sub + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub #End If #End Region - + Public Shared ReadOnly Property [Default]() As MySettings Get - + #If _MyType = "WindowsForms" Then - If Not addedHandler Then - SyncLock addedHandlerLockObject - If Not addedHandler Then - AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings - addedHandler = True - End If - End SyncLock - End If + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If #End If Return defaultInstance End Get @@ -57,13 +57,13 @@ Namespace My End Namespace Namespace My - - _ + + _ Friend Module MySettingsProperty - - _ + + _ Friend ReadOnly Property Settings() As Global.Zootopia_Compiler.My.MySettings Get Return Global.Zootopia_Compiler.My.MySettings.Default diff --git a/Zootopia_Compiler/Resources/Zoo_whale.png b/Zootopia_Compiler/Resources/Zoo_whale.png new file mode 100644 index 0000000000000000000000000000000000000000..a499cf5e988f387f9ea547a276375878e1b5ec15 GIT binary patch literal 14928 zcmZu%MO0o*kbSsYaEB1w-QC^Y-JRf0aCetLa1HM68iKn+aQ6=w{xh3d%%V@fSBpN~ zRn=8pw{E18f+P|=9y|a5NYYYbDgXfX`3VNVLVr$rE@c*<6P%NjwkrT2p#L|(fUF!G z0DxDt78O-evT}5DbhUDHB9RsqC2?|bw6L}_2LR92Tvbao)nhFF$IUwt*@(atSw|I2 zSP~VH=s=7_3K~*4RGA3UpDUQkeQ4t1kocno5fE{4fialMbcj*#%P{+-g>fN85mDo> zJ3d9Wi=B^$Q}0bn0!LN1xeYTgy|9RBQmo4Cfr#ZIL}=R~BZI>``wT)s@ZX#ORM-YH zQr9;!FyP6bkB|0iFHAQ8<~fG|3-roo_c9TLf1sR*Wa@zh{s8NBOXQM;4a5M1yyHYl z03ivmz}yT9RiFS8Fq$wm*#ng50VB$Q!#N-@_bJl{4A4y>#RMxz1W3@$Bg6nJUZ845 zBT5|5VgfKMWCyu{WqN=~TGK)bsA~awr%@5=0a!$UNjV~v8i4cxj7G`GJb@pX0EWbk zCf_w}4eAlir=~LN`P#m5iwEh#(mTUwYBCT}O-p0bVsIFP8)peI^m}FEvIMcAY~M}- zKtUqr=V@=>Jg1Rsrl&dLnvo6ZPkNv~zM7cqy&ud}Itc;5j+_7NI~`*KULY@Yp#6Ix z`30nv0Ybs|$7qXs6rm=d;CNN@*6Bapi2qDzTUj~S-(Qv)6wx&v*Ytb0>^JPye6xG@ z=L0?7Z+Gv03u4g^l7xKP?w`DqD<+spg8N~zei$zaYC-q_5zc)bls0M8qQTfx{^A@b zmKAf$Qv5YiB#C;6{O^a^?iSrEguoU%P-i0m=95TYrf&-IAWMm=<<`6V2mm)7j(zh~ zun>V(Av-f3AD4n}k_F^IpoMgjGXNNfePd7?Zx9@T1pu*vAeuU1{JTCJx?X64KB)CR z1dtKO50P(!{UWF$@MeJoE=JTxMb6b-(RZ`D~IvwG^!vvBJWLSetSTE z2@>yxZ2hipjEW+wVSt=W4Kh@CK z<8?%;e>SVsDuOr68C!nS&}uKnlMj<%6Xq>%nc^Y6s5EBN3KVxY;-`IF`5`IJFsaCAf3ZxFc#zoXn>gN0}&@j_O)8%{0E4iR198 zGN}})_%w`aJ_<4r>gj>mgT%<;T4u; zj%tFx{I%aAp|uC(1{6hqDHr@U-0K`BK`_N_@T4QPMXC(@9>hLK@q22;*PW&#vaMOu2A zR;5&>a;4;H7e~!`X>LiEc!&0D5VG)y45c2Wq-FdxRPK@Lit0uwd?}VZKhJ#)LxpWI z{?86Ej~<88i;TQ(gTOpF$I?x&uA>(MKgKt;H~W{;dr3qs=mx}Z&})d(IDA9w&W?P9 zj3aB;%A)!MLZZdSsmAF$KN8z!`HB`KVkJ;wtcUgXzU|o$+Yc8}KvR%X$jYC{Uu3Ds zx0O(r@XGPZjZ95W6;3T?vS;%%FR>hDA7w9PZ?zcdcMVOV{t~lxSZxcRGaX zaBCN9sq5%BNL1%mlP`8uca)-)wkaelROT&O4%A&Yk2ROK;MN^1L$B2|+c*0eTbf{7 zwhYw_TqJiT`?dSUzVX8#g|8r266z58yEeLD@M!RCW=-c@2>K1(r5!U`YR#a|EVJ%4 zqfbx|TIZ@}&q-QhTei7|+(tx4$_7s`qzf=);}36)cJ0f!-8<{=c>lf6&2GrpJdCY&eLXf{WCBsx~+ULD~OPv%4EA$<*z8J7-ZRWM8;^!n5bF3RM%4M zQSoSei7oIT;F7;5u*b)_$+D?!ILX=DGTJhsIN+FP7`i1IK=xtw;r%fSlm?Q6Swchx z2?yzdzdm{UlJ>+2@~oLZ)UTWi#}u>)V+zLyR|g;TRg+qco+VV1J|1OECr(=j3tL`yARXZ?q#O{Qagp4*KSvOe{*{WHu zx+c2qijxAfizl1jAjvgilpHobZ7-QywK40}t(sZ2JcjlsZYO;2$#aS$9XTCYHEnvf zZ5Q5MO+FTn$M|`i(;IhPUe{P3iwk+&{2N`j-j0t$kM~j5^s9tF3v>ynSqp&>KxiTCj+qEPXf@e^T4VW)Xq0^HoY zf-Y~zpiDNBrn*Bx;`zswzf+S_La@e z4%O4VM-(hJz;(Rk`RF}sb3%@g z!4O~$RxFeV3P1n`%JOsJv_{(E(94MLJs9gW-@DPRAYOu?pDPX7x@5GURZ^gY3ZSuo z+x^;OA#Nu8Ih~#rKX?SlHo0 zl8+WmtdNaf3Q~9x0CLY1&;XMSI=IPSghZ`_>ZQNgI`8E$Y5*Or-Jpt+K$1{X!_+_s zkn;Ah_vJ6a>yZaQLGIXZf8S>J!XZTkPxvF3?lYKuaG8utTPN`@GEK?{!$%vysD#Rl zgv09+#0ah%WZDbS|2%>@0<+JtO4FiUV}(Tu=n&4;f*C;a1XAuhcagBAjoUAhw(Q_d z=Z#}TkOtCdL$1TGLt;c6M&PhIg@6{I_)tK|))vAfUx5Xj;XEKutfCHmFf7w0J3nD7NSrMaHBieK>H;b&a3pcu0qXjvnm>&E z4e#$L3N-KnjJ946GgBY6AI}x|M11g#kwaQCU1lFn_H_OEFpFMuU)1CN9-TAh$c|z#f2}!%1)Npa<%ttz#lF z;WX4h=i#^+fLH0LURT&nD^Se>Bv+4u@B_%%q2ONc5oZ(s>l6)|cKiaK(3t|x2oWG+ z7M+|3{=Cs6^JUTHTL-Wnm4c%~1|m6bQ)mv=4F$f9XnoA|I-<>a2eWFKXFs{t??Wdk z11Ev;f%u_a2*W!PD-tI^fN#jq+oap{zwBEfgKw1?*2YD@T@gW!eFfU2r1M}<@nv8s zmaO>zP%b3>n*ubLR$!w$2)#cK%Gf2toN&bbBROAp$MP&SU8b1bgRl)WGFBg5|*FBl!ZNdb8{*bnpT?+5Ipq+Gj|cfhaYePBGX(7P^F7LyRZb z`6%(`Stt>paKaAl0fCK!AcG!~ghy>0iROzxc(oGAnq4t!;OJ;7zDiCHQvbXZZxJ#B@H}0jFSsFnl9>{myJE;TFe z)NeSwjBmQNYooS=Lx~37C3uB;O>n)Of%rdG;C3VDY`42Ed<9zeOawY^zw!{I#pfD| zjAWO>7hNlJj&cxl#?aV2l1qg%!9p@0WNeHF1<@hjSu_MNh48;=vn|gEg7b5w#Ld)- z*4|3KT%&+FLJ)sz0JIX_b=eVIF$SYFd7?abt&lG74|nhIgpOc(7=CT>v*!eF*pkfs zi@f8QtUqUjJ{zL};-j2GpbNKU0pvchy%uiw{ydvW*JX47!{W}ty06ct-&E5J^32X``FJQ0K#u569df-^$1 zC@Y_e=&?H!iP4U)#P|c>*_jR4FdV_2s7<_TNhI93RG%;2SCZlHXL$YN_`tZ*z*i`f zM1Y#Febd_LW!a^=6UVVC%MOdLRLzLA&e<)a-HCs|jiB;SDX1gJ11_n8%G}=lOS1G+ zig{Ao7bqi@$?ZBJw@C+I{Dl#5Z*aJoGq8#)kF|6c#iIHu=g&316lG<2%0Vyy7ibh- z9PaUnH9Kkw9g}YH8OQF$e~vhq_nBGF=JsxmuV268+zU*43u+W)(-mcRVqilZqQR@^ zVU!>z+q+Qu>fU$A+Z~VXLFh8X#EX9oENS=bUE$UF6q#Od zTW~&3a@E|KZbI-OoXN9+JrNm6Sy(!{|56sr=*#OS__V6?dZtA7T=10nFq(z?YSm++ zsS7Lnl<@Z#)Z6+O?axI!C&9+&2;gQNN+nf1K~HXZ_B5qq%>IrBHqJNYyT})1Tw}XA z20&OBG@r8c`}6Yw$WN|`E7e~wY0?MCm<ehc4k&(Bc7I== zUSdr7xGM7~Bzasp3_>|Y(4KanUfUdpXSD=gD1(;z-_KJS%O!xx-aa$j*L))Bo$5JN z&!(b`$Mzd*LX8n-=%!=$8rt*i;lCOTV@>7Vgo?}6>j6d#GfkmA#AoZ1{(oZ)+?V_F zOc5ZeMw!>pODkjjt^37C&F|Tun;r=EO~>gFoLTfPHj7c#72x=W93to&c32RIE!T z88u+L&1hc?dN6~^Zojz}x2&PIP%Bx}Hgrz9$CQ_oCX9PN>RC#jn2DPnJYPz*bvJg+ zTv<$(OrLy4w;_GDpXk1e>38C&XdB@D|ze$5^+I}^h}=zI_4vNl zaiiVj1trL<9J-dR$1cZ^pErV6(g4bx@ak%iN}ORj_61dxiL)ceFl!Re*6@n+>#B!N58(kwsn>3v4DR_8TxJ|{B@G68<@$dP!>hL^Vkf`2nH zFHPwO_g5{lEi9}HXz5bh9g?>HT(jrj;p@$|RGI*sM!tuSI?nJ34*lWi^If(Zqt6In z`CO99=T%5^veZqrG<>M;=ql-z{0-a~Hc0u%(qBWc5<$^9u@j2~BW|S{G?5qGcm;n! zDsyU`k_Fv~cFbjV9{XtDR<+?yO*lZ^KPS3fa{}$pbqO59)5UIhwkM3l&tF-15Gia8 zKKKg{ljPG`AF-O#>m_hsU8ijX*w7rs@gq3@sK@(*f?{xm_Mz-5cP{_Iz5NUqK%?*- zxP+K!vY4!O!*HFLj>b_6z$v3iJG{RNAL1=&{2SOfUWYt+h+0 z@Z_yzuBIZU%XykP8_!>LS4DMWhuDYFpE_X+x?tX=I*5!c#4?)bOFIlKdDiz?~rQR?cn}DQUg_YLIxpYauq| zU76uUhn)F1V+Uq886{Aj9k2V9VS)OeO^521dfQR3 zZ(|``_q>U_VJ*Cnku0usvTbNZ9phSn6bRWSqZq>tH(Y+QuY1I~|BPBRPJB|eWxI0I#hu{PA70ZRUqI;eZqIn9+V^jl zR9Pncoj^6LevKM?i+JpcuD_EIohcf^7LJ`lj;pO#Q#f=gke-}H6LH4J$)u=YXaVV*9 zm};9%%6bLZz{$K#g68}Es4L>$qi|!+nAX07#Gc2&51}|`oI9N77fI~8v)oirQ`fgD z+s>uj5hR$yJt1s$e5>y|RvubkM1Yt`I)ITabqBKs#ep$R4L!fRHEO~VBQe>cq-mxv zO!ORdE<`KPf-QHFGx}U7nBBC-Xl(C~y_M&a5K2m5eF5XYq1D$#JT+1yw6ODO=&>NV zp=P1EC_qkf$o6AHfS)m1->>hy*hU6=W=nZw*ZSG=Z7KcKX2q>4nKyrJc(z$UO4&N} zm*GhC22^Kzc^vx?VHK^Tg}5;GiYYSFxksjFM`c1jVP;>4A9oa%AE8IFQyY(NrO?9^ zbTO3B!jK@$IW7U7LT)G86X+&g5k7uIVw6XyG`ahZhpDW!x%X(qj_vBMns(axJ-#Cv zR~&RMt69H0+cP(N1QZE3eciq}_54|#g1st3-N2=tWNWIE1<^&ULvU=@av%d|=oUrk zr-)oqxdKWb76Guz+n_e>X#23oTW5|SS`=SYYbnX6TvpJG?RxzA1Ra1m}+tS1qaSd=DO2n5V|`Ukln|jZ)nOgmICFDXBb@Je~Z_^Ev0`Jfih$Nj@VM zr-k+M^~ToVg$5a_iA-NE%lT94@kXT->zxYiq-5?5gNK&;8*e}ST0*P6kYR=^&tAKf zFofU31*LqH^uLJN@$Y?YF4W#D+a$BWQBBqS-3R%Kp$c-Cu!shu+$Hgo_fklMZ3JzLMqkYwXP5-)AQorVk@$^!w9ZYYrOH<$tcHvyzHq01~&z+_vn?`=v^gb7J^YwJc zwe)zi)7nHAoBh-j4rj%EnyZn34&NYsdpZqY4YgD>`Ej7x0!(VC05l7r{VCCMoIls6 z-zT13^s7%UE^o5FZnj&pKN|MHMoTlM9?%5M3aR=KZ*6%R^%HNbS?o3W(W~^Up#FuG ztyTTr$i{CCwSAWmY3Tc|;?UKq)AVS?^3Urj8DZIFt4U9wR4ocR1-3^u*7wqp_}-qJsAxs zk~{}jl7T&f4s+#et%(01y3WScd17^Gh-R}?b0j+6MwoFpFta2U(Nap2 zwWx?3CgQ!X=CBr`J$$F+jG_Ivdp@zL`f9&ee^X308waQnzT+cVu+Sf8u~pDoVl^C} z=5J?(&h10~WUNR8$|*k8+!;`oyClFT?H7%N2)zR`R!ZTi3SG$pZGQe@1^jQrbJ>E|Lbl>D&9!Du9 z+?V~{091wZ1k?6~+lC zqx`URGxN>-eanIv|FNlz?DYI0ctr9z1<}DkZ|r=+LP-}VGmhwzXkQW^`Ksd_DTYfg zk&zvFIYtV=B~ns}3ce!3%k zHA6XRz!F>iY6XF|wSbMXYQjK8yO%umFQQWZfVgdb$lQZ5bdJNF_o$+xu})3u-?PRB z7x)(b2He^u6bj}JCZZ)Qip4y*oqa$p|Glwoa^68pen~3oVKZU`!GW=)5u+wozu%G} zg@b`!sSf06smghpw>i0^k)0xk0ZG2`Z)bGDQK=&K`zL)uquVUT9kRgNWs;$!gr|`j zaFGvMJKa0@RJYfoH2iHXjs{n4jRgK0Eh))Z-2(ad!Kn|YMO@ADEXWbs;AsZ{g#Eq7+es8F`*F2U5 zGdpi=6&vdz>iCayGKYtz`Q@qiA#g z@S3axu*f?IsJp=5)5D`$g$7jf{7gj>GNk}G=$m?vXz+#%yo0a21B$X46$NV!B^JycxNoY2S8;FU1qdZk!(1ZcV zq78p3jY{6n7H3gH<=M*j2&600J&m6&{{gt!RAYVumg_2u->P&_zi28P@46OGMP5AYL{+qEo;*no3hcZZb*9QybOVbPLv{dy>&^k&uxszA81`lk2J6a$~X0R1}{IBrP#2yJ`=$#1N9b}DM%UdKL_ z+8UWCOEsPf@e5#dcNGd!T^D$jD&*JhN&>GloS<*;e___Zet_LmbiWg*8NE2Nl=Yz4 zojb<{XF}%LwnT7GObq1hgcb34A7_KK9N3z3BF{bns8S_vM)%(~GRklGxWfhi^6 z=FbvK^v-okBAyu%`Sj!M2bVta7#ylk)256E9Vp_o)IE5bGUsa~6OJ#);@yCO!BKu* z5^;s|)2@I&cTpZqG6JFqWKz)Nyz#r1Pl954%eNcTVKKm+QbZQh9O>$A*H5dHhnYPC zG9_a}O#N6z2+&L}V@uEIaG)qF(ED`}{u^I742u?M`atht`hf3yXOw}ah(kP4 zy`zK+fgHqN?>+G9mbA6fqM_8_XXCG#V3-dJ27-wuxSbWV)0fU;*)WfV^vNoBr?{RPyM zrqTIGfbMgW2^!E#Q4KHDKo(0(TybzjNh>a2@Y$;k!6hJ=+@1|P-p|mdn?Bh~;=`A% z_tDN+lPwoVUkkC%nnaPL0UT}5$vt9!UELP3dKQ)kJEU_F$)e^Mq-VzJt1d6ILj}?$ zXSd;oRE?e*tM6DdOr2_+zJE!+8IuYJ079X}Rl~B++Swx(lh36wOd?#J4hmIFEcSas zK+fv8<%CXVE_XrJJ5q+rVvigXWQ4?`?7ea?tvxy2R%6n=55q5KDXtz8m$+3{&wp2R zSY58%oR0c3emykP6B}GBh7n;vXUSr^+hAVb6tUi-Q*asU8S~A^w24Ni z=E$(B>aHJe?T{#7AZbns?eoUdttuEz?r1notXmQlA`CgcyYvb8KJA8M4=ZDoRDZq+#xv->tyb0kv~H)r zj`q=vylX-sb|oxS5tHYWhO-_vcIZLK?3civVIQ2UJu-G*hmoNi_v}>Jo3RNgL&GQ1 z0K@K3T-=cUt39E-vEp{0_JBpS?s_9bzJZUPVO1b2a&I*-{~~|NFZ__|m6S(t1)7o3 zpguP`O2OGn7+d#*!&!5|Ing8n?Y05h)9aYyLI0VeMNxG`m=WsGI8VPmIoy&c&f{r| zKoJb^6fjWy7&xR+YK`k*`<|hh=CBvluWD)FKMvcY)tcTzzcpEyW3clRKGFW}Di(KS zx$}l_F{M#8>u|q(sKfJpmvDZN8NTD^uh_@a&At5bU4J!+Tg5N9!WsGWpGUUm zi5XOnP1XLWQP}Qdip`aazB7zrj(ZYqltTH>%+6l6VO}V!V37hVc%WCew?eC>cX$rU z*ZsBlt}S+!T__~nr-bFE-zCU`P*W}8@RU6@PnhVP% zHFv{wKc3#4Z;LOry332JE3Ay?4K(Thd26y}QrKA~_17Z0ko1@@K8Cdb2k3Xycnz*U z`BM=04Nta`%ui(asg{}RzWzGshUIo<78&MwBjHtiD_UcYiVDe#1W)26Mqg!A!rR(D zi-{6;W?otlJ!Sk#b>~*@Oj;h_CmQeULY13`y5wh;wT@AWteSaYaa1729CW0Ny%~{|xgyNNdX1})KK?&LK zXX;nwt`4u3+uwD_cYeZ|0fOqIX&1h6tJR+D8C;XB9U0loqc_0}H4J=1Lv0+@F{Mp7 z?~*ZJM1cewusE>PU4D6@7R4E~j?~;{g66fG<(2FSWgi|Z*lIXCXZaTSGpB5M*gCb0@cUMm0ku!fmZD57YOkSAz?A_V0oc)R*5?BQN zpsMatrU3`)zRJT{L_T8rfrR2|Llwe9-AhB8(O9bouy}H?+Vw5$7+6Dy$dKdFN|ypB zN=MF@b{rVX4N@Efn-IY^#Ce@;o>)9yD%N1nk6mBLNhAgBZ zN$29(?y*<-zUO=e_VGdFS4h{>DaWa|Q)K(uk{Q_>lz88~p43ODiNR&^e_SV9ZB_{- z>@S<=i_n7qA(sRL4Jppvj0irLl#!q&ehIoB=D+cVjQsQDR#Xy{B ztK0PZyEWqT{=28=Qux?IeX=-HREJIK1n+YbsC>6sae*zJZ%wNHnG*Pd=q zKg2G!jqO(80#8szYWR4w`%M`CDPoK_@w!m_GIp%X%!Tj7(isM=h;jH2{Rq!%%tq_( z-+oSo8N1%i7J7VUtj6)G`l*QPyHG9vkw94+ZL2VhceNAJf@!+H;MGDmX)6`Y3IlqR z_Cot;ZL%_bq&d|zG3v3E8&luPkABI^A=B?;OF{amTc&CvC4M1y><`77)d*WkM}iog zM~I*g@(;rHJs8)LK&x2fxkrA_2TREQm-(;O5zH^Q;H3Bel=#&wl`8Zl1fxg%4{`gu zrakA^*`J$d%F^<>o`-+{XH#xU~AUfaP;~7fuz5Bx=bRRID&5TZF z+7*T(?(50SSLA)kaRI-J?=}}%zAh{zQKpwY2aHbMmGcg1BGjBr584Q6;<^A)vLE>l zB(N>K4Q=vUkIU!`z5IO{n;2&c8i6$g*Ss#BSSo?N$J5~wr*-k)43##2H*D;8*m(Vu z;*Mr1WR3@184cNwCH#;%n-qui+pe_-q$JnrfPZI4D2J0jVSBX%ytmK9@^9xeE%E%e zW^>`~Q~bo7@0`B?yiVyfBA}b5qlbbZv)ScqmpbNWPYEJAZMWUbh7bBbAu!%MzZLfR zFmDgt>^r)owxlvE48)Si7M-F2ZaV{k+)>!CT*tMx&6|We(9m}KUHuW!>zGbd}I=PNp z3A_9Ek7@ z(QChCnHJflG*-0aVkXZ%1*5PXUq~0&y#o^Phc9%AC%+{-a`7Yja(c3$dgI)NS6&0P znU9Eh)iJgQSG&5(Q!YN6q3K3vK1woQ;;PAT z_!#6P!;(V&ZFo>z^B7#KaH&QnkI=4l^JhW<+YsBv+q_YFeuvm0J(EIjPhybh5l&Hp z!xpa)q-9+@cBXkQ$NP&&F&=)!tSd4t6P|_WWql~=4@iBM1|~Bh_2(l{{3p9;DP?{& zZM07l7aQ2V@1A_3C>%2aE6fke$JKMXA@RAfi?@oQP-M%E`F|ssir2))^oBg)wv2*V zy$QwYR?@CK<(r>djm7+YiL9%I+-|`3Fkj?2j$u@!|NSc;m@TgSc{fj9Ig`6-^E{DB zWNjyHYm`Ns0!yyNZtxnm{H-;`4x1dVQBjC%gaRD`N~152^hUh|slIvyvkM-ofLLqd zIgT$+uJ((aFSf#8MkA)awC=Ea?<(K(w(l^etP6dGiCG;KHUAng^0K$CmQDA>ep_J| zlLevANX2bl54X7&PO=!5+U>nvyK}Hh03?Lotwc|vV$+7K3QgC?)t2M(A@Zb9(OBT7 z$2IhSXX25aSu1vSDQD=G;lB0pxgUQFQ&fU?O=yK*u7aNnV?C->C)dng4`+gt%Kl8D zLTtu?-5zB$7Z!jG;E2+>65NOHkMLvs9r{ocvF zv+Vt)5PiI9rbUFAiGk23*T@!X`Y7f%LoghlY8_s*Rio_gmEW#DcO5 zv(FF+W+K%ow*JZ|LlXl0&X?Sq?poKqUNT>Tk`|6A*o$TvR?QpiCSbub2pG7H>r*2w zpvRYFOz&r1w@f)Z2~N3w#wEutHpF__U62^{7Jcw5+2Ad=vJhCpi$MhG`+%?92pN3M z5f|9*?8V-L z6bNx^Efgw%6im05yPf;<0_iVpD8A|`JP!|BxYAZdIb8Y(3kI8Cy3efBP^T~agKeVu zPVFmyiU6F!x`PpEo$_)Wi5$l`Ma#y??dJfONd^S*ChTFtpX=s4ymXQS`F z686`9v5svPauNVPeIib=ham+b`zVZ%ow*{E3vl0Q)<#Rj0+jrcy0?2*AWkFaGVQ?C zP15Z}Fnt~nz?AYz&58r`m;L|Vw%Z{nlFx~r4*8VgQjgtw4Z53-Nu`4>YDwWrqeDL_ zt=t7zo*Hc8DqXkSW&aA0NrCGj=ql0i_Y2Ia#JaQ8E$6?IexDr22DtJoQ+|_%L^1TI z`#fXjHY|Odshk_)FvGbQV@WfU+oiml-ug5X2Qc zT<0$~XwL%dHSG?O^VsW2NG<=*i zu#gYI8l-C`oWYQFNQY+@9)Ojohz6ceKp>n|^1`76R|QrBt^tb1X3>g6$=)h$q{j|~l>~Kz)KH1mbcKpDF1w)mJyW+8QRH}#7V))=j(JJ_D zxf<=}u<5XJ?Ge312PuTg(-FcYFNAnF_Wa|kHV&e5yJYRzzucQEiw~+&?9T-Tg)jh@ zgPeXl?sO&U4_zTP30HwWSgyO}8AxlQZe`?y(}PR#t`LdY=QsaZcyQsQukbjQ@P)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z000WSNkl}B8Y)@}0ThV} z_)?%kLP7!wA;>o*#HXSJQ5r%~TGR^Brl}xMwUEl8r1dLy98WxB&x~h0k308$?m1^K zKHNLwI}ZoWmwS)4_TK;XU;p(wa`x;Q1q85;-<`+I1W3amq)_N(diwYSQJQ{OT=19| zcNo=)Bu)Da2%Rg5_qPMM;eB$BB>H}%Qar!5xoVYK1yyk(df+|VkDNVw#sPW|An#LC z(R6TdEHg8G|I@`d`h0?XL`1UQ49qa^TL+1>Hj03>-qmPko%_!`{%^N7SN>^vWuew+ zHk>-Ag6!Db3CJBidRRLFwpqdZG#MM7wBga2Pq?0;FE>=bm>S2x0`n;(DJp`?X3!u& z0n!uPBwNTMcQ!Ha5!IFI=TX`87X zhPJ6eMdPD~@0)bJqyM~Kub!|hBS)qoNf3cb z9CEm~%;!&C;3HGZY}DeDLHE$hvr|U~F-x|^t*vPCzPr$4eIql^6&ukLg3+lrO+D$% z1W}-j-dZO}QoPfh5NV_#6S*S4bNm%PGxIv1*4H`Nc!$!=6ltzNC2}0=+agfUYjd;2 z-T_A4{3G3iQ-3kgH-z`80klMI-sigef39Zw1$^8AMldrZlc7E`Kw+y&wie@^?&OEa zhvZ$8PmRC9bk{NiVU@}39bD6MzHp40=?tIMH#sp{=J^XJsl)+&*(O=%!5g)}Jv%fq z^{rxgW=I3m|}RCq4DP^=?AsLr(Y4@ww?AaIG@QKiv8dr6f;A5<>NO zgS;gC;PwPpu0Kv)GIWPcLyJT-igZ?Bx<)zyax@N~JTwZ{Na%qc+k{>D@Mq%=!T zo2b~`f@q#NnF>OJZWO%3mq^{D~YrUuDfy+OFTfp@xFGwn`bcZ<`) z<(-=i63L7=l7y#b7J2f}65n4O=ezTVh*RZbv$y!YQx|BYjyv@{|M-(5^tlT}_s_C) zc$9oCBCJF-yr3CJ(w`%VWAZ<~N_cw>-zgsUq!V@vT!7SUFz5+teb1h_Mj=S~()p7t zl)LE)WAXufcYd1wT*T?IHNJf5K4PzAeME5nZPK1Ds_#EcezJ#;X_52IfLoX6>0Vt! z5`Im2>t~Y6JxrPjrI8^{KRm`CPDEU~ zxy5s@trI$>)gBxKM(zPd+Br{Fg0Eb8pmc3LJ6Z@mB6fgP)=G*UYi59RWNHoOlMLlM ziyRM{9O@0YSuw(WV77rA%nTUTYV0DtUCu2R!jwHa+u5W-o0&c9?ZXzyamg3R7D65# zQ{wdhA>e&3Y(0VKre-CbH`(3VcCv`C!1|ULmpf67YW3 zRFs_Bk2Ju(hxdtbZ}fW)^k&R-#f%RRGC>pHmZUd0b69xhgxggn-jkWO@6D$c)vN!i z8|#agLh(PeHobDdbkgZU1G++CI@_e$h-qj*jueN-fVc@$UBY0t#nQoGb^|pa@7$XU zi*Nt8maFA7scgLvxZuD9wpUMPLQajL{%&mTCSCO+8M!-Ur3O7281I6_9|T7Bv8JK~ zY5Wz;M`{?wjis+SpIqcUBBIka6=>EhqmNsjRt<^uygyGJycl)8;)+OE;E+|921@=tzOvxQEf$>xN>pzo6@NLjfi{Cun!d$O9?BLgnTwbS6pRDa(vH* z2xwLI)EkrCLRScOfEIVoRwZZg%S(&zyrix*H7Fpes$1ov+`e_?_nnW=v1gj>v`z#X z-cd`8ARFM+AsEH>h$pnPGn|L9f)M+AB}66f+{Nm~@)zPX^(yK*=Q49Ha9gF#t>W#u zU&;mUvZx+Nbz72rb0NpIEyqJ)jnsp0*D14B$C+2p(H>6}r~8YjDB_d3jpggVcyoDS zwLSgpAEljhu2HXU#P!lEJ-tJZdvTL?fU=#!QrYvv^?;?(X`(=R(pGq%RY}z$&Y{@? zBf|q+EN3ZK8*M!qqK-lkT-aK@@$~A-{8bSRJ4fkVfZD2e)mnKysaL+y-#0W&kU5pM zr;Scs1y1ov!s`4TK0Z0fuYB}F_(LB=ray>IpCTQ9i2kYjd4GQwmoL6WRRS_$NXExs z-CUmg)y>V7`8F8a`}Jd=RKg$=lqTu${n5p8 zqV@ty~m*VubR~F0XHk!>SBZlfu8|m+L=l>1>+c{R5 TO#9f|00000NkvXXu0mjfx6+_A literal 0 HcmV?d00001 diff --git a/Zootopia_Compiler/Resources/analyzer.png b/Zootopia_Compiler/Resources/analyzer.png new file mode 100644 index 0000000000000000000000000000000000000000..4153f31731c2cb28198eea8c4ec47583a7c0b1a9 GIT binary patch literal 10098 zcmc(EcQl;Qx9Er@1_>sFL^ni>-up14h9O#r5=69!-ibaKC3+B}M(@2v&1eatM(+%w z2Vrz?^1JV?_wK#F`|e$Lt+(DEdwu8I=Y0E|UC-Y83xBSzbf1Wt2mk=wS5cPN!abJ( z0Q?BxUEIjdTGS8sAaqoI=>h=oF#iQS&pe1b06?T+1A{$(ZtdXe;9~9I$fyE?F*-Us zSlYa^002B^(zUI0v^OcGu?v5os>pyuRR^tyKt?TSWB^4RD<=~n*)t?l_Vh!|uOJ15 z+ce*@koeKj0Z|V%x$Z>}O%Y(2K1T=VAS3!NmVI(;Ct9%UKd$R0Wj0EW(rbnYI)L|* zlm#_~1MU?;=|M}uy6w8PeynF2)qv0I5AaV00ltSI~tk~kX6JBNKawa24vj^nD(2$UIjeo2AHz> zua5x&(oaA6-~kL1nI7V0#Q_+}Es*j6Ye_)q(2EEKfIc69!cw(M95BTV;8W4FR0dQw z06GTAh^qm>djLL7WC#b~whzGc8#A*f0PzVxp?Ih#b?~&DY=aXgsZZ5XO)TOHfrdbC zCjvb^9(wjc6{@EcB4)SDQe}D2UY{Nd1PYNZ9Sr~gS#b|>+#X$d4w94)4vIwAlbCRC zwcot~zka=Xy*5Y>t1T%0{N|+OdKK01lfSzW!tf;s;m_e`UvYr3}ELGy2 z0DxEWEIc}WHIQB)03e?g$XO{z^XKa$u8zC3U+>I)CB8HjK|oo$&`>fc(VGBTXH$;S zASiq2k4idDQ{JDlbV41P)}aZGBs^%{MiOa9(sMIl##i>1K*HN{-+<(1OfyKl*Ae>6 z(LkzCA*W1Vm2W?YWMTY{q|gMb#tAF)YencV>MGM6N;}^Y4>MBy5-0f$AP{sJ+M>jt z7+9?-{qtTOtf^3x8lm`^c=(Mge`*Y67HZhJmRdSWBzt4H#F}&_Mh4c)*YWESfne7= zKAxUVXq6ZjVS;&o6}a?XNe^}9i&FgN@MH6#Dv#R_0u?$4MQ(dQ8O`YBl=ap0)u)sT z8EILBKr@7*g!l+eG#fafP_>rz3+Sxt(Q5(zFnwh%=7|R}g%$rcUf*2YM)1e_z`fFLI z+*9opcCEg*&mOOltqHB&wMY?=)6GfMnlH@O0SU(#K+Cf0wJJ2j3dx1sQpJA+Q>v)u zm3{s=Mr}=HjkT%x<@yCQ|B+rjd020>e^cpK@-O^99{28tJ`C}0 zvf9$aNNoPN#*>T5_I^pITcB_kYt@hG_wJm{DOYsOkUR*~}Eg7o}Wh31zR zfh2Oh&)AIEl&oR~@1$>NPixN?5EW3ur6rEbd5UfGXtJB-J=*OH_EIw1UIk>RITS2- zwQii#`tn}sT-lu$94p<^zgu&UkkIz3QJ_)0w z`6mT7P#dU8)MA6Ffu{jiePMm0g-SKXAphlFeT#jFf%wZjeO&|N8pX2ovL_SGWz7Yk zf+qC@^^%MUtIo=U`tS8c4Ua3=rtZ#`*W11ZL}Ik)3|`*h0cW^g(F126qYg73C9v88uj zaud}<^MC0WuupOlR9ji-S+@TO?-Nfd$$0u>cc7+kHdZukKl5hy0s6sme0^T1svb9; z{(5WaTk&csC$Cwe)rWVUhQ7F4D%BWK&uKTVQL?L-T<+J(>J7IIeD$?2=xZIG?KZJ4 z(OQV__T1#Iv4%eH%f&jg^U!n}nTO#K*ejXuZL_*~y6|z!af=I;iyADXJiK`G zH0i?5xJ=#7X}1@D6#t5VnWTQQ>E}4zsI-n&%*4}eC6Zo-w(InL5AORS_jNy{^{g;E z%6nlpv4o3Q`uh?y?omFa%LHQ#?sQgkylS&K%C$sgHWxoOyZ*f_-SdTwfe z&i`$PN7m8EoD%kKNbt~g+;I#k>`u(5nEufFq1zc^GUDPZ5a+AS%L3TYn<3T=s_W0! z{pD1Yynd(S+mnMMDI?j*hsg=;cJK49wmP;SSIqXHd+6J~dkXTu`t#yq_p8U82i<eE^dGm=i30izds8VcLhy-%-sqQIDof%wuGmbNgN$#(q{8B376 z+aE(VFCWa}hFiQBZHG8J+qQ{){1#)+EZ+MHHkIpA|K+Ine-zO?DQsuvS&J7I#Yd?8 z0!1hurE}_*{7qL(5b%z^yZ0B+=gmSuf3v!qaBNXgT%}Wjj$Xp=Q>0imhx}BoW-;uD zO{6>F0_i6gUa8s7QehWb;hnq{bZ3X0eop8+73%ACc3fpz9sD=!B1{$aRoPSdNR0ZN z7SemaQxT27NBp`uymE>Cm+8RKz)E5Wkkr(Syv2Ia(NYlk`$^B{wKIipiV7o|3SQv( zNl<&#p=R&bSU#N>gI<$ihGW9kji=$_&7uKfi2vE)BDCU)e_S}_0^c99o!E47^BGn{bb*i-;1Jq3 zWuw>eNBt6h^42VBpJ>dmPWa_Og_K+g=SJQ?(&fGb;M|=fI`^XJZ(y|CET!L7dWwDn}&HCPS zAdx-eVug6cV@QRzH1R&mctYZJG#efhI{2~l!M?_}rbApWgV~9Xv_!P;0P?p*n@F8h zk-1ObOX=4N^{P^55WCXY& zSJCZ9)z@t&$6QM%Lv{phCiEj=Y{%*e?`@X$aTYo!^#GHf(MOLeIrnM4%Ah*t%C>3m zf_8#02SIPNV;)8B)4HASN$g5>X(OaFqw9r3BmYM?{K1FhIwCxedZGw%KIgXjrWoc7DX;oo6nz$ zFWf1U*PklS$WZtBjq(FwpOGx^^IkU>!7jzW7wGg~1p^C zx$`b_YJ++sv&5uApk<8|WOgv(?6IGT6(P*eVT8&e{%f%Ggv(1zEkUOwVaSdMG#afL z|8g&5lF~n4gZ{2_YS^Gm&MyS#md@gf3ZkHh#MQaaz)j!=rGhenSOYs$Vg*Nn zlVlDV``MnsQm}zTUU`~hYqzPp>IW0FPh9md^Y5w%mnB7nYsYSoHj<2t>7Rll8PB_0 z^7<1(-<42!prksrL)Pyf;eo*Z>3oCH>x6%d*j}=ndBoeI@Igr~8E^Sn32<^-)^tk6 zi00s!vDNMMw9#fnJJ%PH%!qx&nVli)*%NgOM)YTq8fW-QcxjI69Y^44+X zgdr$uBeyjal-annjs3TDLV+CChA|Q4kcUinc5#?RK>muMLLcz$N6B;qw^^cXl#oHSG!kiJY)e}{TxO3Q3soEf8)%AOF=H!)~ zX2m`-;gq| zE;xpmOq!LyqXvzZTU>1v({q5BXc-7B|4;wQ3dnpH^a8#O={=sDeCOg3^xk|dJeEPQ zC>Zs#DxGd=zooo$ZtlXxK^vR-)RM$JZEI!2Ccc5YZO?*kRpN(9Wi(Jyvel@Tc40Ee zXj~2#)Vms_hJ}uX=MEUrIhpR|lGKYZy`qen+Jh=Lls3hpLmUPoO~|M6itS7*2Fc8j z8CN-^Sd`>1wtawg{Iu0EGT6(3mQjZcxp;(mWg1UjR2wps054u^?Q77D89aqjm{sIw zp_m`zF%Ub^vYktI27c62XIwxCv=#0#+aU*ow#gcRYXXy=l>=(Lo!T^P_q9zpc$%dHr?EL zJ^l5#TiVMQLIhsT&&}QQrHM)?O-K_yrPeE=Jn*$gj$rGb+p=+^&7 z2m;#O`j@D8Z$d*vPID}%q7`0^1tA@OwNbp^?LSWrAcHG$V1&NUSduYWe0X;Yq%|?Y ziW_1HsYHT-9IF!F2XHfMT=6^a?t-*>HpDnNp*sX%boL&>;3}pC$YJ@ofJI(;o;72LeUs5J8iS<)1P6J z#diXuckyo8(m4u&cw?IXR-?b_v!%!^<1LflFBZ%l=fnLRn)RuxoM4Ub>~wAz(}gZ2 z+F7P)r?KuI-*AzSjU*e?l9_55i%Gvd^Faw;wzjI*$x?vdJ0a}Y5AY=&Y`#PSeL!aM zEe;1^?rE6PJP-u6pSY&gCogK~US7K6s>J3+fIBZ_+KN)Sw=62wRALeyWUX%qsQc}5|Mf=<& z13w_(Q@I8)H9tl?<~lWh*8p$`>bx&qJ8r5K9&w#Ka*ejjtv9sEC65VdYBicSNQRsn znLmwD-fAJs0?s;SU@9n09MU_DMkji7TserxM(U%sZ8lX@E3lKqN?n?%?POO1JlcW} z>a8aa9j+R9qZ}vDyip%nq7YBsjSdQ@sJK0zVi}S=Y=pZBt0(N+aS<|`5k^v)Y&Urr zMA4A^c5i(kQjUcFf9^Z++R0y*y>?0K<&qniL;1J>)!ml=30-v--a7&Ju25@zkS%N zWFIP`E7VnI=S0sZ?svd7;&^Xcv+NxHtSxg1n>@BYol0~}wj`yzlC+xA59*!H)26F zgw6INE4JyFz4yjrIZMw1aLZoiefe3+eN$c#0gvvOhyj^ZM2+q>b#8~6Y`e^~N&rFh zU0mNYl@43=Aw4o?yy*q=YkaA%uO2a*ReTuRbAAMO3{Q=#oOH(p?>beyh~JM&NB6YO z!~FJBqUl3a;@f>rGK@c4vPf~x*7~T-GL`ziQ$(8!K5OnbYeA^~j6x{cWL~HJenmX2 z>^U%~&Al~ip*~1M7&9ZaD;;_vUdq6XmQz!uqRWhUEg=C!)i%)fU?u*zfcPJ{`x(p# zKV^snhP_F)PnT?oxRa))MDP}MlGJ&cYO+fj;aHe&;~rAGzl;<5uPi$)X`{S9ZCN<` z3Ksdhz0?~V6U$4x+I!ZUR(RBeO)eQHyf!X4Zeo2XZLsko+r7wG0(Tn^@u)nwy+q$? zz0LL9azlm-GR|>$ox7!{&r;;U;ck(Qw#Tv|q(}Li$4-fG)4iSgkG;*-v%F>%YP#u8y=%HAs*A*`;^;iHR;nB85bKg_Bbs9$@=1`&atqzt~k3h~t0=sie2acQ(o9rR^**uzp541ex4W@U%xpP84 z&-wFnezMx^lZ0RR)j`;yIE(PeT;gWifGZVo6W#V~=4F?~DdfYp=5O2{t!i%aItctf z3Gm;f+ex=t3e6XPnyipB6=iVyPnf!*d`wIw&O6w{nqe#Fa*l>5DrU2qvEdSeui+%j z%cRsBy%|sa<a?Gce1aI`^|Mv{gYGJ_NHPD>Y~5(myx0YY>1D=IarU{}KMp%zKIk z@fJ?sVr(Urf)bG_m{WY&AqaJ2xJJV;Bds|Xjp`|_9CoVz3%PIV6Q0)ZSl)Ko*^-+tT@MSJ;#1i zD%q1aCD%^^fCRQEOzo18D=pg^T#4YFE?>v2O(j4(sZ9k;u~CRhONgga5)CGK`Z5?WLdT_x@2SjRjZN;e3@g z3O`bZm6_+v%d#J|u9b5mYjBS3o`JFZI_aSsg>zBL5d1%k8qCXCaIKS*T$VFodMi5? z+TVVrn+$$K38D{3W+W`AcHNxn|GIMsev2>ZEujY_qhf2ksuvV&YYJkfvx%*e=DzOmh;Ag(a)rWXCx!4H6UlDt-hanGvvX(D>p@YRC|> z`HKv$bzLn)Wfkc-d=WUCXk0sag!wCCW3i5|BMgrGQDUn!M-k7U3|12-7B`4v!l4qZ z*GX$ZS#0>K!)+NrK9oSU9KfxOBcn>0ic>U~h29T!DUDYMd=d4t*@SpZgDW=oQikUd znOSf>T}tRl;PE?LPixoDG_xLeqXehsUlvcdUQFYXV^8*+#CB;F#9wA88Npmuafiuy zW)c!po4;7r95e*zEGn6o*-5IH(Vt&9N!$Wa3Tm9`)|gdZAXZ&htA#EQ_uN^es2IVu z48Y*DXmuQFOcS>#qJLE0TH-B)ER=c~yr%af^sBlOo72nG&BD0KUw%tXF;t+WnrHu@ zG&b_GuOi7(qAyDc9TM{pS4f^ziR{(D9mODYP6!tU2j=>!nN(jWAKjgQl3Pp3x)7y-{zQ z{N<4&WFV4B8?J38s02TC^xsTvP$jK{im99XZ$FPihMLC?hnr{?v%uAIg47YQ=s_)M zMgox5aNpl#uT_NmA=4W7%I!8FM;`|j7WIwJ_d@Q_~S!c2x96kvkP*6dHDOx5AJ4lQAjVXc-%J5zr(<@`al$P z;@S0R(q!y>NQHFO=;z|%VDDUuxslzj)Og;@4-U-?mp2;wzUjxNl77*sV1-jPRFdB} zlh)tunXI42O)4b6aQll;iwp&Rs&40^JWf1@$7`sROPhI2Jgf< zonxiWE6(0fbE4a(3kF~YslS`(?|{tq!D;kz$jn`Wh{}B?_0hfRKVg4RfPQD!KaT5e zvHL!Ueid5A)D6cYj|pSGgU4&uoA=D6y>V?tC7X22V$ooOo73X{hK^q6j;~IBPVbJ? zI35cA#ie_IhB-6N(Yl@kn|4;9_^T>L0RgK~^-woUTe#@PUDFnsdueE~qJnRNe{);w zjIHWQ9>l3t8V$v=Eca--_9Oo;i??9fLboq2M61|FQ$qy4TgFxZoC^A$O&&xtE;273 za=?SzEbf0(Ce%d0>NNiDL4+HL?CT@R8Nz{K)GH1+v$iN3{ooSL2BlbzEem0XB0M2o z?W+Q!AQG`I(aj!}D+q!eojsE;sW*8E(s=tIn=I0Y0sADvv4bgkES&~%6U`x}ew!(7cpN0cm*FwSBilFs_;!0Y~e zTwTATZM=1Yf}3T=9>09lTWM4Jm-xZbT>iR9^!3Qxl+~pe|nyH4XY7aIeIb literal 0 HcmV?d00001 diff --git a/Zootopia_Compiler/Resources/lexi.png b/Zootopia_Compiler/Resources/lexi.png new file mode 100644 index 0000000000000000000000000000000000000000..9071eea6b120615569d80eae9a32c02a017f4f12 GIT binary patch literal 7883 zcmbuD2{_d4+xMs28X*;uJ+ftq2FWrpvM(`-CJj*+a-S3}s(J zh{2F8*(U2)X6A9<|NFV`{`dcR-s5=R_c(sP<2rxGb^Wg8dz{yGe$MOJEn^)PrVC5} z0DwhLSL^n1*$4p8Xfo0tTa(IY$K&GU16><`06<3g_xD6l0VogvU^0P#!MARCKm(xu z9?%DZdSI~N13#!6 z>&FP?jdPgd*l*sX<>`DCLz9s3IF7?q>eO?luMG1-uM;BkW1e>(&W7ZBjW+Hr_ED0UKeczmi*lb?Mivg2d>?7Ym42quvSfYXds_k{e(!Y2SExT@;q zi!BUTz=@z?W=24Z5vt`1Z#0$dhi2xT6OW&qXbDKVX2AIP9N@;I1Wh#HhW3fa*%_i{ zfLF8tryiHPbAVgY04K5V#bLnXY*J>(34mRS5XXsENdUpKt}$8w4;4VkfaUX>0P8D& zb8ZG7l>uL+0ax^_+;jo&Y5^_%rAEZdhR$X|kLjTyC^7_&` zt%n2itA~5BZk22|ssXQ-C#<#}{I1Q-ycc!j;|ufiU-ds~+BtVyg;CsF9b2r(_xItd zM|(Rn*l!{c^7aurw4|BV-fhDI-ht$kPwq}GCh8p3GEoXBS;<6s1pyB{gd|D7wRfS}H4r;(9nkV^4*=L~fa1Q0 zGtxZvh@2gOQ8z$jomZCtkKOc=eE|RmEfE>>?kZ3RBLJZFDnjy|2G2I`yi^N4FOF^! z$9&|Z_(W6WW2@$AO{RN~dHtLuN)VdjPy62SNjk}Xxxoi)G4*(ge84KxYVmFV>JKFV0DxCm%#L?469l4ZjBjr>enqZChEnibciP9j};DlV3sDsI2<&a#B2;n|MM zKn0BUOvKHWlZv!3O+jaV4P9$PYvZrFZv}Zpfb0_|l}^$;F>MvQhCZUXA;lKo(_ote^e4V^9(F6R`=pJy^1&HLuZDxhkR}eFH04ofVvlikzEt_ zyeb)#Q=|khcSg-;&$rEAo#&Ys+O%WJzI(&>4aw}A`0Z{_eeQ+R3%~_>*9>_Li~OwH zQ*ZOk*%cCPHB0kqZkL-zzdZ|ln5Eno$*E^hQ2IJ`_<{$Q#~!5odq6$=R4Tu5`e&=5 zo@Jfy>ECI#VW(K0azu8-xQlb6&NG~M=Z2jx&oD%D565zMm|sznTgh0;WXptFSWDJO zhH@lzGo|XMil*{N%9U;1pLPIRfXeRW4j=;3wKqJl#mxo@zaM93Lix)`o=>8 zB^xrxd=0T`MTL3F;H&yqt*UNsrMQ6@<}!RqF9VEEE{S8(x8TpG&uvJ2li)!E4eR7w z?|2oZrKedJ>lT|9>#Q^>maSp3(M>lSYz`w>H9GXg?uhBQC-&22FPV*-O<|ZYoJMNb zcgkdnyb5^o8nj@|KA8249IV6R978B(I=E@+fHzE*Y)Rtn3AKb8LlJ77Y=dm2YTnj-aMi1vw?*5m z*EIS>*(%!F|K?rraW)^ybr)^fjF_)3p2tMRT0 zb9TSWizllwutblu7W3Ki!TsO+ox5&%eLAcE4C3T=W5RONPL83o1unv+_~KA{3EwwVxJixdSueoWl%irQ=Luo`T;w>_Op+McCt}b zsMfW&`0{ndb;x@3WNt4oS0cyes{iMYrUJ{mdkxjBH z9eY<>04v&a-r!Q-RrkxCQ=d~+nwFooaqLxUsqL)oF=>P5I7Sh`;lk8=)JN1o0Os+f z6Yez6A~YiGemf*R3KeQj0A0ts?pBVkX~ey%)8NoZM3f>HaHT>XovSZOh4z**`jh%0 ztWme%-$y?)I4?TKw!u${MMXzhJq0B^h_SvfD3`7P8=M6D6SNMr(zK>g?s6u|<iyNsJn?}&A_wcdRLUS%1{GDV;JSi;fTR`j>*Z_INcTp6;R_78&d z`dhc7Fr0-lXQZyD-7t(XzLrANI4${>Gw#ynS=glnrr=h-R`-jtgNlPOU%_`I`HeSq zC5;{>uO>Ar1dDvSS|GJh_e8AlMWZ2$;S}n64rf-Nptro*^(MK<my73W;; zTkEar#=lT{xsgju>iKlX5It64ejSYb3o# zOp4d6(#zmYqK}NcA{=nt2we3EuN7tsriG}mmC3O+dlPF}8$z}7!P9IWb&hAx%g*7s z(mBGvicbbD@I*tqn=>a<-WL{sth+bhHsrRvI4zxH$C_4@zL?JH!!kbco`qofer;#> zCSEqZPaNM6Sp%-iZ&v-#=!)s;?^6MpzcJr7KQLEZADXIm9wYe-uJeR6?gCdw@OF)R zWc4mA-r|IX(TLlK>!IFZ)gGwqSVu;{rXL;Y;04%T0#$8-^|#EsAQQ`oVWj)!KwNfeb{Je{f6@v6 zx+Y}FrJvx*2HmJX9WXm|lN!6E(x}pZXY)hAW+i^%tknmrtn%xQ-ai6akz3WA+(yh~!2hskAg1TSqQerSZqS zDd?hm+Xw)7bO``>90>sIQ;*AK0N~*j0N{rc0B}760N{cqJATpz0M72}X=#`TO{`Ag zAL2(59kb2u3*P)6hg&i*zsYgv77AYHur3rdq%*yc@tH%bOi-T=eVNfBqL7Jo=Sq2g zFaVhRutG*u@xeldUfhy6c)|D&PsKRXVp+bBWw^962ySlMO9?X`+@$#=n{dq|hMT8rRVB`Yhd zQB5UdWaH&`FE@}SB|iQndlaW_f0BjtA3gp5&q?QhUMy|mU+ez275=jXdjGM{xYn+bQuW!e}HDoWwd&?&wH__WM(GeKEb`uE}bFv#R>k)D4B!tJ++8 zaDD%w&L4%;amImLcsQ4xGCVlVOXWIb5IOVnu2<*hk0 zbZm(K#pV9+i}<24ut ziAAMV=~fncFJSBH>yy6@r|Ge3@2X{E>e9_E22n#_yg*%(y#L(M|G6a(y&)WoSkYLK z4dfkLj<&@jy7RODz5o9ldbYr`S?GA5mgILh)H)U%`!uwoyR)3j@i33BCjgcoX#(-N zcB@;mPk~Uo*4UHR1Tlsg8Ak%h3m=8W2GUd+lq(B*oe_}do>jRp zTR&~IpG8yoN2C3(j(3EQ=46jH_+;lUCYLn89ykxFBwBuE&k=bYS z8`!a4(R%8Ejd4q>?3tJL8|IcON(UI?h%`0#!+T+n4Q}C;*Da{^H)&iWjMVMPegB9B z)!jn3XSwptBj*~~DJ!FpGG;8+j<2@h!O&6R&$ zl}X#IwiVEf+T8WQ>G3pgnHxa@?JvAuVP;uA$5O9c-({DKS(^o%g-2j? z^jCu_H61<5YL|cE@!W(%ZQPeBZ=gIy+9U^M!@Z7PP{D-DR6KD(y6SK$MbSK-c++T@ z?D~`6tdA}=j!3TPUk^09Fh$pVHa3M|q&(3O$cUvXs>DEDs!?ql-M;nBF+=tvxmYpM zRK}a$)NcMwt1PybD+Lnuvma{nU8&~}XX1%;eM98x$y~odbv82|;m{>cwIEjL+~?nf zLr-i4gyTliKZGdUr3F1_8R@u&ZcjlE7xp>~raT5)6nYtAgXGV!5=1<-V>or(E@P6Wci>JuZY%LoUN1U6wMb0ua zyU_k2?;s=69M1GgqAy6vT)=Dx8!UX(gP{$fq4Mu~PCr&?-GhR6DnFx&y1m+YW)Ev| zunc)CVTUiIi%gVY{~56rH5r?AS!KVB37jD_WDF>zUqfw#%2^t&6v-VvfJxu2!?wW8;m2| zf6IT)b`%5URbG-k^(hAS#`ZS6gu9M zre-&OG?}NUD^M2cn=(J3IdGU>@x<|v(a{gQ1FmU+9!j|enmJIlG8w0zdUn-?6n2Dm zdL*FA6-YxoMfOv`piI982_4_I_qI#KSP>AHt>xHQL?(JNDLb-R+$&!AsKjY?3|eLs zo!Bfx8ulc1^o^Yl?PC8?c`Gh91#bj-B9Kv)f^Qhy`40Csdoa(p&FHwo3%7KdpL%oT zJ!7K6A2A?LB>zlEdn3sz{SUm0_Q+ZkZ!c!WS{BZGHscqOqw6mV@CLit?)Sv3d1j+a zSJ;Ch zp4s9UGF!0*QQ=zrR6H7ZSBLnoCrpv6VaCh%R6fpC;iXMoK{_qQ>K6DWkI7-=zNH-@YW{U3DF$~Pf_X&0M z++WI)8x9SgLWSY{)#^7MopXF&0UfRnzU5=6NKN$K|0f)mH?6y1b-J`>_>|G?&I;YqCMADAfD z%IrX7#J)E{aD^Hv9+Q?pNE9uBrWnz4JsCCQ#YD08`MnEridq{Jj!GzAMwQ7*f!3Xw` zFIaXErta&?7el~J;23Q&aUL7V?AQwZy0%m62X*!o-#~x! zh4*}2AkgWC_)&Jd)d%BHgwdi z4>)`WHW#vwb{$E)taKpbE9G|kz!L*wWLQBu8l+OPk5AePD;KTv_)EE*+(&A zFNjHm+~P(M3XOP=&mtxzhw!Qkw2t^Mi^vf{QWoze<=WprLn%YYUMFn{Q4eKrnkjw` zmwAL6oByIKOR~i%sb`!CwHO?@yAeNgxe}5On~a|+mN(gy-TJ+aR3Gfa|7uz9e)aN^6$$Iy&PBg(Md;uRw*9Y99B1f>cECw zs&ds1QofH%Tr#>+x8vnQrj%Lulxc;M3ANM`PXtCX(BR_VM^xlYo(jQ+PR0K#<$B++ z64icT5jj*~Ax2V1Ei8V`fYkU?-}X%MviXx&+Kb>>VCEWV7D`yafd3$5`f2zC_T=f% zC9{;^1K-fY;4Gw)ag!8ceNDzxmpN3-Aw*vDYNeAU*wZ3$1z)Y_B`GjXM?JY7=g5B1R zU{EcBS?VA&C3rYvL05Y>`gJb)HCyTZ_v+py6&Uif>XPM8=Z?m*8pHk2lEp;~&SrpA9rmFz zjfMz;*Hu=OhTj#>Qx@nn5yDk*@Em7zf5n%73r}F7{-7U;ko8>O>Sqm}%y1D=NSR+? z%2M{5uxacGv}N{8v|HLdLH0=L&=RG5bZgCq?yrRIwCXSBpYf{AUwIBvE8|DyRIIwD zp+yw-59{gfv!dkc@lb(EN@9Uoxibt9BxYmleHU3}mrr!xV<)ri_b~N82fWCcUvjzQ zREu=?_X7sL&}@gUv$YwsbP0w_=eVRY#`sXm<^16=UE#4YOd+S9?)64HMVCI~_V>U@h|Eb>hQ;re7l(xLI6J!kdGh~P(fU8N{MQJ_fjioi)GzrxzKu^NB=w$fkp97kHrL!* z=!Zcas6IG(RZLkS8Y6lZXNF9jDf|?iTz7ou;F_Foi?zXBHL2uORUp04-|c72@myR( zEXjBIO6~_(5MRDYo_c{;0w>=rB{a_T;pq~C8)mrcgG;vpabrtil6Zm)=}}lw*t85O zoqH2F0}c!kwb*DpPM<3|a{{yGr)a|A*oF9(5l#W9_XXjge}Ka;>ili~!aBd0|1bAq g|G=JuIVwHiDP+^?g^Ua6__h$Bchgv_Ow$SRU;8OTx&QzG literal 0 HcmV?d00001 diff --git a/Zootopia_Compiler/Resources/lexical.png b/Zootopia_Compiler/Resources/lexical.png new file mode 100644 index 0000000000000000000000000000000000000000..c5a45b009c8104f71e3c5d52bf213ac1c1428aec GIT binary patch literal 8118 zcmcI|cU05cvu_Xu1*IrO=}1Qeq$4GChzN*uq$))~dT*ggQJQo}C<;mh6qG8xs8j(% zK%@qw1O$SRKp-K>%elXMfA4tiId`ph*Lr_s?J}9!v*$ar=QH!23ij=3rgyqNzuWuc=^-)sOv^wey zrlet)01D)uo|Pf(VU;n`RgfJQ`yRwY0~k1DpLP}mIc{4~I6 z>8LWxr> zRaCFqDyXa*ckk?Ve_AUmNgmNL5c@S21?N-F5Dm$`@S-a+adM1Hm@fdp^DI`%Z85~K zF^1Z)F@=m~2FL3^yJ^T*@84e`t&P|CX#fDrL0~vZLaKoyR)r?kn^Z1@KK;;v{&_Gi z)vcaUqY3bQbJhyu_lIqCUp#A_nOR$1{eJ6{);;H8t7wvYpJR^|@zF6@^#pgY)b&F! zPR2e?|MbyP-xuudS6t)S=N{jmU(eJ(X`v^da3ijM0^M)57H3&8z388z14+Zkyt?{C zD_iWd&;;4#2U3DSt&Wrjyz^A2ip;wH+WrCcp`i$qbx_X_900K2?%O*ldX_r&VZ!ow zD0vr1)PF7nh;;*H`vU+DI)aks!wtZJvjBk3^EmN$nw;3)%Mv{_T)k)Jd+AS{6dr2{ ze(KX=(xP*T3Tii)%QiEHr$Mj)Rjvs?$pT!3TH9tnY^V!l~(T=!t zr!@!9UUKH2O`*E~)LJ0pEPGMn5r412>5Hj?d_yTLrdJKKA z*-o!5OJxus6MvG_p?@PcuHIB_@_dta>uW`h$9m=TUtNN3Kr-2$L%#+za;T*#yg+@e zdB`}MsjfXB-Lr9-R`$~)Y03VNTJM!4&gDE9d4KiI`I>%?cb0Fc+n*df7=Isn`eK}J z&pCzDp;~;-Jemg9x2=u88@%S@5|m?}J*Rk%`mt%B$km+JhK<5)%*UTD-b^Q!8~>cwh$3yj5xd1jS^S#+(Qg{;|1)w#+18jI?ZJ6mR)X6{uguam3Y zU;CN^UxICjPiSmD-u`H!{nGULd&iZIem?pKR~o`3_`NRFBn8LGe-eH_IujKl-d;%L zZckOKu6m)YEqhDWs^Kms*9}O!Qs{qF9AtbBB?>FRfS)e1?27#m_Gp#HBG~LL7KVqW0zGw%lrGP za!U=&?U`!Zf7H-^<(%hSu>3fy6|Pz_rI)V9nC8)Mw<5UW-S6FBAxtC8FKlS^(+CZ@ zYt&jPR;hAZ<@Uhnm(lXkZ$b|u``dOHGpyA($GE2SoBPLid(A`5RV`QEt$nANt8Mmfj&^px z&+gvxx%MMEr!yzIEjpd3MtdQ7hM|VrmKz+{7{GGV^5!CBtQZZ9{*2AvlybKoXBz)5 zyV87VMC_ACi5V23@6PVt8km4dNqu4%KO$M6E(zuAUl{CMy%lueZ@(NdaZmznfcEXY zo~uJEpgqvZ^JQP;%EU@-WCOo`9MoPiU4sMZ%kreXkZ-^y+9q-CO(+4W2U1y9Z>Qh2 zyb7(xIq$NoAF2nGt*Ec4DlW<_+Bkku>}eTn88P|jTk4pI)Q%A#yO1NuZ~!b;h{~P% zNt|Zfy;Fpvh$#N<4B*W<*Tedm9nG}ot(vTwnelJq*LvUbKOEeC_Ld)qDjdri^I%B4 z1K#-dmDYLPIrSs>yhvhlqE!+w!!N~}1Ae1GJ`_H$9f;Jy>*VV!LfvneDA!%TB`>aC zE$OK`tJo&j2JDw~v-vV*U1AM-WXPo~DPF7K^Qa4XvV%$fQSyU+C6c{RYS7*<{KZ%w zHW9{FC3#WeX1>Pl6l0~_Uz$wfui4Us_AiABWzdE9are1jm4Yk4Q@(54iSrom8;Bc4 zWN&A6$cGDlmVG6$*7{ha>RHF_3%3`bH%r+dA$;C4YBxJ?BxGkj^Vh28H_B;t|LMN& z7Bce2HL;%b*(bF{iYJeD$gAPmn=>}o>6*1FH_UBCr^RXO-CeERx<{W3E9cjgUK`!{ z(l9*tOtE;kjJ$KP@8WWH^Q$C7tLxm>>z!{rmFrdg!{_K$SkGKbvZQ&V`r&D_xc8Jv z&5l(;Ex1!S!pJMmp?5gGw~5MYi{656Eirm)etO5=#9GP*+2o8*D&bUTee$%HWsbdo zHRikMeApUivhQ$r(R^-WRn4bXmvOfVx6Sp%>!tS?@~aEh3mAMZ%*-}kKw38L931M- zNfnHW&b22rYqwT(tA6Nkg$<33ssPPjnq$rJ<_hSEg(m0eBOf@LGqU4QZhLC(UI&h- zKGZd5L1keyI?01+B+z}hF(n@9NsZ~M2#-u^oS)DzT1S^DI|9?g=&XyP4mv zZRs-%@OF_(c0;dUP`F@`Uflmfz)vT9brW|EiQ~C&b2cO`^35_Wf;WWQomgo>cw zc9?WHVl{R&XS5fRr-1iJ^WS&pV?298pJU+j`Z$`zgmF^VK_;X2narZhk)#VrTct|s z%E~{00mRJ{nD)5KxNs>ushl)Y%g!bRKAPH^9)lOcUli;Y1N!aNPoe$;Stw1uGtVZ$0h>{;3zdtbh3M1rP$;ly~rY^*sJdnLUN5PwX z4-D=a0RRy~06=U40B}sEjGF*JurvVh(+L2$SqK2I`(`_S)&l@omO(n2=3%qj3p>Gc zmgPzCX&aK1@tJjVKI1d@#ZxLzU1NP*#dqt>i)$%%nz?jZR!r5W%vjG`#Gx5ur_&^c z@O%tZrJd6g^($BC<$f(~08Ym#wzRawL89DQ`68IqQh0P2%W2^W8=BbPmdt;qyfg8= zhHo)e!FSah(!+86qC;1Q{F6tHl!xq$KmMwWS1Gm^40m)=CWGp8bCsic)9A0G%#HuM zSb_iPz)p+Uzbf%3o%DZK?@tt3`2Q&O&-eKE4axa=qiGxex}(aCTLJklGb9J>`9-B6 zY}OJx2y7BCPXbFsByCF!p#)=uT8(6oc%-n0u_%`>ab{0IC1qoin7dZb-P=N(%vgo( zyaor2BTKed&U818h9!DrrwZ=!93iE4)6ktMiw5I{D0IP&`TBwYxqC&uD-4dA|1LG# zN?_C`>K86H9?w(ls{W%+f(v8?H$8tsfp338n$ zwQ=E-nAN8IhcEu_xiQtIkkHenbWeo?yH2c z^V6JIWlL?zWedw{dNSrE;T2 zu8EF9YqGdgIpmx5ct0_uiDq7$fzRKSR9_+G-W>qotvBE?_AW)&Y_;8vGOSO7K%bZJ-I}RY%cs3 z(Z5^%U*hhVVCkW0v*l$X$In*#D_346g(#kuhW(59yP|)M%im<{Fn;dX8QQumR1}2m zwA!%}TRGg4&j)?m-_~D4$oks>^S!vvpMFl#onqUKAD0l|-MjFz zV3w%a-ALh?kC!*4a!$VP$<&5QuZ8_I|G7YQqLPN?hO%4tx1Xw54Ik(g8A^0vbT@YN zY%B{3idFK|KNhIy$Rbs_CF&7s^8*+Ce?eXSGz5rl6{Lwh8J}5rKtTmjX$Y0!7`iEY zM-Lw#NT@C22%GFpQI?Y9^NWSo(HjMVXP4*0Y?rK8AE*LxPB2Bzk)Y7pNR^ij+)-t^ zZPA(hAW}*Ft|;dwBlh_rkzsuhb|#)|@hdnD3o0@ztW#66do_pIx91AVAvw6(+;5B- zT|3thMAn;ZUE1Q<%vpakXu>VEBE;^W{v%yfAUavVei|n27{EL&vCz#dpW{|S(RYRX zZBM3DwmJh*Z2wax!dJ&ab;7q&X_~@lUrJgZZ#7*saO{&Ca-?jCx!)27kRa%E8F@(5)10;_TyC zN+A?*77u+jAYT_^5U-nE3sNiD*UQ}~dz6Ki+Uk^)9&Wc>#ID;=OdQO8qTkE8S+;d` zG+8rguxVcp&z^axNFBWs*qcfc`gUcV^XBxPUhd}TwYPL%xb>_3-7ibr_YsyvsY8 zKjtZ(l}TH-5*5wipC!W>K=92rwBgt^?CT z@u*bPMTQf<<#gzag`R6*%&}6PD7YEc3GQR@wD)5PxpU703-ds;SbEYOOqRU+WdAI4 z<>Ts+b|FPz@t~s0iN=A66S2)!d2W9?Vw_GYW~M&p-&qutY2XQ^|gR zNU!5aKPagMAfRcmd8I6cRJmu+G!tEy|p&K#Sx zmx->!B?lW3xkzhvuDEn8bqT_RF0E%PH^zmiJ0P&(5BBfN%>RON zUB3MurAz^Hz0)#0Q3^`(^G!!Gqk)jN09Hl?g$dm4X@Na|)uY>gO=^Fnsoy33j#B?F z`TS>U`}fg*gKYn|C{h!fLSnjplSEPk<=^GVXkk6!MD5fe7`kw6M3R@-g#k*^yyr!Q z;QS{*Ef7%y_%XxD_1bLqrZXxCHUR{x6*akruXmRJb$xf)%Ai#r`iCCLH`_*0TEb*R7Pol@O z4aWz?tExi;s?K%jVK99Rt>;ZwWe?c-GFrB%*_Ee7cA*tX4T{=aGt9(P)OLel_xCT8 zOvFaDqe%Blfg6E%Q;5DDNhr+o@}?qf^?lgWERw`%dr|ym|<6|9!3a+ zRX=t3WzO2UR3(ltTB;JmQ-sa9OkN}kj;g%9ql>Kw;fZkxG&RIx1P2sYDSSVB@*w5B zMFWULb;l&XQm})@VHGiW?-O_E1c{{MQy%k0X~;w^j9bw|(#pX_5%=;6sth;f|K=(_ zCT*X-5UzVBgcQnSot!rPT3Z%Rq2hx9p=yS3k~CV?A}^Nl?il5mu4Kl+Yl;&Q^yaki~5 zwZI}))JRz7=oiX9Lx^19KqOT;vI3OdO)t4SF6VCS$Jefih#zTt5~=;Pi}qGV8|DM9 zebb0BH-g_M()(qdk7uA*7#z38*StDO1GlFGP_+~cO5SawZ}H;#uV3=O=@9rwy%z3^~F#Mog0Lu`lWi~A8dT(yK%b9 zYeY7fbj@VT9R97@p;)})&Ix!1u_L<(A^FD&L~n{2&vHM4BdF&PA?_!|>og4yT6xwD zfS?(IjSt}~&r)rqblZ5&i63el_}K=Qz_nQ*77FUK2R4lWN5HlHTrC24RAf9Vw!-8v zvhFAp1olOJW#1$%%$c_5*f+nAbn{6>Kp$~`IN0=ul+Bi%8i@+Gp8a_y&SZaF+1)@pA!WESpiWmYXG~Kq`1cE3uTQ)Pp zLVvmU!74X$*69oc)Gc(o)u#5=S*LWm&&6DH4}L9*f2mv}`(!JKGE29~CPPpZ77*rr zyMITdp)TCFQUxIhSi#gWyGW+L6yr;SvMps5bnb{Wr)K%*G6cu3B=#N;|XoPCC>GBM_q9qjmV;aA;m zs~iOqh!EWIakn#ipfRy3b%W3)kk$+y{T734`ck06=L_y8x~K3AAB~A?{M{4!pOE_> z3S<-PH}SznV(>gz&8XJXc> zt_tzK4V>zafuql+bPWc%=7UwWe~OQ4Pe{HL#@F5lBH@j$(>}A)3I)X*q4Mdi8y?%C z_OS56hJ+-y!A1Yqy)fcX)3b_=mJ(jS zUz`Iw-Ioy1+u0}faE0T{V+xRPm{BMisYh?Xt{k==6(|iAjFePK<84tN)(`W>HU~T; zZ@kWHjZPFGdaTW@-!3h$OAn8xc<4Q-2>EHKN6nSZ^nmmy7L>Z?0aOoLUWXVI|E`AX zJcgNgNS@fPjU=lGdq?Gj%m%xl*oiMbf%6H#&y622NXp|!snoPfM;z2JJ>iQPC*6Ys z#o*V0GZ=PKiPv!o__d_t5suBWWFvXwC#6Ia;)OH9ZBPAE%KK1|Ne}iet^-!KWZc_+ zLW)hBm^a#yGa)SDEZQ%ny}e1{791j%9*1VQJ}?Hl=wJM&MD$0aCxypzX(c{=D~hO8 z0*V^c!O}j&D2*NnkjqTlsnalPRKw~rqWE50)ZBQ9Eow{ToN>;H5O3h$HE;etrzsU~ zuqWm>M10(V9b|mdu0I$8Rp^vE@yND;s5}p5JqhoMmKA3Z zjQFoo@&76PN8&=9>OyD1!OmF$Eoa>`lY*vyP=HiWM;fDtPj~u8q;rA9k8s&E<93r6vuw<(t|_76N%=I*3M4uiLFk9 zeNri~dv-5wIUpJ7>v~HdLb{Xc&tLWb2b}u1(LTnWAOYFON~Dl%Hw8*#6admS)~VHU GivK?_00fZ$ literal 0 HcmV?d00001 diff --git a/Zootopia_Compiler/SyntaxAnalyzer.vb b/Zootopia_Compiler/SyntaxAnalyzer.vb new file mode 100644 index 0000000..34a72b2 --- /dev/null +++ b/Zootopia_Compiler/SyntaxAnalyzer.vb @@ -0,0 +1,6426 @@ +' SyntaxAnalyzer.vb +' +' THIS FILE HAS BEEN GENERATED AUTOMATICALLY. DO NOT EDIT! + +Imports Core.Library + +'''A class providing callback methods for the +'''parser. +Public MustInherit Class SyntaxAnalyzer + Inherits Analyzer + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overrides Sub Enter(ByVal node As Node) + Select Case node.Id + Case SyntaxConstants.ENTRANCE + EnterEntrance(CType(node,Token)) + + Case SyntaxConstants.EXIT + EnterExit(CType(node,Token)) + + Case SyntaxConstants.MANE + EnterMane(CType(node,Token)) + + Case SyntaxConstants.LET + EnterLet(CType(node,Token)) + + Case SyntaxConstants.WIPE + EnterWipe(CType(node,Token)) + + Case SyntaxConstants.ZOOIN + EnterZooin(CType(node,Token)) + + Case SyntaxConstants.ZOOUT + EnterZoout(CType(node,Token)) + + Case SyntaxConstants.IF + EnterIf(CType(node,Token)) + + Case SyntaxConstants.EELSIF + EnterEelsif(CType(node,Token)) + + Case SyntaxConstants.EELS + EnterEels(CType(node,Token)) + + Case SyntaxConstants.CHAMOIS + EnterChamois(CType(node,Token)) + + Case SyntaxConstants.TERMITE + EnterTermite(CType(node,Token)) + + Case SyntaxConstants.SEAL + EnterSeal(CType(node,Token)) + + Case SyntaxConstants.WHALE + EnterWhale(CType(node,Token)) + + Case SyntaxConstants.DO + EnterDo(CType(node,Token)) + + Case SyntaxConstants.FUR + EnterFur(CType(node,Token)) + + Case SyntaxConstants.HOP + EnterHop(CType(node,Token)) + + Case SyntaxConstants.SWASP + EnterSwasp(CType(node,Token)) + + Case SyntaxConstants.STORK + EnterStork(CType(node,Token)) + + Case SyntaxConstants.AT + EnterAt(CType(node,Token)) + + Case SyntaxConstants.NULL + EnterNull(CType(node,Token)) + + Case SyntaxConstants.COMSYM + EnterComsym(CType(node,Token)) + + Case SyntaxConstants.TERMI + EnterTermi(CType(node,Token)) + + Case SyntaxConstants.SC + EnterSc(CType(node,Token)) + + Case SyntaxConstants.COMMA + EnterComma(CType(node,Token)) + + Case SyntaxConstants.EQUAL + EnterEqual(CType(node,Token)) + + Case SyntaxConstants.OB + EnterOb(CType(node,Token)) + + Case SyntaxConstants.CB + EnterCb(CType(node,Token)) + + Case SyntaxConstants.OC + EnterOc(CType(node,Token)) + + Case SyntaxConstants.CC + EnterCc(CType(node,Token)) + + Case SyntaxConstants.OP + EnterOp(CType(node,Token)) + + Case SyntaxConstants.CP + EnterCp(CType(node,Token)) + + Case SyntaxConstants.ODC + EnterOdc(CType(node,Token)) + + Case SyntaxConstants.CDC + EnterCdc(CType(node,Token)) + + Case SyntaxConstants.CONC + EnterConc(CType(node,Token)) + + Case SyntaxConstants.CON + EnterCon(CType(node,Token)) + + Case SyntaxConstants.ODA + EnterOda(CType(node,Token)) + + Case SyntaxConstants.CDA + EnterCda(CType(node,Token)) + + Case SyntaxConstants.NEG + EnterNeg(CType(node,Token)) + + Case SyntaxConstants.ADD + EnterAdd(CType(node,Token)) + + Case SyntaxConstants.SUB + EnterSub(CType(node,Token)) + + Case SyntaxConstants.MUL + EnterMul(CType(node,Token)) + + Case SyntaxConstants.DIV + EnterDiv(CType(node,Token)) + + Case SyntaxConstants.MOD + EnterMod(CType(node,Token)) + + Case SyntaxConstants.EXP + EnterExp(CType(node,Token)) + + Case SyntaxConstants.OA + EnterOa(CType(node,Token)) + + Case SyntaxConstants.CA + EnterCa(CType(node,Token)) + + Case SyntaxConstants.OAE + EnterOae(CType(node,Token)) + + Case SyntaxConstants.CAE + EnterCae(CType(node,Token)) + + Case SyntaxConstants.EE + EnterEe(CType(node,Token)) + + Case SyntaxConstants.DE + EnterDe(CType(node,Token)) + + Case SyntaxConstants.EXC + EnterExc(CType(node,Token)) + + Case SyntaxConstants.DAND + EnterDand(CType(node,Token)) + + Case SyntaxConstants.DOR + EnterDor(CType(node,Token)) + + Case SyntaxConstants.INCRE + EnterIncre(CType(node,Token)) + + Case SyntaxConstants.DECRE + EnterDecre(CType(node,Token)) + + Case SyntaxConstants.NEWT + EnterNewt(CType(node,Token)) + + Case SyntaxConstants.DUCK + EnterDuck(CType(node,Token)) + + Case SyntaxConstants.BULL + EnterBull(CType(node,Token)) + + Case SyntaxConstants.STARLING + EnterStarling(CType(node,Token)) + + Case SyntaxConstants.VIPER + EnterViper(CType(node,Token)) + + Case SyntaxConstants.NEWTLIT + EnterNewtlit(CType(node,Token)) + + Case SyntaxConstants.DUCKLIT + EnterDucklit(CType(node,Token)) + + Case SyntaxConstants.STARLIT + EnterStarlit(CType(node,Token)) + + Case SyntaxConstants.TRUE + EnterTrue(CType(node,Token)) + + Case SyntaxConstants.FALSE + EnterFalse(CType(node,Token)) + + Case SyntaxConstants.ID + EnterId(CType(node,Token)) + + Case SyntaxConstants.COMMENT + EnterComment(CType(node,Token)) + + Case SyntaxConstants.PROD_PROGRAM + EnterProdProgram(CType(node,Production)) + + Case SyntaxConstants.PROD_COMMENT + EnterProdComment(CType(node,Production)) + + Case SyntaxConstants.PROD_GLOBAL_DEC + EnterProdGlobalDec(CType(node,Production)) + + Case SyntaxConstants.PROD_VAR_DEC + EnterProdVarDec(CType(node,Production)) + + Case SyntaxConstants.PROD_FUNC_VAR + EnterProdFuncVar(CType(node,Production)) + + Case SyntaxConstants.PROD_IDENT_VAR + EnterProdIdentVar(CType(node,Production)) + + Case SyntaxConstants.PROD_DTYPE + EnterProdDtype(CType(node,Production)) + + Case SyntaxConstants.PROD_NEXT2VAR + EnterProdNext2var(CType(node,Production)) + + Case SyntaxConstants.PROD_NEXT2VAR_TAIL + EnterProdNext2varTail(CType(node,Production)) + + Case SyntaxConstants.PROD_VAL + EnterProdVal(CType(node,Production)) + + Case SyntaxConstants.PROD_VAL1 + EnterProdVal1(CType(node,Production)) + + Case SyntaxConstants.PROD_VAL2 + EnterProdVal2(CType(node,Production)) + + Case SyntaxConstants.PROD_BUL_LIT + EnterProdBulLit(CType(node,Production)) + + Case SyntaxConstants.PROD_ARRAY1D + EnterProdArray1d(CType(node,Production)) + + Case SyntaxConstants.PROD_ELEM1D_NEXT + EnterProdElem1dNext(CType(node,Production)) + + Case SyntaxConstants.PROD_ELEM1D_LIST + EnterProdElem1dList(CType(node,Production)) + + Case SyntaxConstants.PROD_ELEMLIST1D_TAIL + EnterProdElemlist1dTail(CType(node,Production)) + + Case SyntaxConstants.PROD_ELEM2D_NEXT + EnterProdElem2dNext(CType(node,Production)) + + Case SyntaxConstants.PROD_ELEM2D_LIST + EnterProdElem2dList(CType(node,Production)) + + Case SyntaxConstants.PROD_ELEM2D_LIST_TAIL + EnterProdElem2dListTail(CType(node,Production)) + + Case SyntaxConstants.PROD_SIZE + EnterProdSize(CType(node,Production)) + + Case SyntaxConstants.PROD_CONST_DEC + EnterProdConstDec(CType(node,Production)) + + Case SyntaxConstants.PROD_CONST_NEXT + EnterProdConstNext(CType(node,Production)) + + Case SyntaxConstants.PROD_FUNC_NAME + EnterProdFuncName(CType(node,Production)) + + Case SyntaxConstants.PROD_PARAM + EnterProdParam(CType(node,Production)) + + Case SyntaxConstants.PROD_PARAM2 + EnterProdParam2(CType(node,Production)) + + Case SyntaxConstants.PROD_STORK_DEC + EnterProdStorkDec(CType(node,Production)) + + Case SyntaxConstants.PROD_STORK_ELEM + EnterProdStorkElem(CType(node,Production)) + + Case SyntaxConstants.PROD_MULTI_VARDEC + EnterProdMultiVardec(CType(node,Production)) + + Case SyntaxConstants.PROD_MULTISTORK_ELEM + EnterProdMultistorkElem(CType(node,Production)) + + Case SyntaxConstants.PROD_OBJ_DEC + EnterProdObjDec(CType(node,Production)) + + Case SyntaxConstants.PROD_MANE + EnterProdMane(CType(node,Production)) + + Case SyntaxConstants.PROD_LOCAL_DEC + EnterProdLocalDec(CType(node,Production)) + + Case SyntaxConstants.PROD_STATEMENT + EnterProdStatement(CType(node,Production)) + + Case SyntaxConstants.PROD_STATE_NEXT + EnterProdStateNext(CType(node,Production)) + + Case SyntaxConstants.PROD_ASSIGN1 + EnterProdAssign1(CType(node,Production)) + + Case SyntaxConstants.PROD_ASSIGN_TAIL + EnterProdAssignTail(CType(node,Production)) + + Case SyntaxConstants.PROD_NEXT_FIG + EnterProdNextFig(CType(node,Production)) + + Case SyntaxConstants.PROD_NEXT + EnterProdNext(CType(node,Production)) + + Case SyntaxConstants.PROD_SCAN_NEXT + EnterProdScanNext(CType(node,Production)) + + Case SyntaxConstants.PROD_VALUE_DL + EnterProdValueDl(CType(node,Production)) + + Case SyntaxConstants.PROD_FIG + EnterProdFig(CType(node,Production)) + + Case SyntaxConstants.PROD_FUNC_CALL + EnterProdFuncCall(CType(node,Production)) + + Case SyntaxConstants.PROD_ARGS1 + EnterProdArgs1(CType(node,Production)) + + Case SyntaxConstants.PROD_ARGS_TAIL + EnterProdArgsTail(CType(node,Production)) + + Case SyntaxConstants.PROD_ARG_IN + EnterProdArgIn(CType(node,Production)) + + Case SyntaxConstants.PROD_FUNC_NEXT + EnterProdFuncNext(CType(node,Production)) + + Case SyntaxConstants.PROD_FUNC + EnterProdFunc(CType(node,Production)) + + Case SyntaxConstants.PROD_MATH_EQTAIL + EnterProdMathEqtail(CType(node,Production)) + + Case SyntaxConstants.PROD_MATH_EQTAIL1 + EnterProdMathEqtail1(CType(node,Production)) + + Case SyntaxConstants.PROD_MATH_EQTAIL2 + EnterProdMathEqtail2(CType(node,Production)) + + Case SyntaxConstants.PROD_EXPONENT + EnterProdExponent(CType(node,Production)) + + Case SyntaxConstants.PROD_MATH_TAIL + EnterProdMathTail(CType(node,Production)) + + Case SyntaxConstants.PROD_MATH_OP + EnterProdMathOp(CType(node,Production)) + + Case SyntaxConstants.PROD_MATH_FIG + EnterProdMathFig(CType(node,Production)) + + Case SyntaxConstants.PROD_MATH_FIG1 + EnterProdMathFig1(CType(node,Production)) + + Case SyntaxConstants.PROD_MATHEQ_NEXT + EnterProdMatheqNext(CType(node,Production)) + + Case SyntaxConstants.PROD_FUNCTION_CALL + EnterProdFunctionCall(CType(node,Production)) + + Case SyntaxConstants.PROD_CLRSCR + EnterProdClrscr(CType(node,Production)) + + Case SyntaxConstants.PROD_INPUT + EnterProdInput(CType(node,Production)) + + Case SyntaxConstants.PROD_SCAN_FIG + EnterProdScanFig(CType(node,Production)) + + Case SyntaxConstants.PROD_MULTI_INPUT + EnterProdMultiInput(CType(node,Production)) + + Case SyntaxConstants.PROD_ARR1D + EnterProdArr1d(CType(node,Production)) + + Case SyntaxConstants.PROD_ARR2D + EnterProdArr2d(CType(node,Production)) + + Case SyntaxConstants.PROD_STORK_ACCESS1 + EnterProdStorkAccess1(CType(node,Production)) + + Case SyntaxConstants.PROD_OUTPUT + EnterProdOutput(CType(node,Production)) + + Case SyntaxConstants.PROD_OUT + EnterProdOut(CType(node,Production)) + + Case SyntaxConstants.PROD_OUTPUT_NEXT + EnterProdOutputNext(CType(node,Production)) + + Case SyntaxConstants.PROD_MULTI_OUTPUT + EnterProdMultiOutput(CType(node,Production)) + + Case SyntaxConstants.PROD_CONDITIONAL + EnterProdConditional(CType(node,Production)) + + Case SyntaxConstants.PROD_CONDI + EnterProdCondi(CType(node,Production)) + + Case SyntaxConstants.PROD_NOT_FIG + EnterProdNotFig(CType(node,Production)) + + Case SyntaxConstants.PROD_COND_EXPR + EnterProdCondExpr(CType(node,Production)) + + Case SyntaxConstants.PROD_COND_TAIL + EnterProdCondTail(CType(node,Production)) + + Case SyntaxConstants.PROD_REL_EXPR + EnterProdRelExpr(CType(node,Production)) + + Case SyntaxConstants.PROD_RELEX_TAIL + EnterProdRelexTail(CType(node,Production)) + + Case SyntaxConstants.PROD_EXPRESSION + EnterProdExpression(CType(node,Production)) + + Case SyntaxConstants.PROD_EXPR_NEXT + EnterProdExprNext(CType(node,Production)) + + Case SyntaxConstants.PROD_REL_OP1 + EnterProdRelOp1(CType(node,Production)) + + Case SyntaxConstants.PROD_REL_OP2 + EnterProdRelOp2(CType(node,Production)) + + Case SyntaxConstants.PROD_REL_FIG + EnterProdRelFig(CType(node,Production)) + + Case SyntaxConstants.PROD_LOG_EXPR + EnterProdLogExpr(CType(node,Production)) + + Case SyntaxConstants.PROD_LOG_EXPR_NEXT + EnterProdLogExprNext(CType(node,Production)) + + Case SyntaxConstants.PROD_LOG_OP + EnterProdLogOp(CType(node,Production)) + + Case SyntaxConstants.PROD_COND_EELSIF + EnterProdCondEelsif(CType(node,Production)) + + Case SyntaxConstants.PROD_COND_EELS + EnterProdCondEels(CType(node,Production)) + + Case SyntaxConstants.PROD_SWASP_CASE + EnterProdSwaspCase(CType(node,Production)) + + Case SyntaxConstants.PROD_SWASP_CASE1 + EnterProdSwaspCase1(CType(node,Production)) + + Case SyntaxConstants.PROD_TERM_EXPR + EnterProdTermExpr(CType(node,Production)) + + Case SyntaxConstants.PROD_DEFAULT + EnterProdDefault(CType(node,Production)) + + Case SyntaxConstants.PROD_ITERATIVE + EnterProdIterative(CType(node,Production)) + + Case SyntaxConstants.PROD_LOOP_FIG1 + EnterProdLoopFig1(CType(node,Production)) + + Case SyntaxConstants.PROD_REL_EXPR1 + EnterProdRelExpr1(CType(node,Production)) + + Case SyntaxConstants.PROD_LOOP_FIG2 + EnterProdLoopFig2(CType(node,Production)) + + Case SyntaxConstants.PROD_INCREM_DECREM + EnterProdIncremDecrem(CType(node,Production)) + + Case SyntaxConstants.PROD_VAR + EnterProdVar(CType(node,Production)) + + Case SyntaxConstants.PROD_UNARY_OP + EnterProdUnaryOp(CType(node,Production)) + + Case SyntaxConstants.PROD_SUB_FUNCTION + EnterProdSubFunction(CType(node,Production)) + + Case SyntaxConstants.PROD_FUNC_INSIDE + EnterProdFuncInside(CType(node,Production)) + + Case SyntaxConstants.PROD_FUNC_ARGS + EnterProdFuncArgs(CType(node,Production)) + + Case SyntaxConstants.PROD_MULTIFUNC_ARGS + EnterProdMultifuncArgs(CType(node,Production)) + + Case SyntaxConstants.PROD_RESULT + EnterProdResult(CType(node,Production)) + + Case SyntaxConstants.PROD_FIG_TAIL + EnterProdFigTail(CType(node,Production)) + + Case SyntaxConstants.PROD_RESULT_TAIL + EnterProdResultTail(CType(node,Production)) + + End Select + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overrides Function [Exit](ByVal node As Node) As Node + Select Case node.Id + Case SyntaxConstants.ENTRANCE + return ExitEntrance(CType(node,Token)) + + Case SyntaxConstants.EXIT + return ExitExit(CType(node,Token)) + + Case SyntaxConstants.MANE + return ExitMane(CType(node,Token)) + + Case SyntaxConstants.LET + return ExitLet(CType(node,Token)) + + Case SyntaxConstants.WIPE + return ExitWipe(CType(node,Token)) + + Case SyntaxConstants.ZOOIN + return ExitZooin(CType(node,Token)) + + Case SyntaxConstants.ZOOUT + return ExitZoout(CType(node,Token)) + + Case SyntaxConstants.IF + return ExitIf(CType(node,Token)) + + Case SyntaxConstants.EELSIF + return ExitEelsif(CType(node,Token)) + + Case SyntaxConstants.EELS + return ExitEels(CType(node,Token)) + + Case SyntaxConstants.CHAMOIS + return ExitChamois(CType(node,Token)) + + Case SyntaxConstants.TERMITE + return ExitTermite(CType(node,Token)) + + Case SyntaxConstants.SEAL + return ExitSeal(CType(node,Token)) + + Case SyntaxConstants.WHALE + return ExitWhale(CType(node,Token)) + + Case SyntaxConstants.DO + return ExitDo(CType(node,Token)) + + Case SyntaxConstants.FUR + return ExitFur(CType(node,Token)) + + Case SyntaxConstants.HOP + return ExitHop(CType(node,Token)) + + Case SyntaxConstants.SWASP + return ExitSwasp(CType(node,Token)) + + Case SyntaxConstants.STORK + return ExitStork(CType(node,Token)) + + Case SyntaxConstants.AT + return ExitAt(CType(node,Token)) + + Case SyntaxConstants.NULL + return ExitNull(CType(node,Token)) + + Case SyntaxConstants.COMSYM + return ExitComsym(CType(node,Token)) + + Case SyntaxConstants.TERMI + return ExitTermi(CType(node,Token)) + + Case SyntaxConstants.SC + return ExitSc(CType(node,Token)) + + Case SyntaxConstants.COMMA + return ExitComma(CType(node,Token)) + + Case SyntaxConstants.EQUAL + return ExitEqual(CType(node,Token)) + + Case SyntaxConstants.OB + return ExitOb(CType(node,Token)) + + Case SyntaxConstants.CB + return ExitCb(CType(node,Token)) + + Case SyntaxConstants.OC + return ExitOc(CType(node,Token)) + + Case SyntaxConstants.CC + return ExitCc(CType(node,Token)) + + Case SyntaxConstants.OP + return ExitOp(CType(node,Token)) + + Case SyntaxConstants.CP + return ExitCp(CType(node,Token)) + + Case SyntaxConstants.ODC + return ExitOdc(CType(node,Token)) + + Case SyntaxConstants.CDC + return ExitCdc(CType(node,Token)) + + Case SyntaxConstants.CONC + return ExitConc(CType(node,Token)) + + Case SyntaxConstants.CON + return ExitCon(CType(node,Token)) + + Case SyntaxConstants.ODA + return ExitOda(CType(node,Token)) + + Case SyntaxConstants.CDA + return ExitCda(CType(node,Token)) + + Case SyntaxConstants.NEG + return ExitNeg(CType(node,Token)) + + Case SyntaxConstants.ADD + return ExitAdd(CType(node,Token)) + + Case SyntaxConstants.SUB + return ExitSub(CType(node,Token)) + + Case SyntaxConstants.MUL + return ExitMul(CType(node,Token)) + + Case SyntaxConstants.DIV + return ExitDiv(CType(node,Token)) + + Case SyntaxConstants.MOD + return ExitMod(CType(node,Token)) + + Case SyntaxConstants.EXP + return ExitExp(CType(node,Token)) + + Case SyntaxConstants.OA + return ExitOa(CType(node,Token)) + + Case SyntaxConstants.CA + return ExitCa(CType(node,Token)) + + Case SyntaxConstants.OAE + return ExitOae(CType(node,Token)) + + Case SyntaxConstants.CAE + return ExitCae(CType(node,Token)) + + Case SyntaxConstants.EE + return ExitEe(CType(node,Token)) + + Case SyntaxConstants.DE + return ExitDe(CType(node,Token)) + + Case SyntaxConstants.EXC + return ExitExc(CType(node,Token)) + + Case SyntaxConstants.DAND + return ExitDand(CType(node,Token)) + + Case SyntaxConstants.DOR + return ExitDor(CType(node,Token)) + + Case SyntaxConstants.INCRE + return ExitIncre(CType(node,Token)) + + Case SyntaxConstants.DECRE + return ExitDecre(CType(node,Token)) + + Case SyntaxConstants.NEWT + return ExitNewt(CType(node,Token)) + + Case SyntaxConstants.DUCK + return ExitDuck(CType(node,Token)) + + Case SyntaxConstants.BULL + return ExitBull(CType(node,Token)) + + Case SyntaxConstants.STARLING + return ExitStarling(CType(node,Token)) + + Case SyntaxConstants.VIPER + return ExitViper(CType(node,Token)) + + Case SyntaxConstants.NEWTLIT + return ExitNewtlit(CType(node,Token)) + + Case SyntaxConstants.DUCKLIT + return ExitDucklit(CType(node,Token)) + + Case SyntaxConstants.STARLIT + return ExitStarlit(CType(node,Token)) + + Case SyntaxConstants.TRUE + return ExitTrue(CType(node,Token)) + + Case SyntaxConstants.FALSE + return ExitFalse(CType(node,Token)) + + Case SyntaxConstants.ID + return ExitId(CType(node,Token)) + + Case SyntaxConstants.COMMENT + return ExitComment(CType(node,Token)) + + Case SyntaxConstants.PROD_PROGRAM + return ExitProdProgram(CType(node,Production)) + + Case SyntaxConstants.PROD_COMMENT + return ExitProdComment(CType(node,Production)) + + Case SyntaxConstants.PROD_GLOBAL_DEC + return ExitProdGlobalDec(CType(node,Production)) + + Case SyntaxConstants.PROD_VAR_DEC + return ExitProdVarDec(CType(node,Production)) + + Case SyntaxConstants.PROD_FUNC_VAR + return ExitProdFuncVar(CType(node,Production)) + + Case SyntaxConstants.PROD_IDENT_VAR + return ExitProdIdentVar(CType(node,Production)) + + Case SyntaxConstants.PROD_DTYPE + return ExitProdDtype(CType(node,Production)) + + Case SyntaxConstants.PROD_NEXT2VAR + return ExitProdNext2var(CType(node,Production)) + + Case SyntaxConstants.PROD_NEXT2VAR_TAIL + return ExitProdNext2varTail(CType(node,Production)) + + Case SyntaxConstants.PROD_VAL + return ExitProdVal(CType(node,Production)) + + Case SyntaxConstants.PROD_VAL1 + return ExitProdVal1(CType(node,Production)) + + Case SyntaxConstants.PROD_VAL2 + return ExitProdVal2(CType(node,Production)) + + Case SyntaxConstants.PROD_BUL_LIT + return ExitProdBulLit(CType(node,Production)) + + Case SyntaxConstants.PROD_ARRAY1D + return ExitProdArray1d(CType(node,Production)) + + Case SyntaxConstants.PROD_ELEM1D_NEXT + return ExitProdElem1dNext(CType(node,Production)) + + Case SyntaxConstants.PROD_ELEM1D_LIST + return ExitProdElem1dList(CType(node,Production)) + + Case SyntaxConstants.PROD_ELEMLIST1D_TAIL + return ExitProdElemlist1dTail(CType(node,Production)) + + Case SyntaxConstants.PROD_ELEM2D_NEXT + return ExitProdElem2dNext(CType(node,Production)) + + Case SyntaxConstants.PROD_ELEM2D_LIST + return ExitProdElem2dList(CType(node,Production)) + + Case SyntaxConstants.PROD_ELEM2D_LIST_TAIL + return ExitProdElem2dListTail(CType(node,Production)) + + Case SyntaxConstants.PROD_SIZE + return ExitProdSize(CType(node,Production)) + + Case SyntaxConstants.PROD_CONST_DEC + return ExitProdConstDec(CType(node,Production)) + + Case SyntaxConstants.PROD_CONST_NEXT + return ExitProdConstNext(CType(node,Production)) + + Case SyntaxConstants.PROD_FUNC_NAME + return ExitProdFuncName(CType(node,Production)) + + Case SyntaxConstants.PROD_PARAM + return ExitProdParam(CType(node,Production)) + + Case SyntaxConstants.PROD_PARAM2 + return ExitProdParam2(CType(node,Production)) + + Case SyntaxConstants.PROD_STORK_DEC + return ExitProdStorkDec(CType(node,Production)) + + Case SyntaxConstants.PROD_STORK_ELEM + return ExitProdStorkElem(CType(node,Production)) + + Case SyntaxConstants.PROD_MULTI_VARDEC + return ExitProdMultiVardec(CType(node,Production)) + + Case SyntaxConstants.PROD_MULTISTORK_ELEM + return ExitProdMultistorkElem(CType(node,Production)) + + Case SyntaxConstants.PROD_OBJ_DEC + return ExitProdObjDec(CType(node,Production)) + + Case SyntaxConstants.PROD_MANE + return ExitProdMane(CType(node,Production)) + + Case SyntaxConstants.PROD_LOCAL_DEC + return ExitProdLocalDec(CType(node,Production)) + + Case SyntaxConstants.PROD_STATEMENT + return ExitProdStatement(CType(node,Production)) + + Case SyntaxConstants.PROD_STATE_NEXT + return ExitProdStateNext(CType(node,Production)) + + Case SyntaxConstants.PROD_ASSIGN1 + return ExitProdAssign1(CType(node,Production)) + + Case SyntaxConstants.PROD_ASSIGN_TAIL + return ExitProdAssignTail(CType(node,Production)) + + Case SyntaxConstants.PROD_NEXT_FIG + return ExitProdNextFig(CType(node,Production)) + + Case SyntaxConstants.PROD_NEXT + return ExitProdNext(CType(node,Production)) + + Case SyntaxConstants.PROD_SCAN_NEXT + return ExitProdScanNext(CType(node,Production)) + + Case SyntaxConstants.PROD_VALUE_DL + return ExitProdValueDl(CType(node,Production)) + + Case SyntaxConstants.PROD_FIG + return ExitProdFig(CType(node,Production)) + + Case SyntaxConstants.PROD_FUNC_CALL + return ExitProdFuncCall(CType(node,Production)) + + Case SyntaxConstants.PROD_ARGS1 + return ExitProdArgs1(CType(node,Production)) + + Case SyntaxConstants.PROD_ARGS_TAIL + return ExitProdArgsTail(CType(node,Production)) + + Case SyntaxConstants.PROD_ARG_IN + return ExitProdArgIn(CType(node,Production)) + + Case SyntaxConstants.PROD_FUNC_NEXT + return ExitProdFuncNext(CType(node,Production)) + + Case SyntaxConstants.PROD_FUNC + return ExitProdFunc(CType(node,Production)) + + Case SyntaxConstants.PROD_MATH_EQTAIL + return ExitProdMathEqtail(CType(node,Production)) + + Case SyntaxConstants.PROD_MATH_EQTAIL1 + return ExitProdMathEqtail1(CType(node,Production)) + + Case SyntaxConstants.PROD_MATH_EQTAIL2 + return ExitProdMathEqtail2(CType(node,Production)) + + Case SyntaxConstants.PROD_EXPONENT + return ExitProdExponent(CType(node,Production)) + + Case SyntaxConstants.PROD_MATH_TAIL + return ExitProdMathTail(CType(node,Production)) + + Case SyntaxConstants.PROD_MATH_OP + return ExitProdMathOp(CType(node,Production)) + + Case SyntaxConstants.PROD_MATH_FIG + return ExitProdMathFig(CType(node,Production)) + + Case SyntaxConstants.PROD_MATH_FIG1 + return ExitProdMathFig1(CType(node,Production)) + + Case SyntaxConstants.PROD_MATHEQ_NEXT + return ExitProdMatheqNext(CType(node,Production)) + + Case SyntaxConstants.PROD_FUNCTION_CALL + return ExitProdFunctionCall(CType(node,Production)) + + Case SyntaxConstants.PROD_CLRSCR + return ExitProdClrscr(CType(node,Production)) + + Case SyntaxConstants.PROD_INPUT + return ExitProdInput(CType(node,Production)) + + Case SyntaxConstants.PROD_SCAN_FIG + return ExitProdScanFig(CType(node,Production)) + + Case SyntaxConstants.PROD_MULTI_INPUT + return ExitProdMultiInput(CType(node,Production)) + + Case SyntaxConstants.PROD_ARR1D + return ExitProdArr1d(CType(node,Production)) + + Case SyntaxConstants.PROD_ARR2D + return ExitProdArr2d(CType(node,Production)) + + Case SyntaxConstants.PROD_STORK_ACCESS1 + return ExitProdStorkAccess1(CType(node,Production)) + + Case SyntaxConstants.PROD_OUTPUT + return ExitProdOutput(CType(node,Production)) + + Case SyntaxConstants.PROD_OUT + return ExitProdOut(CType(node,Production)) + + Case SyntaxConstants.PROD_OUTPUT_NEXT + return ExitProdOutputNext(CType(node,Production)) + + Case SyntaxConstants.PROD_MULTI_OUTPUT + return ExitProdMultiOutput(CType(node,Production)) + + Case SyntaxConstants.PROD_CONDITIONAL + return ExitProdConditional(CType(node,Production)) + + Case SyntaxConstants.PROD_CONDI + return ExitProdCondi(CType(node,Production)) + + Case SyntaxConstants.PROD_NOT_FIG + return ExitProdNotFig(CType(node,Production)) + + Case SyntaxConstants.PROD_COND_EXPR + return ExitProdCondExpr(CType(node,Production)) + + Case SyntaxConstants.PROD_COND_TAIL + return ExitProdCondTail(CType(node,Production)) + + Case SyntaxConstants.PROD_REL_EXPR + return ExitProdRelExpr(CType(node,Production)) + + Case SyntaxConstants.PROD_RELEX_TAIL + return ExitProdRelexTail(CType(node,Production)) + + Case SyntaxConstants.PROD_EXPRESSION + return ExitProdExpression(CType(node,Production)) + + Case SyntaxConstants.PROD_EXPR_NEXT + return ExitProdExprNext(CType(node,Production)) + + Case SyntaxConstants.PROD_REL_OP1 + return ExitProdRelOp1(CType(node,Production)) + + Case SyntaxConstants.PROD_REL_OP2 + return ExitProdRelOp2(CType(node,Production)) + + Case SyntaxConstants.PROD_REL_FIG + return ExitProdRelFig(CType(node,Production)) + + Case SyntaxConstants.PROD_LOG_EXPR + return ExitProdLogExpr(CType(node,Production)) + + Case SyntaxConstants.PROD_LOG_EXPR_NEXT + return ExitProdLogExprNext(CType(node,Production)) + + Case SyntaxConstants.PROD_LOG_OP + return ExitProdLogOp(CType(node,Production)) + + Case SyntaxConstants.PROD_COND_EELSIF + return ExitProdCondEelsif(CType(node,Production)) + + Case SyntaxConstants.PROD_COND_EELS + return ExitProdCondEels(CType(node,Production)) + + Case SyntaxConstants.PROD_SWASP_CASE + return ExitProdSwaspCase(CType(node,Production)) + + Case SyntaxConstants.PROD_SWASP_CASE1 + return ExitProdSwaspCase1(CType(node,Production)) + + Case SyntaxConstants.PROD_TERM_EXPR + return ExitProdTermExpr(CType(node,Production)) + + Case SyntaxConstants.PROD_DEFAULT + return ExitProdDefault(CType(node,Production)) + + Case SyntaxConstants.PROD_ITERATIVE + return ExitProdIterative(CType(node,Production)) + + Case SyntaxConstants.PROD_LOOP_FIG1 + return ExitProdLoopFig1(CType(node,Production)) + + Case SyntaxConstants.PROD_REL_EXPR1 + return ExitProdRelExpr1(CType(node,Production)) + + Case SyntaxConstants.PROD_LOOP_FIG2 + return ExitProdLoopFig2(CType(node,Production)) + + Case SyntaxConstants.PROD_INCREM_DECREM + return ExitProdIncremDecrem(CType(node,Production)) + + Case SyntaxConstants.PROD_VAR + return ExitProdVar(CType(node,Production)) + + Case SyntaxConstants.PROD_UNARY_OP + return ExitProdUnaryOp(CType(node,Production)) + + Case SyntaxConstants.PROD_SUB_FUNCTION + return ExitProdSubFunction(CType(node,Production)) + + Case SyntaxConstants.PROD_FUNC_INSIDE + return ExitProdFuncInside(CType(node,Production)) + + Case SyntaxConstants.PROD_FUNC_ARGS + return ExitProdFuncArgs(CType(node,Production)) + + Case SyntaxConstants.PROD_MULTIFUNC_ARGS + return ExitProdMultifuncArgs(CType(node,Production)) + + Case SyntaxConstants.PROD_RESULT + return ExitProdResult(CType(node,Production)) + + Case SyntaxConstants.PROD_FIG_TAIL + return ExitProdFigTail(CType(node,Production)) + + Case SyntaxConstants.PROD_RESULT_TAIL + return ExitProdResultTail(CType(node,Production)) + + End Select + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overrides Sub Child(ByVal node As Production, ByVal child As Node) + Select Case node.Id + Case SyntaxConstants.PROD_PROGRAM + ChildProdProgram(node, child) + + Case SyntaxConstants.PROD_COMMENT + ChildProdComment(node, child) + + Case SyntaxConstants.PROD_GLOBAL_DEC + ChildProdGlobalDec(node, child) + + Case SyntaxConstants.PROD_VAR_DEC + ChildProdVarDec(node, child) + + Case SyntaxConstants.PROD_FUNC_VAR + ChildProdFuncVar(node, child) + + Case SyntaxConstants.PROD_IDENT_VAR + ChildProdIdentVar(node, child) + + Case SyntaxConstants.PROD_DTYPE + ChildProdDtype(node, child) + + Case SyntaxConstants.PROD_NEXT2VAR + ChildProdNext2var(node, child) + + Case SyntaxConstants.PROD_NEXT2VAR_TAIL + ChildProdNext2varTail(node, child) + + Case SyntaxConstants.PROD_VAL + ChildProdVal(node, child) + + Case SyntaxConstants.PROD_VAL1 + ChildProdVal1(node, child) + + Case SyntaxConstants.PROD_VAL2 + ChildProdVal2(node, child) + + Case SyntaxConstants.PROD_BUL_LIT + ChildProdBulLit(node, child) + + Case SyntaxConstants.PROD_ARRAY1D + ChildProdArray1d(node, child) + + Case SyntaxConstants.PROD_ELEM1D_NEXT + ChildProdElem1dNext(node, child) + + Case SyntaxConstants.PROD_ELEM1D_LIST + ChildProdElem1dList(node, child) + + Case SyntaxConstants.PROD_ELEMLIST1D_TAIL + ChildProdElemlist1dTail(node, child) + + Case SyntaxConstants.PROD_ELEM2D_NEXT + ChildProdElem2dNext(node, child) + + Case SyntaxConstants.PROD_ELEM2D_LIST + ChildProdElem2dList(node, child) + + Case SyntaxConstants.PROD_ELEM2D_LIST_TAIL + ChildProdElem2dListTail(node, child) + + Case SyntaxConstants.PROD_SIZE + ChildProdSize(node, child) + + Case SyntaxConstants.PROD_CONST_DEC + ChildProdConstDec(node, child) + + Case SyntaxConstants.PROD_CONST_NEXT + ChildProdConstNext(node, child) + + Case SyntaxConstants.PROD_FUNC_NAME + ChildProdFuncName(node, child) + + Case SyntaxConstants.PROD_PARAM + ChildProdParam(node, child) + + Case SyntaxConstants.PROD_PARAM2 + ChildProdParam2(node, child) + + Case SyntaxConstants.PROD_STORK_DEC + ChildProdStorkDec(node, child) + + Case SyntaxConstants.PROD_STORK_ELEM + ChildProdStorkElem(node, child) + + Case SyntaxConstants.PROD_MULTI_VARDEC + ChildProdMultiVardec(node, child) + + Case SyntaxConstants.PROD_MULTISTORK_ELEM + ChildProdMultistorkElem(node, child) + + Case SyntaxConstants.PROD_OBJ_DEC + ChildProdObjDec(node, child) + + Case SyntaxConstants.PROD_MANE + ChildProdMane(node, child) + + Case SyntaxConstants.PROD_LOCAL_DEC + ChildProdLocalDec(node, child) + + Case SyntaxConstants.PROD_STATEMENT + ChildProdStatement(node, child) + + Case SyntaxConstants.PROD_STATE_NEXT + ChildProdStateNext(node, child) + + Case SyntaxConstants.PROD_ASSIGN1 + ChildProdAssign1(node, child) + + Case SyntaxConstants.PROD_ASSIGN_TAIL + ChildProdAssignTail(node, child) + + Case SyntaxConstants.PROD_NEXT_FIG + ChildProdNextFig(node, child) + + Case SyntaxConstants.PROD_NEXT + ChildProdNext(node, child) + + Case SyntaxConstants.PROD_SCAN_NEXT + ChildProdScanNext(node, child) + + Case SyntaxConstants.PROD_VALUE_DL + ChildProdValueDl(node, child) + + Case SyntaxConstants.PROD_FIG + ChildProdFig(node, child) + + Case SyntaxConstants.PROD_FUNC_CALL + ChildProdFuncCall(node, child) + + Case SyntaxConstants.PROD_ARGS1 + ChildProdArgs1(node, child) + + Case SyntaxConstants.PROD_ARGS_TAIL + ChildProdArgsTail(node, child) + + Case SyntaxConstants.PROD_ARG_IN + ChildProdArgIn(node, child) + + Case SyntaxConstants.PROD_FUNC_NEXT + ChildProdFuncNext(node, child) + + Case SyntaxConstants.PROD_FUNC + ChildProdFunc(node, child) + + Case SyntaxConstants.PROD_MATH_EQTAIL + ChildProdMathEqtail(node, child) + + Case SyntaxConstants.PROD_MATH_EQTAIL1 + ChildProdMathEqtail1(node, child) + + Case SyntaxConstants.PROD_MATH_EQTAIL2 + ChildProdMathEqtail2(node, child) + + Case SyntaxConstants.PROD_EXPONENT + ChildProdExponent(node, child) + + Case SyntaxConstants.PROD_MATH_TAIL + ChildProdMathTail(node, child) + + Case SyntaxConstants.PROD_MATH_OP + ChildProdMathOp(node, child) + + Case SyntaxConstants.PROD_MATH_FIG + ChildProdMathFig(node, child) + + Case SyntaxConstants.PROD_MATH_FIG1 + ChildProdMathFig1(node, child) + + Case SyntaxConstants.PROD_MATHEQ_NEXT + ChildProdMatheqNext(node, child) + + Case SyntaxConstants.PROD_FUNCTION_CALL + ChildProdFunctionCall(node, child) + + Case SyntaxConstants.PROD_CLRSCR + ChildProdClrscr(node, child) + + Case SyntaxConstants.PROD_INPUT + ChildProdInput(node, child) + + Case SyntaxConstants.PROD_SCAN_FIG + ChildProdScanFig(node, child) + + Case SyntaxConstants.PROD_MULTI_INPUT + ChildProdMultiInput(node, child) + + Case SyntaxConstants.PROD_ARR1D + ChildProdArr1d(node, child) + + Case SyntaxConstants.PROD_ARR2D + ChildProdArr2d(node, child) + + Case SyntaxConstants.PROD_STORK_ACCESS1 + ChildProdStorkAccess1(node, child) + + Case SyntaxConstants.PROD_OUTPUT + ChildProdOutput(node, child) + + Case SyntaxConstants.PROD_OUT + ChildProdOut(node, child) + + Case SyntaxConstants.PROD_OUTPUT_NEXT + ChildProdOutputNext(node, child) + + Case SyntaxConstants.PROD_MULTI_OUTPUT + ChildProdMultiOutput(node, child) + + Case SyntaxConstants.PROD_CONDITIONAL + ChildProdConditional(node, child) + + Case SyntaxConstants.PROD_CONDI + ChildProdCondi(node, child) + + Case SyntaxConstants.PROD_NOT_FIG + ChildProdNotFig(node, child) + + Case SyntaxConstants.PROD_COND_EXPR + ChildProdCondExpr(node, child) + + Case SyntaxConstants.PROD_COND_TAIL + ChildProdCondTail(node, child) + + Case SyntaxConstants.PROD_REL_EXPR + ChildProdRelExpr(node, child) + + Case SyntaxConstants.PROD_RELEX_TAIL + ChildProdRelexTail(node, child) + + Case SyntaxConstants.PROD_EXPRESSION + ChildProdExpression(node, child) + + Case SyntaxConstants.PROD_EXPR_NEXT + ChildProdExprNext(node, child) + + Case SyntaxConstants.PROD_REL_OP1 + ChildProdRelOp1(node, child) + + Case SyntaxConstants.PROD_REL_OP2 + ChildProdRelOp2(node, child) + + Case SyntaxConstants.PROD_REL_FIG + ChildProdRelFig(node, child) + + Case SyntaxConstants.PROD_LOG_EXPR + ChildProdLogExpr(node, child) + + Case SyntaxConstants.PROD_LOG_EXPR_NEXT + ChildProdLogExprNext(node, child) + + Case SyntaxConstants.PROD_LOG_OP + ChildProdLogOp(node, child) + + Case SyntaxConstants.PROD_COND_EELSIF + ChildProdCondEelsif(node, child) + + Case SyntaxConstants.PROD_COND_EELS + ChildProdCondEels(node, child) + + Case SyntaxConstants.PROD_SWASP_CASE + ChildProdSwaspCase(node, child) + + Case SyntaxConstants.PROD_SWASP_CASE1 + ChildProdSwaspCase1(node, child) + + Case SyntaxConstants.PROD_TERM_EXPR + ChildProdTermExpr(node, child) + + Case SyntaxConstants.PROD_DEFAULT + ChildProdDefault(node, child) + + Case SyntaxConstants.PROD_ITERATIVE + ChildProdIterative(node, child) + + Case SyntaxConstants.PROD_LOOP_FIG1 + ChildProdLoopFig1(node, child) + + Case SyntaxConstants.PROD_REL_EXPR1 + ChildProdRelExpr1(node, child) + + Case SyntaxConstants.PROD_LOOP_FIG2 + ChildProdLoopFig2(node, child) + + Case SyntaxConstants.PROD_INCREM_DECREM + ChildProdIncremDecrem(node, child) + + Case SyntaxConstants.PROD_VAR + ChildProdVar(node, child) + + Case SyntaxConstants.PROD_UNARY_OP + ChildProdUnaryOp(node, child) + + Case SyntaxConstants.PROD_SUB_FUNCTION + ChildProdSubFunction(node, child) + + Case SyntaxConstants.PROD_FUNC_INSIDE + ChildProdFuncInside(node, child) + + Case SyntaxConstants.PROD_FUNC_ARGS + ChildProdFuncArgs(node, child) + + Case SyntaxConstants.PROD_MULTIFUNC_ARGS + ChildProdMultifuncArgs(node, child) + + Case SyntaxConstants.PROD_RESULT + ChildProdResult(node, child) + + Case SyntaxConstants.PROD_FIG_TAIL + ChildProdFigTail(node, child) + + Case SyntaxConstants.PROD_RESULT_TAIL + ChildProdResultTail(node, child) + + End Select + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterEntrance(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitEntrance(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterExit(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitExit(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterMane(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitMane(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterLet(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitLet(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterWipe(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitWipe(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterZooin(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitZooin(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterZoout(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitZoout(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterIf(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitIf(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterEelsif(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitEelsif(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterEels(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitEels(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterChamois(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitChamois(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterTermite(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitTermite(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterSeal(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitSeal(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterWhale(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitWhale(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterDo(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitDo(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterFur(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitFur(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterHop(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitHop(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterSwasp(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitSwasp(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterStork(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitStork(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterAt(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitAt(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterNull(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitNull(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterComsym(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitComsym(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterTermi(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitTermi(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterSc(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitSc(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterComma(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitComma(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterEqual(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitEqual(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterOb(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitOb(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterCb(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitCb(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterOc(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitOc(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterCc(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitCc(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterOp(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitOp(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterCp(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitCp(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterOdc(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitOdc(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterCdc(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitCdc(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterConc(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitConc(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterCon(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitCon(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterOda(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitOda(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterCda(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitCda(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterNeg(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitNeg(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterAdd(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitAdd(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterSub(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitSub(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterMul(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitMul(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterDiv(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitDiv(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterMod(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitMod(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterExp(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitExp(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterOa(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitOa(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterCa(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitCa(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterOae(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitOae(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterCae(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitCae(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterEe(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitEe(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterDe(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitDe(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterExc(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitExc(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterDand(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitDand(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterDor(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitDor(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterIncre(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitIncre(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterDecre(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitDecre(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterNewt(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitNewt(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterDuck(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitDuck(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterBull(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitBull(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterStarling(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitStarling(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterViper(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitViper(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterNewtlit(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitNewtlit(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterDucklit(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitDucklit(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterStarlit(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitStarlit(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterTrue(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitTrue(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterFalse(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitFalse(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterId(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitId(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterComment(ByVal node As Token) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitComment(ByVal node As Token) As Node + Return node + End Function + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdProgram(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdProgram(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdProgram(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdComment(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdComment(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdComment(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdGlobalDec(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdGlobalDec(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdGlobalDec(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdVarDec(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdVarDec(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdVarDec(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdFuncVar(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdFuncVar(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdFuncVar(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdIdentVar(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdIdentVar(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdIdentVar(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdDtype(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdDtype(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdDtype(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdNext2var(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdNext2var(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdNext2var(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdNext2varTail(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdNext2varTail(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdNext2varTail(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdVal(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdVal(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdVal(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdVal1(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdVal1(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdVal1(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdVal2(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdVal2(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdVal2(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdBulLit(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdBulLit(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdBulLit(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdArray1d(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdArray1d(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdArray1d(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdElem1dNext(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdElem1dNext(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdElem1dNext(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdElem1dList(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdElem1dList(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdElem1dList(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdElemlist1dTail(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdElemlist1dTail(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdElemlist1dTail(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdElem2dNext(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdElem2dNext(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdElem2dNext(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdElem2dList(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdElem2dList(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdElem2dList(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdElem2dListTail(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdElem2dListTail(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdElem2dListTail(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdSize(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdSize(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdSize(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdConstDec(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdConstDec(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdConstDec(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdConstNext(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdConstNext(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdConstNext(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdFuncName(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdFuncName(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdFuncName(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdParam(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdParam(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdParam(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdParam2(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdParam2(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdParam2(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdStorkDec(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdStorkDec(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdStorkDec(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdStorkElem(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdStorkElem(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdStorkElem(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdMultiVardec(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdMultiVardec(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdMultiVardec(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdMultistorkElem(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdMultistorkElem(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdMultistorkElem(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdObjDec(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdObjDec(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdObjDec(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdMane(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdMane(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdMane(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdLocalDec(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdLocalDec(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdLocalDec(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdStatement(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdStatement(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdStatement(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdStateNext(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdStateNext(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdStateNext(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdAssign1(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdAssign1(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdAssign1(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdAssignTail(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdAssignTail(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdAssignTail(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdNextFig(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdNextFig(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdNextFig(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdNext(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdNext(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdNext(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdScanNext(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdScanNext(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdScanNext(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdValueDl(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdValueDl(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdValueDl(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdFig(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdFig(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdFig(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdFuncCall(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdFuncCall(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdFuncCall(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdArgs1(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdArgs1(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdArgs1(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdArgsTail(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdArgsTail(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdArgsTail(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdArgIn(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdArgIn(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdArgIn(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdFuncNext(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdFuncNext(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdFuncNext(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdFunc(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdFunc(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdFunc(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdMathEqtail(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdMathEqtail(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdMathEqtail(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdMathEqtail1(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdMathEqtail1(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdMathEqtail1(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdMathEqtail2(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdMathEqtail2(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdMathEqtail2(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdExponent(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdExponent(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdExponent(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdMathTail(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdMathTail(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdMathTail(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdMathOp(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdMathOp(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdMathOp(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdMathFig(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdMathFig(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdMathFig(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdMathFig1(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdMathFig1(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdMathFig1(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdMatheqNext(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdMatheqNext(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdMatheqNext(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdFunctionCall(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdFunctionCall(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdFunctionCall(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdClrscr(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdClrscr(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdClrscr(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdInput(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdInput(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdInput(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdScanFig(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdScanFig(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdScanFig(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdMultiInput(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdMultiInput(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdMultiInput(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdArr1d(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdArr1d(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdArr1d(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdArr2d(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdArr2d(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdArr2d(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdStorkAccess1(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdStorkAccess1(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdStorkAccess1(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdOutput(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdOutput(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdOutput(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdOut(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdOut(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdOut(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdOutputNext(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdOutputNext(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdOutputNext(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdMultiOutput(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdMultiOutput(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdMultiOutput(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdConditional(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdConditional(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdConditional(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdCondi(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdCondi(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdCondi(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdNotFig(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdNotFig(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdNotFig(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdCondExpr(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdCondExpr(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdCondExpr(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdCondTail(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdCondTail(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdCondTail(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdRelExpr(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdRelExpr(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdRelExpr(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdRelexTail(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdRelexTail(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdRelexTail(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdExpression(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdExpression(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdExpression(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdExprNext(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdExprNext(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdExprNext(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdRelOp1(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdRelOp1(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdRelOp1(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdRelOp2(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdRelOp2(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdRelOp2(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdRelFig(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdRelFig(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdRelFig(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdLogExpr(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdLogExpr(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdLogExpr(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdLogExprNext(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdLogExprNext(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdLogExprNext(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdLogOp(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdLogOp(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdLogOp(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdCondEelsif(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdCondEelsif(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdCondEelsif(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdCondEels(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdCondEels(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdCondEels(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdSwaspCase(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdSwaspCase(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdSwaspCase(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdSwaspCase1(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdSwaspCase1(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdSwaspCase1(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdTermExpr(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdTermExpr(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdTermExpr(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdDefault(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdDefault(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdDefault(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdIterative(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdIterative(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdIterative(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdLoopFig1(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdLoopFig1(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdLoopFig1(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdRelExpr1(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdRelExpr1(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdRelExpr1(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdLoopFig2(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdLoopFig2(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdLoopFig2(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdIncremDecrem(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdIncremDecrem(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdIncremDecrem(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdVar(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdVar(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdVar(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdUnaryOp(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdUnaryOp(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdUnaryOp(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdSubFunction(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdSubFunction(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdSubFunction(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdFuncInside(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdFuncInside(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdFuncInside(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdFuncArgs(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdFuncArgs(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdFuncArgs(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdMultifuncArgs(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdMultifuncArgs(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdMultifuncArgs(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdResult(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdResult(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdResult(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdFigTail(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdFigTail(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdFigTail(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub + + '''Called when entering a parse tree node. + ''' + '''the node being entered + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub EnterProdResultTail(ByVal node As Production) + End Sub + + '''Called when exiting a parse tree node. + ''' + '''the node being exited + ''' + '''the node to add to the parse tree, or + ''' null if no parse tree should be created + ''' + '''if the node analysis + '''discovered errors + Public Overridable Function ExitProdResultTail(ByVal node As Production) As Node + Return node + End Function + + '''Called when adding a child to a parse tree + '''node. + ''' + '''the parent node + '''the child node, or null + ''' + '''if the node analysis + '''discovered errors + Public Overridable Sub ChildProdResultTail(ByVal node As Production, ByVal child As Node) + node.AddChild(child) + End Sub +End Class diff --git a/Zootopia_Compiler/SyntaxConstants.vb b/Zootopia_Compiler/SyntaxConstants.vb new file mode 100644 index 0000000..7c63fb1 --- /dev/null +++ b/Zootopia_Compiler/SyntaxConstants.vb @@ -0,0 +1,181 @@ +' SyntaxConstants.vb +' +' THIS FILE HAS BEEN GENERATED AUTOMATICALLY. DO NOT EDIT! + +'''An enumeration with token and production node +'''constants. +Public Enum SyntaxConstants + [ENTRANCE] = 1001 + [EXIT] = 1002 + [MANE] = 1003 + [LET] = 1004 + [WIPE] = 1005 + [ZOOIN] = 1006 + [ZOOUT] = 1007 + [IF] = 1008 + [EELSIF] = 1009 + [EELS] = 1010 + [CHAMOIS] = 1011 + [TERMITE] = 1012 + [SEAL] = 1013 + [WHALE] = 1014 + [DO] = 1015 + [FUR] = 1016 + [HOP] = 1017 + [SWASP] = 1018 + [STORK] = 1019 + [AT] = 1020 + [NULL] = 1021 + [COMSYM] = 1022 + [TERMI] = 1023 + [SC] = 1024 + [COMMA] = 1025 + [EQUAL] = 1026 + [OB] = 1027 + [CB] = 1028 + [OC] = 1029 + [CC] = 1030 + [OP] = 1031 + [CP] = 1032 + [ODC] = 1033 + [CDC] = 1034 + [CONC] = 1035 + [CON] = 1036 + [ODA] = 1037 + [CDA] = 1038 + [NEG] = 1039 + [ADD] = 1040 + [SUB] = 1041 + [MUL] = 1042 + [DIV] = 1043 + [MOD] = 1044 + [EXP] = 1045 + [OA] = 1046 + [CA] = 1047 + [OAE] = 1048 + [CAE] = 1049 + [EE] = 1050 + [DE] = 1051 + [EXC] = 1052 + [DAND] = 1053 + [DOR] = 1054 + [INCRE] = 1055 + [DECRE] = 1056 + [NEWT] = 1057 + [DUCK] = 1058 + [BULL] = 1059 + [STARLING] = 1060 + [VIPER] = 1061 + [NEWTLIT] = 1062 + [DUCKLIT] = 1063 + [STARLIT] = 1064 + [TRUE] = 1065 + [FALSE] = 1066 + [ID] = 1067 + [COMMENT] = 1068 + [WHITESPACE] = 1069 + [PROD_PROGRAM] = 2001 + [PROD_COMMENT] = 2002 + [PROD_GLOBAL_DEC] = 2003 + [PROD_VAR_DEC] = 2004 + [PROD_FUNC_VAR] = 2005 + [PROD_IDENT_VAR] = 2006 + [PROD_DTYPE] = 2007 + [PROD_NEXT2VAR] = 2008 + [PROD_NEXT2VAR_TAIL] = 2009 + [PROD_VAL] = 2010 + [PROD_VAL1] = 2011 + [PROD_VAL2] = 2012 + [PROD_BUL_LIT] = 2013 + [PROD_ARRAY1D] = 2014 + [PROD_ELEM1D_NEXT] = 2015 + [PROD_ELEM1D_LIST] = 2016 + [PROD_ELEMLIST1D_TAIL] = 2017 + [PROD_ELEM2D_NEXT] = 2018 + [PROD_ELEM2D_LIST] = 2019 + [PROD_ELEM2D_LIST_TAIL] = 2020 + [PROD_SIZE] = 2021 + [PROD_CONST_DEC] = 2022 + [PROD_CONST_NEXT] = 2023 + [PROD_FUNC_NAME] = 2024 + [PROD_PARAM] = 2025 + [PROD_PARAM2] = 2026 + [PROD_STORK_DEC] = 2027 + [PROD_STORK_ELEM] = 2028 + [PROD_MULTI_VARDEC] = 2029 + [PROD_MULTISTORK_ELEM] = 2030 + [PROD_OBJ_DEC] = 2031 + [PROD_MANE] = 2032 + [PROD_LOCAL_DEC] = 2033 + [PROD_STATEMENT] = 2034 + [PROD_STATE_NEXT] = 2035 + [PROD_ASSIGN1] = 2036 + [PROD_ASSIGN_TAIL] = 2037 + [PROD_NEXT_FIG] = 2038 + [PROD_NEXT] = 2039 + [PROD_SCAN_NEXT] = 2040 + [PROD_VALUE_DL] = 2041 + [PROD_FIG] = 2042 + [PROD_FUNC_CALL] = 2043 + [PROD_ARGS1] = 2044 + [PROD_ARGS_TAIL] = 2045 + [PROD_ARG_IN] = 2046 + [PROD_FUNC_NEXT] = 2047 + [PROD_FUNC] = 2048 + [PROD_MATH_EQTAIL] = 2049 + [PROD_MATH_EQTAIL1] = 2050 + [PROD_MATH_EQTAIL2] = 2051 + [PROD_EXPONENT] = 2052 + [PROD_MATH_TAIL] = 2053 + [PROD_MATH_OP] = 2054 + [PROD_MATH_FIG] = 2055 + [PROD_MATH_FIG1] = 2056 + [PROD_MATHEQ_NEXT] = 2057 + [PROD_FUNCTION_CALL] = 2058 + [PROD_CLRSCR] = 2059 + [PROD_INPUT] = 2060 + [PROD_SCAN_FIG] = 2061 + [PROD_MULTI_INPUT] = 2062 + [PROD_ARR1D] = 2063 + [PROD_ARR2D] = 2064 + [PROD_STORK_ACCESS1] = 2065 + [PROD_OUTPUT] = 2066 + [PROD_OUT] = 2067 + [PROD_OUTPUT_NEXT] = 2068 + [PROD_MULTI_OUTPUT] = 2069 + [PROD_CONDITIONAL] = 2070 + [PROD_CONDI] = 2071 + [PROD_NOT_FIG] = 2072 + [PROD_COND_EXPR] = 2073 + [PROD_COND_TAIL] = 2074 + [PROD_REL_EXPR] = 2075 + [PROD_RELEX_TAIL] = 2076 + [PROD_EXPRESSION] = 2077 + [PROD_EXPR_NEXT] = 2078 + [PROD_REL_OP1] = 2079 + [PROD_REL_OP2] = 2080 + [PROD_REL_FIG] = 2081 + [PROD_LOG_EXPR] = 2082 + [PROD_LOG_EXPR_NEXT] = 2083 + [PROD_LOG_OP] = 2084 + [PROD_COND_EELSIF] = 2085 + [PROD_COND_EELS] = 2086 + [PROD_SWASP_CASE] = 2087 + [PROD_SWASP_CASE1] = 2088 + [PROD_TERM_EXPR] = 2089 + [PROD_DEFAULT] = 2090 + [PROD_ITERATIVE] = 2091 + [PROD_LOOP_FIG1] = 2092 + [PROD_REL_EXPR1] = 2093 + [PROD_LOOP_FIG2] = 2094 + [PROD_INCREM_DECREM] = 2095 + [PROD_VAR] = 2096 + [PROD_UNARY_OP] = 2097 + [PROD_SUB_FUNCTION] = 2098 + [PROD_FUNC_INSIDE] = 2099 + [PROD_FUNC_ARGS] = 2100 + [PROD_MULTIFUNC_ARGS] = 2101 + [PROD_RESULT] = 2102 + [PROD_FIG_TAIL] = 2103 + [PROD_RESULT_TAIL] = 2104 +End Enum diff --git a/Zootopia_Compiler/SyntaxInitializer.vb b/Zootopia_Compiler/SyntaxInitializer.vb new file mode 100644 index 0000000..aef2432 --- /dev/null +++ b/Zootopia_Compiler/SyntaxInitializer.vb @@ -0,0 +1,155 @@ +Imports System +Imports System.IO +Imports TokenLibrary.TokenLibrary +Imports Core.Library + + + +Public Class SyntaxInitializer + Inherits SyntaxAnalyzer + + Public Class Tokens + Dim line As Integer + Dim token As String + Dim lexeme As String + Dim attribute As String + Public Sub setLine(ByVal line As Integer) + Me.line = line + End Sub + Public Sub setToken(ByVal token As String) + Me.token = token + End Sub + Public Sub setLexeme(ByVal lexeme As String) + Me.lexeme = lexeme + End Sub + Public Sub setAttrib(ByVal attribute As String) + Me.attribute = attribute + End Sub + Public Function getLine() As Integer + Return Me.line + End Function + Public Function getToken() As String + Return Me.token + End Function + Public Function getLexeme() As String + Return Me.lexeme + End Function + Public Function getAttrib() As String + Return Me.attribute + End Function + End Class + + + Public production As String = "" + Public recursiveprod As String = "" + Dim currparent As Node + Dim prevparent As New List(Of Node)() + + Public Overrides Sub Enter(ByVal node As Node) + Dim name As String = node.GetName + If (name.Contains("prod_")) Then + + node.SetParent(currparent) + name = name.Substring(5) + + If (IsNothing(currparent) <> True) Then + + production += "Enter: <" + name + "> Parent: " + currparent.GetName() + vbNewLine + + Else + + production += "Enter: <" + name + vbNewLine + + prevparent.Add(currparent) + currparent = node + End If + + Else + + node.SetParent(currparent) + production += "Enter: " + name + " Parent: " + currparent.GetName() + vbNewLine + End If + + + + End Sub + + Public Overrides Function [Exit](ByVal node As Node) As Node + If (currparent.Equals(node)) Then + currparent = prevparent(prevparent.Count - 1) + prevparent.RemoveAt(prevparent.Count - 1) + End If + Return node + End Function + + Public errors As ErrorClass = New ErrorClass() + Public Function Start(ByVal tokens As List(Of Tokens)) As String + Dim tokenstream = "" + Dim result As String + Dim line As Integer = 1 + For Each t In tokens + If (t.getLine <> line) Then + line = t.getLine + tokenstream += vbCrLf + t.getToken + " " + Else + tokenstream += t.getToken + " " + End If + Next + + tokenstream = tokenstream.TrimEnd() + + Dim p As Parser + p = CreateParser(tokenstream) + + Try + p.Parse() + Fail("Parsing succeeded") + result = "Syntax Analyzer Run Successfully" + Catch e As ParserCreationException + Fail(e.Message) + result = e.Message + + Catch e As ParserLogException + Dim Message As String = "Expected: " + errors.setColumn(e.GetError(0).Column) + errors.setLines(e.GetError(0).Line) + If (p.GetLastProductionState() = "NULL") Then + + Dim ps As New PredictSet() + Dim code = p.GetLastProductionCode() + Message += ps.GetPredictSet(code) + + Else + For Each item As String In e.GetError(0).Details + Message += item + ", " + Next + End If + Message += "on line: " + errors.getLines().ToString() + "." + result = Message + End Try + recursiveprod = p.GetRecursiveProduction() + Return result + End Function + + Private Function CreateParser(ByVal input As String) As Parser + Dim parser As Parser + + Try + parser = New SyntaxParser(New StringReader(input), Me) + parser.Prepare() + + Catch e As ParserCreationException + Fail(e.Message) + + End Try + + Return parser + End Function + + Protected Sub Fail(ByVal message As String) + If (message = "parsing succeeded") Then + Throw New Exception(message) + End If + End Sub + +End Class \ No newline at end of file diff --git a/Zootopia_Compiler/SyntaxParser.vb b/Zootopia_Compiler/SyntaxParser.vb new file mode 100644 index 0000000..71ffce8 --- /dev/null +++ b/Zootopia_Compiler/SyntaxParser.vb @@ -0,0 +1,1207 @@ +' SyntaxParser.vb +' +' THIS FILE HAS BEEN GENERATED AUTOMATICALLY. DO NOT EDIT! + +Imports System.IO + +Imports Core.Library + +'''A token stream parser. +Public Class SyntaxParser + Inherits RecursiveDescentParser + + '''An enumeration with the generated production node + '''identity constants. + + '''Creates a new parser with a default analyzer. + ''' + '''the input stream to read from + ''' + '''if the parser + '''couldn't be initialized correctly + Public Sub New(ByVal input As TextReader) + MyBase.New(input) + CreatePatterns() + End Sub + + '''Creates a new parser. + ''' + '''the input stream to read from + ''' + '''the analyzer to parse with + ''' + '''if the parser + '''couldn't be initialized correctly + Public Sub New(ByVal input As TextReader, ByVal analyzer As SyntaxAnalyzer) + MyBase.New(input, analyzer) + CreatePatterns() + End Sub + + '''Creates a new tokenizer for this parser. Can be overridden + '''by a subclass to provide a custom implementation. + ''' + '''the input stream to read from + ''' + '''the tokenizer created + ''' + '''if the tokenizer + '''couldn't be initialized correctly + Protected Overrides Function NewTokenizer(ByVal input As TextReader) As Tokenizer + Return New SyntaxTokenizer(input) + End Function + + '''Initializes the parser by creating all the production + '''patterns. + ''' + '''if the parser + '''couldn't be initialized correctly + Private Sub CreatePatterns() + Dim pattern As ProductionPattern + Dim alt As ProductionPatternAlternative + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_PROGRAM), "prod_program") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.ENTRANCE), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_COMMENT), 0, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_GLOBAL_DEC), 0, 1) + alt.AddToken(CInt(SyntaxConstants.MANE), 1, 1) + alt.AddToken(CInt(SyntaxConstants.OP), 1, 1) + alt.AddToken(CInt(SyntaxConstants.CP), 1, 1) + alt.AddToken(CInt(SyntaxConstants.ODC), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_MANE), 0, 1) + alt.AddToken(CInt(SyntaxConstants.CDC), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_SUB_FUNCTION), 0, 1) + alt.AddToken(CInt(SyntaxConstants.EXIT), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_COMMENT), "prod_comment") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.COMSYM), 1, 1) + alt.AddToken(CInt(SyntaxConstants.COMMENT), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_COMMENT), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_GLOBAL_DEC), "prod_global_dec") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_STORK_DEC), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_GLOBAL_DEC), 0, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_CONST_DEC), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_GLOBAL_DEC), 0, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_VAR_DEC), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_GLOBAL_DEC), 0, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.VIPER), 1, 1) + alt.AddToken(CInt(SyntaxConstants.AT), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_FUNC_NAME), 1, 1) + alt.AddToken(CInt(SyntaxConstants.OP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_PARAM), 0, 1) + alt.AddToken(CInt(SyntaxConstants.CP), 1, 1) + alt.AddToken(CInt(SyntaxConstants.TERMI), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_COMMENT), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_VAR_DEC), "prod_var_dec") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_IDENT_VAR), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_FUNC_VAR), 0, 1) + alt.AddToken(CInt(SyntaxConstants.TERMI), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_COMMENT), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_FUNC_VAR), "prod_func_var") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.OP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_PARAM), 0, 1) + alt.AddToken(CInt(SyntaxConstants.CP), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_NEXT2VAR), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_IDENT_VAR), "prod_ident_var") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_DTYPE), 1, 1) + alt.AddToken(CInt(SyntaxConstants.AT), 1, 1) + alt.AddToken(CInt(SyntaxConstants.ID), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_DTYPE), "prod_dtype") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.NEWT), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.DUCK), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.STARLING), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.BULL), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_NEXT2VAR), "prod_next2var") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.COMMA), 1, 1) + alt.AddToken(CInt(SyntaxConstants.ID), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_NEXT2VAR), 0, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.EQUAL), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_VAL), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_NEXT2VAR_TAIL), 0, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_ARRAY1D), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_NEXT2VAR_TAIL), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_NEXT2VAR_TAIL), "prod_next2var_tail") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.COMMA), 1, 1) + alt.AddToken(CInt(SyntaxConstants.ID), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_NEXT2VAR), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_VAL), "prod_val") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_VAL1), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_VAL2), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_VAL1), "prod_val1") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.NEWTLIT), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.DUCKLIT), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_VAL2), "prod_val2") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.STARLIT), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_BUL_LIT), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_BUL_LIT), "prod_bulLit") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.TRUE), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.FALSE), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_ARRAY1D), "prod_array1D") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.OB), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_SIZE), 0, 1) + alt.AddToken(CInt(SyntaxConstants.CB), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_ELEM1D_NEXT), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_ELEM1D_NEXT), "prod_elem1D_next") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.EQUAL), 1, 1) + alt.AddToken(CInt(SyntaxConstants.OC), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_ELEM1D_LIST), 1, 1) + alt.AddToken(CInt(SyntaxConstants.CC), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.OB), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_SIZE), 0, 1) + alt.AddToken(CInt(SyntaxConstants.CB), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_ELEM2D_NEXT), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_ELEM1D_LIST), "prod_elem1D_list") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_VAL), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_ELEMLIST1D_TAIL), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_ELEMLIST1D_TAIL), "prod_elemlist1D_tail") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.COMMA), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_VAL), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_ELEMLIST1D_TAIL), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_ELEM2D_NEXT), "prod_elem2D_next") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.EQUAL), 1, 1) + alt.AddToken(CInt(SyntaxConstants.OC), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_ELEM2D_LIST), 1, 1) + alt.AddToken(CInt(SyntaxConstants.CC), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_ELEM2D_LIST), "prod_elem2D_list") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.OP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_ELEM1D_LIST), 1, 1) + alt.AddToken(CInt(SyntaxConstants.CP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_ELEM2D_LIST_TAIL), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_ELEM2D_LIST_TAIL), "prod_elem2D_list_tail") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.COMMA), 1, 1) + alt.AddToken(CInt(SyntaxConstants.OP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_ELEM1D_LIST), 1, 1) + alt.AddToken(CInt(SyntaxConstants.CP), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_SIZE), "prod_size") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.NEWTLIT), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.ID), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_CONST_DEC), "prod_const_dec") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.LET), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_IDENT_VAR), 1, 1) + alt.AddToken(CInt(SyntaxConstants.EQUAL), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_VAL), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_CONST_NEXT), 0, 1) + alt.AddToken(CInt(SyntaxConstants.TERMI), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_COMMENT), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_CONST_NEXT), "prod_const_next") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.COMMA), 1, 1) + alt.AddToken(CInt(SyntaxConstants.ID), 1, 1) + alt.AddToken(CInt(SyntaxConstants.EQUAL), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_VAL), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_CONST_NEXT), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_FUNC_NAME), "prod_func_name") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.ID), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_PARAM), "prod_param") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_DTYPE), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_PARAM2), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_PARAM2), "prod_param2") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.COMMA), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_DTYPE), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_PARAM2), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_STORK_DEC), "prod_stork_dec") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.STORK), 1, 1) + alt.AddToken(CInt(SyntaxConstants.AT), 1, 1) + alt.AddToken(CInt(SyntaxConstants.ID), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_COMMENT), 0, 1) + alt.AddToken(CInt(SyntaxConstants.ODC), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_STORK_ELEM), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_MULTISTORK_ELEM), 0, 1) + alt.AddToken(CInt(SyntaxConstants.CDC), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_OBJ_DEC), 0, 1) + alt.AddToken(CInt(SyntaxConstants.TERMI), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_COMMENT), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_STORK_ELEM), "prod_stork_elem") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_IDENT_VAR), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_MULTI_VARDEC), 0, 1) + alt.AddToken(CInt(SyntaxConstants.TERMI), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_COMMENT), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_MULTI_VARDEC), "prod_multi_vardec") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.COMMA), 1, 1) + alt.AddToken(CInt(SyntaxConstants.ID), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_MULTI_VARDEC), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_MULTISTORK_ELEM), "prod_multistork_elem") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_STORK_ELEM), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_OBJ_DEC), "prod_obj_dec") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.ID), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_MULTI_VARDEC), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_MANE), "prod_mane") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_LOCAL_DEC), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_STATEMENT), 0, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_STATEMENT), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_LOCAL_DEC), "prod_local_dec") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_IDENT_VAR), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_NEXT2VAR), 0, 1) + alt.AddToken(CInt(SyntaxConstants.TERMI), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_LOCAL_DEC), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_STATEMENT), "prod_statement") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_INPUT), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_STATEMENT), 0, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_COMMENT), 0, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_OUTPUT), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_STATEMENT), 0, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_COMMENT), 0, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_CONDITIONAL), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_STATEMENT), 0, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_COMMENT), 0, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_ITERATIVE), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_STATEMENT), 0, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_COMMENT), 0, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.ID), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_STATE_NEXT), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_STATEMENT), 0, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_CLRSCR), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_STATEMENT), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_STATE_NEXT), "prod_state_next") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_ASSIGN1), 1, 1) + alt.AddToken(CInt(SyntaxConstants.ID), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_SCAN_FIG), 0, 1) + alt.AddToken(CInt(SyntaxConstants.EQUAL), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_NEXT_FIG), 1, 1) + alt.AddToken(CInt(SyntaxConstants.TERMI), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_ASSIGN1), "prod_assign1") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.ID), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_ASSIGN_TAIL), 0, 1) + alt.AddToken(CInt(SyntaxConstants.EQUAL), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_NEXT_FIG), 1, 1) + alt.AddToken(CInt(SyntaxConstants.TERMI), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_ASSIGN_TAIL), "prod_assign_tail") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_SCAN_FIG), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_NEXT_FIG), "prod_next_fig") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_VAL1), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_SCAN_NEXT), 0, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_MATH_EQTAIL1), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.ID), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_NEXT), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_NEXT), "prod_next") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_SCAN_FIG), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_SCAN_NEXT), 0, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.EQUAL), 1, 1) + alt.AddToken(CInt(SyntaxConstants.ID), 1, 1) + alt.AddToken(CInt(SyntaxConstants.CON), 1, 1) + alt.AddToken(CInt(SyntaxConstants.ID), 1, 1) + alt.AddToken(CInt(SyntaxConstants.TERMI), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_FUNC_CALL), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_EXPONENT), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_SCAN_NEXT), "prod_scan_next") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_MATH_OP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_MATH_FIG1), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_MATH_TAIL), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_VALUE_DL), "prod_valueDL") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.STARLIT), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_BUL_LIT), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_FIG), "prod_fig") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.NEWTLIT), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.DUCKLIT), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_FUNC_CALL), "prod_func_call") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.OP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_ARGS1), 0, 1) + alt.AddToken(CInt(SyntaxConstants.CP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_FUNC_NEXT), 0, 1) + alt.AddToken(CInt(SyntaxConstants.TERMI), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_ARGS1), "prod_args1") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_ARG_IN), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_ARGS_TAIL), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_ARGS_TAIL), "prod_args_tail") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.COMMA), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_ARG_IN), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_ARGS_TAIL), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_ARG_IN), "prod_arg_in") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.ID), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_ARR1D), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_VAL), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_FUNC_NEXT), "prod_func_next") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_MATH_OP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_FUNC), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_FUNC), "prod_func") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_NEXT_FIG), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_FUNC_NEXT), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_MATH_EQTAIL), "prod_math_eqtail") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_MATH_EQTAIL1), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_MATH_EQTAIL2), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_MATH_EQTAIL1), "prod_math_eqtail1") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.OP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_MATH_FIG), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_MATH_OP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_MATH_FIG), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_MATHEQ_NEXT), 1, 1) + alt.AddToken(CInt(SyntaxConstants.CP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_EXPONENT), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_MATH_EQTAIL2), "prod_math_eqtail2") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_MATH_FIG1), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_MATH_OP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_MATH_FIG1), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_MATH_TAIL), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_EXPONENT), "prod_exponent") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.EXP), 1, 1) + alt.AddToken(CInt(SyntaxConstants.OP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_MATH_FIG1), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_MATH_OP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_MATH_FIG1), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_MATH_TAIL), 1, 1) + alt.AddToken(CInt(SyntaxConstants.CP), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_MATH_TAIL), "prod_math_tail") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_MATH_OP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_MATH_FIG1), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_MATH_TAIL), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_MATH_OP), "prod_math_op") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.ADD), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.SUB), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.MUL), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.DIV), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.MOD), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_MATH_FIG), "prod_math_fig") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.ID), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_SCAN_FIG), 0, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_VAL1), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_MATH_EQTAIL1), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_MATH_FIG1), "prod_math_fig1") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.ID), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_SCAN_FIG), 0, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_VAL1), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_MATHEQ_NEXT), "prod_matheq_next") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_MATH_OP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_MATH_EQTAIL), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_FUNCTION_CALL), "prod_function_call") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.OP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_ARGS1), 1, 1) + alt.AddToken(CInt(SyntaxConstants.CP), 1, 1) + alt.AddToken(CInt(SyntaxConstants.TERMI), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_CLRSCR), "prod_clrscr") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.WIPE), 1, 1) + alt.AddToken(CInt(SyntaxConstants.TERMI), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_INPUT), "prod_input") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.ZOOIN), 1, 1) + alt.AddToken(CInt(SyntaxConstants.CDA), 1, 1) + alt.AddToken(CInt(SyntaxConstants.ID), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_SCAN_FIG), 0, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_MULTI_INPUT), 0, 1) + alt.AddToken(CInt(SyntaxConstants.TERMI), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_COMMENT), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_SCAN_FIG), "prod_scan_fig") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_ARR1D), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_STORK_ACCESS1), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_MULTI_INPUT), "prod_multi_input") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.CDA), 1, 1) + alt.AddToken(CInt(SyntaxConstants.ID), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_SCAN_FIG), 0, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_MULTI_INPUT), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_ARR1D), "prod_arr1D") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.OB), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_SIZE), 0, 1) + alt.AddToken(CInt(SyntaxConstants.CB), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_ARR2D), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_ARR2D), "prod_arr2D") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.OB), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_SIZE), 0, 1) + alt.AddToken(CInt(SyntaxConstants.CB), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_STORK_ACCESS1), "prod_stork_access1") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.CONC), 1, 1) + alt.AddToken(CInt(SyntaxConstants.ID), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_OUTPUT), "prod_output") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.ZOOUT), 1, 1) + alt.AddToken(CInt(SyntaxConstants.ODA), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_OUT), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_MULTI_OUTPUT), 0, 1) + alt.AddToken(CInt(SyntaxConstants.TERMI), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_OUT), "prod_out") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.ID), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_OUTPUT_NEXT), 0, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_MATH_EQTAIL1), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.STARLIT), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_OUTPUT_NEXT), "prod_output_next") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_MATH_EQTAIL2), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_FUNC_CALL), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_SCAN_FIG), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_MULTI_OUTPUT), "prod_multi_output") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.ODA), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_OUT), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_MULTI_OUTPUT), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_CONDITIONAL), "prod_conditional") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.IF), 1, 1) + alt.AddToken(CInt(SyntaxConstants.OP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_CONDI), 1, 1) + alt.AddToken(CInt(SyntaxConstants.CP), 1, 1) + alt.AddToken(CInt(SyntaxConstants.ODC), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_STATEMENT), 1, 1) + alt.AddToken(CInt(SyntaxConstants.CDC), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_COND_EELSIF), 0, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_COND_EELS), 0, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.SWASP), 1, 1) + alt.AddToken(CInt(SyntaxConstants.OP), 1, 1) + alt.AddToken(CInt(SyntaxConstants.ID), 1, 1) + alt.AddToken(CInt(SyntaxConstants.CP), 1, 1) + alt.AddToken(CInt(SyntaxConstants.ODC), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_SWASP_CASE), 0, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_DEFAULT), 1, 1) + alt.AddToken(CInt(SyntaxConstants.CDC), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_CONDI), "prod_condi") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.OP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_COND_EXPR), 1, 1) + alt.AddToken(CInt(SyntaxConstants.CP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_COND_TAIL), 0, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.EXC), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_NOT_FIG), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_NOT_FIG), "prod_not_fig") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.ID), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_BUL_LIT), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.OP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_COND_EXPR), 1, 1) + alt.AddToken(CInt(SyntaxConstants.CP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_COND_TAIL), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_COND_EXPR), "prod_cond_expr") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_REL_EXPR), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_COND_TAIL), "prod_cond_tail") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_LOG_EXPR), 1, 1) + alt.AddToken(CInt(SyntaxConstants.OP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_COND_EXPR), 1, 1) + alt.AddToken(CInt(SyntaxConstants.CP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_COND_TAIL), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_REL_EXPR), "prod_rel_expr") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_EXPRESSION), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_RELEX_TAIL), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_RELEX_TAIL), "prod_relex_tail") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_REL_OP1), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_EXPRESSION), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_REL_OP2), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_REL_FIG), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_EXPRESSION), "prod_expression") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_VAL1), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.OP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_MATH_FIG), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_MATH_OP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_MATH_FIG), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_MATH_TAIL), 0, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.ID), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_EXPR_NEXT), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_EXPR_NEXT), "prod_expr_next") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_SCAN_FIG), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_SCAN_NEXT), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_REL_OP1), "prod_rel_op1") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.OA), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.CA), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.OAE), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.CAE), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_REL_OP2), "prod_rel_op2") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.EE), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.DE), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_REL_FIG), "prod_rel_fig") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_BUL_LIT), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.NULL), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.ID), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_SCAN_FIG), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.STARLIT), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_LOG_EXPR), "prod_log_expr") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_LOG_OP), 1, 1) + alt.AddToken(CInt(SyntaxConstants.OP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_REL_EXPR), 1, 1) + alt.AddToken(CInt(SyntaxConstants.CP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_LOG_EXPR_NEXT), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_LOG_EXPR_NEXT), "prod_log_expr_next") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_LOG_OP), 1, 1) + alt.AddToken(CInt(SyntaxConstants.OP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_REL_EXPR), 1, 1) + alt.AddToken(CInt(SyntaxConstants.CP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_LOG_EXPR_NEXT), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_LOG_OP), "prod_log_op") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.DAND), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.DOR), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_COND_EELSIF), "prod_cond_eelsif") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.EELSIF), 1, 1) + alt.AddToken(CInt(SyntaxConstants.OP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_CONDI), 1, 1) + alt.AddToken(CInt(SyntaxConstants.CP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_COMMENT), 0, 1) + alt.AddToken(CInt(SyntaxConstants.ODC), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_STATEMENT), 0, 1) + alt.AddToken(CInt(SyntaxConstants.CDC), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_COMMENT), 0, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_COND_EELSIF), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_COND_EELS), "prod_cond_eels") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.EELS), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_COMMENT), 0, 1) + alt.AddToken(CInt(SyntaxConstants.ODC), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_STATEMENT), 0, 1) + alt.AddToken(CInt(SyntaxConstants.CDC), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_COMMENT), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_SWASP_CASE), "prod_swasp_case") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.CHAMOIS), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_TERM_EXPR), 1, 1) + alt.AddToken(CInt(SyntaxConstants.SC), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_STATEMENT), 0, 1) + alt.AddToken(CInt(SyntaxConstants.TERMITE), 1, 1) + alt.AddToken(CInt(SyntaxConstants.TERMI), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_SWASP_CASE1), 0, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_COMMENT), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_SWASP_CASE1), "prod_swasp_case1") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_SWASP_CASE), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_TERM_EXPR), "prod_term_expr") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.NEWTLIT), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.STARLIT), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_DEFAULT), "prod_default") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.SEAL), 1, 1) + alt.AddToken(CInt(SyntaxConstants.TERMI), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_STATEMENT), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_ITERATIVE), "prod_iterative") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.WHALE), 1, 1) + alt.AddToken(CInt(SyntaxConstants.OP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_CONDI), 1, 1) + alt.AddToken(CInt(SyntaxConstants.CP), 1, 1) + alt.AddToken(CInt(SyntaxConstants.ODC), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_STATEMENT), 0, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_LOOP_FIG2), 1, 1) + alt.AddToken(CInt(SyntaxConstants.TERMI), 1, 1) + alt.AddToken(CInt(SyntaxConstants.CDC), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_COMMENT), 0, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.DO), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_COMMENT), 0, 1) + alt.AddToken(CInt(SyntaxConstants.ODC), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_STATEMENT), 0, 1) + alt.AddToken(CInt(SyntaxConstants.CDC), 1, 1) + alt.AddToken(CInt(SyntaxConstants.WHALE), 1, 1) + alt.AddToken(CInt(SyntaxConstants.OP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_CONDI), 1, 1) + alt.AddToken(CInt(SyntaxConstants.CP), 1, 1) + alt.AddToken(CInt(SyntaxConstants.TERMI), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.FUR), 1, 1) + alt.AddToken(CInt(SyntaxConstants.OP), 1, 1) + alt.AddToken(CInt(SyntaxConstants.ID), 1, 1) + alt.AddToken(CInt(SyntaxConstants.EQUAL), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_LOOP_FIG1), 1, 1) + alt.AddToken(CInt(SyntaxConstants.TERMI), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_REL_EXPR1), 1, 1) + alt.AddToken(CInt(SyntaxConstants.TERMI), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_LOOP_FIG2), 1, 1) + alt.AddToken(CInt(SyntaxConstants.CP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_COMMENT), 0, 1) + alt.AddToken(CInt(SyntaxConstants.ODC), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_STATEMENT), 0, 1) + alt.AddToken(CInt(SyntaxConstants.CDC), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_COMMENT), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_LOOP_FIG1), "prod_loop_fig1") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.NEWTLIT), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.ID), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_REL_EXPR1), "prod_rel_expr1") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.ID), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_REL_OP1), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_ARG_IN), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_LOOP_FIG2), "prod_loop_fig2") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_INCREM_DECREM), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_INCREM_DECREM), "prod_increm_decrem") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_UNARY_OP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_VAR), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_VAR), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_UNARY_OP), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_VAR), "prod_var") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_LOOP_FIG1), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_UNARY_OP), "prod_unary_op") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.INCRE), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.DECRE), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_SUB_FUNCTION), "prod_sub_function") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_DTYPE), 1, 1) + alt.AddToken(CInt(SyntaxConstants.AT), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_FUNC_NAME), 1, 1) + alt.AddToken(CInt(SyntaxConstants.OP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_FUNC_ARGS), 0, 1) + alt.AddToken(CInt(SyntaxConstants.CP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_COMMENT), 0, 1) + alt.AddToken(CInt(SyntaxConstants.ODC), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_FUNC_INSIDE), 1, 1) + alt.AddToken(CInt(SyntaxConstants.HOP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_RESULT), 0, 1) + alt.AddToken(CInt(SyntaxConstants.TERMI), 1, 1) + alt.AddToken(CInt(SyntaxConstants.CDC), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_COMMENT), 0, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_SUB_FUNCTION), 0, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.VIPER), 1, 1) + alt.AddToken(CInt(SyntaxConstants.AT), 1, 1) + alt.AddToken(CInt(SyntaxConstants.ID), 1, 1) + alt.AddToken(CInt(SyntaxConstants.OP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_FUNC_ARGS), 0, 1) + alt.AddToken(CInt(SyntaxConstants.CP), 1, 1) + alt.AddToken(CInt(SyntaxConstants.ODC), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_FUNC_INSIDE), 0, 1) + alt.AddToken(CInt(SyntaxConstants.CDC), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_SUB_FUNCTION), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_FUNC_INSIDE), "prod_func_inside") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_LOCAL_DEC), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_STATEMENT), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_FUNC_ARGS), "prod_func_args") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_IDENT_VAR), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_MULTIFUNC_ARGS), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_MULTIFUNC_ARGS), "prod_multifunc_args") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.COMMA), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_FUNC_ARGS), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_RESULT), "prod_result") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_VAL2), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.ID), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_RESULT_TAIL), 0, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.DUCKLIT), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.NEWTLIT), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_MATH_OP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_LOOP_FIG1), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_FIG_TAIL), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_FIG_TAIL), "prod_fig_tail") + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_MATH_OP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_LOOP_FIG1), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_FIG_TAIL), 0, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + + pattern = New ProductionPattern(CInt(SyntaxConstants.PROD_RESULT_TAIL), "prod_result_tail") + alt = New ProductionPatternAlternative() + alt.AddToken(CInt(SyntaxConstants.OP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_ARGS1), 0, 1) + alt.AddToken(CInt(SyntaxConstants.CP), 1, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_MATH_OP), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_LOOP_FIG1), 1, 1) + alt.AddProduction(CInt(SyntaxConstants.PROD_FIG_TAIL), 0, 1) + pattern.AddAlternative(alt) + alt = New ProductionPatternAlternative() + alt.AddProduction(CInt(SyntaxConstants.PROD_ARR1D), 1, 1) + pattern.AddAlternative(alt) + AddPattern(pattern) + End Sub +End Class diff --git a/Zootopia_Compiler/SyntaxTokenizer.vb b/Zootopia_Compiler/SyntaxTokenizer.vb new file mode 100644 index 0000000..86ba952 --- /dev/null +++ b/Zootopia_Compiler/SyntaxTokenizer.vb @@ -0,0 +1,241 @@ +' SyntaxTokenizer.vb +' +' THIS FILE HAS BEEN GENERATED AUTOMATICALLY. DO NOT EDIT! + +Imports System.IO + +Imports Core.Library + +'''A character stream tokenizer. +Public Class SyntaxTokenizer + Inherits Tokenizer + + '''Creates a new tokenizer for the specified input + '''stream. + ''' + '''the input stream to read + ''' + '''if the tokenizer + '''couldn't be initialized correctly + Public Sub New(ByVal input As TextReader) + MyBase.New(input, False) + CreatePatterns() + End Sub + + '''Initializes the tokenizer by creating all the token + '''patterns. + ''' + '''if the tokenizer + '''couldn't be initialized correctly + Private Sub CreatePatterns() + Dim pattern as TokenPattern + + pattern = New TokenPattern(CInt(SyntaxConstants.ENTRANCE), "ENTRANCE", TokenPattern.PatternType.STRING, "entrance") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.EXIT), "EXIT", TokenPattern.PatternType.STRING, "exit") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.MANE), "MANE", TokenPattern.PatternType.STRING, "mane") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.LET), "LET", TokenPattern.PatternType.STRING, "let") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.WIPE), "WIPE", TokenPattern.PatternType.STRING, "wipe") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.ZOOIN), "ZOOIN", TokenPattern.PatternType.STRING, "zooin") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.ZOOUT), "ZOOUT", TokenPattern.PatternType.STRING, "zoout") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.IF), "IF", TokenPattern.PatternType.STRING, "if") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.EELSIF), "EELSIF", TokenPattern.PatternType.STRING, "eelsif") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.EELS), "EELS", TokenPattern.PatternType.STRING, "eels") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.CHAMOIS), "CHAMOIS", TokenPattern.PatternType.STRING, "chamois") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.TERMITE), "TERMITE", TokenPattern.PatternType.STRING, "termite") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.SEAL), "SEAL", TokenPattern.PatternType.STRING, "seal") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.WHALE), "WHALE", TokenPattern.PatternType.STRING, "whale") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.DO), "DO", TokenPattern.PatternType.STRING, "do") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.FUR), "FUR", TokenPattern.PatternType.STRING, "fur") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.HOP), "HOP", TokenPattern.PatternType.STRING, "hop") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.SWASP), "SWASP", TokenPattern.PatternType.STRING, "swasp") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.STORK), "STORK", TokenPattern.PatternType.STRING, "stork") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.AT), "AT", TokenPattern.PatternType.STRING, "at") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.NULL), "NULL", TokenPattern.PatternType.STRING, "null") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.COMSYM), "COMSYM", TokenPattern.PatternType.STRING, "'") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.TERMI), "TERMI", TokenPattern.PatternType.STRING, ":") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.SC), "SC", TokenPattern.PatternType.STRING, ";") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.COMMA), "COMMA", TokenPattern.PatternType.STRING, ",") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.EQUAL), "EQUAL", TokenPattern.PatternType.STRING, "=") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.OB), "OB", TokenPattern.PatternType.STRING, "[") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.CB), "CB", TokenPattern.PatternType.STRING, "]") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.OC), "OC", TokenPattern.PatternType.STRING, "{") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.CC), "CC", TokenPattern.PatternType.STRING, "}") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.OP), "OP", TokenPattern.PatternType.STRING, "(") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.CP), "CP", TokenPattern.PatternType.STRING, ")") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.ODC), "ODC", TokenPattern.PatternType.STRING, "{{") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.CDC), "CDC", TokenPattern.PatternType.STRING, "}}") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.CONC), "CONC", TokenPattern.PatternType.STRING, ".+") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.CON), "CON", TokenPattern.PatternType.STRING, "?") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.ODA), "ODA", TokenPattern.PatternType.STRING, "<<") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.CDA), "CDA", TokenPattern.PatternType.STRING, ">>") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.NEG), "NEG", TokenPattern.PatternType.STRING, "~") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.ADD), "ADD", TokenPattern.PatternType.STRING, "+") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.SUB), "SUB", TokenPattern.PatternType.STRING, "-") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.MUL), "MUL", TokenPattern.PatternType.STRING, "*") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.DIV), "DIV", TokenPattern.PatternType.STRING, "/") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.MOD), "MOD", TokenPattern.PatternType.STRING, "%") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.EXP), "EXP", TokenPattern.PatternType.STRING, "^") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.OA), "OA", TokenPattern.PatternType.STRING, "<") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.CA), "CA", TokenPattern.PatternType.STRING, ">") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.OAE), "OAE", TokenPattern.PatternType.STRING, "<=") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.CAE), "CAE", TokenPattern.PatternType.STRING, ">=") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.EE), "EE", TokenPattern.PatternType.STRING, "!=") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.DE), "DE", TokenPattern.PatternType.STRING, "==") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.EXC), "EXC", TokenPattern.PatternType.STRING, "!") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.DAND), "DAND", TokenPattern.PatternType.STRING, "&&") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.DOR), "DOR", TokenPattern.PatternType.STRING, "||") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.INCRE), "INCRE", TokenPattern.PatternType.STRING, "++") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.DECRE), "DECRE", TokenPattern.PatternType.STRING, "--") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.NEWT), "NEWT", TokenPattern.PatternType.STRING, "newt") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.DUCK), "DUCK", TokenPattern.PatternType.STRING, "duck") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.BULL), "BULL", TokenPattern.PatternType.STRING, "bull") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.STARLING), "STARLING", TokenPattern.PatternType.STRING, "starling") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.VIPER), "VIPER", TokenPattern.PatternType.STRING, "viper") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.NEWTLIT), "NEWTLIT", TokenPattern.PatternType.STRING, "newt literals") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.DUCKLIT), "DUCKLIT", TokenPattern.PatternType.STRING, "duck literals") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.STARLIT), "STARLIT", TokenPattern.PatternType.STRING, "starling literals") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.TRUE), "TRUE", TokenPattern.PatternType.STRING, "true") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.FALSE), "FALSE", TokenPattern.PatternType.STRING, "false") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.ID), "ID", TokenPattern.PatternType.STRING, "id") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.COMMENT), "COMMENT", TokenPattern.PatternType.STRING, "comment") + AddPattern(pattern) + + pattern = New TokenPattern(CInt(SyntaxConstants.WHITESPACE), "WHITESPACE", TokenPattern.PatternType.REGEXP, "[ \t\n\r\s]+") + pattern.Ignore = True + AddPattern(pattern) + End Sub +End Class diff --git a/Zootopia_Compiler/Zootopia_Compiler.vbproj b/Zootopia_Compiler/Zootopia_Compiler.vbproj index 7651fd5..bdf5e01 100644 --- a/Zootopia_Compiler/Zootopia_Compiler.vbproj +++ b/Zootopia_Compiler/Zootopia_Compiler.vbproj @@ -5,14 +5,15 @@ Debug AnyCPU {E5EC999D-71D4-4FD6-B6E0-D1D6AB111463} - WinExe - Zootopia_Compiler.My.MyApplication + Exe + Zootopia_Compiler.Form1 Zootopia_Compiler Zootopia_Compiler 512 - WindowsForms - v4.5.2 + Console + v4.5 true + AnyCPU @@ -94,6 +95,11 @@ Settings.settings True + + + + + @@ -118,6 +124,43 @@ + + + + + + + + + + + + + + + + + + {a371b79e-2c88-40a3-8aa5-3c5731ff607f} + Code Generation + + + {100bf7e7-b634-4e6b-948e-22d0566fb2af} + Core Library + + + {e187009e-0b2b-4569-b16c-c35ef06fdfe1} + SemanticsAnalyzer + + + {c19858d3-1865-438d-afea-d2451a2ca503} + Syntax Analyzer + + + {17d6f07e-f7be-41de-8d3c-1881ee21f14a} + TokenLibrary + + + \ No newline at end of file diff --git a/Code Generation/OutputInitializer.cs b/Code Generation/OutputInitializer.cs new file mode 100644 index 0000000..0bd95c3 --- /dev/null +++ b/Code Generation/OutputInitializer.cs @@ -0,0 +1,87 @@ +using System; +using System.CodeDom.Compiler; +using System.Diagnostics; + +namespace Code_Generation +{ + public class OutputInitializer + { + public string error = ""; + public void Start(string code) + { + CompilerResults cr = ExecuteCode(code); + bool pass; + if (cr.Errors.Count > 0) + { + pass = false; + } + else + { + pass = true; + } + + if (pass) + { + // Display a successful compilation message. + Console.WriteLine("Source {0} built into {1} successfully.", + "Zootopia_Output", cr.PathToAssembly); + var process = Process.Start(cr.PathToAssembly); + + process.WaitForExit(); + process.Close(); + } + else + { + // Display compilation errors. + Console.WriteLine("Errors building {0} into {1}", + "Zootopia_Output", cr.PathToAssembly); + + foreach (CompilerError ce in cr.Errors) + { + error += ce.ErrorText + "\n"; + Console.WriteLine(" {0}", ce.ToString()); + Console.WriteLine(); + } + } + } + + private CompilerResults ExecuteCode(string code) + { + CodeDomProvider provider = null; + CompilerResults cr = null; + provider = CodeDomProvider.CreateProvider("CSharp"); + // Select the code provider based on the input file extension. + + if (provider != null) + { + + // Format the executable file name. + // Build the output assembly path using the current directory + // and _cs.exe or _vb.exe. + + String exeName = String.Format(@"{0}\{1}.exe", + System.Environment.CurrentDirectory, "Zootopia_Output"); + + CompilerParameters cp = new CompilerParameters(); + + // Generate an executable instead of + // a class library. + cp.GenerateExecutable = true; + + // Specify the assembly file name to generate. + cp.OutputAssembly = exeName; + + // Save the assembly as a physical file. + cp.GenerateInMemory = false; + + // Set whether to treat all warnings as errors. + cp.TreatWarningsAsErrors = false; + + // Invoke compilation of the source file. + cr = provider.CompileAssemblyFromSource(cp, code); + + } + return cr; + } + } +} diff --git a/Code Generation/Properties/AssemblyInfo.cs b/Code Generation/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..95b4cd5 --- /dev/null +++ b/Code Generation/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Code Generation")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Code Generation")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("e58302ee-b74f-4b4e-bea8-85eba0c3ffd8")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/CodeGeneration/Code Generation.csproj b/CodeGeneration/Code Translation.csproj similarity index 98% rename from CodeGeneration/Code Generation.csproj rename to CodeGeneration/Code Translation.csproj index f616e28..c388eb3 100644 --- a/CodeGeneration/Code Generation.csproj +++ b/CodeGeneration/Code Translation.csproj @@ -41,7 +41,7 @@ - + diff --git a/CodeGeneration/CodeGenInitialize.cs b/CodeGeneration/CodeTranslator.cs similarity index 89% rename from CodeGeneration/CodeGenInitialize.cs rename to CodeGeneration/CodeTranslator.cs index 43e9e9b..5b67cec 100644 --- a/CodeGeneration/CodeGenInitialize.cs +++ b/CodeGeneration/CodeTranslator.cs @@ -9,12 +9,12 @@ using System.IO; using Semantics_Analyzer; -namespace Code_Generation +namespace Code_Translation { - public class CodeGenInitialize : SyntaxAnalyzer + public class CodeTranslator : SyntaxAnalyzer { - public CodeGenInitialize() + public CodeTranslator() : this(new List(), new Semantics_Analyzer.SemanticsInitializer()) { } public Boolean runtime_error = false; private List tokens; @@ -23,9 +23,10 @@ public CodeGenInitialize() private List index; private List objects; private List task; + private string currscope = "Mane"; - public CodeGenInitialize(List tokens, SemanticsInitializer semantics) + public CodeTranslator(List tokens, SemanticsInitializer semantics) { this.tokens = tokens; this.arrays = semantics.arrays; @@ -64,6 +65,7 @@ public List getAttribute() private bool isAdd; private string input_datatype; private bool isDec; + private bool isMultiOutput; public string Start() { @@ -218,6 +220,7 @@ public override Node ExitZooin(Token node) { if (isAdd) { + isRead = true; isAdd = false; } return node; @@ -230,7 +233,8 @@ public override Node ExitZoout(Token node) { if (isAdd) { - + code += "Console.Write"; + isSay = true; isAdd = false; } return node; @@ -565,7 +569,7 @@ public override Node ExitOdc(Token node) { if (isAdd) { - code += "(\n"; + code += "{\n"; isAdd = false; } return node; @@ -578,7 +582,7 @@ public override Node ExitCdc(Token node) { if (isAdd) { - code += ")\n"; + code += "}\n"; isAdd = false; } return node; @@ -617,7 +621,14 @@ public override Node ExitOda(Token node) { if (isAdd) { - code += "<<"; + if (isMultiOutput) + { + code += " + "; + } + else + { + code += "("; + } isAdd = false; } return node; @@ -630,7 +641,6 @@ public override Node ExitCda(Token node) { if (isAdd) { - code += ">>"; isAdd = false; } return node; @@ -643,7 +653,7 @@ public override Node ExitNeg(Token node) { if (isAdd) { - code += "~"; + code += "-"; isAdd = false; } return node; @@ -961,7 +971,7 @@ public override Node ExitStarlit(Token node) { Tokens t = new Tokens(); t = GetTokens(node.GetStartLine(), node.GetStartColumn()); - code += t.getLexemes(); + code += "\"" + t.getLexemes() + "\""; isAdd = false; } return node; @@ -1002,7 +1012,7 @@ public override Node ExitId(Token node) { Tokens t = new Tokens(); t = GetTokens(node.GetStartLine(), node.GetStartColumn()); - code += " " + t.getLexemes(); + code += " " + t.getLexemes().Remove(0,1); isAdd = false; } return node; @@ -1026,7 +1036,7 @@ public override Node ExitComment(Token node) public override void EnterProdProgram(Production node) { - Console.Clear(); + } @@ -1062,11 +1072,13 @@ public override void ChildProdComment(Production node, Node child) public override void EnterProdGlobalDec(Production node) { + currscope = "Global"; } public override Node ExitProdGlobalDec(Production node) { + currscope = "Mane"; return node; } @@ -1560,6 +1572,7 @@ public override void EnterProdMane(Production node) public override Node ExitProdMane(Production node) { + code += "\nConsole.ReadKey();\n"; return node; } @@ -1594,6 +1607,7 @@ public override void EnterProdStatement(Production node) public override Node ExitProdStatement(Production node) { + return node; } @@ -1662,6 +1676,7 @@ public override void EnterProdNextFig(Production node) public override Node ExitProdNextFig(Production node) { + return node; } @@ -1747,22 +1762,7 @@ public override void EnterProdMathEqtail1(Production node) public override Node ExitProdMathEqtail1(Production node) { - Node math = node.GetChildAt(1); - Node mathfig = math.GetChildAt(0); - if (mathfig.GetName() == "ID") - { - - } - else if (mathfig.GetName() == "prod_va1") - { - - } - else - { - - } - - + return node; } @@ -1943,103 +1943,117 @@ public override void EnterProdInput(Production node) { } - + public override Node ExitProdInput(Production node) { - //Node input = node.GetChildAt(1); - //Tokens token; - //if (input.GetName() == "CDA") + + return node; + //if (!runtime_error) //{ - // Node ident = node.GetChildAt(2); - // int idline = ident.GetStartLine(); - // int idcol = ident.GetStartColumn(); - // token = GetTokens(idline, idcol); - // foreach (var item in identifiers) + // Node isRead = node.GetChildAt(0); + // if (isRead.GetName() == "READ") // { - // if (item.getId() == token.getLexemes()) + // Node id = node.GetChildAt(1); + // int idcol = id.GetStartColumn(); + // int idline = id.GetStartLine(); + // Tokens token = GetTokens(idline, idcol); + // foreach (var item in identifiers) // { - // var ins = (String)Console.ReadLine(); - // if (String.IsNullOrEmpty(ins)) + // if (item.getId() == token.getLexemes()) // { - // ins = Console.ReadLine(); - // } - // string dtype = item.getDtype(); - // bool isneg = false; - // switch (dtype) - // { - - // case "Newt": - // int input_int = 0; - // if (ins.Contains("~")) - // { - // isneg = true; - // ins = ins.Remove(0, 1); - // } - // if (Int32.TryParse(ins, out input_int)) - // { - // if (isneg) + // var input = (String)Console.ReadLine(); + // if(String.IsNullOrEmpty(input)) + // { + + // input = Console.ReadLine(); + // } + // string dtype = item.getDtype(); + // bool isneg = false; + // switch (dtype) + // { + // case "Int": + // int input_int = 0; + // if (input.Contains("~")) // { - // input_int *= -1; + // isneg = true; + // input = input.Remove(0, 1); // } - // item.setValue(input_int.ToString()); - // } - // else - // { - // runtime_error = true; - // Console.WriteLine(""); - // Console.WriteLine("Runtime Error: Type Mismatch"); - // } - // break; - // case "Duck": - // double input_double = 0.0; - // if (ins.Contains("~")) - // { - // isneg = true; - // ins = ins.Remove(0, 1); - // } - // if (Double.TryParse(ins, out input_double)) - // { - // if (isneg) + // if (Int32.TryParse(input, out input_int)) // { - // input_double *= -1; + // if (isneg) + // { + // input_int *= -1; + // } + // item.setValue(input_int.ToString()); // } - // item.setValue(input_double.ToString()); - // } - // else - // { - // runtime_error = true; - // Console.WriteLine(""); - // Console.WriteLine("Runtime Error: Type Mismatch"); - // } - // break; - // case "Bull": - // if (ins == "true" || ins == "false") - // { - // item.setValue(ins); - // } - // else - // { - // runtime_error = true; - // Console.WriteLine(""); - // Console.WriteLine("Runtime Error: Type Mismatch"); - // } - // break; - // case "Starling": - // item.setValue(ins); - // break; - // } + // else + // { + // runtime_error = true; + // Console.WriteLine(""); + // Console.WriteLine("Runtime error: Type mismatch!"); - // } - // } + // } + // break; + // case "Double": + // double input_double = 0; + // if (input.Contains("~")) + // { + // isneg = true; + // input = input.Remove(0, 1); + // } + // if (Double.TryParse(input, out input_double)) + // { + // if (isneg) + // { + // input_double *= -1; + // } + // item.setValue(input_double.ToString()); + // } + // else + // { + // runtime_error = true; + // Console.WriteLine(""); + // Console.WriteLine("Runtime error: Type mismatch!"); + // } - //} + // break; + // - return node; } - + public override void ChildProdInput(Production node, Node child) { + if (child.GetName() == "ID") + { + Tokens t = new Tokens(); + t = GetTokens(child.GetStartLine(), child.GetStartColumn()); + //t = tokens[t.getCode()]; + string input_datatype = ""; + + foreach (var item in identifiers) + { + if (item.getScope() == currscope) + { + if (item.getId() == t.getLexemes()) + { + input_datatype = item.getDtype(); + } + } + } + + switch (input_datatype) + { + case "Newt": code += " = Int32.Parse(Console.ReadLine())"; break; + case "Duck": code += " = Double.Parse(Console.ReadLine())"; break; + case "Char": code += " = Char.Parse(Console.ReadLine())"; break; + case "Starling": code += " = Console.ReadLine()"; break; + case "Bull": code += " = Boolean.Parse(Console.ReadLine())"; break; + default: + break; + } + + } node.AddChild(child); } @@ -2063,6 +2077,7 @@ public override void ChildProdScanFig(Production node, Node child) public override void EnterProdMultiInput(Production node) { + code += ";\n"; } @@ -2075,6 +2090,36 @@ public override Node ExitProdMultiInput(Production node) public override void ChildProdMultiInput(Production node, Node child) { node.AddChild(child); + if (child.GetName() == "ID") + { + Tokens t = new Tokens(); + t = GetTokens(child.GetStartLine(), child.GetStartColumn()); + //t = tokens[t.getCode()]; + string input_datatype = ""; + + foreach (var item in identifiers) + { + if (item.getScope() == currscope) + { + if (item.getId() == t.getLexemes()) + { + input_datatype = item.getDtype(); + } + } + } + + switch (input_datatype) + { + case "Newt": code += " = Int32.Parse(Console.ReadLine())"; break; + case "Duck": code += " = Double.Parse(Console.ReadLine())"; break; + case "Char": code += " = Char.Parse(Console.ReadLine())"; break; + case "Starling": code += " = Console.ReadLine()"; break; + case "Bull": code += " = Boolean.Parse(Console.ReadLine())"; break; + default: + break; + } + + } } @@ -2143,6 +2188,11 @@ public override Node ExitProdOutput(Production node) public override void ChildProdOutput(Production node, Node child) { node.AddChild(child); + if (child.GetName() == "TERMI") + { + code = code.Remove(code.Length - 2, 2); + code += ");\n"; + } } @@ -2193,11 +2243,13 @@ public override void ChildProdOut(Production node, Node child) public override void EnterProdMultiOutput(Production node) { + isMultiOutput = true; } public override Node ExitProdMultiOutput(Production node) { + isMultiOutput = false; return node; } diff --git a/SemanticsAnalyzer/SemanticsInitializer.cs b/SemanticsAnalyzer/SemanticsInitializer.cs index 6eb3539..1cb17ca 100644 --- a/SemanticsAnalyzer/SemanticsInitializer.cs +++ b/SemanticsAnalyzer/SemanticsInitializer.cs @@ -974,7 +974,7 @@ public override void ChildProdMane(Production node, Node child) public override void EnterProdLocalDec(Production node) { - currscope = "Local"; + currscope = "Mane"; } diff --git a/Syntax Analyzer/SyntaxAnalyzer.cs b/Syntax Analyzer/SyntaxAnalyzer.cs index c1ad7af..f115fce 100644 --- a/Syntax Analyzer/SyntaxAnalyzer.cs +++ b/Syntax Analyzer/SyntaxAnalyzer.cs @@ -1,11 +1,25 @@ - +/* + * SyntaxAnalyzer.cs + * + * THIS FILE HAS BEEN GENERATED AUTOMATICALLY. DO NOT EDIT! + */ using Core.Library; - +/** + * A class providing callback methods for the + * parser. + */ public abstract class SyntaxAnalyzer : Analyzer { - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public override void Enter(Node node) { switch (node.Id) { case (int) SyntaxConstants.ENTRANCE: @@ -140,9 +154,9 @@ public override void Enter(Node node) { case (int) SyntaxConstants.MOD: EnterMod((Token) node); break; - //case (int) SyntaxConstants.EXP: - // EnterExp((Token) node); - // break; + case (int) SyntaxConstants.EXP: + EnterExp((Token) node); + break; case (int) SyntaxConstants.OA: EnterOa((Token) node); break; @@ -497,7 +511,17 @@ public override void Enter(Node node) { } } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public override Node Exit(Node node) { switch (node.Id) { case (int) SyntaxConstants.ENTRANCE: @@ -588,8 +612,8 @@ public override Node Exit(Node node) { return ExitDiv((Token) node); case (int) SyntaxConstants.MOD: return ExitMod((Token) node); - //case (int) SyntaxConstants.EXP: - // return ExitExp((Token) node); + case (int) SyntaxConstants.EXP: + return ExitExp((Token) node); case (int) SyntaxConstants.OA: return ExitOa((Token) node); case (int) SyntaxConstants.CA: @@ -828,7 +852,16 @@ public override Node Exit(Node node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public override void Child(Production node, Node child) { switch (node.Id) { case (int) SyntaxConstants.PROD_PROGRAM: @@ -1116,1930 +1149,5530 @@ public override void Child(Production node, Node child) { } } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterEntrance(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitEntrance(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterExit(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitExit(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterMane(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitMane(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterLet(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitLet(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterWipe(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitWipe(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterZooin(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitZooin(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterZoout(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitZoout(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterIf(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitIf(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterEelsif(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitEelsif(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterEels(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitEels(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterChamois(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitChamois(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterTermite(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitTermite(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterSeal(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitSeal(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterWhale(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitWhale(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterDo(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitDo(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterFur(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitFur(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterHop(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitHop(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterSwasp(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitSwasp(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterStork(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitStork(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterAt(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitAt(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterNull(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitNull(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterComsym(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitComsym(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterTermi(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitTermi(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterSc(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitSc(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterComma(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitComma(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterEqual(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitEqual(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterOb(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitOb(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterCb(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitCb(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterOc(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitOc(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterCc(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitCc(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterOp(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitOp(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterCp(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitCp(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterOdc(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitOdc(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterCdc(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitCdc(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterConc(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitConc(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterCon(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitCon(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterOda(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitOda(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterCda(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitCda(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterNeg(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitNeg(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterAdd(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitAdd(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterSub(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitSub(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterMul(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitMul(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterDiv(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitDiv(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterMod(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitMod(Token node) { return node; } - - //public virtual void EnterExp(Token node) { - //} - - - //public virtual Node ExitExp(Token node) { - // return node; - //} - - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterExp(Token node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitExp(Token node) { + return node; + } + + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterOa(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitOa(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterCa(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitCa(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterOae(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitOae(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterCae(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitCae(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterEe(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitEe(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterDe(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitDe(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterExc(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitExc(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterDand(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitDand(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterDor(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitDor(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterIncre(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitIncre(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterDecre(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitDecre(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterNewt(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitNewt(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterDuck(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitDuck(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterBull(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitBull(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterStarling(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitStarling(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterViper(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitViper(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterNewtlit(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitNewtlit(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterDucklit(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitDucklit(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterStarlit(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitStarlit(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterTrue(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitTrue(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterFalse(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitFalse(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterId(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitId(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterComment(Token node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitComment(Token node) { return node; } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdProgram(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdProgram(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdProgram(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdComment(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdComment(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdComment(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdGlobalDec(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdGlobalDec(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdGlobalDec(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdVarDec(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdVarDec(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdVarDec(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdFuncVar(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdFuncVar(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdFuncVar(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdIdentVar(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdIdentVar(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdIdentVar(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdDtype(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdDtype(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdDtype(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdNext2var(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdNext2var(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdNext2var(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdNext2varTail(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdNext2varTail(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdNext2varTail(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdVal(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdVal(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdVal(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdVal1(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdVal1(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdVal1(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdVal2(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdVal2(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdVal2(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdBulLit(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdBulLit(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdBulLit(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdArray1d(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdArray1d(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdArray1d(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdElem1dNext(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdElem1dNext(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdElem1dNext(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdElem1dList(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdElem1dList(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdElem1dList(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdElemlist1dTail(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdElemlist1dTail(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdElemlist1dTail(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdElem2dNext(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdElem2dNext(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdElem2dNext(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdElem2dList(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdElem2dList(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdElem2dList(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdElem2dListTail(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdElem2dListTail(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdElem2dListTail(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdSize(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdSize(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdSize(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdConstDec(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdConstDec(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdConstDec(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdConstNext(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdConstNext(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdConstNext(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdFuncName(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdFuncName(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdFuncName(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdParam(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdParam(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdParam(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdParam2(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdParam2(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdParam2(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdStorkDec(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdStorkDec(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdStorkDec(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdStorkElem(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdStorkElem(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdStorkElem(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdMultiVardec(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdMultiVardec(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdMultiVardec(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdMultistorkElem(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdMultistorkElem(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdMultistorkElem(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdObjDec(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdObjDec(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdObjDec(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdMane(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdMane(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdMane(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdLocalDec(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdLocalDec(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdLocalDec(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdStatement(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdStatement(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdStatement(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdStateNext(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdStateNext(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdStateNext(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdAssign1(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdAssign1(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdAssign1(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdAssignTail(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdAssignTail(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdAssignTail(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdNextFig(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdNextFig(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdNextFig(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdMathEqtail1(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdMathEqtail1(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdMathEqtail1(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdMathEqtail2(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdMathEqtail2(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdMathEqtail2(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdMathTail(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdMathTail(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdMathTail(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdMathOp(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdMathOp(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdMathOp(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdMathFig(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdMathFig(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdMathFig(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdMathFig1(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdMathFig1(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdMathFig1(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdMatheqNext(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdMatheqNext(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdMatheqNext(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdFunctionCall(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdFunctionCall(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdFunctionCall(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdScanNext(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdScanNext(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdScanNext(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdArgs1(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdArgs1(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdArgs1(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdArgsTail(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdArgsTail(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdArgsTail(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdArgIn(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdArgIn(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdArgIn(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdClrscr(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdClrscr(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdClrscr(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdInput(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdInput(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdInput(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdScanFig(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdScanFig(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdScanFig(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdMultiInput(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdMultiInput(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdMultiInput(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdArr1d(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdArr1d(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdArr1d(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdArr2d(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdArr2d(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdArr2d(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdStorkAccess1(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdStorkAccess1(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdStorkAccess1(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdOutput(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdOutput(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdOutput(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdOut(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdOut(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdOut(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdMultiOutput(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdMultiOutput(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdMultiOutput(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdConditional(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdConditional(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdConditional(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdCondi(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdCondi(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdCondi(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdNotFig(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdNotFig(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdNotFig(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdCondExpr(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdCondExpr(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdCondExpr(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdCondTail(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdCondTail(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdCondTail(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdRelExpr(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdRelExpr(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdRelExpr(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdRelexTail(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdRelexTail(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdRelexTail(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdExpression(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdExpression(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdExpression(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdRelOp1(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdRelOp1(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdRelOp1(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdRelOp2(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdRelOp2(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdRelOp2(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdRelFig(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdRelFig(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdRelFig(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdLogExpr(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdLogExpr(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdLogExpr(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdLogExprNext(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdLogExprNext(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdLogExprNext(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdLogOp(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdLogOp(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdLogOp(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdCondEelsif(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdCondEelsif(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdCondEelsif(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdCondEels(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdCondEels(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdCondEels(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdSwaspCase(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdSwaspCase(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdSwaspCase(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdSwaspCase1(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdSwaspCase1(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdSwaspCase1(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdTermExpr(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdTermExpr(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdTermExpr(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdDefault(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdDefault(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdDefault(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdIterative(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdIterative(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdIterative(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdLoopFig1(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdLoopFig1(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdLoopFig1(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdRelExpr1(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdRelExpr1(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdRelExpr1(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdLoopFig2(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdLoopFig2(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdLoopFig2(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdIncremDecrem(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdIncremDecrem(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdIncremDecrem(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdVar(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdVar(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdVar(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdUnaryOp(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdUnaryOp(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdUnaryOp(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdSubFunction(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdSubFunction(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdSubFunction(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdFuncInside(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdFuncInside(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdFuncInside(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdFuncArgs(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdFuncArgs(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdFuncArgs(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdMultifuncArgs(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdMultifuncArgs(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdMultifuncArgs(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdResult(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdResult(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdResult(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdFigTail(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdFigTail(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdFigTail(Production node, Node child) { node.AddChild(child); } - + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ public virtual void EnterProdResultTail(Production node) { } - + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ public virtual Node ExitProdResultTail(Production node) { return node; } - + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ public virtual void ChildProdResultTail(Production node, Node child) { node.AddChild(child); } diff --git a/Syntax Analyzer/SyntaxParser.cs b/Syntax Analyzer/SyntaxParser.cs index 73e87e7..1369ca5 100644 --- a/Syntax Analyzer/SyntaxParser.cs +++ b/Syntax Analyzer/SyntaxParser.cs @@ -818,9 +818,6 @@ private void CreatePatterns() { "prod_cond_tail"); alt = new ProductionPatternAlternative(); alt.AddProduction((int) SyntaxConstants.PROD_LOG_EXPR, 1, 1); - alt.AddToken((int) SyntaxConstants.OP, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_COND_EXPR, 1, 1); - alt.AddToken((int) SyntaxConstants.CP, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_COND_TAIL, 0, 1); pattern.AddAlternative(alt); AddPattern(pattern); diff --git a/Zootopia_Compiler.sln b/Zootopia_Compiler.sln index 291eb14..743e59d 100644 --- a/Zootopia_Compiler.sln +++ b/Zootopia_Compiler.sln @@ -13,7 +13,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Syntax Analyzer", "Syntax A EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SemanticsAnalyzer", "SemanticsAnalyzer\SemanticsAnalyzer.csproj", "{E187009E-0B2B-4569-B16C-C35EF06FDFE1}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Code Generation", "CodeGeneration\Code Generation.csproj", "{A371B79E-2C88-40A3-8AA5-3C5731FF607F}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Code Translation", "CodeGeneration\Code Translation.csproj", "{A371B79E-2C88-40A3-8AA5-3C5731FF607F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Code Generation", "Code Generation\Code Generation.csproj", "{E58302EE-B74F-4B4E-BEA8-85EBA0C3FFD8}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -45,6 +47,10 @@ Global {A371B79E-2C88-40A3-8AA5-3C5731FF607F}.Debug|Any CPU.Build.0 = Debug|Any CPU {A371B79E-2C88-40A3-8AA5-3C5731FF607F}.Release|Any CPU.ActiveCfg = Release|Any CPU {A371B79E-2C88-40A3-8AA5-3C5731FF607F}.Release|Any CPU.Build.0 = Release|Any CPU + {E58302EE-B74F-4B4E-BEA8-85EBA0C3FFD8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E58302EE-B74F-4B4E-BEA8-85EBA0C3FFD8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E58302EE-B74F-4B4E-BEA8-85EBA0C3FFD8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E58302EE-B74F-4B4E-BEA8-85EBA0C3FFD8}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Zootopia_Compiler/Form1.Designer.vb b/Zootopia_Compiler/Form1.Designer.vb index 852ac54..b0cd902 100644 --- a/Zootopia_Compiler/Form1.Designer.vb +++ b/Zootopia_Compiler/Form1.Designer.vb @@ -22,6 +22,7 @@ Partial Class Form1 'Do not modify it using the code editor. Private Sub InitializeComponent() + Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form1)) Me.rTBCode = New System.Windows.Forms.RichTextBox() Me.dGridLexi = New System.Windows.Forms.ListView() Me.Number = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) @@ -34,14 +35,10 @@ Partial Class Form1 Me.ColumnHeader3 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) Me.ColumnHeader1 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) Me.Panel1 = New System.Windows.Forms.Panel() - Me.Panel3 = New System.Windows.Forms.Panel() Me.Label1 = New System.Windows.Forms.Label() - Me.PictureBox1 = New System.Windows.Forms.PictureBox() Me.dGridBoard = New System.Windows.Forms.ListView() Me.ColumnHeader = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) Me.ColumnHeader17 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) - Me.lineNum = New System.Windows.Forms.PictureBox() - Me.btnAna = New System.Windows.Forms.Button() Me.dGridIden = New System.Windows.Forms.ListView() Me.ColumnHeader7 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) Me.ColumnHeader8 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) @@ -60,9 +57,18 @@ Partial Class Form1 Me.ColumnHeader6 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) Me.dGridSemantic = New System.Windows.Forms.ListView() Me.btnClr = New System.Windows.Forms.Button() + Me.Panel3 = New System.Windows.Forms.Panel() + Me.PictureBox1 = New System.Windows.Forms.PictureBox() + Me.lineNum = New System.Windows.Forms.PictureBox() + Me.btnAna = New System.Windows.Forms.Button() + Me.ToolStrip1 = New System.Windows.Forms.ToolStrip() + Me.ToolStripDropDownButton1 = New System.Windows.Forms.ToolStripDropDownButton() + Me.CodeGenerationToolStripMenuItem1 = New System.Windows.Forms.ToolStripMenuItem() + Me.ConsoleOutputToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.Panel1.SuspendLayout() CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.lineNum, System.ComponentModel.ISupportInitialize).BeginInit() + Me.ToolStrip1.SuspendLayout() Me.SuspendLayout() ' 'rTBCode @@ -161,15 +167,6 @@ Partial Class Form1 Me.Panel1.Size = New System.Drawing.Size(165, 458) Me.Panel1.TabIndex = 9 ' - 'Panel3 - ' - Me.Panel3.BackgroundImage = Global.Zootopia_Compiler.My.Resources.Resources.analyzer - Me.Panel3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom - Me.Panel3.Location = New System.Drawing.Point(58, 170) - Me.Panel3.Name = "Panel3" - Me.Panel3.Size = New System.Drawing.Size(49, 198) - Me.Panel3.TabIndex = 10 - ' 'Label1 ' Me.Label1.AutoSize = True @@ -178,16 +175,6 @@ Partial Class Form1 Me.Label1.Size = New System.Drawing.Size(0, 13) Me.Label1.TabIndex = 10 ' - 'PictureBox1 - ' - Me.PictureBox1.BackgroundImage = Global.Zootopia_Compiler.My.Resources.Resources.Zoo_whale - Me.PictureBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom - Me.PictureBox1.Location = New System.Drawing.Point(10, 12) - Me.PictureBox1.Name = "PictureBox1" - Me.PictureBox1.Size = New System.Drawing.Size(142, 139) - Me.PictureBox1.TabIndex = 10 - Me.PictureBox1.TabStop = False - ' 'dGridBoard ' Me.dGridBoard.BackColor = System.Drawing.SystemColors.ControlLightLight @@ -214,32 +201,6 @@ Partial Class Form1 Me.ColumnHeader17.Text = "board_name" Me.ColumnHeader17.Width = 84 ' - 'lineNum - ' - Me.lineNum.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(191, Byte), Integer), CType(CType(79, Byte), Integer)) - Me.lineNum.Location = New System.Drawing.Point(190, 11) - Me.lineNum.Name = "lineNum" - Me.lineNum.Size = New System.Drawing.Size(30, 446) - Me.lineNum.TabIndex = 8 - Me.lineNum.TabStop = False - ' - 'btnAna - ' - Me.btnAna.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(191, Byte), Integer), CType(CType(79, Byte), Integer)) - Me.btnAna.FlatAppearance.MouseDownBackColor = System.Drawing.Color.DarkOrange - Me.btnAna.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Orange - Me.btnAna.FlatStyle = System.Windows.Forms.FlatStyle.Flat - Me.btnAna.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) - Me.btnAna.ForeColor = System.Drawing.Color.White - Me.btnAna.Image = Global.Zootopia_Compiler.My.Resources.Resources.analyze - Me.btnAna.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft - Me.btnAna.Location = New System.Drawing.Point(1, 463) - Me.btnAna.Name = "btnAna" - Me.btnAna.Size = New System.Drawing.Size(360, 57) - Me.btnAna.TabIndex = 3 - Me.btnAna.Text = "Analyze" - Me.btnAna.UseVisualStyleBackColor = False - ' 'dGridIden ' Me.dGridIden.BackColor = System.Drawing.SystemColors.ControlLightLight @@ -371,12 +332,92 @@ Partial Class Form1 Me.btnClr.Text = "Clear" Me.btnClr.UseVisualStyleBackColor = False ' + 'Panel3 + ' + Me.Panel3.BackgroundImage = Global.Zootopia_Compiler.My.Resources.Resources.analyzer + Me.Panel3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom + Me.Panel3.Location = New System.Drawing.Point(58, 170) + Me.Panel3.Name = "Panel3" + Me.Panel3.Size = New System.Drawing.Size(49, 198) + Me.Panel3.TabIndex = 10 + ' + 'PictureBox1 + ' + Me.PictureBox1.BackgroundImage = Global.Zootopia_Compiler.My.Resources.Resources.Zoo_whale + Me.PictureBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom + Me.PictureBox1.Location = New System.Drawing.Point(10, 12) + Me.PictureBox1.Name = "PictureBox1" + Me.PictureBox1.Size = New System.Drawing.Size(142, 139) + Me.PictureBox1.TabIndex = 10 + Me.PictureBox1.TabStop = False + ' + 'lineNum + ' + Me.lineNum.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(191, Byte), Integer), CType(CType(79, Byte), Integer)) + Me.lineNum.Location = New System.Drawing.Point(190, 11) + Me.lineNum.Name = "lineNum" + Me.lineNum.Size = New System.Drawing.Size(30, 446) + Me.lineNum.TabIndex = 8 + Me.lineNum.TabStop = False + ' + 'btnAna + ' + Me.btnAna.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(191, Byte), Integer), CType(CType(79, Byte), Integer)) + Me.btnAna.FlatAppearance.MouseDownBackColor = System.Drawing.Color.DarkOrange + Me.btnAna.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Orange + Me.btnAna.FlatStyle = System.Windows.Forms.FlatStyle.Flat + Me.btnAna.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.btnAna.ForeColor = System.Drawing.Color.White + Me.btnAna.Image = Global.Zootopia_Compiler.My.Resources.Resources.analyze + Me.btnAna.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft + Me.btnAna.Location = New System.Drawing.Point(1, 463) + Me.btnAna.Name = "btnAna" + Me.btnAna.Size = New System.Drawing.Size(360, 57) + Me.btnAna.TabIndex = 3 + Me.btnAna.Text = "Analyze" + Me.btnAna.UseVisualStyleBackColor = False + ' + 'ToolStrip1 + ' + Me.ToolStrip1.Dock = System.Windows.Forms.DockStyle.Bottom + Me.ToolStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToolStripDropDownButton1}) + Me.ToolStrip1.Location = New System.Drawing.Point(0, 540) + Me.ToolStrip1.Name = "ToolStrip1" + Me.ToolStrip1.Size = New System.Drawing.Size(1100, 25) + Me.ToolStrip1.TabIndex = 44 + Me.ToolStrip1.Text = "ToolStrip1" + ' + 'ToolStripDropDownButton1 + ' + Me.ToolStripDropDownButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image + Me.ToolStripDropDownButton1.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ConsoleOutputToolStripMenuItem, Me.CodeGenerationToolStripMenuItem1}) + Me.ToolStripDropDownButton1.Image = CType(resources.GetObject("ToolStripDropDownButton1.Image"), System.Drawing.Image) + Me.ToolStripDropDownButton1.ImageTransparentColor = System.Drawing.Color.Magenta + Me.ToolStripDropDownButton1.Name = "ToolStripDropDownButton1" + Me.ToolStripDropDownButton1.Size = New System.Drawing.Size(29, 22) + Me.ToolStripDropDownButton1.Text = "ToolStripDropDownButton1" + ' + 'CodeGenerationToolStripMenuItem1 + ' + Me.CodeGenerationToolStripMenuItem1.Checked = True + Me.CodeGenerationToolStripMenuItem1.CheckState = System.Windows.Forms.CheckState.Checked + Me.CodeGenerationToolStripMenuItem1.Name = "CodeGenerationToolStripMenuItem1" + Me.CodeGenerationToolStripMenuItem1.Size = New System.Drawing.Size(162, 22) + Me.CodeGenerationToolStripMenuItem1.Text = "Code generation" + ' + 'ConsoleOutputToolStripMenuItem + ' + Me.ConsoleOutputToolStripMenuItem.Name = "ConsoleOutputToolStripMenuItem" + Me.ConsoleOutputToolStripMenuItem.Size = New System.Drawing.Size(162, 22) + Me.ConsoleOutputToolStripMenuItem.Text = "Console output" + ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.BackColor = System.Drawing.Color.White - Me.ClientSize = New System.Drawing.Size(1100, 541) + Me.ClientSize = New System.Drawing.Size(1100, 565) + Me.Controls.Add(Me.ToolStrip1) Me.Controls.Add(Me.btnClr) Me.Controls.Add(Me.ErrorText) Me.Controls.Add(Me.dGridSemantic) @@ -394,6 +435,8 @@ Partial Class Form1 Me.Panel1.PerformLayout() CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.lineNum, System.ComponentModel.ISupportInitialize).EndInit() + Me.ToolStrip1.ResumeLayout(False) + Me.ToolStrip1.PerformLayout() Me.ResumeLayout(False) Me.PerformLayout() @@ -436,4 +479,8 @@ Partial Class Form1 Friend WithEvents ColumnHeader6 As ColumnHeader Friend WithEvents dGridSemantic As ListView Friend WithEvents btnClr As Button + Friend WithEvents ToolStrip1 As ToolStrip + Friend WithEvents ToolStripDropDownButton1 As ToolStripDropDownButton + Friend WithEvents ConsoleOutputToolStripMenuItem As ToolStripMenuItem + Friend WithEvents CodeGenerationToolStripMenuItem1 As ToolStripMenuItem End Class diff --git a/Zootopia_Compiler/Form1.resx b/Zootopia_Compiler/Form1.resx index 1af7de1..6df57a8 100644 --- a/Zootopia_Compiler/Form1.resx +++ b/Zootopia_Compiler/Form1.resx @@ -117,4 +117,26 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 106, 17 + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 + 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw + bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc + VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 + c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 + Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo + mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ + kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D + TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + + + 25 + \ No newline at end of file diff --git a/Zootopia_Compiler/Form1.vb b/Zootopia_Compiler/Form1.vb index eb21278..500bd74 100644 --- a/Zootopia_Compiler/Form1.vb +++ b/Zootopia_Compiler/Form1.vb @@ -6,9 +6,11 @@ Imports System.CodeDom.Compiler Imports Microsoft.VisualBasic Imports Syntax_Analyzer Imports Core.Library +Imports Code_Translation Imports Code_Generation + Public Class Form1 Public objList As ListViewItem Dim tokee(20000) As String '3 @@ -3137,7 +3139,7 @@ Public Class Form1 symbolCtr += 1 tokens = New TokenLibrary.TokenLibrary.TokenClass tokens.setTokens("newt literals") - tokens.setLexemes("newtlit") + tokens.setLexemes(number) tokens.setAttributes("newtlit") tokens.setLines(line) tokenstream.Add(tokens) @@ -3177,7 +3179,7 @@ Public Class Form1 symbolCtr += 1 tokens = New TokenLibrary.TokenLibrary.TokenClass tokens.setTokens("duck literals") - tokens.setLexemes("ducklit") + tokens.setLexemes(number) tokens.setAttributes("ducklit") tokens.setLines(line) tokenstream.Add(tokens) @@ -3365,11 +3367,22 @@ Public Class Form1 End If - Dim generate As New CodeGenInitialize + Dim generate As New CodeTranslator generate = codeGenStart(tokenDump(tokenstream), semantics) generate.Start() Dim code As String = generate.code - MessageBox.Show(code) + code += vbLf & "}" & vbLf & "}" + If CodeGenerationToolStripMenuItem1.Checked Then + MessageBox.Show(code) + End If + If ConsoleOutputToolStripMenuItem.Checked Then + Dim output As New OutputInitializer + output.Start(code) + If (output.error <> "") Then + MessageBox.Show(output.error, "Woops!") + End If + End If + End Sub Function SemanticStart(ByVal tokens As List(Of Semantics_Analyzer.SemanticsInitializer.Tokens)) As Semantics_Analyzer.SemanticsInitializer @@ -3382,10 +3395,10 @@ Public Class Form1 Return sem End Function - Function codeGenStart(ByVal tokens As List(Of CodeGenInitialize.Tokens), ByVal semantics As Semantics_Analyzer.SemanticsInitializer) As CodeGenInitialize - Dim gen As New CodeGenInitialize + Function codeGenStart(ByVal tokens As List(Of CodeTranslator.Tokens), ByVal semantics As Semantics_Analyzer.SemanticsInitializer) As CodeTranslator + Dim gen As New CodeTranslator Try - gen = New CodeGenInitialize(tokens, semantics) + gen = New CodeTranslator(tokens, semantics) Catch ex As Exception MessageBox.Show(ex.Message) End Try @@ -3407,12 +3420,12 @@ Public Class Form1 Return token End Function - Function tokenDump(ByVal tokens As List(Of TokenLibrary.TokenLibrary.TokenClass)) As List(Of CodeGenInitialize.Tokens) - Dim token As New List(Of CodeGenInitialize.Tokens) - Dim t As New CodeGenInitialize.Tokens + Function tokenDump(ByVal tokens As List(Of TokenLibrary.TokenLibrary.TokenClass)) As List(Of CodeTranslator.Tokens) + Dim token As New List(Of CodeTranslator.Tokens) + Dim t As New CodeTranslator.Tokens For Each item In tokens - t = New CodeGenInitialize.Tokens + t = New CodeTranslator.Tokens t.setAttributes(item.getAttributes) t.setLexemes(item.getLexemes) t.setLines(item.getLines) @@ -6148,6 +6161,24 @@ Public Class Form1 Private Sub dGridIden_SelectedIndexChanged(sender As Object, e As EventArgs) Handles dGridIden.SelectedIndexChanged End Sub + + + + Private Sub CodeGenerationToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles CodeGenerationToolStripMenuItem1.Click + If CodeGenerationToolStripMenuItem1.Checked Then + CodeGenerationToolStripMenuItem1.Checked = False + Else + CodeGenerationToolStripMenuItem1.Checked = True + End If + End Sub + + Private Sub ConsoleOutputToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ConsoleOutputToolStripMenuItem.Click + If ConsoleOutputToolStripMenuItem.Checked Then + ConsoleOutputToolStripMenuItem.Checked = False + Else + ConsoleOutputToolStripMenuItem.Checked = True + End If + End Sub End Class diff --git a/Zootopia_Compiler/My Project/Application.Designer.vb b/Zootopia_Compiler/My Project/Application.Designer.vb index 88dd01c..6dc9325 100644 --- a/Zootopia_Compiler/My Project/Application.Designer.vb +++ b/Zootopia_Compiler/My Project/Application.Designer.vb @@ -11,3 +11,28 @@ Option Strict On Option Explicit On + +Namespace My + + 'NOTE: This file is auto-generated; do not modify it directly. To make changes, + ' or if you encounter build errors in this file, go to the Project Designer + ' (go to Project Properties or double-click the My Project node in + ' Solution Explorer), and make changes on the Application tab. + ' + Partial Friend Class MyApplication + + _ + Public Sub New() + MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows) + Me.IsSingleInstance = false + Me.EnableVisualStyles = true + Me.SaveMySettingsOnExit = true + Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses + End Sub + + _ + Protected Overrides Sub OnCreateMainForm() + Me.MainForm = Global.Zootopia_Compiler.Form1 + End Sub + End Class +End Namespace diff --git a/Zootopia_Compiler/Zootopia_Compiler.vbproj b/Zootopia_Compiler/Zootopia_Compiler.vbproj index 427c2bb..1885c1d 100644 --- a/Zootopia_Compiler/Zootopia_Compiler.vbproj +++ b/Zootopia_Compiler/Zootopia_Compiler.vbproj @@ -5,12 +5,12 @@ Debug AnyCPU {E5EC999D-71D4-4FD6-B6E0-D1D6AB111463} - Exe - Zootopia_Compiler.Form1 + WinExe + Zootopia_Compiler.My.MyApplication Zootopia_Compiler Zootopia_Compiler 512 - Console + WindowsForms v4.5 true @@ -135,10 +135,14 @@ - - {a371b79e-2c88-40a3-8aa5-3c5731ff607f} + + {e58302ee-b74f-4b4e-bea8-85eba0c3ffd8} Code Generation + + {a371b79e-2c88-40a3-8aa5-3c5731ff607f} + Code Translation + {100bf7e7-b634-4e6b-948e-22d0566fb2af} Core Library From 39e0640e5a0c06e744921dd0d0045acec6ef59df Mon Sep 17 00:00:00 2001 From: darylcaguia Date: Sun, 5 Feb 2017 21:26:06 +0800 Subject: [PATCH 04/10] Tweaked Design --- Zootopia_Compiler/Form1.Designer.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zootopia_Compiler/Form1.Designer.vb b/Zootopia_Compiler/Form1.Designer.vb index b0cd902..0d89d54 100644 --- a/Zootopia_Compiler/Form1.Designer.vb +++ b/Zootopia_Compiler/Form1.Designer.vb @@ -395,7 +395,7 @@ Partial Class Form1 Me.ToolStripDropDownButton1.ImageTransparentColor = System.Drawing.Color.Magenta Me.ToolStripDropDownButton1.Name = "ToolStripDropDownButton1" Me.ToolStripDropDownButton1.Size = New System.Drawing.Size(29, 22) - Me.ToolStripDropDownButton1.Text = "ToolStripDropDownButton1" + Me.ToolStripDropDownButton1.Text = "Developer Option" ' 'CodeGenerationToolStripMenuItem1 ' From 096a123a6eddbcfca90642f7ba5178fe6a9dc605 Mon Sep 17 00:00:00 2001 From: darylcaguia Date: Mon, 6 Feb 2017 15:24:50 +0800 Subject: [PATCH 05/10] Code Generation (Switch) --- CodeGeneration/CodeTranslator.cs | 2 +- Syntax Analyzer/SyntaxParser.cs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CodeGeneration/CodeTranslator.cs b/CodeGeneration/CodeTranslator.cs index 5b67cec..284f14b 100644 --- a/CodeGeneration/CodeTranslator.cs +++ b/CodeGeneration/CodeTranslator.cs @@ -452,7 +452,7 @@ public override Node ExitSc(Token node) { if (isAdd) { - code += ";\n"; + code += ":\n"; isAdd = false; } return node; diff --git a/Syntax Analyzer/SyntaxParser.cs b/Syntax Analyzer/SyntaxParser.cs index 1369ca5..a7edb04 100644 --- a/Syntax Analyzer/SyntaxParser.cs +++ b/Syntax Analyzer/SyntaxParser.cs @@ -997,8 +997,10 @@ private void CreatePatterns() { "prod_default"); alt = new ProductionPatternAlternative(); alt.AddToken((int) SyntaxConstants.SEAL, 1, 1); - alt.AddToken((int) SyntaxConstants.TERMI, 1, 1); + alt.AddToken((int) SyntaxConstants.SC, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 0, 1); + alt.AddToken((int) SyntaxConstants.TERMITE, 1, 1); + alt.AddToken((int) SyntaxConstants.TERMI, 1, 1); pattern.AddAlternative(alt); AddPattern(pattern); From 1d396e7f0c47525cbfd59d74d9be8b07997cf907 Mon Sep 17 00:00:00 2001 From: darylcaguia Date: Mon, 6 Feb 2017 21:30:12 +0800 Subject: [PATCH 06/10] Fixed Global Declaration --- CodeGeneration/CodeTranslator.cs | 1 + Zootopia_Compiler/Form1.vb | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CodeGeneration/CodeTranslator.cs b/CodeGeneration/CodeTranslator.cs index 284f14b..bad5741 100644 --- a/CodeGeneration/CodeTranslator.cs +++ b/CodeGeneration/CodeTranslator.cs @@ -157,6 +157,7 @@ public override Node ExitEntrance(Token node) { if (isAdd) { + code += "static "; isAdd = false; } return node; diff --git a/Zootopia_Compiler/Form1.vb b/Zootopia_Compiler/Form1.vb index 500bd74..0a879ef 100644 --- a/Zootopia_Compiler/Form1.vb +++ b/Zootopia_Compiler/Form1.vb @@ -497,7 +497,7 @@ Public Class Form1 If sc(i + 1) = "e" And sc(i + 2) = "l" And sc(i + 3) = "s" Then If sc(i + 1) = "e" And sc(i + 2) = "l" And sc(i + 3) = "s" And sc(i + 4) = "i" Then If sc(i + 1) = "e" And sc(i + 2) = "l" And sc(i + 3) = "s" And sc(i + 4) = "i" And sc(i + 5) = "f" Then - If sc(i + 6) = "(" Then + If sc(i + 6) = "(" Or sc(i + 6) = " " Then symbolCtr += 1 tokens = New TokenLibrary.TokenLibrary.TokenClass tokens.setTokens("eelsif") @@ -755,7 +755,7 @@ Public Class Form1 ElseIf sc(i + 1) = "u" Then If sc(i + 1) = "u" And sc(i + 2) = "r" Then - If sc(i + 3) = "(" Then + If sc(i + 3) = "(" Or sc(i + 3) = " " Then symbolCtr += 1 tokens = New TokenLibrary.TokenLibrary.TokenClass tokens.setTokens("fur") From e6e0b4845ee326e85d87f3254f677827018541b3 Mon Sep 17 00:00:00 2001 From: Mark Daryl Caguia Date: Thu, 9 Feb 2017 16:35:36 +0800 Subject: [PATCH 07/10] Fixed Do-While (Temporarily) --- CodeGeneration/CodeTranslator.cs | 686 +++++++++---------- Core Library/Core Library/SyntaxConstants.cs | 101 ++- SemanticsAnalyzer/SemanticsInitializer.cs | 101 +-- Syntax Analyzer/SyntaxAnalyzer.cs | 226 +----- Syntax Analyzer/SyntaxConstants.cs | 102 ++- Syntax Analyzer/SyntaxParser.cs | 128 +--- Zootopia_Compiler/Form1.vb | 4 +- 7 files changed, 485 insertions(+), 863 deletions(-) diff --git a/CodeGeneration/CodeTranslator.cs b/CodeGeneration/CodeTranslator.cs index bad5741..5cb26ba 100644 --- a/CodeGeneration/CodeTranslator.cs +++ b/CodeGeneration/CodeTranslator.cs @@ -66,6 +66,7 @@ public List getAttribute() private string input_datatype; private bool isDec; private bool isMultiOutput; + private bool isGlobal; public string Start() { @@ -145,7 +146,7 @@ public Tokens GetTokens(int line, int column) } return token; } - + //START TOKENS @@ -157,7 +158,15 @@ public override Node ExitEntrance(Token node) { if (isAdd) { - code += "static "; + //if (isGlobal) + //{ + // code += "static "; + // isAdd = false; + //} + //else + //{ + // isAdd = false; + //} isAdd = false; } return node; @@ -352,7 +361,7 @@ public override Node ExitFur(Token node) { if (isAdd) { - code += "for "; + code += "for "; isAdd = false; } return node; @@ -596,7 +605,7 @@ public override Node ExitConc(Token node) { if (isAdd) { - code += ".+"; + code += "+"; isAdd = false; } return node; @@ -724,7 +733,7 @@ public override Node ExitMod(Token node) } return node; } - public override void EnterOa(Token node) + public override void EnterOa(Token node) { isAdd = true; } @@ -849,7 +858,7 @@ public override Node ExitIncre(Token node) { if (isAdd) { - code += " ++ "; + code += "++"; isAdd = false; } return node; @@ -862,7 +871,7 @@ public override Node ExitDecre(Token node) { if (isAdd) { - code += " -- "; + code += "--"; isAdd = false; } return node; @@ -1013,7 +1022,7 @@ public override Node ExitId(Token node) { Tokens t = new Tokens(); t = GetTokens(node.GetStartLine(), node.GetStartColumn()); - code += " " + t.getLexemes().Remove(0,1); + code += " " + t.getLexemes().Remove(0, 1); isAdd = false; } return node; @@ -1034,797 +1043,784 @@ public override Node ExitComment(Token node) //END TOKENS - + public override void EnterProdProgram(Production node) { - + } - + public override Node ExitProdProgram(Production node) { return node; } - + public override void ChildProdProgram(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdComment(Production node) { } - + public override Node ExitProdComment(Production node) { return node; } - public override void ChildProdComment(Production node, Node child) { node.AddChild(child); } - public override void EnterProdGlobalDec(Production node) { + isGlobal = true; currscope = "Global"; } - public override Node ExitProdGlobalDec(Production node) { + isGlobal = false; currscope = "Mane"; return node; } - public override void ChildProdGlobalDec(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdVarDec(Production node) { + if (currscope == "Global") + { + code += "\npublic static "; + } } - + public override Node ExitProdVarDec(Production node) { return node; } - + public override void ChildProdVarDec(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdFuncVar(Production node) { } - + public override Node ExitProdFuncVar(Production node) { return node; } - + public override void ChildProdFuncVar(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdIdentVar(Production node) { } - + public override Node ExitProdIdentVar(Production node) { return node; } - + public override void ChildProdIdentVar(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdDtype(Production node) { } - + public override Node ExitProdDtype(Production node) { return node; } - + public override void ChildProdDtype(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdNext2var(Production node) { } - + public override Node ExitProdNext2var(Production node) { return node; } - + public override void ChildProdNext2var(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdNext2varTail(Production node) { } - + public override Node ExitProdNext2varTail(Production node) { return node; } - + public override void ChildProdNext2varTail(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdVal(Production node) { } - + public override Node ExitProdVal(Production node) { return node; } - + public override void ChildProdVal(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdVal1(Production node) { } - + public override Node ExitProdVal1(Production node) { return node; } - + public override void ChildProdVal1(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdVal2(Production node) { } - + public override Node ExitProdVal2(Production node) { return node; } - + public override void ChildProdVal2(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdBulLit(Production node) { } - + public override Node ExitProdBulLit(Production node) { return node; } - + public override void ChildProdBulLit(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdArray1d(Production node) { } - + public override Node ExitProdArray1d(Production node) { return node; } - + public override void ChildProdArray1d(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdElem1dNext(Production node) { } - + public override Node ExitProdElem1dNext(Production node) { return node; } - + public override void ChildProdElem1dNext(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdElem1dList(Production node) { } - + public override Node ExitProdElem1dList(Production node) { return node; } - + public override void ChildProdElem1dList(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdElemlist1dTail(Production node) { } - + public override Node ExitProdElemlist1dTail(Production node) { return node; } - + public override void ChildProdElemlist1dTail(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdElem2dNext(Production node) { } - + public override Node ExitProdElem2dNext(Production node) { return node; } - + public override void ChildProdElem2dNext(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdElem2dList(Production node) { } - + public override Node ExitProdElem2dList(Production node) { return node; } - + public override void ChildProdElem2dList(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdElem2dListTail(Production node) { } - + public override Node ExitProdElem2dListTail(Production node) { return node; } - + public override void ChildProdElem2dListTail(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdSize(Production node) { } - + public override Node ExitProdSize(Production node) { return node; } - + public override void ChildProdSize(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdConstDec(Production node) { } - + public override Node ExitProdConstDec(Production node) { return node; } - + public override void ChildProdConstDec(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdConstNext(Production node) { } - + public override Node ExitProdConstNext(Production node) { return node; } - + public override void ChildProdConstNext(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdFuncName(Production node) { } - + public override Node ExitProdFuncName(Production node) { return node; } - + public override void ChildProdFuncName(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdParam(Production node) { } - + public override Node ExitProdParam(Production node) { return node; } - + public override void ChildProdParam(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdParam2(Production node) { } - + public override Node ExitProdParam2(Production node) { return node; } - + public override void ChildProdParam2(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdStorkDec(Production node) { } - + public override Node ExitProdStorkDec(Production node) { return node; } - + public override void ChildProdStorkDec(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdStorkElem(Production node) { } - + public override Node ExitProdStorkElem(Production node) { return node; } - + public override void ChildProdStorkElem(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdMultiVardec(Production node) { } - + public override Node ExitProdMultiVardec(Production node) { return node; } - + public override void ChildProdMultiVardec(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdMultistorkElem(Production node) { } - + public override Node ExitProdMultistorkElem(Production node) { return node; } - + public override void ChildProdMultistorkElem(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdObjDec(Production node) { } - + public override Node ExitProdObjDec(Production node) { return node; } - + public override void ChildProdObjDec(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdMane(Production node) { } - + public override Node ExitProdMane(Production node) { code += "\nConsole.ReadKey();\n"; return node; } - + public override void ChildProdMane(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdLocalDec(Production node) { } - + public override Node ExitProdLocalDec(Production node) { - return node; + return node; } - + public override void ChildProdLocalDec(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdStatement(Production node) { } - + public override Node ExitProdStatement(Production node) { - + return node; } - + public override void ChildProdStatement(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdStateNext(Production node) { } - + public override Node ExitProdStateNext(Production node) { return node; } - + public override void ChildProdStateNext(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdAssign1(Production node) { } - + public override Node ExitProdAssign1(Production node) { return node; } - + public override void ChildProdAssign1(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdAssignTail(Production node) { } - + public override Node ExitProdAssignTail(Production node) { return node; } - + public override void ChildProdAssignTail(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdNextFig(Production node) { } - + public override Node ExitProdNextFig(Production node) { - + return node; } - + public override void ChildProdNextFig(Production node, Node child) { node.AddChild(child); } + - - public override void EnterProdScanNext(Production node) - { - } - - public override Node ExitProdScanNext(Production node) - { - return node; - } - - public override void ChildProdScanNext(Production node, Node child) - { - node.AddChild(child); - } - - public override void EnterProdArgs1(Production node) { } - + public override Node ExitProdArgs1(Production node) { return node; } - + public override void ChildProdArgs1(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdArgsTail(Production node) { } - + public override Node ExitProdArgsTail(Production node) { return node; } - + public override void ChildProdArgsTail(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdArgIn(Production node) { } - + public override Node ExitProdArgIn(Production node) { return node; } - + public override void ChildProdArgIn(Production node, Node child) { node.AddChild(child); } - - + + public override void EnterProdMathEqtail1(Production node) { } - + public override Node ExitProdMathEqtail1(Production node) { - + return node; } - + public override void ChildProdMathEqtail1(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdMathEqtail2(Production node) { } - + public override Node ExitProdMathEqtail2(Production node) { return node; } - + public override void ChildProdMathEqtail2(Production node, Node child) { node.AddChild(child); } - - - - - - - + + + + + + + public override void EnterProdMathTail(Production node) { } - + public override Node ExitProdMathTail(Production node) { return node; } - + public override void ChildProdMathTail(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdMathOp(Production node) { } - + public override Node ExitProdMathOp(Production node) { return node; } - + public override void ChildProdMathOp(Production node, Node child) { //Node op = child.GetChildAt(0); @@ -1851,95 +1847,95 @@ public override void ChildProdMathOp(Production node, Node child) node.AddChild(child); } - - public override void EnterProdMathFig(Production node) - { - } + //public override void EnterProdMathFig(Production node) + //{ - - public override Node ExitProdMathFig(Production node) - { - return node; - } + //} + + + //public override Node ExitProdMathFig(Production node) + //{ + // return node; + //} + + + //public override void ChildProdMathFig(Production node, Node child) + //{ + // Node val = child.GetChildAt(0); + + // node.AddChild(child); + //} - - public override void ChildProdMathFig(Production node, Node child) - { - Node val = child.GetChildAt(0); - - node.AddChild(child); - } - public override void EnterProdMathFig1(Production node) { } - + public override Node ExitProdMathFig1(Production node) { return node; } - + public override void ChildProdMathFig1(Production node, Node child) { node.AddChild(child); } - - public override void EnterProdMatheqNext(Production node) + + public override void EnterProdMatheq(Production node) { } - - public override Node ExitProdMatheqNext(Production node) + + public override Node ExitProdMatheq(Production node) { return node; } - - public override void ChildProdMatheqNext(Production node, Node child) + + public override void ChildProdMatheq(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdFunctionCall(Production node) { } - + public override Node ExitProdFunctionCall(Production node) { return node; } - + public override void ChildProdFunctionCall(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdClrscr(Production node) { } - + public override Node ExitProdClrscr(Production node) { return node; } - + public override void ChildProdClrscr(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdInput(Production node) { } @@ -1947,7 +1943,7 @@ public override void EnterProdInput(Production node) public override Node ExitProdInput(Production node) { - + return node; //if (!runtime_error) //{ @@ -2058,36 +2054,35 @@ public override void ChildProdInput(Production node, Node child) node.AddChild(child); } - + public override void EnterProdScanFig(Production node) { } - + public override Node ExitProdScanFig(Production node) { return node; } - + public override void ChildProdScanFig(Production node, Node child) { node.AddChild(child); } - public override void EnterProdMultiInput(Production node) { code += ";\n"; } - + public override Node ExitProdMultiInput(Production node) { return node; } - + public override void ChildProdMultiInput(Production node, Node child) { node.AddChild(child); @@ -2123,69 +2118,69 @@ public override void ChildProdMultiInput(Production node, Node child) } } - + public override void EnterProdArr1d(Production node) { } - + public override Node ExitProdArr1d(Production node) { return node; } - + public override void ChildProdArr1d(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdArr2d(Production node) { } - + public override Node ExitProdArr2d(Production node) { return node; } - + public override void ChildProdArr2d(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdStorkAccess1(Production node) { } - + public override Node ExitProdStorkAccess1(Production node) { return node; } - + public override void ChildProdStorkAccess1(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdOutput(Production node) { } - + public override Node ExitProdOutput(Production node) { return node; } - + public override void ChildProdOutput(Production node, Node child) { node.AddChild(child); @@ -2196,20 +2191,20 @@ public override void ChildProdOutput(Production node, Node child) } } - + public override void EnterProdOut(Production node) { } - + public override Node ExitProdOut(Production node) { - + return node; } - + public override void ChildProdOut(Production node, Node child) { ////Node output = node.GetChildAt(0); @@ -2240,599 +2235,564 @@ public override void ChildProdOut(Production node, Node child) //} node.AddChild(child); } - - + + public override void EnterProdMultiOutput(Production node) { isMultiOutput = true; } - + public override Node ExitProdMultiOutput(Production node) { isMultiOutput = false; return node; } - + public override void ChildProdMultiOutput(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdConditional(Production node) { } - + public override Node ExitProdConditional(Production node) { return node; } - + public override void ChildProdConditional(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdCondi(Production node) { } - + public override Node ExitProdCondi(Production node) { return node; } - + public override void ChildProdCondi(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdNotFig(Production node) { } - + public override Node ExitProdNotFig(Production node) { return node; } - + public override void ChildProdNotFig(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdCondExpr(Production node) { } - + public override Node ExitProdCondExpr(Production node) { return node; } - + public override void ChildProdCondExpr(Production node, Node child) { node.AddChild(child); } - - public override void EnterProdCondTail(Production node) - { - } - - - public override Node ExitProdCondTail(Production node) - { - return node; - } - - public override void ChildProdCondTail(Production node, Node child) - { - node.AddChild(child); - } - public override void EnterProdRelExpr(Production node) { } - + public override Node ExitProdRelExpr(Production node) { return node; } - + public override void ChildProdRelExpr(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdRelexTail(Production node) { } - + public override Node ExitProdRelexTail(Production node) { return node; } - + public override void ChildProdRelexTail(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdExpression(Production node) { } - + public override Node ExitProdExpression(Production node) { return node; } - + public override void ChildProdExpression(Production node, Node child) { node.AddChild(child); } - - + + public override void EnterProdRelOp1(Production node) { } - + public override Node ExitProdRelOp1(Production node) { return node; } - + public override void ChildProdRelOp1(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdRelOp2(Production node) { } - + public override Node ExitProdRelOp2(Production node) { return node; } - + public override void ChildProdRelOp2(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdRelFig(Production node) { } - + public override Node ExitProdRelFig(Production node) { return node; } - + public override void ChildProdRelFig(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdLogExpr(Production node) { } - + public override Node ExitProdLogExpr(Production node) { return node; } - + public override void ChildProdLogExpr(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdLogExprNext(Production node) { } - + public override Node ExitProdLogExprNext(Production node) { return node; } - + public override void ChildProdLogExprNext(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdLogOp(Production node) { } - + public override Node ExitProdLogOp(Production node) { return node; } - + public override void ChildProdLogOp(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdCondEelsif(Production node) { } - + public override Node ExitProdCondEelsif(Production node) { return node; } - + public override void ChildProdCondEelsif(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdCondEels(Production node) { } - + public override Node ExitProdCondEels(Production node) { return node; } - + public override void ChildProdCondEels(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdSwaspCase(Production node) { } - + public override Node ExitProdSwaspCase(Production node) { return node; } - + public override void ChildProdSwaspCase(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdSwaspCase1(Production node) { } - + public override Node ExitProdSwaspCase1(Production node) { return node; } - + public override void ChildProdSwaspCase1(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdTermExpr(Production node) { } - + public override Node ExitProdTermExpr(Production node) { return node; } - + public override void ChildProdTermExpr(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdDefault(Production node) { } - + public override Node ExitProdDefault(Production node) { return node; } - + public override void ChildProdDefault(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdIterative(Production node) { } - + public override Node ExitProdIterative(Production node) { return node; } - + public override void ChildProdIterative(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdLoopFig1(Production node) { } - + public override Node ExitProdLoopFig1(Production node) { return node; } - + public override void ChildProdLoopFig1(Production node, Node child) { node.AddChild(child); } - - public override void EnterProdRelExpr1(Production node) + public override void EnterProdLoopFig2(Production node) { } - - public override Node ExitProdRelExpr1(Production node) + + public override Node ExitProdLoopFig2(Production node) { return node; } - - public override void ChildProdRelExpr1(Production node, Node child) + + public override void ChildProdLoopFig2(Production node, Node child) { node.AddChild(child); } - - public override void EnterProdLoopFig2(Production node) + public override void EnterProdRelExpr1(Production node) { } - - public override Node ExitProdLoopFig2(Production node) + + public override Node ExitProdRelExpr1(Production node) { return node; } - - public override void ChildProdLoopFig2(Production node, Node child) + + public override void ChildProdRelExpr1(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdIncremDecrem(Production node) { } - + public override Node ExitProdIncremDecrem(Production node) { return node; } - + public override void ChildProdIncremDecrem(Production node, Node child) { node.AddChild(child); } - - public override void EnterProdVar(Production node) - { - } - - public override Node ExitProdVar(Production node) - { - return node; - } - - - public override void ChildProdVar(Production node, Node child) - { - node.AddChild(child); - } - - public override void EnterProdUnaryOp(Production node) { } - + public override Node ExitProdUnaryOp(Production node) { return node; } - + public override void ChildProdUnaryOp(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdSubFunction(Production node) { } - + public override Node ExitProdSubFunction(Production node) { return node; } - + public override void ChildProdSubFunction(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdFuncInside(Production node) { } - + public override Node ExitProdFuncInside(Production node) { return node; } - + public override void ChildProdFuncInside(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdFuncArgs(Production node) { } - + public override Node ExitProdFuncArgs(Production node) { return node; } - + public override void ChildProdFuncArgs(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdMultifuncArgs(Production node) { } - + public override Node ExitProdMultifuncArgs(Production node) { return node; } - + public override void ChildProdMultifuncArgs(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdResult(Production node) { } - + public override Node ExitProdResult(Production node) { return node; } - + public override void ChildProdResult(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdFigTail(Production node) { } - + public override Node ExitProdFigTail(Production node) { return node; } - + public override void ChildProdFigTail(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdResultTail(Production node) { } - + public override Node ExitProdResultTail(Production node) { return node; } - + public override void ChildProdResultTail(Production node, Node child) { node.AddChild(child); diff --git a/Core Library/Core Library/SyntaxConstants.cs b/Core Library/Core Library/SyntaxConstants.cs index 1e44227..2b554e0 100644 --- a/Core Library/Core Library/SyntaxConstants.cs +++ b/Core Library/Core Library/SyntaxConstants.cs @@ -119,58 +119,53 @@ public enum SyntaxConstants PROD_NEXT_FIG = 2038, PROD_MATH_EQTAIL1 = 2039, PROD_MATH_EQTAIL2 = 2040, - PROD_MATH_TAIL = 2041, - PROD_MATH_OP = 2042, - PROD_MATH_FIG = 2043, + PROD_MATHEQ = 2041, + PROD_MATH_TAIL = 2042, + PROD_MATH_OP = 2043, PROD_MATH_FIG1 = 2044, - PROD_MATHEQ_NEXT = 2045, - PROD_FUNCTION_CALL = 2046, - PROD_SCAN_NEXT = 2047, - PROD_ARGS1 = 2048, - PROD_ARGS_TAIL = 2049, - PROD_ARG_IN = 2050, - PROD_CLRSCR = 2051, - PROD_INPUT = 2052, - PROD_SCAN_FIG = 2053, - PROD_MULTI_INPUT = 2054, - PROD_ARR1D = 2055, - PROD_ARR2D = 2056, - PROD_STORK_ACCESS1 = 2057, - PROD_OUTPUT = 2058, - PROD_OUT = 2059, - PROD_MULTI_OUTPUT = 2060, - PROD_CONDITIONAL = 2061, - PROD_CONDI = 2062, - PROD_NOT_FIG = 2063, - PROD_COND_EXPR = 2064, - PROD_COND_TAIL = 2065, - PROD_REL_EXPR = 2066, - PROD_RELEX_TAIL = 2067, - PROD_EXPRESSION = 2068, - PROD_REL_OP1 = 2069, - PROD_REL_OP2 = 2070, - PROD_REL_FIG = 2071, - PROD_LOG_EXPR = 2072, - PROD_LOG_EXPR_NEXT = 2073, - PROD_LOG_OP = 2074, - PROD_COND_EELSIF = 2075, - PROD_COND_EELS = 2076, - PROD_SWASP_CASE = 2077, - PROD_SWASP_CASE1 = 2078, - PROD_TERM_EXPR = 2079, - PROD_DEFAULT = 2080, - PROD_ITERATIVE = 2081, - PROD_LOOP_FIG1 = 2082, - PROD_REL_EXPR1 = 2083, - PROD_LOOP_FIG2 = 2084, - PROD_INCREM_DECREM = 2085, - PROD_VAR = 2086, - PROD_UNARY_OP = 2087, - PROD_SUB_FUNCTION = 2088, - PROD_FUNC_INSIDE = 2089, - PROD_FUNC_ARGS = 2090, - PROD_MULTIFUNC_ARGS = 2091, - PROD_RESULT = 2092, - PROD_FIG_TAIL = 2093, - PROD_RESULT_TAIL = 2094 + PROD_FUNCTION_CALL = 2045, + PROD_ARGS1 = 2046, + PROD_ARGS_TAIL = 2047, + PROD_ARG_IN = 2048, + PROD_CLRSCR = 2049, + PROD_INPUT = 2050, + PROD_SCAN_FIG = 2051, + PROD_MULTI_INPUT = 2052, + PROD_ARR1D = 2053, + PROD_ARR2D = 2054, + PROD_STORK_ACCESS1 = 2055, + PROD_OUTPUT = 2056, + PROD_OUT = 2057, + PROD_MULTI_OUTPUT = 2058, + PROD_CONDITIONAL = 2059, + PROD_CONDI = 2060, + PROD_NOT_FIG = 2061, + PROD_COND_EXPR = 2062, + PROD_REL_EXPR = 2063, + PROD_RELEX_TAIL = 2064, + PROD_EXPRESSION = 2065, + PROD_REL_OP1 = 2066, + PROD_REL_OP2 = 2067, + PROD_REL_FIG = 2068, + PROD_LOG_EXPR = 2069, + PROD_LOG_EXPR_NEXT = 2070, + PROD_LOG_OP = 2071, + PROD_COND_EELSIF = 2072, + PROD_COND_EELS = 2073, + PROD_SWASP_CASE = 2074, + PROD_SWASP_CASE1 = 2075, + PROD_TERM_EXPR = 2076, + PROD_DEFAULT = 2077, + PROD_ITERATIVE = 2078, + PROD_LOOP_FIG1 = 2079, + PROD_REL_EXPR1 = 2080, + PROD_INCREM_DECREM = 2081, + PROD_UNARY_OP = 2082, + PROD_SUB_FUNCTION = 2083, + PROD_FUNC_INSIDE = 2084, + PROD_FUNC_ARGS = 2085, + PROD_MULTIFUNC_ARGS = 2086, + PROD_RESULT = 2087, + PROD_FIG_TAIL = 2088, + PROD_RESULT_TAIL = 2089 } diff --git a/SemanticsAnalyzer/SemanticsInitializer.cs b/SemanticsAnalyzer/SemanticsInitializer.cs index 1cb17ca..5f9e6da 100644 --- a/SemanticsAnalyzer/SemanticsInitializer.cs +++ b/SemanticsAnalyzer/SemanticsInitializer.cs @@ -1124,32 +1124,9 @@ public override void ChildProdNextFig(Production node, Node child) { node.AddChild(child); } - - - - - - - public override void EnterProdScanNext(Production node) - { - } - - - public override Node ExitProdScanNext(Production node) - { - return node; - } - - - public override void ChildProdScanNext(Production node, Node child) - { - node.AddChild(child); - } - - public override void EnterProdArgs1(Production node) { } @@ -1275,23 +1252,6 @@ public override void ChildProdMathOp(Production node, Node child) } - public override void EnterProdMathFig(Production node) - { - } - - - public override Node ExitProdMathFig(Production node) - { - return node; - } - - - public override void ChildProdMathFig(Production node, Node child) - { - node.AddChild(child); - } - - public override void EnterProdMathFig1(Production node) { } @@ -1309,18 +1269,18 @@ public override void ChildProdMathFig1(Production node, Node child) } - public override void EnterProdMatheqNext(Production node) + public override void EnterProdMatheq(Production node) { } - public override Node ExitProdMatheqNext(Production node) + public override Node ExitProdMatheq(Production node) { return node; } - public override void ChildProdMatheqNext(Production node, Node child) + public override void ChildProdMatheq(Production node, Node child) { node.AddChild(child); } @@ -1581,21 +1541,7 @@ public override void ChildProdCondExpr(Production node, Node child) } - public override void EnterProdCondTail(Production node) - { - } - - - public override Node ExitProdCondTail(Production node) - { - return node; - } - - - public override void ChildProdCondTail(Production node, Node child) - { - node.AddChild(child); - } + public override void EnterProdRelExpr(Production node) @@ -1886,74 +1832,57 @@ public override void ChildProdLoopFig1(Production node, Node child) node.AddChild(child); } - - public override void EnterProdRelExpr1(Production node) - { - } - - - public override Node ExitProdRelExpr1(Production node) - { - return node; - } - - - public override void ChildProdRelExpr1(Production node, Node child) - { - node.AddChild(child); - } - - public override void EnterProdLoopFig2(Production node) { } - + public override Node ExitProdLoopFig2(Production node) { return node; } - + public override void ChildProdLoopFig2(Production node, Node child) { node.AddChild(child); } - - public override void EnterProdIncremDecrem(Production node) + + public override void EnterProdRelExpr1(Production node) { } - public override Node ExitProdIncremDecrem(Production node) + public override Node ExitProdRelExpr1(Production node) { return node; } - public override void ChildProdIncremDecrem(Production node, Node child) + public override void ChildProdRelExpr1(Production node, Node child) { node.AddChild(child); } - public override void EnterProdVar(Production node) + + public override void EnterProdIncremDecrem(Production node) { } - public override Node ExitProdVar(Production node) + public override Node ExitProdIncremDecrem(Production node) { return node; } - public override void ChildProdVar(Production node, Node child) + public override void ChildProdIncremDecrem(Production node, Node child) { node.AddChild(child); } - + public override void EnterProdUnaryOp(Production node) { diff --git a/Syntax Analyzer/SyntaxAnalyzer.cs b/Syntax Analyzer/SyntaxAnalyzer.cs index f115fce..802e2d3 100644 --- a/Syntax Analyzer/SyntaxAnalyzer.cs +++ b/Syntax Analyzer/SyntaxAnalyzer.cs @@ -346,27 +346,21 @@ public override void Enter(Node node) { case (int) SyntaxConstants.PROD_MATH_EQTAIL2: EnterProdMathEqtail2((Production) node); break; + case (int) SyntaxConstants.PROD_MATHEQ: + EnterProdMatheq((Production) node); + break; case (int) SyntaxConstants.PROD_MATH_TAIL: EnterProdMathTail((Production) node); break; case (int) SyntaxConstants.PROD_MATH_OP: EnterProdMathOp((Production) node); break; - case (int) SyntaxConstants.PROD_MATH_FIG: - EnterProdMathFig((Production) node); - break; case (int) SyntaxConstants.PROD_MATH_FIG1: EnterProdMathFig1((Production) node); break; - case (int) SyntaxConstants.PROD_MATHEQ_NEXT: - EnterProdMatheqNext((Production) node); - break; case (int) SyntaxConstants.PROD_FUNCTION_CALL: EnterProdFunctionCall((Production) node); break; - case (int) SyntaxConstants.PROD_SCAN_NEXT: - EnterProdScanNext((Production) node); - break; case (int) SyntaxConstants.PROD_ARGS1: EnterProdArgs1((Production) node); break; @@ -418,9 +412,6 @@ public override void Enter(Node node) { case (int) SyntaxConstants.PROD_COND_EXPR: EnterProdCondExpr((Production) node); break; - case (int) SyntaxConstants.PROD_COND_TAIL: - EnterProdCondTail((Production) node); - break; case (int) SyntaxConstants.PROD_REL_EXPR: EnterProdRelExpr((Production) node); break; @@ -481,9 +472,6 @@ public override void Enter(Node node) { case (int) SyntaxConstants.PROD_INCREM_DECREM: EnterProdIncremDecrem((Production) node); break; - case (int) SyntaxConstants.PROD_VAR: - EnterProdVar((Production) node); - break; case (int) SyntaxConstants.PROD_UNARY_OP: EnterProdUnaryOp((Production) node); break; @@ -740,20 +728,16 @@ public override Node Exit(Node node) { return ExitProdMathEqtail1((Production) node); case (int) SyntaxConstants.PROD_MATH_EQTAIL2: return ExitProdMathEqtail2((Production) node); + case (int) SyntaxConstants.PROD_MATHEQ: + return ExitProdMatheq((Production) node); case (int) SyntaxConstants.PROD_MATH_TAIL: return ExitProdMathTail((Production) node); case (int) SyntaxConstants.PROD_MATH_OP: return ExitProdMathOp((Production) node); - case (int) SyntaxConstants.PROD_MATH_FIG: - return ExitProdMathFig((Production) node); case (int) SyntaxConstants.PROD_MATH_FIG1: return ExitProdMathFig1((Production) node); - case (int) SyntaxConstants.PROD_MATHEQ_NEXT: - return ExitProdMatheqNext((Production) node); case (int) SyntaxConstants.PROD_FUNCTION_CALL: return ExitProdFunctionCall((Production) node); - case (int) SyntaxConstants.PROD_SCAN_NEXT: - return ExitProdScanNext((Production) node); case (int) SyntaxConstants.PROD_ARGS1: return ExitProdArgs1((Production) node); case (int) SyntaxConstants.PROD_ARGS_TAIL: @@ -788,8 +772,6 @@ public override Node Exit(Node node) { return ExitProdNotFig((Production) node); case (int) SyntaxConstants.PROD_COND_EXPR: return ExitProdCondExpr((Production) node); - case (int) SyntaxConstants.PROD_COND_TAIL: - return ExitProdCondTail((Production) node); case (int) SyntaxConstants.PROD_REL_EXPR: return ExitProdRelExpr((Production) node); case (int) SyntaxConstants.PROD_RELEX_TAIL: @@ -830,8 +812,6 @@ public override Node Exit(Node node) { return ExitProdLoopFig2((Production) node); case (int) SyntaxConstants.PROD_INCREM_DECREM: return ExitProdIncremDecrem((Production) node); - case (int) SyntaxConstants.PROD_VAR: - return ExitProdVar((Production) node); case (int) SyntaxConstants.PROD_UNARY_OP: return ExitProdUnaryOp((Production) node); case (int) SyntaxConstants.PROD_SUB_FUNCTION: @@ -984,27 +964,21 @@ public override void Child(Production node, Node child) { case (int) SyntaxConstants.PROD_MATH_EQTAIL2: ChildProdMathEqtail2(node, child); break; + case (int) SyntaxConstants.PROD_MATHEQ: + ChildProdMatheq(node, child); + break; case (int) SyntaxConstants.PROD_MATH_TAIL: ChildProdMathTail(node, child); break; case (int) SyntaxConstants.PROD_MATH_OP: ChildProdMathOp(node, child); break; - case (int) SyntaxConstants.PROD_MATH_FIG: - ChildProdMathFig(node, child); - break; case (int) SyntaxConstants.PROD_MATH_FIG1: ChildProdMathFig1(node, child); break; - case (int) SyntaxConstants.PROD_MATHEQ_NEXT: - ChildProdMatheqNext(node, child); - break; case (int) SyntaxConstants.PROD_FUNCTION_CALL: ChildProdFunctionCall(node, child); break; - case (int) SyntaxConstants.PROD_SCAN_NEXT: - ChildProdScanNext(node, child); - break; case (int) SyntaxConstants.PROD_ARGS1: ChildProdArgs1(node, child); break; @@ -1056,9 +1030,6 @@ public override void Child(Production node, Node child) { case (int) SyntaxConstants.PROD_COND_EXPR: ChildProdCondExpr(node, child); break; - case (int) SyntaxConstants.PROD_COND_TAIL: - ChildProdCondTail(node, child); - break; case (int) SyntaxConstants.PROD_REL_EXPR: ChildProdRelExpr(node, child); break; @@ -1119,9 +1090,6 @@ public override void Child(Production node, Node child) { case (int) SyntaxConstants.PROD_INCREM_DECREM: ChildProdIncremDecrem(node, child); break; - case (int) SyntaxConstants.PROD_VAR: - ChildProdVar(node, child); - break; case (int) SyntaxConstants.PROD_UNARY_OP: ChildProdUnaryOp(node, child); break; @@ -4525,7 +4493,7 @@ public virtual void ChildProdMathEqtail2(Production node, Node child) { * if the node analysis * discovered errors */ - public virtual void EnterProdMathTail(Production node) { + public virtual void EnterProdMatheq(Production node) { } /** @@ -4539,7 +4507,7 @@ public virtual void EnterProdMathTail(Production node) { * if the node analysis * discovered errors */ - public virtual Node ExitProdMathTail(Production node) { + public virtual Node ExitProdMatheq(Production node) { return node; } @@ -4553,7 +4521,7 @@ public virtual Node ExitProdMathTail(Production node) { * if the node analysis * discovered errors */ - public virtual void ChildProdMathTail(Production node, Node child) { + public virtual void ChildProdMatheq(Production node, Node child) { node.AddChild(child); } @@ -4565,7 +4533,7 @@ public virtual void ChildProdMathTail(Production node, Node child) { * if the node analysis * discovered errors */ - public virtual void EnterProdMathOp(Production node) { + public virtual void EnterProdMathTail(Production node) { } /** @@ -4579,7 +4547,7 @@ public virtual void EnterProdMathOp(Production node) { * if the node analysis * discovered errors */ - public virtual Node ExitProdMathOp(Production node) { + public virtual Node ExitProdMathTail(Production node) { return node; } @@ -4593,7 +4561,7 @@ public virtual Node ExitProdMathOp(Production node) { * if the node analysis * discovered errors */ - public virtual void ChildProdMathOp(Production node, Node child) { + public virtual void ChildProdMathTail(Production node, Node child) { node.AddChild(child); } @@ -4605,7 +4573,7 @@ public virtual void ChildProdMathOp(Production node, Node child) { * if the node analysis * discovered errors */ - public virtual void EnterProdMathFig(Production node) { + public virtual void EnterProdMathOp(Production node) { } /** @@ -4619,7 +4587,7 @@ public virtual void EnterProdMathFig(Production node) { * if the node analysis * discovered errors */ - public virtual Node ExitProdMathFig(Production node) { + public virtual Node ExitProdMathOp(Production node) { return node; } @@ -4633,7 +4601,7 @@ public virtual Node ExitProdMathFig(Production node) { * if the node analysis * discovered errors */ - public virtual void ChildProdMathFig(Production node, Node child) { + public virtual void ChildProdMathOp(Production node, Node child) { node.AddChild(child); } @@ -4677,46 +4645,6 @@ public virtual void ChildProdMathFig1(Production node, Node child) { node.AddChild(child); } - /** - * Called when entering a parse tree node. - * - * the node being entered - * - * if the node analysis - * discovered errors - */ - public virtual void EnterProdMatheqNext(Production node) { - } - - /** - * Called when exiting a parse tree node. - * - * the node being exited - * - * the node to add to the parse tree, or - * null if no parse tree should be created - * - * if the node analysis - * discovered errors - */ - public virtual Node ExitProdMatheqNext(Production node) { - return node; - } - - /** - * Called when adding a child to a parse tree - * node. - * - * the parent node - * the child node, or null - * - * if the node analysis - * discovered errors - */ - public virtual void ChildProdMatheqNext(Production node, Node child) { - node.AddChild(child); - } - /** * Called when entering a parse tree node. * @@ -4757,46 +4685,6 @@ public virtual void ChildProdFunctionCall(Production node, Node child) { node.AddChild(child); } - /** - * Called when entering a parse tree node. - * - * the node being entered - * - * if the node analysis - * discovered errors - */ - public virtual void EnterProdScanNext(Production node) { - } - - /** - * Called when exiting a parse tree node. - * - * the node being exited - * - * the node to add to the parse tree, or - * null if no parse tree should be created - * - * if the node analysis - * discovered errors - */ - public virtual Node ExitProdScanNext(Production node) { - return node; - } - - /** - * Called when adding a child to a parse tree - * node. - * - * the parent node - * the child node, or null - * - * if the node analysis - * discovered errors - */ - public virtual void ChildProdScanNext(Production node, Node child) { - node.AddChild(child); - } - /** * Called when entering a parse tree node. * @@ -5477,46 +5365,6 @@ public virtual void ChildProdCondExpr(Production node, Node child) { node.AddChild(child); } - /** - * Called when entering a parse tree node. - * - * the node being entered - * - * if the node analysis - * discovered errors - */ - public virtual void EnterProdCondTail(Production node) { - } - - /** - * Called when exiting a parse tree node. - * - * the node being exited - * - * the node to add to the parse tree, or - * null if no parse tree should be created - * - * if the node analysis - * discovered errors - */ - public virtual Node ExitProdCondTail(Production node) { - return node; - } - - /** - * Called when adding a child to a parse tree - * node. - * - * the parent node - * the child node, or null - * - * if the node analysis - * discovered errors - */ - public virtual void ChildProdCondTail(Production node, Node child) { - node.AddChild(child); - } - /** * Called when entering a parse tree node. * @@ -6317,46 +6165,6 @@ public virtual void ChildProdIncremDecrem(Production node, Node child) { node.AddChild(child); } - /** - * Called when entering a parse tree node. - * - * the node being entered - * - * if the node analysis - * discovered errors - */ - public virtual void EnterProdVar(Production node) { - } - - /** - * Called when exiting a parse tree node. - * - * the node being exited - * - * the node to add to the parse tree, or - * null if no parse tree should be created - * - * if the node analysis - * discovered errors - */ - public virtual Node ExitProdVar(Production node) { - return node; - } - - /** - * Called when adding a child to a parse tree - * node. - * - * the parent node - * the child node, or null - * - * if the node analysis - * discovered errors - */ - public virtual void ChildProdVar(Production node, Node child) { - node.AddChild(child); - } - /** * Called when entering a parse tree node. * diff --git a/Syntax Analyzer/SyntaxConstants.cs b/Syntax Analyzer/SyntaxConstants.cs index fe8b683..cc6488c 100644 --- a/Syntax Analyzer/SyntaxConstants.cs +++ b/Syntax Analyzer/SyntaxConstants.cs @@ -118,58 +118,54 @@ public enum SyntaxConstants { PROD_NEXT_FIG = 2038, PROD_MATH_EQTAIL1 = 2039, PROD_MATH_EQTAIL2 = 2040, - PROD_MATH_TAIL = 2041, - PROD_MATH_OP = 2042, - PROD_MATH_FIG = 2043, + PROD_MATHEQ = 2041, + PROD_MATH_TAIL = 2042, + PROD_MATH_OP = 2043, PROD_MATH_FIG1 = 2044, - PROD_MATHEQ_NEXT = 2045, - PROD_FUNCTION_CALL = 2046, - PROD_SCAN_NEXT = 2047, - PROD_ARGS1 = 2048, - PROD_ARGS_TAIL = 2049, - PROD_ARG_IN = 2050, - PROD_CLRSCR = 2051, - PROD_INPUT = 2052, - PROD_SCAN_FIG = 2053, - PROD_MULTI_INPUT = 2054, - PROD_ARR1D = 2055, - PROD_ARR2D = 2056, - PROD_STORK_ACCESS1 = 2057, - PROD_OUTPUT = 2058, - PROD_OUT = 2059, - PROD_MULTI_OUTPUT = 2060, - PROD_CONDITIONAL = 2061, - PROD_CONDI = 2062, - PROD_NOT_FIG = 2063, - PROD_COND_EXPR = 2064, - PROD_COND_TAIL = 2065, - PROD_REL_EXPR = 2066, - PROD_RELEX_TAIL = 2067, - PROD_EXPRESSION = 2068, - PROD_REL_OP1 = 2069, - PROD_REL_OP2 = 2070, - PROD_REL_FIG = 2071, - PROD_LOG_EXPR = 2072, - PROD_LOG_EXPR_NEXT = 2073, - PROD_LOG_OP = 2074, - PROD_COND_EELSIF = 2075, - PROD_COND_EELS = 2076, - PROD_SWASP_CASE = 2077, - PROD_SWASP_CASE1 = 2078, - PROD_TERM_EXPR = 2079, - PROD_DEFAULT = 2080, - PROD_ITERATIVE = 2081, - PROD_LOOP_FIG1 = 2082, - PROD_REL_EXPR1 = 2083, - PROD_LOOP_FIG2 = 2084, - PROD_INCREM_DECREM = 2085, - PROD_VAR = 2086, - PROD_UNARY_OP = 2087, - PROD_SUB_FUNCTION = 2088, - PROD_FUNC_INSIDE = 2089, - PROD_FUNC_ARGS = 2090, - PROD_MULTIFUNC_ARGS = 2091, - PROD_RESULT = 2092, - PROD_FIG_TAIL = 2093, - PROD_RESULT_TAIL = 2094 + PROD_FUNCTION_CALL = 2045, + PROD_ARGS1 = 2046, + PROD_ARGS_TAIL = 2047, + PROD_ARG_IN = 2048, + PROD_CLRSCR = 2049, + PROD_INPUT = 2050, + PROD_SCAN_FIG = 2051, + PROD_MULTI_INPUT = 2052, + PROD_ARR1D = 2053, + PROD_ARR2D = 2054, + PROD_STORK_ACCESS1 = 2055, + PROD_OUTPUT = 2056, + PROD_OUT = 2057, + PROD_MULTI_OUTPUT = 2058, + PROD_CONDITIONAL = 2059, + PROD_CONDI = 2060, + PROD_NOT_FIG = 2061, + PROD_COND_EXPR = 2062, + PROD_REL_EXPR = 2063, + PROD_RELEX_TAIL = 2064, + PROD_EXPRESSION = 2065, + PROD_REL_OP1 = 2066, + PROD_REL_OP2 = 2067, + PROD_REL_FIG = 2068, + PROD_LOG_EXPR = 2069, + PROD_LOG_EXPR_NEXT = 2070, + PROD_LOG_OP = 2071, + PROD_COND_EELSIF = 2072, + PROD_COND_EELS = 2073, + PROD_SWASP_CASE = 2074, + PROD_SWASP_CASE1 = 2075, + PROD_TERM_EXPR = 2076, + PROD_DEFAULT = 2077, + PROD_ITERATIVE = 2078, + PROD_LOOP_FIG1 = 2079, + PROD_REL_EXPR1 = 2080, + PROD_LOOP_FIG2 = 2081, + PROD_INCREM_DECREM = 2082, + PROD_UNARY_OP = 2083, + PROD_SUB_FUNCTION = 2084, + PROD_FUNC_INSIDE = 2085, + PROD_FUNC_ARGS = 2086, + PROD_MULTIFUNC_ARGS = 2087, + PROD_RESULT = 2088, + PROD_FIG_TAIL = 2089, + PROD_RESULT_TAIL = 2090 } diff --git a/Syntax Analyzer/SyntaxParser.cs b/Syntax Analyzer/SyntaxParser.cs index a7edb04..4754e86 100644 --- a/Syntax Analyzer/SyntaxParser.cs +++ b/Syntax Analyzer/SyntaxParser.cs @@ -80,7 +80,6 @@ private void CreatePatterns() { "prod_program"); alt = new ProductionPatternAlternative(); alt.AddToken((int) SyntaxConstants.ENTRANCE, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); alt.AddProduction((int) SyntaxConstants.PROD_GLOBAL_DEC, 0, 1); alt.AddToken((int) SyntaxConstants.MANE, 1, 1); alt.AddToken((int) SyntaxConstants.OP, 1, 1); @@ -98,7 +97,6 @@ private void CreatePatterns() { alt = new ProductionPatternAlternative(); alt.AddToken((int) SyntaxConstants.COMSYM, 1, 1); alt.AddToken((int) SyntaxConstants.COMMENT, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); pattern.AddAlternative(alt); AddPattern(pattern); @@ -124,7 +122,6 @@ private void CreatePatterns() { alt.AddProduction((int) SyntaxConstants.PROD_PARAM, 0, 1); alt.AddToken((int) SyntaxConstants.CP, 1, 1); alt.AddToken((int) SyntaxConstants.TERMI, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); pattern.AddAlternative(alt); AddPattern(pattern); @@ -134,7 +131,6 @@ private void CreatePatterns() { alt.AddProduction((int) SyntaxConstants.PROD_IDENT_VAR, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_FUNC_VAR, 0, 1); alt.AddToken((int) SyntaxConstants.TERMI, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); pattern.AddAlternative(alt); AddPattern(pattern); @@ -334,7 +330,6 @@ private void CreatePatterns() { alt.AddProduction((int) SyntaxConstants.PROD_VAL, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_CONST_NEXT, 0, 1); alt.AddToken((int) SyntaxConstants.TERMI, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); pattern.AddAlternative(alt); AddPattern(pattern); @@ -379,14 +374,12 @@ private void CreatePatterns() { alt.AddToken((int) SyntaxConstants.STORK, 1, 1); alt.AddToken((int) SyntaxConstants.AT, 1, 1); alt.AddToken((int) SyntaxConstants.ID, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); alt.AddToken((int) SyntaxConstants.ODC, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_STORK_ELEM, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_MULTISTORK_ELEM, 0, 1); alt.AddToken((int) SyntaxConstants.CDC, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_OBJ_DEC, 0, 1); alt.AddToken((int) SyntaxConstants.TERMI, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); pattern.AddAlternative(alt); AddPattern(pattern); @@ -396,7 +389,6 @@ private void CreatePatterns() { alt.AddProduction((int) SyntaxConstants.PROD_IDENT_VAR, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_MULTI_VARDEC, 0, 1); alt.AddToken((int) SyntaxConstants.TERMI, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); pattern.AddAlternative(alt); AddPattern(pattern); @@ -450,22 +442,18 @@ private void CreatePatterns() { alt = new ProductionPatternAlternative(); alt.AddProduction((int) SyntaxConstants.PROD_INPUT, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 0, 1); - alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); pattern.AddAlternative(alt); alt = new ProductionPatternAlternative(); alt.AddProduction((int) SyntaxConstants.PROD_OUTPUT, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 0, 1); - alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); pattern.AddAlternative(alt); alt = new ProductionPatternAlternative(); alt.AddProduction((int) SyntaxConstants.PROD_CONDITIONAL, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 0, 1); - alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); pattern.AddAlternative(alt); alt = new ProductionPatternAlternative(); alt.AddProduction((int) SyntaxConstants.PROD_ITERATIVE, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 0, 1); - alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); pattern.AddAlternative(alt); alt = new ProductionPatternAlternative(); alt.AddToken((int) SyntaxConstants.ID, 1, 1); @@ -473,6 +461,10 @@ private void CreatePatterns() { alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 0, 1); pattern.AddAlternative(alt); alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_LOOP_FIG2, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 0, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); alt.AddProduction((int) SyntaxConstants.PROD_CLRSCR, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 0, 1); pattern.AddAlternative(alt); @@ -510,25 +502,16 @@ private void CreatePatterns() { alt = new ProductionPatternAlternative(); alt.AddProduction((int) SyntaxConstants.PROD_MATH_EQTAIL2, 1, 1); pattern.AddAlternative(alt); - alt = new ProductionPatternAlternative(); - alt.AddProduction((int) SyntaxConstants.PROD_MATH_EQTAIL1, 1, 1); - pattern.AddAlternative(alt); - alt = new ProductionPatternAlternative(); - alt.AddToken((int) SyntaxConstants.EQUAL, 1, 1); - alt.AddToken((int) SyntaxConstants.ID, 1, 1); - alt.AddToken((int) SyntaxConstants.CON, 1, 1); - alt.AddToken((int) SyntaxConstants.ID, 1, 1); - pattern.AddAlternative(alt); AddPattern(pattern); pattern = new ProductionPattern((int) SyntaxConstants.PROD_MATH_EQTAIL1, "prod_math_eqtail1"); alt = new ProductionPatternAlternative(); alt.AddToken((int) SyntaxConstants.OP, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_MATH_FIG, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_MATH_FIG1, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_MATH_OP, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_MATH_FIG, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_MATHEQ_NEXT, 0, 1); + alt.AddProduction((int) SyntaxConstants.PROD_MATH_FIG1, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_MATH_TAIL, 0, 1); alt.AddToken((int) SyntaxConstants.CP, 1, 1); pattern.AddAlternative(alt); AddPattern(pattern); @@ -537,6 +520,13 @@ private void CreatePatterns() { "prod_math_eqtail2"); alt = new ProductionPatternAlternative(); alt.AddProduction((int) SyntaxConstants.PROD_MATH_FIG1, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_MATHEQ, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_MATHEQ, + "prod_matheq"); + alt = new ProductionPatternAlternative(); alt.AddProduction((int) SyntaxConstants.PROD_MATH_OP, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_MATH_FIG1, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_MATH_TAIL, 0, 1); @@ -571,20 +561,6 @@ private void CreatePatterns() { pattern.AddAlternative(alt); AddPattern(pattern); - pattern = new ProductionPattern((int) SyntaxConstants.PROD_MATH_FIG, - "prod_math_fig"); - alt = new ProductionPatternAlternative(); - alt.AddToken((int) SyntaxConstants.ID, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_ASSIGN_TAIL, 0, 1); - pattern.AddAlternative(alt); - alt = new ProductionPatternAlternative(); - alt.AddProduction((int) SyntaxConstants.PROD_VAL1, 1, 1); - pattern.AddAlternative(alt); - alt = new ProductionPatternAlternative(); - alt.AddProduction((int) SyntaxConstants.PROD_MATH_EQTAIL1, 1, 1); - pattern.AddAlternative(alt); - AddPattern(pattern); - pattern = new ProductionPattern((int) SyntaxConstants.PROD_MATH_FIG1, "prod_math_fig1"); alt = new ProductionPatternAlternative(); @@ -594,14 +570,8 @@ private void CreatePatterns() { alt = new ProductionPatternAlternative(); alt.AddProduction((int) SyntaxConstants.PROD_VAL1, 1, 1); pattern.AddAlternative(alt); - AddPattern(pattern); - - pattern = new ProductionPattern((int) SyntaxConstants.PROD_MATHEQ_NEXT, - "prod_matheq_next"); alt = new ProductionPatternAlternative(); - alt.AddProduction((int) SyntaxConstants.PROD_MATH_OP, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_MATH_FIG, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_MATHEQ_NEXT, 0, 1); + alt.AddProduction((int) SyntaxConstants.PROD_MATH_EQTAIL1, 1, 1); pattern.AddAlternative(alt); AddPattern(pattern); @@ -615,15 +585,6 @@ private void CreatePatterns() { pattern.AddAlternative(alt); AddPattern(pattern); - pattern = new ProductionPattern((int) SyntaxConstants.PROD_SCAN_NEXT, - "prod_scan_next"); - alt = new ProductionPatternAlternative(); - alt.AddProduction((int) SyntaxConstants.PROD_MATH_OP, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_MATH_FIG1, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_MATH_TAIL, 0, 1); - pattern.AddAlternative(alt); - AddPattern(pattern); - pattern = new ProductionPattern((int) SyntaxConstants.PROD_ARGS1, "prod_args1"); alt = new ProductionPatternAlternative(); @@ -669,7 +630,6 @@ private void CreatePatterns() { alt.AddProduction((int) SyntaxConstants.PROD_ASSIGN_TAIL, 0, 1); alt.AddProduction((int) SyntaxConstants.PROD_MULTI_INPUT, 0, 1); alt.AddToken((int) SyntaxConstants.TERMI, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); pattern.AddAlternative(alt); AddPattern(pattern); @@ -736,7 +696,7 @@ private void CreatePatterns() { alt = new ProductionPatternAlternative(); alt.AddToken((int) SyntaxConstants.ID, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_ASSIGN_TAIL, 0, 1); - alt.AddProduction((int) SyntaxConstants.PROD_SCAN_NEXT, 0, 1); + alt.AddProduction((int) SyntaxConstants.PROD_MATH_TAIL, 0, 1); pattern.AddAlternative(alt); alt = new ProductionPatternAlternative(); alt.AddToken((int) SyntaxConstants.STARLIT, 1, 1); @@ -783,7 +743,7 @@ private void CreatePatterns() { alt.AddToken((int) SyntaxConstants.OP, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_COND_EXPR, 1, 1); alt.AddToken((int) SyntaxConstants.CP, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_COND_TAIL, 0, 1); + alt.AddProduction((int) SyntaxConstants.PROD_LOG_EXPR, 0, 1); pattern.AddAlternative(alt); alt = new ProductionPatternAlternative(); alt.AddToken((int) SyntaxConstants.EXC, 1, 1); @@ -803,7 +763,7 @@ private void CreatePatterns() { alt.AddToken((int) SyntaxConstants.OP, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_COND_EXPR, 1, 1); alt.AddToken((int) SyntaxConstants.CP, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_COND_TAIL, 0, 1); + alt.AddProduction((int) SyntaxConstants.PROD_LOG_EXPR, 0, 1); pattern.AddAlternative(alt); AddPattern(pattern); @@ -814,14 +774,6 @@ private void CreatePatterns() { pattern.AddAlternative(alt); AddPattern(pattern); - pattern = new ProductionPattern((int) SyntaxConstants.PROD_COND_TAIL, - "prod_cond_tail"); - alt = new ProductionPatternAlternative(); - alt.AddProduction((int) SyntaxConstants.PROD_LOG_EXPR, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_COND_TAIL, 0, 1); - pattern.AddAlternative(alt); - AddPattern(pattern); - pattern = new ProductionPattern((int) SyntaxConstants.PROD_REL_EXPR, "prod_rel_expr"); alt = new ProductionPatternAlternative(); @@ -849,16 +801,16 @@ private void CreatePatterns() { pattern.AddAlternative(alt); alt = new ProductionPatternAlternative(); alt.AddToken((int) SyntaxConstants.OP, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_MATH_FIG, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_MATH_FIG1, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_MATH_OP, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_MATH_FIG, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_MATH_FIG1, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_MATH_TAIL, 0, 1); alt.AddToken((int) SyntaxConstants.CP, 1, 1); pattern.AddAlternative(alt); alt = new ProductionPatternAlternative(); alt.AddToken((int) SyntaxConstants.ID, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_ASSIGN_TAIL, 0, 1); - alt.AddProduction((int) SyntaxConstants.PROD_SCAN_NEXT, 0, 1); + alt.AddProduction((int) SyntaxConstants.PROD_MATH_TAIL, 0, 1); pattern.AddAlternative(alt); AddPattern(pattern); @@ -941,11 +893,9 @@ private void CreatePatterns() { alt.AddToken((int) SyntaxConstants.OP, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_CONDI, 1, 1); alt.AddToken((int) SyntaxConstants.CP, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); alt.AddToken((int) SyntaxConstants.ODC, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 0, 1); alt.AddToken((int) SyntaxConstants.CDC, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); alt.AddProduction((int) SyntaxConstants.PROD_COND_EELSIF, 0, 1); pattern.AddAlternative(alt); AddPattern(pattern); @@ -954,11 +904,9 @@ private void CreatePatterns() { "prod_cond_eels"); alt = new ProductionPatternAlternative(); alt.AddToken((int) SyntaxConstants.EELS, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); alt.AddToken((int) SyntaxConstants.ODC, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 0, 1); alt.AddToken((int) SyntaxConstants.CDC, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); pattern.AddAlternative(alt); AddPattern(pattern); @@ -972,7 +920,6 @@ private void CreatePatterns() { alt.AddToken((int) SyntaxConstants.TERMITE, 1, 1); alt.AddToken((int) SyntaxConstants.TERMI, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_SWASP_CASE1, 0, 1); - alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); pattern.AddAlternative(alt); AddPattern(pattern); @@ -997,10 +944,8 @@ private void CreatePatterns() { "prod_default"); alt = new ProductionPatternAlternative(); alt.AddToken((int) SyntaxConstants.SEAL, 1, 1); - alt.AddToken((int) SyntaxConstants.SC, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 0, 1); - alt.AddToken((int) SyntaxConstants.TERMITE, 1, 1); alt.AddToken((int) SyntaxConstants.TERMI, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 0, 1); pattern.AddAlternative(alt); AddPattern(pattern); @@ -1012,17 +957,16 @@ private void CreatePatterns() { alt.AddProduction((int) SyntaxConstants.PROD_CONDI, 1, 1); alt.AddToken((int) SyntaxConstants.CP, 1, 1); alt.AddToken((int) SyntaxConstants.ODC, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 0, 1); - alt.AddProduction((int) SyntaxConstants.PROD_LOOP_FIG2, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_LOOP_FIG2, 0, 1); alt.AddToken((int) SyntaxConstants.TERMI, 1, 1); alt.AddToken((int) SyntaxConstants.CDC, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); pattern.AddAlternative(alt); alt = new ProductionPatternAlternative(); alt.AddToken((int) SyntaxConstants.DO, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); alt.AddToken((int) SyntaxConstants.ODC, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 0, 1); + alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_LOOP_FIG2, 0, 1); alt.AddToken((int) SyntaxConstants.CDC, 1, 1); alt.AddToken((int) SyntaxConstants.WHALE, 1, 1); alt.AddToken((int) SyntaxConstants.OP, 1, 1); @@ -1037,15 +981,13 @@ private void CreatePatterns() { alt.AddToken((int) SyntaxConstants.EQUAL, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_LOOP_FIG1, 1, 1); alt.AddToken((int) SyntaxConstants.TERMI, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_REL_EXPR1, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_COND_EXPR, 1, 1); alt.AddToken((int) SyntaxConstants.TERMI, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_LOOP_FIG2, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_INCREM_DECREM, 1, 1); alt.AddToken((int) SyntaxConstants.CP, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); alt.AddToken((int) SyntaxConstants.ODC, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 0, 1); alt.AddToken((int) SyntaxConstants.CDC, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); pattern.AddAlternative(alt); AddPattern(pattern); @@ -1072,6 +1014,7 @@ private void CreatePatterns() { "prod_loop_fig2"); alt = new ProductionPatternAlternative(); alt.AddProduction((int) SyntaxConstants.PROD_INCREM_DECREM, 1, 1); + alt.AddToken((int) SyntaxConstants.TERMI, 1, 1); pattern.AddAlternative(alt); AddPattern(pattern); @@ -1079,18 +1022,11 @@ private void CreatePatterns() { "prod_increm_decrem"); alt = new ProductionPatternAlternative(); alt.AddProduction((int) SyntaxConstants.PROD_UNARY_OP, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_VAR, 1, 1); - pattern.AddAlternative(alt); - alt = new ProductionPatternAlternative(); - alt.AddProduction((int) SyntaxConstants.PROD_VAR, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_UNARY_OP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_LOOP_FIG1, 1, 1); pattern.AddAlternative(alt); - AddPattern(pattern); - - pattern = new ProductionPattern((int) SyntaxConstants.PROD_VAR, - "prod_var"); alt = new ProductionPatternAlternative(); alt.AddProduction((int) SyntaxConstants.PROD_LOOP_FIG1, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_UNARY_OP, 1, 1); pattern.AddAlternative(alt); AddPattern(pattern); @@ -1113,14 +1049,12 @@ private void CreatePatterns() { alt.AddToken((int) SyntaxConstants.OP, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_FUNC_ARGS, 0, 1); alt.AddToken((int) SyntaxConstants.CP, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); alt.AddToken((int) SyntaxConstants.ODC, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_FUNC_INSIDE, 1, 1); alt.AddToken((int) SyntaxConstants.HOP, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_RESULT, 0, 1); alt.AddToken((int) SyntaxConstants.TERMI, 1, 1); alt.AddToken((int) SyntaxConstants.CDC, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_COMMENT, 0, 1); alt.AddProduction((int) SyntaxConstants.PROD_SUB_FUNCTION, 0, 1); pattern.AddAlternative(alt); alt = new ProductionPatternAlternative(); diff --git a/Zootopia_Compiler/Form1.vb b/Zootopia_Compiler/Form1.vb index 0a879ef..8fc0555 100644 --- a/Zootopia_Compiler/Form1.vb +++ b/Zootopia_Compiler/Form1.vb @@ -1858,7 +1858,7 @@ Public Class Form1 symbolCtr += 1 tokens = New TokenLibrary.TokenLibrary.TokenClass tokens.setTokens("++") - tokens.setLexemes("increOp") + tokens.setLexemes("++") tokens.setAttributes("increOp, ++") tokens.setLines(line) tokenstream.Add(tokens) @@ -1925,7 +1925,7 @@ Public Class Form1 symbolCtr += 1 tokens = New TokenLibrary.TokenLibrary.TokenClass tokens.setTokens("--") - tokens.setLexemes("decreOp") + tokens.setLexemes("--") tokens.setAttributes("decreOp, --") tokens.setLines(line) tokenstream.Add(tokens) From bd6849bf134a5a7243fe4680711ae5e7a242dc72 Mon Sep 17 00:00:00 2001 From: Mark Daryl Caguia Date: Mon, 13 Feb 2017 10:25:24 +0800 Subject: [PATCH 08/10] Function Declaration and Definition --- CodeGeneration/CodeTranslator.cs | 375 +++++- Core Library/Core Library/SyntaxConstants.cs | 166 +-- SemanticsAnalyzer/SemanticsInitializer.cs | 85 +- Syntax Analyzer/SyntaxAnalyzer.cs | 144 +++ Syntax Analyzer/SyntaxConstants.cs | 167 +-- Syntax Analyzer/SyntaxParser.cs | 58 +- Zootopia_Compiler/Form1.Designer.vb | 58 +- Zootopia_Compiler/Form1.vb | 1194 +++++++++--------- 8 files changed, 1411 insertions(+), 836 deletions(-) diff --git a/CodeGeneration/CodeTranslator.cs b/CodeGeneration/CodeTranslator.cs index 5cb26ba..9342daf 100644 --- a/CodeGeneration/CodeTranslator.cs +++ b/CodeGeneration/CodeTranslator.cs @@ -24,8 +24,7 @@ public CodeTranslator() private List objects; private List task; private string currscope = "Mane"; - - + public CodeTranslator(List tokens, SemanticsInitializer semantics) { this.tokens = tokens; @@ -40,6 +39,10 @@ public class Tokens : TokenClass { public List attribute = new List(); + public string datatype; + + public int code; + public void addAttribute(string attribute) { this.attribute.Add(attribute); @@ -49,8 +52,29 @@ public List getAttribute() { return this.attribute; } + + public void setDatatype(string datatype) + { + this.datatype = datatype; + } + + public string getDatatype() + { + return this.datatype; + } + + public void setCode(int code) + { + this.code = code; + } + + public int getCode() + { + return this.code; + } } + public string error = ""; public string code = "using System; \nnamespace Zootopia\n{\n public class Compiler\n{\n"; private bool isRead = false; @@ -67,6 +91,17 @@ public List getAttribute() private bool isDec; private bool isMultiOutput; private bool isGlobal; + private bool isIdentVar = false; + private string varid; + private string vardtype; + private bool isFunct = false; + private bool hasDeclared = false; + private bool isFirstDec = false; + private bool isArrayDec = false; + private string arrval; + private bool isFunctVar = false; + private bool isFunctArgs = false; + private bool isSemiDone; public string Start() { @@ -110,6 +145,8 @@ public string Start() return result; } + + private Parser CreateParser(string input) { SyntaxParser parser = null; @@ -191,7 +228,7 @@ public override Node ExitMane(Token node) { if (isAdd) { - code += "static void Main"; + code += "public static void Main"; isAdd = false; } return node; @@ -374,7 +411,7 @@ public override Node ExitHop(Token node) { if (isAdd) { - code += "return"; + code += "return "; isAdd = false; } return node; @@ -449,7 +486,18 @@ public override Node ExitTermi(Token node) { if (isAdd) { - code += ";\n"; + if (!isFunct) + { + if (!isIdentVar) + { + if (!isFunctVar) + { + code += ";\n"; + } + } + } + else + isFunct = false; isAdd = false; } return node; @@ -501,7 +549,9 @@ public override Node ExitOb(Token node) { if (isAdd) { - code += "["; + if (!isArray) + if(!isArrayDec) + code += "["; isAdd = false; } return node; @@ -514,7 +564,11 @@ public override Node ExitCb(Token node) { if (isAdd) { - code += "]"; + if (isArray) + if (!isArrayDec) + { + code += "]"; + } isAdd = false; } return node; @@ -566,7 +620,10 @@ public override Node ExitCp(Token node) { if (isAdd) { - code += ")"; + if (!isFunct) + { + code += ")"; + } isAdd = false; } return node; @@ -884,7 +941,18 @@ public override Node ExitNewt(Token node) { if (isAdd) { - code += "int "; + if (!isArray) + { + if (!isIdentVar) + { + if (!isFunct) + { + input_datatype = "Int"; + code += "int "; + } + } + + } isAdd = false; } return node; @@ -897,7 +965,18 @@ public override Node ExitDuck(Token node) { if (isAdd) { - code += "double "; + if (!isArray) + { + if(!isIdentVar) + { + if (!isFunct) + { + input_datatype = "Double"; + code += "double "; + } + } + + } isAdd = false; } return node; @@ -910,7 +989,12 @@ public override Node ExitBull(Token node) { if (isAdd) { - code += "bool "; + if (!isArray) + { + if (!isIdentVar) + if (!isFunct) + code += "bool "; + } isAdd = false; } return node; @@ -923,7 +1007,17 @@ public override Node ExitStarling(Token node) { if (isAdd) { - code += "string "; + if (!isArray) + { + if(!isIdentVar) + { + if (!isFunct) + { + input_datatype = "String"; + code += "string "; + } + } + } isAdd = false; } return node; @@ -949,9 +1043,15 @@ public override Node ExitNewtlit(Token node) { if (isAdd) { - Tokens t = new Tokens(); - t = GetTokens(node.GetStartLine(), node.GetStartColumn()); - code += t.getLexemes(); + if (!isArray) + { + if (!isArrayDec) + { + Tokens t = new Tokens(); + t = GetTokens(node.GetStartLine(), node.GetStartColumn()); + code += t.getLexemes(); + } + } isAdd = false; } return node; @@ -1020,9 +1120,20 @@ public override Node ExitId(Token node) { if (isAdd) { - Tokens t = new Tokens(); - t = GetTokens(node.GetStartLine(), node.GetStartColumn()); - code += " " + t.getLexemes().Remove(0, 1); + if (!isArray) + { + if (!isIdentVar) + { + Tokens t = new Tokens(); + t = GetTokens(node.GetStartLine(), node.GetStartColumn()); + code += " " + t.getLexemes().Remove(0, 1); + if (isDec) + { + int codenum = t.getCode(); + tokens[codenum].setDatatype(input_datatype); + } + } + } isAdd = false; } return node; @@ -1101,20 +1212,32 @@ public override void EnterProdVarDec(Production node) { if (currscope == "Global") { - code += "\npublic static "; + code += "\n"; } + isDec = true; } public override Node ExitProdVarDec(Production node) { + isIdentVar = false; return node; } public override void ChildProdVarDec(Production node, Node child) { + node.AddChild(child); + if(child.GetName() == "TERMI") + { + if(!hasDeclared) + { + code += "public static " + vardtype + " " + varid ; + } + isIdentVar = true; + code += ";\n"; + } } @@ -1131,17 +1254,54 @@ public override Node ExitProdFuncVar(Production node) public override void ChildProdFuncVar(Production node, Node child) { + if (child.GetName() == "OP" && isIdentVar) + { + + code = code.Remove(code.Length - 16, 16); + isFunct = true; + isIdentVar = false; + + } node.AddChild(child); } public override void EnterProdIdentVar(Production node) { + if (!isFunctArgs) { + isSemiDone = false; + isIdentVar = true; + } + isFirstDec = true; } public override Node ExitProdIdentVar(Production node) { + vardtype = " "; varid = " "; + Tokens t = new Tokens(); + t = GetTokens(node.GetChildAt(0).GetStartLine(), node.GetChildAt(0).GetStartColumn()); + vardtype = t.getLexemes(); + t = GetTokens(node.GetChildAt(2).GetStartLine(), node.GetChildAt(2).GetStartColumn()); + varid = t.getLexemes(); + varid = varid.Remove(0, 1); + + switch (vardtype) + { + case "newt": + vardtype = "int"; + break; + case "duck": + vardtype = "double"; + break; + case "starling": + vardtype = "string"; + break; + case "bull": + vardtype = "bool"; + break; + } + return node; } @@ -1171,6 +1331,7 @@ public override void ChildProdDtype(Production node, Node child) public override void EnterProdNext2var(Production node) { + } @@ -1183,13 +1344,88 @@ public override Node ExitProdNext2var(Production node) public override void ChildProdNext2var(Production node, Node child) { node.AddChild(child); + Tokens st = new Tokens(); + st = GetTokens(child.GetStartLine(), child.GetStartColumn()); + string ss = st.getLexemes(); + if (node.GetChildCount() == 1 && child.GetName() == "prod_array1D") + { + string codes = code; + if (!isFirstDec) + code += ";\n"; + else + { + isFirstDec = false; + } + if (currscope == "Global") + { + code += "public static "; + } + Node val = child.GetChildAt(1).GetChildAt(0); + if (val.GetName() == "NEWTLIT") + { + Tokens tval = new Tokens(); + tval = GetTokens(val.GetStartLine(), child.GetStartColumn()); + arrval = tval.getLexemes(); + } + } + else if(node.GetChildCount() == 1 && child.GetName() == "EQUAL") + { + + code = code.Remove(code.Length - 2, 2); + + if (!isFirstDec) + code += ";\n"; + else + { + isFirstDec = false; + } + if (currscope == "Global") + { + code += "public static "; + } + code += vardtype + " " + varid + " = "; + hasDeclared = true; + } + else if (node.GetChildCount() == 2 && node.GetChildAt(0).GetName() == "COMMA") + { + code = code.Remove(code.Length - 2, 2); + if(!hasDeclared) + { + if (!isFirstDec) + code += ";\n"; + else + { + isFirstDec = false; + } + if (currscope == "Global") + { + code += "public static "; + } + code += vardtype + " " + varid; + } + Tokens t = new Tokens(); + t = GetTokens(child.GetStartLine(), child.GetStartColumn()); + varid = t.getLexemes(); + varid = varid.Remove(0, 1); + hasDeclared = false; + } + if (child.GetName() == "prod_next2var") + { + Tokens t = new Tokens(); + t = GetTokens(child.GetStartLine(), child.GetStartColumn()); + if(t.getLexemes() == "," && !isSemiDone) + { + code += ";\n"; + isSemiDone = true; + } + } } public override void EnterProdNext2varTail(Production node) { - } + } public override Node ExitProdNext2varTail(Production node) { @@ -1200,6 +1436,70 @@ public override Node ExitProdNext2varTail(Production node) public override void ChildProdNext2varTail(Production node, Node child) { node.AddChild(child); + if (node.GetChildCount() == 2 && node.GetChildAt(0).GetName() == "COMMA") + { + code = code.Remove(code.Length - 2, 2); + if (!hasDeclared) + { + if (!isFirstDec) + code += ";\n"; + else + { + isFirstDec = false; + } + if (currscope == "Global") + { + code += "public static "; + } + code += vardtype + " " + varid; + } + Tokens t = new Tokens(); + t = GetTokens(child.GetStartLine(), child.GetStartColumn()); + varid = t.getLexemes(); + varid = varid.Remove(0, 1); + hasDeclared = false; + } + if (child.GetName() == "prod_next2var") + { + Tokens t = new Tokens(); + t = GetTokens(child.GetStartLine(), child.GetStartColumn()); + if (t.getLexemes() == "," && !isSemiDone) + { + code += ";\n"; + isSemiDone = true; + } + } + + + //if (node.GetChildCount() == 2 && node.GetChildAt(0).GetName() == "COMMA") + //{ + // code = code.Remove(code.Length - 2, 2); + // if (!hasDeclared) + // { + // if (!isFirstDec) + // code += ";\n"; + // else + // { + // isFirstDec = false; + // } + // if(currscope == "Global") + // { + // code += "public static "; + // } + // code += vardtype + " " + varid; + // } + // Tokens t = new Tokens(); + // t = GetTokens(child.GetStartLine(), child.GetStartColumn()); + // varid = t.getLexemes(); + // varid = varid.Remove(0, 1); + // hasDeclared = false; + // isFirstDec = false; + //} + //if(child.GetName() == "prod_next2var") + //{ + // Tokens t = new Tokens(); + // t = GetTokens(child.GetChildAt(1).GetStartLine(), child.GetChildAt(1).GetStartColumn()); + //} } @@ -1272,12 +1572,21 @@ public override void ChildProdBulLit(Production node, Node child) public override void EnterProdArray1d(Production node) - { + { + isAdd = true; + isArrayDec = true; } public override Node ExitProdArray1d(Production node) { + isArrayDec = false; + isArray = false; + //var size = " "; + //var input_size = 0; + //Node arrsize = node.GetChildAt(1); + //Node arrval = arrsize.GetChildAt(0).GetValue(Int32.Parse(size, out input_size)); + return node; } @@ -1602,6 +1911,7 @@ public override void EnterProdLocalDec(Production node) public override Node ExitProdLocalDec(Production node) { + isIdentVar = false; return node; } @@ -1609,6 +1919,15 @@ public override Node ExitProdLocalDec(Production node) public override void ChildProdLocalDec(Production node, Node child) { node.AddChild(child); + if (child.GetName() == "TERMI") + { + if (!hasDeclared) + { + code += vardtype + " " + varid; + } + isIdentVar = true; + code += ";\n"; + } } @@ -2570,6 +2889,7 @@ public override void EnterProdDefault(Production node) public override Node ExitProdDefault(Production node) { + code += "break;\n"; return node; } @@ -2682,6 +3002,7 @@ public override void ChildProdUnaryOp(Production node, Node child) public override void EnterProdSubFunction(Production node) { + code += "\npublic static "; } @@ -2694,6 +3015,7 @@ public override Node ExitProdSubFunction(Production node) public override void ChildProdSubFunction(Production node, Node child) { node.AddChild(child); + } @@ -2711,16 +3033,27 @@ public override Node ExitProdFuncInside(Production node) public override void ChildProdFuncInside(Production node, Node child) { node.AddChild(child); + //if (child.GetName() == "TERMI") + //{ + // if (!hasDeclared) + // { + // code += vardtype + " " + varid; + // } + // isIdentVar = true; + // code += ";\n"; + //} } public override void EnterProdFuncArgs(Production node) { + isFunctArgs = true; } public override Node ExitProdFuncArgs(Production node) { + isFunctArgs = false; return node; } diff --git a/Core Library/Core Library/SyntaxConstants.cs b/Core Library/Core Library/SyntaxConstants.cs index 2b554e0..bd9ddfd 100644 --- a/Core Library/Core Library/SyntaxConstants.cs +++ b/Core Library/Core Library/SyntaxConstants.cs @@ -87,85 +87,89 @@ public enum SyntaxConstants PROD_IDENT_VAR = 2006, PROD_DTYPE = 2007, PROD_NEXT2VAR = 2008, - PROD_NEXT2VAR_TAIL = 2009, - PROD_VAL = 2010, - PROD_VAL1 = 2011, - PROD_VAL2 = 2012, - PROD_BUL_LIT = 2013, - PROD_ARRAY1D = 2014, - PROD_ELEM1D_NEXT = 2015, - PROD_ELEM1D_LIST = 2016, - PROD_ELEMLIST1D_TAIL = 2017, - PROD_ELEM2D_NEXT = 2018, - PROD_ELEM2D_LIST = 2019, - PROD_ELEM2D_LIST_TAIL = 2020, - PROD_SIZE = 2021, - PROD_CONST_DEC = 2022, - PROD_CONST_NEXT = 2023, - PROD_FUNC_NAME = 2024, - PROD_PARAM = 2025, - PROD_PARAM2 = 2026, - PROD_STORK_DEC = 2027, - PROD_STORK_ELEM = 2028, - PROD_MULTI_VARDEC = 2029, - PROD_MULTISTORK_ELEM = 2030, - PROD_OBJ_DEC = 2031, - PROD_MANE = 2032, - PROD_LOCAL_DEC = 2033, - PROD_STATEMENT = 2034, - PROD_STATE_NEXT = 2035, - PROD_ASSIGN1 = 2036, - PROD_ASSIGN_TAIL = 2037, - PROD_NEXT_FIG = 2038, - PROD_MATH_EQTAIL1 = 2039, - PROD_MATH_EQTAIL2 = 2040, - PROD_MATHEQ = 2041, - PROD_MATH_TAIL = 2042, - PROD_MATH_OP = 2043, - PROD_MATH_FIG1 = 2044, - PROD_FUNCTION_CALL = 2045, - PROD_ARGS1 = 2046, - PROD_ARGS_TAIL = 2047, - PROD_ARG_IN = 2048, - PROD_CLRSCR = 2049, - PROD_INPUT = 2050, - PROD_SCAN_FIG = 2051, - PROD_MULTI_INPUT = 2052, - PROD_ARR1D = 2053, - PROD_ARR2D = 2054, - PROD_STORK_ACCESS1 = 2055, - PROD_OUTPUT = 2056, - PROD_OUT = 2057, - PROD_MULTI_OUTPUT = 2058, - PROD_CONDITIONAL = 2059, - PROD_CONDI = 2060, - PROD_NOT_FIG = 2061, - PROD_COND_EXPR = 2062, - PROD_REL_EXPR = 2063, - PROD_RELEX_TAIL = 2064, - PROD_EXPRESSION = 2065, - PROD_REL_OP1 = 2066, - PROD_REL_OP2 = 2067, - PROD_REL_FIG = 2068, - PROD_LOG_EXPR = 2069, - PROD_LOG_EXPR_NEXT = 2070, - PROD_LOG_OP = 2071, - PROD_COND_EELSIF = 2072, - PROD_COND_EELS = 2073, - PROD_SWASP_CASE = 2074, - PROD_SWASP_CASE1 = 2075, - PROD_TERM_EXPR = 2076, - PROD_DEFAULT = 2077, - PROD_ITERATIVE = 2078, - PROD_LOOP_FIG1 = 2079, - PROD_REL_EXPR1 = 2080, - PROD_INCREM_DECREM = 2081, - PROD_UNARY_OP = 2082, - PROD_SUB_FUNCTION = 2083, - PROD_FUNC_INSIDE = 2084, - PROD_FUNC_ARGS = 2085, - PROD_MULTIFUNC_ARGS = 2086, - PROD_RESULT = 2087, - PROD_FIG_TAIL = 2088, - PROD_RESULT_TAIL = 2089 + PROD_IDCHOICE = 2009, + PROD_NEXT2VAR_TAIL = 2010, + PROD_VAL = 2011, + PROD_VAL1 = 2012, + PROD_VAL2 = 2013, + PROD_BUL_LIT = 2014, + PROD_ARRAY1D = 2015, + PROD_ELEM1D_NEXT = 2016, + PROD_ELEM1D_LIST = 2017, + PROD_ELEMLIST1D_TAIL = 2018, + PROD_ELEM2D_NEXT = 2019, + PROD_ELEM2D_LIST = 2020, + PROD_ELEM2D_LIST_TAIL = 2021, + PROD_SIZE = 2022, + PROD_CONST_DEC = 2023, + PROD_CONST_NEXT = 2024, + PROD_FUNC_NAME = 2025, + PROD_PARAM = 2026, + PROD_PARAM2 = 2027, + PROD_STORK_DEC = 2028, + PROD_STORK_ELEM = 2029, + PROD_MULTI_VARDEC = 2030, + PROD_MULTISTORK_ELEM = 2031, + PROD_OBJ_DEC = 2032, + PROD_MANE = 2033, + PROD_LOCAL_DEC = 2034, + PROD_STATEMENT = 2035, + PROD_STATE_NEXT = 2036, + PROD_ASSIGN1 = 2037, + PROD_ASSIGN_TAIL = 2038, + PROD_ASSIGN_CHOICE = 2039, + PROD_NEXT_FIG = 2040, + PROD_MATH_EQTAIL1 = 2041, + PROD_MATH_EQTAIL2 = 2042, + PROD_MATHEQ = 2043, + PROD_MATH_TAIL = 2044, + PROD_MATH_OP = 2045, + PROD_MATH_FIG1 = 2046, + PROD_FUNCTION_CALL = 2047, + PROD_ARGS1 = 2048, + PROD_ARGS_TAIL = 2049, + PROD_ARG_IN = 2050, + PROD_CLRSCR = 2051, + PROD_RETURN = 2052, + PROD_INPUT = 2053, + PROD_SCAN_FIG = 2054, + PROD_MULTI_INPUT = 2055, + PROD_ARR1D = 2056, + PROD_ARR2D = 2057, + PROD_STORK_ACCESS1 = 2058, + PROD_OUTPUT = 2059, + PROD_OUT = 2060, + PROD_MULTI_OUTPUT = 2061, + PROD_CONDITIONAL = 2062, + PROD_CONDI = 2063, + PROD_NOT_FIG = 2064, + PROD_COND_EXPR = 2065, + PROD_REL_EXPR = 2066, + PROD_RELEX_TAIL = 2067, + PROD_EXPRESSION = 2068, + PROD_REL_OP1 = 2069, + PROD_REL_OP2 = 2070, + PROD_REL_FIG = 2071, + PROD_LOG_EXPR = 2072, + PROD_LOG_EXPR_NEXT = 2073, + PROD_LOG_OP = 2074, + PROD_COND_EELSIF = 2075, + PROD_COND_EELS = 2076, + PROD_SWASP_CASE = 2077, + PROD_SWASP_CASE1 = 2078, + PROD_TERM_EXPR = 2079, + PROD_DEFAULT = 2080, + PROD_ITERATIVE = 2081, + PROD_LOOP_FIG1 = 2082, + PROD_REL_EXPR1 = 2083, + PROD_LOOP_FIG2 = 2084, + PROD_INCREM_DECREM = 2085, + PROD_UNARY_OP = 2086, + PROD_SUB_FUNCTION = 2087, + PROD_FUNC_INSIDE = 2088, + PROD_FUNC_ARGS = 2089, + PROD_MULTIFUNC_ARGS = 2090, + PROD_RESULT = 2091, + PROD_FIG_TAIL = 2092, + PROD_RESULT_TAIL = 2093 } diff --git a/SemanticsAnalyzer/SemanticsInitializer.cs b/SemanticsAnalyzer/SemanticsInitializer.cs index 5f9e6da..f7ca053 100644 --- a/SemanticsAnalyzer/SemanticsInitializer.cs +++ b/SemanticsAnalyzer/SemanticsInitializer.cs @@ -971,7 +971,6 @@ public override void ChildProdMane(Production node, Node child) node.AddChild(child); } - public override void EnterProdLocalDec(Production node) { currscope = "Mane"; @@ -1003,7 +1002,18 @@ public override Node ExitProdLocalDec(Production node) Node next2var = node.GetChildAt(1); if (next2var.GetName() == "prod_next2var") { - saveVariables(next2var, dtype, scope); + if (next2var.GetChildAt(0).GetName() == "EQUAL") + { + if (next2var.GetChildCount() > 2) + { + next2var = next2var.GetChildAt(2); + saveVariables(next2var, dtype, scope); + } + } + else + { + saveVariables(next2var, dtype, scope); + } } } @@ -1015,23 +1025,39 @@ private void saveVariables(Node node, string dtype, string scope) int idline, idcol; string id = ""; bool isSaved = false; - idline = node.GetChildAt(1).GetStartLine(); - idcol = node.GetChildAt(1).GetStartColumn(); - Tokens token = new Tokens(); - token = GetTokens(idline, idcol); - id = token.getLexemes(); - SemanticsConstants.Identifiers identifier = new SemanticsConstants.Identifiers(); - identifier = setIdentifier(id, "", dtype, scope, "", idline, token.getTokens()); - isSaved = checkIdentifier(identifier); - - if (node.GetChildCount() > 2) + if(node.GetChildCount() == 1) { - Node next2var = node.GetChildAt(2); - if (next2var.GetName() == "prod_next2var") + idline = node.GetChildAt(0).GetStartLine(); + idcol = node.GetChildAt(0).GetStartColumn(); + Tokens token = new Tokens(); + token = GetTokens(idline, idcol); + id = token.getLexemes(); + SemanticsConstants.Identifiers identifier = new SemanticsConstants.Identifiers(); + identifier = setIdentifier(id, "", dtype, scope, "", idline, token.getTokens()); + isSaved = checkIdentifier(identifier); + + } + else + { + idline = node.GetChildAt(1).GetStartLine(); + idcol = node.GetChildAt(1).GetStartColumn(); + Tokens token = new Tokens(); + token = GetTokens(idline, idcol); + id = token.getLexemes(); + SemanticsConstants.Identifiers identifier = new SemanticsConstants.Identifiers(); + identifier = setIdentifier(id, "", dtype, scope, "", idline, token.getTokens()); + isSaved = checkIdentifier(identifier); + if (node.GetChildCount() > 2) { - saveVariables(next2var, dtype, scope); + Node next2var = node.GetChildAt(2); + if (next2var.GetName() == "prod_next2var") + { + saveVariables(next2var, dtype, scope); + } } } + + } @@ -1378,10 +1404,37 @@ public override void EnterProdArr1d(Production node) public override Node ExitProdArr1d(Production node) { + string dtype = "", scope = currscope, id = ""; + Node ident_var = node.GetChildAt(0); + Node datatype = ident_var.GetChildAt(0).GetChildAt(0); + dtype = getDtype(datatype.GetName()); + bool isFunct = false; + bool isArray = false; + bool isSaved = false; + int idline, idcol; + idline = ident_var.GetChildAt(2).GetStartLine(); + idcol = ident_var.GetChildAt(2).GetStartColumn(); + Tokens token = new Tokens(); + token = GetTokens(idline, idcol); + id = token.getLexemes(); + SemanticsConstants.Identifiers identifier = new SemanticsConstants.Identifiers(); + identifier = setIdentifier(id, "", dtype, scope, "", idline, token.getTokens()); + isSaved = checkIdentifier(identifier); + + + if (node.GetChildCount() > 2) + { + Node next2var = node.GetChildAt(1); + if (next2var.GetName() == "prod_next2var") + { + saveVariables(next2var, dtype, scope); + } + } + return node; } - + public override void ChildProdArr1d(Production node, Node child) { node.AddChild(child); diff --git a/Syntax Analyzer/SyntaxAnalyzer.cs b/Syntax Analyzer/SyntaxAnalyzer.cs index 802e2d3..c0bf992 100644 --- a/Syntax Analyzer/SyntaxAnalyzer.cs +++ b/Syntax Analyzer/SyntaxAnalyzer.cs @@ -250,6 +250,9 @@ public override void Enter(Node node) { case (int) SyntaxConstants.PROD_NEXT2VAR: EnterProdNext2var((Production) node); break; + case (int) SyntaxConstants.PROD_IDCHOICE: + EnterProdIdchoice((Production) node); + break; case (int) SyntaxConstants.PROD_NEXT2VAR_TAIL: EnterProdNext2varTail((Production) node); break; @@ -337,6 +340,9 @@ public override void Enter(Node node) { case (int) SyntaxConstants.PROD_ASSIGN_TAIL: EnterProdAssignTail((Production) node); break; + case (int) SyntaxConstants.PROD_ASSIGN_CHOICE: + EnterProdAssignChoice((Production) node); + break; case (int) SyntaxConstants.PROD_NEXT_FIG: EnterProdNextFig((Production) node); break; @@ -373,6 +379,9 @@ public override void Enter(Node node) { case (int) SyntaxConstants.PROD_CLRSCR: EnterProdClrscr((Production) node); break; + case (int) SyntaxConstants.PROD_RETURN: + EnterProdReturn((Production) node); + break; case (int) SyntaxConstants.PROD_INPUT: EnterProdInput((Production) node); break; @@ -664,6 +673,8 @@ public override Node Exit(Node node) { return ExitProdDtype((Production) node); case (int) SyntaxConstants.PROD_NEXT2VAR: return ExitProdNext2var((Production) node); + case (int) SyntaxConstants.PROD_IDCHOICE: + return ExitProdIdchoice((Production) node); case (int) SyntaxConstants.PROD_NEXT2VAR_TAIL: return ExitProdNext2varTail((Production) node); case (int) SyntaxConstants.PROD_VAL: @@ -722,6 +733,8 @@ public override Node Exit(Node node) { return ExitProdAssign1((Production) node); case (int) SyntaxConstants.PROD_ASSIGN_TAIL: return ExitProdAssignTail((Production) node); + case (int) SyntaxConstants.PROD_ASSIGN_CHOICE: + return ExitProdAssignChoice((Production) node); case (int) SyntaxConstants.PROD_NEXT_FIG: return ExitProdNextFig((Production) node); case (int) SyntaxConstants.PROD_MATH_EQTAIL1: @@ -746,6 +759,8 @@ public override Node Exit(Node node) { return ExitProdArgIn((Production) node); case (int) SyntaxConstants.PROD_CLRSCR: return ExitProdClrscr((Production) node); + case (int) SyntaxConstants.PROD_RETURN: + return ExitProdReturn((Production) node); case (int) SyntaxConstants.PROD_INPUT: return ExitProdInput((Production) node); case (int) SyntaxConstants.PROD_SCAN_FIG: @@ -868,6 +883,9 @@ public override void Child(Production node, Node child) { case (int) SyntaxConstants.PROD_NEXT2VAR: ChildProdNext2var(node, child); break; + case (int) SyntaxConstants.PROD_IDCHOICE: + ChildProdIdchoice(node, child); + break; case (int) SyntaxConstants.PROD_NEXT2VAR_TAIL: ChildProdNext2varTail(node, child); break; @@ -955,6 +973,9 @@ public override void Child(Production node, Node child) { case (int) SyntaxConstants.PROD_ASSIGN_TAIL: ChildProdAssignTail(node, child); break; + case (int) SyntaxConstants.PROD_ASSIGN_CHOICE: + ChildProdAssignChoice(node, child); + break; case (int) SyntaxConstants.PROD_NEXT_FIG: ChildProdNextFig(node, child); break; @@ -991,6 +1012,9 @@ public override void Child(Production node, Node child) { case (int) SyntaxConstants.PROD_CLRSCR: ChildProdClrscr(node, child); break; + case (int) SyntaxConstants.PROD_RETURN: + ChildProdReturn(node, child); + break; case (int) SyntaxConstants.PROD_INPUT: ChildProdInput(node, child); break; @@ -3205,6 +3229,46 @@ public virtual void ChildProdNext2var(Production node, Node child) { node.AddChild(child); } + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdIdchoice(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdIdchoice(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdIdchoice(Production node, Node child) { + node.AddChild(child); + } + /** * Called when entering a parse tree node. * @@ -4365,6 +4429,46 @@ public virtual void ChildProdAssignTail(Production node, Node child) { node.AddChild(child); } + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdAssignChoice(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdAssignChoice(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdAssignChoice(Production node, Node child) { + node.AddChild(child); + } + /** * Called when entering a parse tree node. * @@ -4845,6 +4949,46 @@ public virtual void ChildProdClrscr(Production node, Node child) { node.AddChild(child); } + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdReturn(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdReturn(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdReturn(Production node, Node child) { + node.AddChild(child); + } + /** * Called when entering a parse tree node. * diff --git a/Syntax Analyzer/SyntaxConstants.cs b/Syntax Analyzer/SyntaxConstants.cs index cc6488c..3d1010d 100644 --- a/Syntax Analyzer/SyntaxConstants.cs +++ b/Syntax Analyzer/SyntaxConstants.cs @@ -86,86 +86,89 @@ public enum SyntaxConstants { PROD_IDENT_VAR = 2006, PROD_DTYPE = 2007, PROD_NEXT2VAR = 2008, - PROD_NEXT2VAR_TAIL = 2009, - PROD_VAL = 2010, - PROD_VAL1 = 2011, - PROD_VAL2 = 2012, - PROD_BUL_LIT = 2013, - PROD_ARRAY1D = 2014, - PROD_ELEM1D_NEXT = 2015, - PROD_ELEM1D_LIST = 2016, - PROD_ELEMLIST1D_TAIL = 2017, - PROD_ELEM2D_NEXT = 2018, - PROD_ELEM2D_LIST = 2019, - PROD_ELEM2D_LIST_TAIL = 2020, - PROD_SIZE = 2021, - PROD_CONST_DEC = 2022, - PROD_CONST_NEXT = 2023, - PROD_FUNC_NAME = 2024, - PROD_PARAM = 2025, - PROD_PARAM2 = 2026, - PROD_STORK_DEC = 2027, - PROD_STORK_ELEM = 2028, - PROD_MULTI_VARDEC = 2029, - PROD_MULTISTORK_ELEM = 2030, - PROD_OBJ_DEC = 2031, - PROD_MANE = 2032, - PROD_LOCAL_DEC = 2033, - PROD_STATEMENT = 2034, - PROD_STATE_NEXT = 2035, - PROD_ASSIGN1 = 2036, - PROD_ASSIGN_TAIL = 2037, - PROD_NEXT_FIG = 2038, - PROD_MATH_EQTAIL1 = 2039, - PROD_MATH_EQTAIL2 = 2040, - PROD_MATHEQ = 2041, - PROD_MATH_TAIL = 2042, - PROD_MATH_OP = 2043, - PROD_MATH_FIG1 = 2044, - PROD_FUNCTION_CALL = 2045, - PROD_ARGS1 = 2046, - PROD_ARGS_TAIL = 2047, - PROD_ARG_IN = 2048, - PROD_CLRSCR = 2049, - PROD_INPUT = 2050, - PROD_SCAN_FIG = 2051, - PROD_MULTI_INPUT = 2052, - PROD_ARR1D = 2053, - PROD_ARR2D = 2054, - PROD_STORK_ACCESS1 = 2055, - PROD_OUTPUT = 2056, - PROD_OUT = 2057, - PROD_MULTI_OUTPUT = 2058, - PROD_CONDITIONAL = 2059, - PROD_CONDI = 2060, - PROD_NOT_FIG = 2061, - PROD_COND_EXPR = 2062, - PROD_REL_EXPR = 2063, - PROD_RELEX_TAIL = 2064, - PROD_EXPRESSION = 2065, - PROD_REL_OP1 = 2066, - PROD_REL_OP2 = 2067, - PROD_REL_FIG = 2068, - PROD_LOG_EXPR = 2069, - PROD_LOG_EXPR_NEXT = 2070, - PROD_LOG_OP = 2071, - PROD_COND_EELSIF = 2072, - PROD_COND_EELS = 2073, - PROD_SWASP_CASE = 2074, - PROD_SWASP_CASE1 = 2075, - PROD_TERM_EXPR = 2076, - PROD_DEFAULT = 2077, - PROD_ITERATIVE = 2078, - PROD_LOOP_FIG1 = 2079, - PROD_REL_EXPR1 = 2080, - PROD_LOOP_FIG2 = 2081, - PROD_INCREM_DECREM = 2082, - PROD_UNARY_OP = 2083, - PROD_SUB_FUNCTION = 2084, - PROD_FUNC_INSIDE = 2085, - PROD_FUNC_ARGS = 2086, - PROD_MULTIFUNC_ARGS = 2087, - PROD_RESULT = 2088, - PROD_FIG_TAIL = 2089, - PROD_RESULT_TAIL = 2090 + PROD_IDCHOICE = 2009, + PROD_NEXT2VAR_TAIL = 2010, + PROD_VAL = 2011, + PROD_VAL1 = 2012, + PROD_VAL2 = 2013, + PROD_BUL_LIT = 2014, + PROD_ARRAY1D = 2015, + PROD_ELEM1D_NEXT = 2016, + PROD_ELEM1D_LIST = 2017, + PROD_ELEMLIST1D_TAIL = 2018, + PROD_ELEM2D_NEXT = 2019, + PROD_ELEM2D_LIST = 2020, + PROD_ELEM2D_LIST_TAIL = 2021, + PROD_SIZE = 2022, + PROD_CONST_DEC = 2023, + PROD_CONST_NEXT = 2024, + PROD_FUNC_NAME = 2025, + PROD_PARAM = 2026, + PROD_PARAM2 = 2027, + PROD_STORK_DEC = 2028, + PROD_STORK_ELEM = 2029, + PROD_MULTI_VARDEC = 2030, + PROD_MULTISTORK_ELEM = 2031, + PROD_OBJ_DEC = 2032, + PROD_MANE = 2033, + PROD_LOCAL_DEC = 2034, + PROD_STATEMENT = 2035, + PROD_STATE_NEXT = 2036, + PROD_ASSIGN1 = 2037, + PROD_ASSIGN_TAIL = 2038, + PROD_ASSIGN_CHOICE = 2039, + PROD_NEXT_FIG = 2040, + PROD_MATH_EQTAIL1 = 2041, + PROD_MATH_EQTAIL2 = 2042, + PROD_MATHEQ = 2043, + PROD_MATH_TAIL = 2044, + PROD_MATH_OP = 2045, + PROD_MATH_FIG1 = 2046, + PROD_FUNCTION_CALL = 2047, + PROD_ARGS1 = 2048, + PROD_ARGS_TAIL = 2049, + PROD_ARG_IN = 2050, + PROD_CLRSCR = 2051, + PROD_RETURN = 2052, + PROD_INPUT = 2053, + PROD_SCAN_FIG = 2054, + PROD_MULTI_INPUT = 2055, + PROD_ARR1D = 2056, + PROD_ARR2D = 2057, + PROD_STORK_ACCESS1 = 2058, + PROD_OUTPUT = 2059, + PROD_OUT = 2060, + PROD_MULTI_OUTPUT = 2061, + PROD_CONDITIONAL = 2062, + PROD_CONDI = 2063, + PROD_NOT_FIG = 2064, + PROD_COND_EXPR = 2065, + PROD_REL_EXPR = 2066, + PROD_RELEX_TAIL = 2067, + PROD_EXPRESSION = 2068, + PROD_REL_OP1 = 2069, + PROD_REL_OP2 = 2070, + PROD_REL_FIG = 2071, + PROD_LOG_EXPR = 2072, + PROD_LOG_EXPR_NEXT = 2073, + PROD_LOG_OP = 2074, + PROD_COND_EELSIF = 2075, + PROD_COND_EELS = 2076, + PROD_SWASP_CASE = 2077, + PROD_SWASP_CASE1 = 2078, + PROD_TERM_EXPR = 2079, + PROD_DEFAULT = 2080, + PROD_ITERATIVE = 2081, + PROD_LOOP_FIG1 = 2082, + PROD_REL_EXPR1 = 2083, + PROD_LOOP_FIG2 = 2084, + PROD_INCREM_DECREM = 2085, + PROD_UNARY_OP = 2086, + PROD_SUB_FUNCTION = 2087, + PROD_FUNC_INSIDE = 2088, + PROD_FUNC_ARGS = 2089, + PROD_MULTIFUNC_ARGS = 2090, + PROD_RESULT = 2091, + PROD_FIG_TAIL = 2092, + PROD_RESULT_TAIL = 2093 } diff --git a/Syntax Analyzer/SyntaxParser.cs b/Syntax Analyzer/SyntaxParser.cs index 4754e86..da41e23 100644 --- a/Syntax Analyzer/SyntaxParser.cs +++ b/Syntax Analyzer/SyntaxParser.cs @@ -180,7 +180,7 @@ private void CreatePatterns() { pattern.AddAlternative(alt); alt = new ProductionPatternAlternative(); alt.AddToken((int) SyntaxConstants.EQUAL, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_VAL, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_IDCHOICE, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_NEXT2VAR_TAIL, 0, 1); pattern.AddAlternative(alt); alt = new ProductionPatternAlternative(); @@ -189,6 +189,16 @@ private void CreatePatterns() { pattern.AddAlternative(alt); AddPattern(pattern); + pattern = new ProductionPattern((int) SyntaxConstants.PROD_IDCHOICE, + "prod_idchoice"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_VAL, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.ID, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + pattern = new ProductionPattern((int) SyntaxConstants.PROD_NEXT2VAR_TAIL, "prod_next2var_tail"); alt = new ProductionPatternAlternative(); @@ -242,7 +252,7 @@ private void CreatePatterns() { "prod_array1D"); alt = new ProductionPatternAlternative(); alt.AddToken((int) SyntaxConstants.OB, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_SIZE, 0, 1); + alt.AddProduction((int) SyntaxConstants.PROD_SIZE, 1, 1); alt.AddToken((int) SyntaxConstants.CB, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_ELEM1D_NEXT, 0, 1); pattern.AddAlternative(alt); @@ -258,7 +268,7 @@ private void CreatePatterns() { pattern.AddAlternative(alt); alt = new ProductionPatternAlternative(); alt.AddToken((int) SyntaxConstants.OB, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_SIZE, 0, 1); + alt.AddProduction((int) SyntaxConstants.PROD_SIZE, 1, 1); alt.AddToken((int) SyntaxConstants.CB, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_ELEM2D_NEXT, 0, 1); pattern.AddAlternative(alt); @@ -421,9 +431,11 @@ private void CreatePatterns() { alt = new ProductionPatternAlternative(); alt.AddProduction((int) SyntaxConstants.PROD_LOCAL_DEC, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 0, 1); + alt.AddProduction((int) SyntaxConstants.PROD_RETURN, 0, 1); pattern.AddAlternative(alt); alt = new ProductionPatternAlternative(); alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_RETURN, 0, 1); pattern.AddAlternative(alt); AddPattern(pattern); @@ -497,11 +509,26 @@ private void CreatePatterns() { pattern.AddAlternative(alt); AddPattern(pattern); + pattern = new ProductionPattern((int) SyntaxConstants.PROD_ASSIGN_CHOICE, + "prod_assign_choice"); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_ASSIGN_TAIL, 1, 1); + pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.OP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_ARGS1, 0, 1); + alt.AddToken((int) SyntaxConstants.CP, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + pattern = new ProductionPattern((int) SyntaxConstants.PROD_NEXT_FIG, "prod_next_fig"); alt = new ProductionPatternAlternative(); alt.AddProduction((int) SyntaxConstants.PROD_MATH_EQTAIL2, 1, 1); pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.STARLIT, 1, 1); + pattern.AddAlternative(alt); AddPattern(pattern); pattern = new ProductionPattern((int) SyntaxConstants.PROD_MATH_EQTAIL1, @@ -565,7 +592,7 @@ private void CreatePatterns() { "prod_math_fig1"); alt = new ProductionPatternAlternative(); alt.AddToken((int) SyntaxConstants.ID, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_ASSIGN_TAIL, 0, 1); + alt.AddProduction((int) SyntaxConstants.PROD_ASSIGN_CHOICE, 0, 1); pattern.AddAlternative(alt); alt = new ProductionPatternAlternative(); alt.AddProduction((int) SyntaxConstants.PROD_VAL1, 1, 1); @@ -579,7 +606,7 @@ private void CreatePatterns() { "prod_function_call"); alt = new ProductionPatternAlternative(); alt.AddToken((int) SyntaxConstants.OP, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_ARGS1, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_ARGS1, 0, 1); alt.AddToken((int) SyntaxConstants.CP, 1, 1); alt.AddToken((int) SyntaxConstants.TERMI, 1, 1); pattern.AddAlternative(alt); @@ -606,7 +633,7 @@ private void CreatePatterns() { "prod_arg_in"); alt = new ProductionPatternAlternative(); alt.AddToken((int) SyntaxConstants.ID, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_ARR1D, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_ARR1D, 0, 1); pattern.AddAlternative(alt); alt = new ProductionPatternAlternative(); alt.AddProduction((int) SyntaxConstants.PROD_VAL, 1, 1); @@ -621,6 +648,15 @@ private void CreatePatterns() { pattern.AddAlternative(alt); AddPattern(pattern); + pattern = new ProductionPattern((int) SyntaxConstants.PROD_RETURN, + "prod_return"); + alt = new ProductionPatternAlternative(); + alt.AddToken((int) SyntaxConstants.HOP, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_RESULT, 1, 1); + alt.AddToken((int) SyntaxConstants.TERMI, 1, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + pattern = new ProductionPattern((int) SyntaxConstants.PROD_INPUT, "prod_input"); alt = new ProductionPatternAlternative(); @@ -657,7 +693,7 @@ private void CreatePatterns() { "prod_arr1D"); alt = new ProductionPatternAlternative(); alt.AddToken((int) SyntaxConstants.OB, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_SIZE, 0, 1); + alt.AddProduction((int) SyntaxConstants.PROD_SIZE, 1, 1); alt.AddToken((int) SyntaxConstants.CB, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_ARR2D, 0, 1); pattern.AddAlternative(alt); @@ -667,7 +703,7 @@ private void CreatePatterns() { "prod_arr2D"); alt = new ProductionPatternAlternative(); alt.AddToken((int) SyntaxConstants.OB, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_SIZE, 0, 1); + alt.AddProduction((int) SyntaxConstants.PROD_SIZE, 1, 1); alt.AddToken((int) SyntaxConstants.CB, 1, 1); pattern.AddAlternative(alt); AddPattern(pattern); @@ -944,7 +980,7 @@ private void CreatePatterns() { "prod_default"); alt = new ProductionPatternAlternative(); alt.AddToken((int) SyntaxConstants.SEAL, 1, 1); - alt.AddToken((int) SyntaxConstants.TERMI, 1, 1); + alt.AddToken((int) SyntaxConstants.SC, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 0, 1); pattern.AddAlternative(alt); AddPattern(pattern); @@ -959,7 +995,6 @@ private void CreatePatterns() { alt.AddToken((int) SyntaxConstants.ODC, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_LOOP_FIG2, 0, 1); - alt.AddToken((int) SyntaxConstants.TERMI, 1, 1); alt.AddToken((int) SyntaxConstants.CDC, 1, 1); pattern.AddAlternative(alt); alt = new ProductionPatternAlternative(); @@ -1077,6 +1112,9 @@ private void CreatePatterns() { alt.AddProduction((int) SyntaxConstants.PROD_LOCAL_DEC, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 0, 1); pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 1, 1); + pattern.AddAlternative(alt); AddPattern(pattern); pattern = new ProductionPattern((int) SyntaxConstants.PROD_FUNC_ARGS, diff --git a/Zootopia_Compiler/Form1.Designer.vb b/Zootopia_Compiler/Form1.Designer.vb index 0d89d54..a350642 100644 --- a/Zootopia_Compiler/Form1.Designer.vb +++ b/Zootopia_Compiler/Form1.Designer.vb @@ -35,7 +35,9 @@ Partial Class Form1 Me.ColumnHeader3 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) Me.ColumnHeader1 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) Me.Panel1 = New System.Windows.Forms.Panel() + Me.Panel3 = New System.Windows.Forms.Panel() Me.Label1 = New System.Windows.Forms.Label() + Me.PictureBox1 = New System.Windows.Forms.PictureBox() Me.dGridBoard = New System.Windows.Forms.ListView() Me.ColumnHeader = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) Me.ColumnHeader17 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) @@ -57,14 +59,12 @@ Partial Class Form1 Me.ColumnHeader6 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) Me.dGridSemantic = New System.Windows.Forms.ListView() Me.btnClr = New System.Windows.Forms.Button() - Me.Panel3 = New System.Windows.Forms.Panel() - Me.PictureBox1 = New System.Windows.Forms.PictureBox() Me.lineNum = New System.Windows.Forms.PictureBox() Me.btnAna = New System.Windows.Forms.Button() Me.ToolStrip1 = New System.Windows.Forms.ToolStrip() Me.ToolStripDropDownButton1 = New System.Windows.Forms.ToolStripDropDownButton() - Me.CodeGenerationToolStripMenuItem1 = New System.Windows.Forms.ToolStripMenuItem() Me.ConsoleOutputToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() + Me.CodeGenerationToolStripMenuItem1 = New System.Windows.Forms.ToolStripMenuItem() Me.Panel1.SuspendLayout() CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.lineNum, System.ComponentModel.ISupportInitialize).BeginInit() @@ -78,7 +78,7 @@ Partial Class Form1 Me.rTBCode.Name = "rTBCode" Me.rTBCode.Size = New System.Drawing.Size(362, 446) Me.rTBCode.TabIndex = 2 - Me.rTBCode.Text = "" + Me.rTBCode.Text = "entrance" & Global.Microsoft.VisualBasic.ChrW(10) & "mane()" & Global.Microsoft.VisualBasic.ChrW(10) & "{{" & Global.Microsoft.VisualBasic.ChrW(10) & Global.Microsoft.VisualBasic.ChrW(10) & "}}" & Global.Microsoft.VisualBasic.ChrW(10) & "exit" ' 'dGridLexi ' @@ -167,6 +167,15 @@ Partial Class Form1 Me.Panel1.Size = New System.Drawing.Size(165, 458) Me.Panel1.TabIndex = 9 ' + 'Panel3 + ' + Me.Panel3.BackgroundImage = Global.Zootopia_Compiler.My.Resources.Resources.analyzer + Me.Panel3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom + Me.Panel3.Location = New System.Drawing.Point(58, 170) + Me.Panel3.Name = "Panel3" + Me.Panel3.Size = New System.Drawing.Size(49, 198) + Me.Panel3.TabIndex = 10 + ' 'Label1 ' Me.Label1.AutoSize = True @@ -175,6 +184,16 @@ Partial Class Form1 Me.Label1.Size = New System.Drawing.Size(0, 13) Me.Label1.TabIndex = 10 ' + 'PictureBox1 + ' + Me.PictureBox1.BackgroundImage = Global.Zootopia_Compiler.My.Resources.Resources.Zoo_whale + Me.PictureBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom + Me.PictureBox1.Location = New System.Drawing.Point(10, 12) + Me.PictureBox1.Name = "PictureBox1" + Me.PictureBox1.Size = New System.Drawing.Size(142, 139) + Me.PictureBox1.TabIndex = 10 + Me.PictureBox1.TabStop = False + ' 'dGridBoard ' Me.dGridBoard.BackColor = System.Drawing.SystemColors.ControlLightLight @@ -332,25 +351,6 @@ Partial Class Form1 Me.btnClr.Text = "Clear" Me.btnClr.UseVisualStyleBackColor = False ' - 'Panel3 - ' - Me.Panel3.BackgroundImage = Global.Zootopia_Compiler.My.Resources.Resources.analyzer - Me.Panel3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom - Me.Panel3.Location = New System.Drawing.Point(58, 170) - Me.Panel3.Name = "Panel3" - Me.Panel3.Size = New System.Drawing.Size(49, 198) - Me.Panel3.TabIndex = 10 - ' - 'PictureBox1 - ' - Me.PictureBox1.BackgroundImage = Global.Zootopia_Compiler.My.Resources.Resources.Zoo_whale - Me.PictureBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom - Me.PictureBox1.Location = New System.Drawing.Point(10, 12) - Me.PictureBox1.Name = "PictureBox1" - Me.PictureBox1.Size = New System.Drawing.Size(142, 139) - Me.PictureBox1.TabIndex = 10 - Me.PictureBox1.TabStop = False - ' 'lineNum ' Me.lineNum.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(191, Byte), Integer), CType(CType(79, Byte), Integer)) @@ -397,6 +397,12 @@ Partial Class Form1 Me.ToolStripDropDownButton1.Size = New System.Drawing.Size(29, 22) Me.ToolStripDropDownButton1.Text = "Developer Option" ' + 'ConsoleOutputToolStripMenuItem + ' + Me.ConsoleOutputToolStripMenuItem.Name = "ConsoleOutputToolStripMenuItem" + Me.ConsoleOutputToolStripMenuItem.Size = New System.Drawing.Size(162, 22) + Me.ConsoleOutputToolStripMenuItem.Text = "Console output" + ' 'CodeGenerationToolStripMenuItem1 ' Me.CodeGenerationToolStripMenuItem1.Checked = True @@ -405,12 +411,6 @@ Partial Class Form1 Me.CodeGenerationToolStripMenuItem1.Size = New System.Drawing.Size(162, 22) Me.CodeGenerationToolStripMenuItem1.Text = "Code generation" ' - 'ConsoleOutputToolStripMenuItem - ' - Me.ConsoleOutputToolStripMenuItem.Name = "ConsoleOutputToolStripMenuItem" - Me.ConsoleOutputToolStripMenuItem.Size = New System.Drawing.Size(162, 22) - Me.ConsoleOutputToolStripMenuItem.Text = "Console output" - ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) diff --git a/Zootopia_Compiler/Form1.vb b/Zootopia_Compiler/Form1.vb index 8fc0555..343ee1b 100644 --- a/Zootopia_Compiler/Form1.vb +++ b/Zootopia_Compiler/Form1.vb @@ -2981,7 +2981,7 @@ Public Class Form1 symbolCtr += 1 tokens = New TokenLibrary.TokenLibrary.TokenClass tokens.setTokens("~") - tokens.setLexemes("~") + tokens.setLexemes("negOp") tokens.setAttributes("negOp, ~, unary") tokens.setLines(line) tokenstream.Add(tokens) @@ -3343,7 +3343,7 @@ Public Class Form1 lexinew() - identifierList() + 'identifierList() Dim semantics As New Semantics_Analyzer.SemanticsInitializer 'semantic() @@ -5450,600 +5450,600 @@ Public Class Form1 End Sub - Private Sub identifierList() - Dim x As Integer = 0 - Dim isMane As Boolean = False - Dim isStork As Boolean = False - Dim isFunction As Boolean = False - Dim Ctr As Integer = 0 - Dim bCtr As Integer = 0 - Dim erCtr As Integer = 0 - Dim valDType As String = "" - Dim value As String = "" - Dim curDtype As String = "" - Dim type As String = "" - Dim used As String = "No" - Dim arraySize As String = "" - Dim arraySize2 As String = "" - Dim parameter As String = "" - Dim constAns As String = "" - - Dim dtype(4) As String - dtype(0) = "newt" - dtype(1) = "duck" - dtype(2) = "bull" - dtype(3) = "starling" - - For i As Integer = 0 To dGridLexi.Items.Count - 1 - selinee(i) = dGridLexi.Items.Item(i).SubItems(1).Text() 'LINE - Next - - For i As Integer = 0 To dGridLexi.Items.Count - 1 - setokee(i) = dGridLexi.Items.Item(i).SubItems(3).Text() 'TOKEN - Next - - While x < dGridLexi.Items.Count - If setokee(x) = "mane" Then - isStork = False - isMane = True - End If - - If setokee(x) = "stork" Then - isStork = True - 'MessageBox.Show(isStork) - Ctr += 1 - objList = dGridIden.Items.Add(Ctr) - objList.SubItems.Add(dGridLexi.Items.Item(x + 2).SubItems(2).Text()) - objList.SubItems.Add("-") - objList.SubItems.Add("-") - objList.SubItems.Add("-") - objList.SubItems.Add("stork") - objList.SubItems.Add("-") - objList.SubItems.Add("-") - objList.SubItems.Add("-") - objList.SubItems.Add("stork/global") - objList.SubItems.Add("-") - End If - - If setokee(x) = "clsymbol" Then - Dim termi As Integer = x - Dim termi2 As Integer = x - Dim iden As String = "" - If setokee(x + 1) = "identifier" Then - While termi2 >= 0 - If setokee(termi2) = "stork" Then - Exit While - End If - termi2 -= 1 - End While - - iden = dGridLexi.Items.Item(x).SubItems(2).Text - While setokee(termi) <> ":" - If setokee(termi) = "identifier" Then - bCtr += 1 - objList = dGridBoard.Items.Add(dGridLexi.Items.Item(termi).SubItems(2).Text()) - objList.SubItems.Add(dGridLexi.Items.Item(termi2 + 2).SubItems(2).Text()) - End If - termi += 1 - End While - isStork = False - ElseIf setokee(x + 1) = ":" Then - isStork = False - End If - End If - - If setokee(x) = "viper" Then - Dim kawnter As Integer = x - While setokee(kawnter) <> "clpar" - kawnter += 1 - End While - - If setokee(kawnter + 1) = ":" Then - Ctr += 1 - objList = dGridIden.Items.Add(Ctr) - objList.SubItems.Add(dGridLexi.Items.Item(x + 2).SubItems(2).Text()) - objList.SubItems.Add(setokee(x)) - objList.SubItems.Add("-") - objList.SubItems.Add("-") - objList.SubItems.Add("function") - objList.SubItems.Add("No") - objList.SubItems.Add("-") - objList.SubItems.Add("0") - objList.SubItems.Add("global") - objList.SubItems.Add("-") - End If - End If - - If inArray(setokee(x), dtype, 4) Then - Dim kownt As Integer = x - While setokee(kownt) <> "newline" - If setokee(kownt) = "newline" Then - Exit While - End If - kownt += 1 - End While - - If setokee(kownt - 1) = "clpar" Or setokee(kownt - 1) = "opsymbol" Then - isMane = False - isStork = False - isFunction = True - End If - - End If - - If inArray(setokee(x), dtype, 4) Then - curDtype = setokee(x) - - Dim declCount As Integer = 0 - Dim declCtr As Integer = x - While Not (setokee(declCtr) = ":" Or setokee(declCtr) = "newline") - If setokee(declCtr) = "at" Then - declCount += 1 - End If - declCtr += 1 - End While - - If declCount = 1 Then - While Not (setokee(x) = ":" Or setokee(x) = "newline") - - 'MessageBox.Show("x= " & x & ", " & setokee(x) & ", " & setokee(x + 1) & ", " & setokee(x + 2) & ", " & setokee(x + 3)) - - If setokee(x) = "identifier" And setokee(x + 1) <> "clsquare" And Not (setokee(x) = "identifier" And setokee(x + 1) = "oppar" And setokee(x + 2) = "clpar" And (setokee(x + 3) = "newline" Or setokee(x + 3) = "opsymbol")) Then - If setokee(x + 1) = "assgnOp" Then - valDType = setokee(x + 2).ToString - value = dGridLexi.Items.Item(x + 2).SubItems(2).Text() - If setokee(x - 3) = "let" Then - type = "constant" - Else - type = "variable" - End If - - ElseIf setokee(x + 1) = "opsquare" Then - value = "-" - If curDtype = "newt" Then - valDType = "newtlit" - ElseIf curDtype = "duck" Then - valDType = "ducklit" - ElseIf curDtype = "bull" Then - valDType = "bullLit" - ElseIf curDtype = "starling" Then - valDType = "starlinglit" - End If - If setokee(x + 3) = "opsquare" Or setokee(x + 4) = "opsquare" Then - type = "array2" - Else - type = "array1" - End If - ElseIf setokee(x + 1) = "oppar" Then - Dim lol As Integer = x + 1 - While setokee(lol) <> "newline" - If setokee(lol) = ":" Then - Exit While - End If - lol += 1 - End While - - If Not (setokee(x + 1) = "oppar" And setokee(x + 2) = "clpar" And (setokee(x + 3) = "newline" Or setokee(x + 3) = "opsymbol")) Then - value = "-" - If curDtype = "newt" Then - valDType = "newtlit" - ElseIf curDtype = "duck" Then - valDType = "ducklit" - ElseIf curDtype = "bull" Then - valDType = "bullLit" - ElseIf curDtype = "starling" Then - valDType = "starlinglit" - End If - type = "function" - End If - Else - If Not (setokee(x) = "identifier" And setokee(x + 1) = "oppar" And setokee(x + 2) = "clpar" And (setokee(x + 3) = "newline" Or setokee(x + 3) = "opsymbol")) Then - If curDtype = "newt" Then - value = "0" - valDType = "newtlit" - ElseIf curDtype = "duck" Then - value = "true" - valDType = "bullLit" - ElseIf curDtype = "duck" Then - value = "0.0" - valDType = "ducklit" - ElseIf curDtype = "starling" Then - value = "" - valDType = "starlinglit" - End If - type = "variable" - End If - End If - - Ctr += 1 - objList = dGridIden.Items.Add(Ctr) - objList.SubItems.Add(dGridLexi.Items.Item(x).SubItems(2).Text()) - objList.SubItems.Add(curDtype) - objList.SubItems.Add(value) - objList.SubItems.Add(valDType) - objList.SubItems.Add(type) - objList.SubItems.Add(used) - - If dGridIden.Items.Item(Ctr - 1).SubItems(5).Text() = "array1" Then - If setokee(x + 2) = "newtlit" Then - arraySize = dGridLexi.Items.Item(x + 2).SubItems(2).Text() - arraySize2 = "-" - ElseIf setokee(x + 2) = "identifier" Then - Dim arrID As String = dGridLexi.Items.Item(x + 2).SubItems(2).Text - Dim a As Integer - For index As Integer = 0 To dGridIden.Items.Count - 1 - If dGridIden.Items.Item(index).SubItems(1).Text = arrID Then - a = index - End If - Next - - Dim val As String = dGridIden.Items.Item(a).SubItems(3).Text - arraySize = val - arraySize2 = "-" - ElseIf setokee(x + 2) = "clsquare" Then - arraySize = "100" - arraySize2 = "-" - End If - ElseIf dGridIden.Items.Item(Ctr - 1).SubItems(5).Text() = "array2" Then - If setokee(x + 2) = "newtlit" Then - arraySize = dGridLexi.Items.Item(x + 2).SubItems(2).Text() - If setokee(x + 5) = "newtlit" Then - arraySize = arraySize - arraySize2 = dGridLexi.Items.Item(x + 5).SubItems(2).Text() - ElseIf setokee(x + 5) = "identifier" Then - Dim arrayID As String = dGridLexi.Items.Item(x + 5).SubItems(2).Text - Dim b As Integer - For index As Integer = 0 To dGridIden.Items.Count - 1 - If dGridIden.Items.Item(index).SubItems(1).Text = arrayID Then - b = index - End If - Next - Dim value1 As String = dGridIden.Items.Item(b).SubItems(3).Text - arraySize = arraySize - arraySize2 = value1 - ElseIf setokee(x + 5) = "clsquare" Then - arraySize = arraySize - arraySize2 = "10" - End If - ElseIf setokee(x + 2) = "identifier" Then - Dim arrID As String = dGridLexi.Items.Item(x + 2).SubItems(2).Text - Dim a As Integer - For index As Integer = 0 To dGridIden.Items.Count - 1 - If dGridIden.Items.Item(index).SubItems(1).Text = arrID Then - a = index - End If - Next - - Dim val As String = dGridIden.Items.Item(a).SubItems(3).Text - arraySize = val - - If setokee(x + 5) = "newtlit" Then '[@s][2] - arraySize = arraySize - arraySize2 = dGridLexi.Items.Item(x + 5).SubItems(2).Text() - ElseIf setokee(x + 5) = "identifier" Then '[@s][@a] - Dim arrayID As String = dGridLexi.Items.Item(x + 5).SubItems(2).Text - Dim b As Integer - For index As Integer = 0 To dGridIden.Items.Count - 1 - If dGridIden.Items.Item(index).SubItems(1).Text = arrayID Then - b = index - End If - Next - Dim value1 As String = dGridIden.Items.Item(b).SubItems(3).Text - arraySize = arraySize - arraySize2 = value1 - ElseIf setokee(x + 5) = "clsquare" Then '[@s][] - arraySize = arraySize - arraySize2 = "10" - End If - - ElseIf setokee(x + 2) = "clsquare" Then - arraySize = "10" - If setokee(x + 4) = "newtlit" Then - arraySize = arraySize - arraySize2 = dGridLexi.Items.Item(x + 4).SubItems(2).Text() - ElseIf setokee(x + 4) = "identifier" Then - Dim arrayID As String = dGridLexi.Items.Item(x + 4).SubItems(2).Text - Dim b As Integer - For index As Integer = 0 To dGridIden.Items.Count - 1 - If dGridIden.Items.Item(index).SubItems(1).Text = arrayID Then - b = index - End If - Next - Dim value1 As String = dGridIden.Items.Item(b).SubItems(3).Text - arraySize = arraySize - arraySize2 = value1 - ElseIf setokee(x + 4) = "clsquare" Then - arraySize = arraySize - arraySize2 = "10" - End If - End If - Else - arraySize = "-" - arraySize2 = "-" - End If - - objList.SubItems.Add(arraySize) - - - If dGridIden.Items.Item(Ctr - 1).SubItems(5).Text() = "function" Then - Dim paramCtr As Integer = x - Dim paramCount As Integer = 0 - While Not setokee(paramCtr) = "clpar" - If inArray(setokee(paramCtr), dtype, 4) Then - paramCount += 1 - End If - paramCtr += 1 - End While - parameter = paramCount.ToString - Else - parameter = "-" - End If - - objList.SubItems.Add(parameter) - - If isMane = True Then - objList.SubItems.Add("mane") - ElseIf isStork = True Then - Dim kaw As Integer = x - While kaw >= 0 - If setokee(kaw) = "opsymbol" Then - Exit While - Else - kaw -= 1 - End If - End While - If setokee(kaw - 1) = "newline" Then - objList.SubItems.Add(dGridLexi.Items.Item(kaw - 2).SubItems(2).Text) - Else - objList.SubItems.Add(dGridLexi.Items.Item(kaw - 1).SubItems(2).Text) - End If - ElseIf isFunction = True Then - objList.SubItems.Add("subfunction") - Else - objList.SubItems.Add("global") - End If - - objList.SubItems.Add(arraySize2) - End If - x += 1 - End While - ElseIf declCount >= 1 Then - Dim kawnt As Integer = x - While setokee(kawnt) <> "newline" - If setokee(kawnt) = "newline" Then - Exit While - End If - kawnt += 1 - End While - - While setokee(x) <> "," - If setokee(x) = "identifier" And setokee(x + 1) <> "clsquare" And Not (setokee(x) = "identifier" And setokee(x + 1) = "oppar" And (setokee(kawnt - 1) = "clpar" Or setokee(kawnt - 1) = "opsymbol")) Then - If setokee(x + 1) = "assgnOp" Then - valDType = setokee(x + 2).ToString - value = dGridLexi.Items.Item(x + 2).SubItems(2).Text() - If setokee(x - 3) = "let" Then - type = "constant" - Else - type = "variable" - End If - - ElseIf setokee(x + 1) = "opsquare" Then - value = "-" - If curDtype = "newt" Then - valDType = "newtlit" - ElseIf curDtype = "duck" Then - valDType = "ducklit" - ElseIf curDtype = "bull" Then - valDType = "bullLit" - ElseIf curDtype = "starling" Then - valDType = "starlinglit" - End If - If setokee(x + 3) = "opsquare" Or setokee(x + 4) = "opsquare" Then - type = "array2" - Else - type = "array1" - End If - ElseIf setokee(x + 1) = "oppar" Then - Dim lol As Integer = x + 1 - While setokee(lol) <> "newline" - If setokee(lol) = ":" Then - Exit While - End If - lol += 1 - End While - - If Not (setokee(x + 1) = "oppar" And setokee(x + 2) = "clpar" And (setokee(x + 3) = "newline" Or setokee(x + 3) = "opsymbol")) Then - value = "-" - If curDtype = "newt" Then - valDType = "newtlit" - ElseIf curDtype = "duck" Then - valDType = "ducklit" - ElseIf curDtype = "bull" Then - valDType = "bullLit" - ElseIf curDtype = "starling" Then - valDType = "starlinglit" - End If - type = "function" - End If - Else - If Not (setokee(x) = "identifier" And setokee(x + 1) = "oppar" And setokee(x + 2) = "clpar" And (setokee(x + 3) = "newline" Or setokee(x + 3) = "opsymbol")) Then - If curDtype = "newt" Then - value = "0" - valDType = "newtlit" - ElseIf curDtype = "bull" Then - value = "true" - valDType = "bullLit" - ElseIf curDtype = "duck" Then - value = "0.0" - valDType = "ducklit" - ElseIf curDtype = "starling" Then - value = "" - valDType = "starlinglit" - End If - type = "variable" - End If - End If - - Ctr += 1 - objList = dGridIden.Items.Add(Ctr) - objList.SubItems.Add(dGridLexi.Items.Item(x).SubItems(2).Text()) - objList.SubItems.Add(curDtype) - objList.SubItems.Add(value) - objList.SubItems.Add(valDType) - objList.SubItems.Add(type) - objList.SubItems.Add(used) - - If dGridIden.Items.Item(Ctr - 1).SubItems(5).Text() = "array1" Then 'size ng array - If setokee(x + 2) = "newtlit" Then - arraySize = dGridLexi.Items.Item(x + 2).SubItems(2).Text() - arraySize2 = "-" - ElseIf setokee(x + 2) = "identifier" Then - Dim arrID As String = dGridLexi.Items.Item(x + 2).SubItems(2).Text - Dim a As Integer - For index As Integer = 0 To dGridIden.Items.Count - 1 - If dGridIden.Items.Item(index).SubItems(1).Text = arrID Then - a = index - End If - Next - - Dim val As String = dGridIden.Items.Item(a).SubItems(3).Text - arraySize = val - arraySize2 = "-" - ElseIf setokee(x + 2) = "clsquare" Then - arraySize = "100" - arraySize2 = "-" - End If - ElseIf dGridIden.Items.Item(Ctr - 1).SubItems(5).Text() = "array2" Then - If setokee(x + 2) = "newtlit" Then - arraySize = dGridLexi.Items.Item(x + 2).SubItems(2).Text() - If setokee(x + 5) = "newtlit" Then - arraySize = arraySize - arraySize2 = dGridLexi.Items.Item(x + 5).SubItems(2).Text() - ElseIf setokee(x + 5) = "identifier" Then - Dim arrayID As String = dGridLexi.Items.Item(x + 5).SubItems(2).Text - Dim b As Integer - For index As Integer = 0 To dGridIden.Items.Count - 1 - If dGridIden.Items.Item(index).SubItems(1).Text = arrayID Then - b = index - End If - Next - Dim value1 As String = dGridIden.Items.Item(b).SubItems(3).Text - arraySize = arraySize - arraySize2 = value1 - ElseIf setokee(x + 5) = "clsquare" Then - arraySize = arraySize - arraySize2 = "10" - End If - ElseIf setokee(x + 2) = "identifier" Then - Dim arrID As String = dGridLexi.Items.Item(x + 2).SubItems(2).Text - Dim a As Integer - For index As Integer = 0 To dGridIden.Items.Count - 1 - If dGridIden.Items.Item(index).SubItems(1).Text = arrID Then - a = index - End If - Next - - Dim val As String = dGridIden.Items.Item(a).SubItems(3).Text - arraySize = val - - If setokee(x + 5) = "newtlit" Then - arraySize = arraySize - arraySize2 = dGridLexi.Items.Item(x + 5).SubItems(2).Text() - ElseIf setokee(x + 5) = "identifier" Then - Dim arrayID As String = dGridLexi.Items.Item(x + 5).SubItems(2).Text - Dim b As Integer - For index As Integer = 0 To dGridIden.Items.Count - 1 - If dGridIden.Items.Item(index).SubItems(1).Text = arrayID Then - b = index - End If - Next - Dim value1 As String = dGridIden.Items.Item(b).SubItems(3).Text - arraySize = arraySize - arraySize2 = value1 - ElseIf setokee(x + 5) = "clsquare" Then - arraySize = arraySize - arraySize2 = "10" - End If - - ElseIf setokee(x + 2) = "clsquare" Then - arraySize = "10" - If setokee(x + 4) = "newtlit" Then - arraySize = arraySize - arraySize2 = dGridLexi.Items.Item(x + 4).SubItems(2).Text() - ElseIf setokee(x + 4) = "identifier" Then - Dim arrayID As String = dGridLexi.Items.Item(x + 4).SubItems(2).Text - Dim b As Integer - For index As Integer = 0 To dGridIden.Items.Count - 1 - If dGridIden.Items.Item(index).SubItems(1).Text = arrayID Then - b = index - End If - Next - Dim value1 As String = dGridIden.Items.Item(b).SubItems(3).Text - arraySize = arraySize - arraySize2 = value1 - ElseIf setokee(x + 4) = "clsquare" Then - arraySize = arraySize - arraySize2 = "10" - End If - End If - Else - arraySize = "-" - arraySize2 = "-" - End If - - objList.SubItems.Add(arraySize) - - If dGridIden.Items.Item(Ctr - 1).SubItems(5).Text() = "function" Then - Dim paramCtr As Integer = x - Dim paramCount As Integer = 0 - While Not setokee(paramCtr) = "clpar" - If inArray(setokee(paramCtr), dtype, 4) Then - paramCount += 1 - End If - paramCtr += 1 - End While - parameter = paramCount.ToString - Else - parameter = "-" - End If - - objList.SubItems.Add(parameter) - - If isMane = True Then - objList.SubItems.Add("mane") - ElseIf isStork = True Then - Dim kaw As Integer = x - While kaw >= 0 - If setokee(kaw) = "opsymbol" Then - Exit While - Else - kaw -= 1 - End If - End While - If setokee(kaw - 1) = "newline" Then - objList.SubItems.Add(dGridLexi.Items.Item(kaw - 2).SubItems(2).Text) - Else - objList.SubItems.Add(dGridLexi.Items.Item(kaw - 1).SubItems(2).Text) - End If - - ElseIf isFunction = True Then - objList.SubItems.Add("subfunction") - Else - objList.SubItems.Add("global") - End If - - objList.SubItems.Add(arraySize2) - - End If - x += 1 - End While - End If - End If - - - x += 1 - End While - End Sub + 'Private Sub identifierList() + ' Dim x As Integer = 0 + ' Dim isMane As Boolean = False + ' Dim isStork As Boolean = False + ' Dim isFunction As Boolean = False + ' Dim Ctr As Integer = 0 + ' Dim bCtr As Integer = 0 + ' Dim erCtr As Integer = 0 + ' Dim valDType As String = "" + ' Dim value As String = "" + ' Dim curDtype As String = "" + ' Dim type As String = "" + ' Dim used As String = "No" + ' Dim arraySize As String = "" + ' Dim arraySize2 As String = "" + ' Dim parameter As String = "" + ' Dim constAns As String = "" + + ' Dim dtype(4) As String + ' dtype(0) = "newt" + ' dtype(1) = "duck" + ' dtype(2) = "bull" + ' dtype(3) = "starling" + + ' For i As Integer = 0 To dGridLexi.Items.Count - 1 + ' selinee(i) = dGridLexi.Items.Item(i).SubItems(1).Text() 'LINE + ' Next + + ' For i As Integer = 0 To dGridLexi.Items.Count - 1 + ' setokee(i) = dGridLexi.Items.Item(i).SubItems(3).Text() 'TOKEN + ' Next + + ' While x < dGridLexi.Items.Count + ' If setokee(x) = "mane" Then + ' isStork = False + ' isMane = True + ' End If + + ' If setokee(x) = "stork" Then + ' isStork = True + ' 'MessageBox.Show(isStork) + ' Ctr += 1 + ' objList = dGridIden.Items.Add(Ctr) + ' objList.SubItems.Add(dGridLexi.Items.Item(x + 2).SubItems(2).Text()) + ' objList.SubItems.Add("-") + ' objList.SubItems.Add("-") + ' objList.SubItems.Add("-") + ' objList.SubItems.Add("stork") + ' objList.SubItems.Add("-") + ' objList.SubItems.Add("-") + ' objList.SubItems.Add("-") + ' objList.SubItems.Add("stork/global") + ' objList.SubItems.Add("-") + ' End If + + ' If setokee(x) = "clsymbol" Then + ' Dim termi As Integer = x + ' Dim termi2 As Integer = x + ' Dim iden As String = "" + ' If setokee(x + 1) = "identifier" Then + ' While termi2 >= 0 + ' If setokee(termi2) = "stork" Then + ' Exit While + ' End If + ' termi2 -= 1 + ' End While + + ' iden = dGridLexi.Items.Item(x).SubItems(2).Text + ' While setokee(termi) <> ":" + ' If setokee(termi) = "identifier" Then + ' bCtr += 1 + ' objList = dGridBoard.Items.Add(dGridLexi.Items.Item(termi).SubItems(2).Text()) + ' objList.SubItems.Add(dGridLexi.Items.Item(termi2 + 2).SubItems(2).Text()) + ' End If + ' termi += 1 + ' End While + ' isStork = False + ' ElseIf setokee(x + 1) = ":" Then + ' isStork = False + ' End If + ' End If + + ' If setokee(x) = "viper" Then + ' Dim kawnter As Integer = x + ' While setokee(kawnter) <> "clpar" + ' kawnter += 1 + ' End While + + ' If setokee(kawnter + 1) = ":" Then + ' Ctr += 1 + ' objList = dGridIden.Items.Add(Ctr) + ' objList.SubItems.Add(dGridLexi.Items.Item(x + 2).SubItems(2).Text()) + ' objList.SubItems.Add(setokee(x)) + ' objList.SubItems.Add("-") + ' objList.SubItems.Add("-") + ' objList.SubItems.Add("function") + ' objList.SubItems.Add("No") + ' objList.SubItems.Add("-") + ' objList.SubItems.Add("0") + ' objList.SubItems.Add("global") + ' objList.SubItems.Add("-") + ' End If + ' End If + + ' If inArray(setokee(x), dtype, 4) Then + ' Dim kownt As Integer = x + ' While setokee(kownt) <> "newline" + ' If setokee(kownt) = "newline" Then + ' Exit While + ' End If + ' kownt += 1 + ' End While + + ' If setokee(kownt - 1) = "clpar" Or setokee(kownt - 1) = "opsymbol" Then + ' isMane = False + ' isStork = False + ' isFunction = True + ' End If + + ' End If + + ' If inArray(setokee(x), dtype, 4) Then + ' curDtype = setokee(x) + + ' Dim declCount As Integer = 0 + ' Dim declCtr As Integer = x + ' While Not (setokee(declCtr) = ":" Or setokee(declCtr) = "newline") + ' If setokee(declCtr) = "at" Then + ' declCount += 1 + ' End If + ' declCtr += 1 + ' End While + + ' If declCount = 1 Then + ' While Not (setokee(x) = ":" Or setokee(x) = "newline") + + ' 'MessageBox.Show("x= " & x & ", " & setokee(x) & ", " & setokee(x + 1) & ", " & setokee(x + 2) & ", " & setokee(x + 3)) + + ' If setokee(x) = "identifier" And setokee(x + 1) <> "clsquare" And Not (setokee(x) = "identifier" And setokee(x + 1) = "oppar" And setokee(x + 2) = "clpar" And (setokee(x + 3) = "newline" Or setokee(x + 3) = "opsymbol")) Then + ' If setokee(x + 1) = "assgnOp" Then + ' valDType = setokee(x + 2).ToString + ' value = dGridLexi.Items.Item(x + 2).SubItems(2).Text() + ' If setokee(x - 3) = "let" Then + ' type = "constant" + ' Else + ' type = "variable" + ' End If + + ' ElseIf setokee(x + 1) = "opsquare" Then + ' value = "-" + ' If curDtype = "newt" Then + ' valDType = "newtlit" + ' ElseIf curDtype = "duck" Then + ' valDType = "ducklit" + ' ElseIf curDtype = "bull" Then + ' valDType = "bullLit" + ' ElseIf curDtype = "starling" Then + ' valDType = "starlinglit" + ' End If + ' If setokee(x + 3) = "opsquare" Or setokee(x + 4) = "opsquare" Then + ' type = "array2" + ' Else + ' type = "array1" + ' End If + ' ElseIf setokee(x + 1) = "oppar" Then + ' Dim lol As Integer = x + 1 + ' While setokee(lol) <> "newline" + ' If setokee(lol) = ":" Then + ' Exit While + ' End If + ' lol += 1 + ' End While + + ' If Not (setokee(x + 1) = "oppar" And setokee(x + 2) = "clpar" And (setokee(x + 3) = "newline" Or setokee(x + 3) = "opsymbol")) Then + ' value = "-" + ' If curDtype = "newt" Then + ' valDType = "newtlit" + ' ElseIf curDtype = "duck" Then + ' valDType = "ducklit" + ' ElseIf curDtype = "bull" Then + ' valDType = "bullLit" + ' ElseIf curDtype = "starling" Then + ' valDType = "starlinglit" + ' End If + ' type = "function" + ' End If + ' Else + ' If Not (setokee(x) = "identifier" And setokee(x + 1) = "oppar" And setokee(x + 2) = "clpar" And (setokee(x + 3) = "newline" Or setokee(x + 3) = "opsymbol")) Then + ' If curDtype = "newt" Then + ' value = "0" + ' valDType = "newtlit" + ' ElseIf curDtype = "duck" Then + ' value = "true" + ' valDType = "bullLit" + ' ElseIf curDtype = "duck" Then + ' value = "0.0" + ' valDType = "ducklit" + ' ElseIf curDtype = "starling" Then + ' value = "" + ' valDType = "starlinglit" + ' End If + ' type = "variable" + ' End If + ' End If + + ' Ctr += 1 + ' objList = dGridIden.Items.Add(Ctr) + ' objList.SubItems.Add(dGridLexi.Items.Item(x).SubItems(2).Text()) + ' objList.SubItems.Add(curDtype) + ' objList.SubItems.Add(value) + ' objList.SubItems.Add(valDType) + ' objList.SubItems.Add(type) + ' objList.SubItems.Add(used) + + ' If dGridIden.Items.Item(Ctr - 1).SubItems(5).Text() = "array1" Then + ' If setokee(x + 2) = "newtlit" Then + ' arraySize = dGridLexi.Items.Item(x + 2).SubItems(2).Text() + ' arraySize2 = "-" + ' ElseIf setokee(x + 2) = "identifier" Then + ' Dim arrID As String = dGridLexi.Items.Item(x + 2).SubItems(2).Text + ' Dim a As Integer + ' For index As Integer = 0 To dGridIden.Items.Count - 1 + ' If dGridIden.Items.Item(index).SubItems(1).Text = arrID Then + ' a = index + ' End If + ' Next + + ' Dim val As String = dGridIden.Items.Item(a).SubItems(3).Text + ' arraySize = val + ' arraySize2 = "-" + ' ElseIf setokee(x + 2) = "clsquare" Then + ' arraySize = "100" + ' arraySize2 = "-" + ' End If + ' ElseIf dGridIden.Items.Item(Ctr - 1).SubItems(5).Text() = "array2" Then + ' If setokee(x + 2) = "newtlit" Then + ' arraySize = dGridLexi.Items.Item(x + 2).SubItems(2).Text() + ' If setokee(x + 5) = "newtlit" Then + ' arraySize = arraySize + ' arraySize2 = dGridLexi.Items.Item(x + 5).SubItems(2).Text() + ' ElseIf setokee(x + 5) = "identifier" Then + ' Dim arrayID As String = dGridLexi.Items.Item(x + 5).SubItems(2).Text + ' Dim b As Integer + ' For index As Integer = 0 To dGridIden.Items.Count - 1 + ' If dGridIden.Items.Item(index).SubItems(1).Text = arrayID Then + ' b = index + ' End If + ' Next + ' Dim value1 As String = dGridIden.Items.Item(b).SubItems(3).Text + ' arraySize = arraySize + ' arraySize2 = value1 + ' ElseIf setokee(x + 5) = "clsquare" Then + ' arraySize = arraySize + ' arraySize2 = "10" + ' End If + ' ElseIf setokee(x + 2) = "identifier" Then + ' Dim arrID As String = dGridLexi.Items.Item(x + 2).SubItems(2).Text + ' Dim a As Integer + ' For index As Integer = 0 To dGridIden.Items.Count - 1 + ' If dGridIden.Items.Item(index).SubItems(1).Text = arrID Then + ' a = index + ' End If + ' Next + + ' Dim val As String = dGridIden.Items.Item(a).SubItems(3).Text + ' arraySize = val + + ' If setokee(x + 5) = "newtlit" Then '[@s][2] + ' arraySize = arraySize + ' arraySize2 = dGridLexi.Items.Item(x + 5).SubItems(2).Text() + ' ElseIf setokee(x + 5) = "identifier" Then '[@s][@a] + ' Dim arrayID As String = dGridLexi.Items.Item(x + 5).SubItems(2).Text + ' Dim b As Integer + ' For index As Integer = 0 To dGridIden.Items.Count - 1 + ' If dGridIden.Items.Item(index).SubItems(1).Text = arrayID Then + ' b = index + ' End If + ' Next + ' Dim value1 As String = dGridIden.Items.Item(b).SubItems(3).Text + ' arraySize = arraySize + ' arraySize2 = value1 + ' ElseIf setokee(x + 5) = "clsquare" Then '[@s][] + ' arraySize = arraySize + ' arraySize2 = "10" + ' End If + + ' ElseIf setokee(x + 2) = "clsquare" Then + ' arraySize = "10" + ' If setokee(x + 4) = "newtlit" Then + ' arraySize = arraySize + ' arraySize2 = dGridLexi.Items.Item(x + 4).SubItems(2).Text() + ' ElseIf setokee(x + 4) = "identifier" Then + ' Dim arrayID As String = dGridLexi.Items.Item(x + 4).SubItems(2).Text + ' Dim b As Integer + ' For index As Integer = 0 To dGridIden.Items.Count - 1 + ' If dGridIden.Items.Item(index).SubItems(1).Text = arrayID Then + ' b = index + ' End If + ' Next + ' Dim value1 As String = dGridIden.Items.Item(b).SubItems(3).Text + ' arraySize = arraySize + ' arraySize2 = value1 + ' ElseIf setokee(x + 4) = "clsquare" Then + ' arraySize = arraySize + ' arraySize2 = "10" + ' End If + ' End If + ' Else + ' arraySize = "-" + ' arraySize2 = "-" + ' End If + + ' objList.SubItems.Add(arraySize) + + + ' If dGridIden.Items.Item(Ctr - 1).SubItems(5).Text() = "function" Then + ' Dim paramCtr As Integer = x + ' Dim paramCount As Integer = 0 + ' While Not setokee(paramCtr) = "clpar" + ' If inArray(setokee(paramCtr), dtype, 4) Then + ' paramCount += 1 + ' End If + ' paramCtr += 1 + ' End While + ' parameter = paramCount.ToString + ' Else + ' parameter = "-" + ' End If + + ' objList.SubItems.Add(parameter) + + ' If isMane = True Then + ' objList.SubItems.Add("mane") + ' ElseIf isStork = True Then + ' Dim kaw As Integer = x + ' While kaw >= 0 + ' If setokee(kaw) = "opsymbol" Then + ' Exit While + ' Else + ' kaw -= 1 + ' End If + ' End While + ' If setokee(kaw - 1) = "newline" Then + ' objList.SubItems.Add(dGridLexi.Items.Item(kaw - 2).SubItems(2).Text) + ' Else + ' objList.SubItems.Add(dGridLexi.Items.Item(kaw - 1).SubItems(2).Text) + ' End If + ' ElseIf isFunction = True Then + ' objList.SubItems.Add("subfunction") + ' Else + ' objList.SubItems.Add("global") + ' End If + + ' objList.SubItems.Add(arraySize2) + ' End If + ' x += 1 + ' End While + ' ElseIf declCount >= 1 Then + ' Dim kawnt As Integer = x + ' While setokee(kawnt) <> "newline" + ' If setokee(kawnt) = "newline" Then + ' Exit While + ' End If + ' kawnt += 1 + ' End While + + ' While setokee(x) <> "," + ' If setokee(x) = "identifier" And setokee(x + 1) <> "clsquare" And Not (setokee(x) = "identifier" And setokee(x + 1) = "oppar" And (setokee(kawnt - 1) = "clpar" Or setokee(kawnt - 1) = "opsymbol")) Then + ' If setokee(x + 1) = "assgnOp" Then + ' valDType = setokee(x + 2).ToString + ' value = dGridLexi.Items.Item(x + 2).SubItems(2).Text() + ' If setokee(x - 3) = "let" Then + ' type = "constant" + ' Else + ' type = "variable" + ' End If + + ' ElseIf setokee(x + 1) = "opsquare" Then + ' value = "-" + ' If curDtype = "newt" Then + ' valDType = "newtlit" + ' ElseIf curDtype = "duck" Then + ' valDType = "ducklit" + ' ElseIf curDtype = "bull" Then + ' valDType = "bullLit" + ' ElseIf curDtype = "starling" Then + ' valDType = "starlinglit" + ' End If + ' If setokee(x + 3) = "opsquare" Or setokee(x + 4) = "opsquare" Then + ' type = "array2" + ' Else + ' type = "array1" + ' End If + ' ElseIf setokee(x + 1) = "oppar" Then + ' Dim lol As Integer = x + 1 + ' While setokee(lol) <> "newline" + ' If setokee(lol) = ":" Then + ' Exit While + ' End If + ' lol += 1 + ' End While + + ' If Not (setokee(x + 1) = "oppar" And setokee(x + 2) = "clpar" And (setokee(x + 3) = "newline" Or setokee(x + 3) = "opsymbol")) Then + ' value = "-" + ' If curDtype = "newt" Then + ' valDType = "newtlit" + ' ElseIf curDtype = "duck" Then + ' valDType = "ducklit" + ' ElseIf curDtype = "bull" Then + ' valDType = "bullLit" + ' ElseIf curDtype = "starling" Then + ' valDType = "starlinglit" + ' End If + ' type = "function" + ' End If + ' Else + ' If Not (setokee(x) = "identifier" And setokee(x + 1) = "oppar" And setokee(x + 2) = "clpar" And (setokee(x + 3) = "newline" Or setokee(x + 3) = "opsymbol")) Then + ' If curDtype = "newt" Then + ' value = "0" + ' valDType = "newtlit" + ' ElseIf curDtype = "bull" Then + ' value = "true" + ' valDType = "bullLit" + ' ElseIf curDtype = "duck" Then + ' value = "0.0" + ' valDType = "ducklit" + ' ElseIf curDtype = "starling" Then + ' value = "" + ' valDType = "starlinglit" + ' End If + ' type = "variable" + ' End If + ' End If + + ' Ctr += 1 + ' objList = dGridIden.Items.Add(Ctr) + ' objList.SubItems.Add(dGridLexi.Items.Item(x).SubItems(2).Text()) + ' objList.SubItems.Add(curDtype) + ' objList.SubItems.Add(value) + ' objList.SubItems.Add(valDType) + ' objList.SubItems.Add(type) + ' objList.SubItems.Add(used) + + ' If dGridIden.Items.Item(Ctr - 1).SubItems(5).Text() = "array1" Then 'size ng array + ' If setokee(x + 2) = "newtlit" Then + ' arraySize = dGridLexi.Items.Item(x + 2).SubItems(2).Text() + ' arraySize2 = "-" + ' ElseIf setokee(x + 2) = "identifier" Then + ' Dim arrID As String = dGridLexi.Items.Item(x + 2).SubItems(2).Text + ' Dim a As Integer + ' For index As Integer = 0 To dGridIden.Items.Count - 1 + ' If dGridIden.Items.Item(index).SubItems(1).Text = arrID Then + ' a = index + ' End If + ' Next + + ' Dim val As String = dGridIden.Items.Item(a).SubItems(3).Text + ' arraySize = val + ' arraySize2 = "-" + ' ElseIf setokee(x + 2) = "clsquare" Then + ' arraySize = "100" + ' arraySize2 = "-" + ' End If + ' ElseIf dGridIden.Items.Item(Ctr - 1).SubItems(5).Text() = "array2" Then + ' If setokee(x + 2) = "newtlit" Then + ' arraySize = dGridLexi.Items.Item(x + 2).SubItems(2).Text() + ' If setokee(x + 5) = "newtlit" Then + ' arraySize = arraySize + ' arraySize2 = dGridLexi.Items.Item(x + 5).SubItems(2).Text() + ' ElseIf setokee(x + 5) = "identifier" Then + ' Dim arrayID As String = dGridLexi.Items.Item(x + 5).SubItems(2).Text + ' Dim b As Integer + ' For index As Integer = 0 To dGridIden.Items.Count - 1 + ' If dGridIden.Items.Item(index).SubItems(1).Text = arrayID Then + ' b = index + ' End If + ' Next + ' Dim value1 As String = dGridIden.Items.Item(b).SubItems(3).Text + ' arraySize = arraySize + ' arraySize2 = value1 + ' ElseIf setokee(x + 5) = "clsquare" Then + ' arraySize = arraySize + ' arraySize2 = "10" + ' End If + ' ElseIf setokee(x + 2) = "identifier" Then + ' Dim arrID As String = dGridLexi.Items.Item(x + 2).SubItems(2).Text + ' Dim a As Integer + ' For index As Integer = 0 To dGridIden.Items.Count - 1 + ' If dGridIden.Items.Item(index).SubItems(1).Text = arrID Then + ' a = index + ' End If + ' Next + + ' Dim val As String = dGridIden.Items.Item(a).SubItems(3).Text + ' arraySize = val + + ' If setokee(x + 5) = "newtlit" Then + ' arraySize = arraySize + ' arraySize2 = dGridLexi.Items.Item(x + 5).SubItems(2).Text() + ' ElseIf setokee(x + 5) = "identifier" Then + ' Dim arrayID As String = dGridLexi.Items.Item(x + 5).SubItems(2).Text + ' Dim b As Integer + ' For index As Integer = 0 To dGridIden.Items.Count - 1 + ' If dGridIden.Items.Item(index).SubItems(1).Text = arrayID Then + ' b = index + ' End If + ' Next + ' Dim value1 As String = dGridIden.Items.Item(b).SubItems(3).Text + ' arraySize = arraySize + ' arraySize2 = value1 + ' ElseIf setokee(x + 5) = "clsquare" Then + ' arraySize = arraySize + ' arraySize2 = "10" + ' End If + + ' ElseIf setokee(x + 2) = "clsquare" Then + ' arraySize = "10" + ' If setokee(x + 4) = "newtlit" Then + ' arraySize = arraySize + ' arraySize2 = dGridLexi.Items.Item(x + 4).SubItems(2).Text() + ' ElseIf setokee(x + 4) = "identifier" Then + ' Dim arrayID As String = dGridLexi.Items.Item(x + 4).SubItems(2).Text + ' Dim b As Integer + ' For index As Integer = 0 To dGridIden.Items.Count - 1 + ' If dGridIden.Items.Item(index).SubItems(1).Text = arrayID Then + ' b = index + ' End If + ' Next + ' Dim value1 As String = dGridIden.Items.Item(b).SubItems(3).Text + ' arraySize = arraySize + ' arraySize2 = value1 + ' ElseIf setokee(x + 4) = "clsquare" Then + ' arraySize = arraySize + ' arraySize2 = "10" + ' End If + ' End If + ' Else + ' arraySize = "-" + ' arraySize2 = "-" + ' End If + + ' objList.SubItems.Add(arraySize) + + ' If dGridIden.Items.Item(Ctr - 1).SubItems(5).Text() = "function" Then + ' Dim paramCtr As Integer = x + ' Dim paramCount As Integer = 0 + ' While Not setokee(paramCtr) = "clpar" + ' If inArray(setokee(paramCtr), dtype, 4) Then + ' paramCount += 1 + ' End If + ' paramCtr += 1 + ' End While + ' parameter = paramCount.ToString + ' Else + ' parameter = "-" + ' End If + + ' objList.SubItems.Add(parameter) + + ' If isMane = True Then + ' objList.SubItems.Add("mane") + ' ElseIf isStork = True Then + ' Dim kaw As Integer = x + ' While kaw >= 0 + ' If setokee(kaw) = "opsymbol" Then + ' Exit While + ' Else + ' kaw -= 1 + ' End If + ' End While + ' If setokee(kaw - 1) = "newline" Then + ' objList.SubItems.Add(dGridLexi.Items.Item(kaw - 2).SubItems(2).Text) + ' Else + ' objList.SubItems.Add(dGridLexi.Items.Item(kaw - 1).SubItems(2).Text) + ' End If + + ' ElseIf isFunction = True Then + ' objList.SubItems.Add("subfunction") + ' Else + ' objList.SubItems.Add("global") + ' End If + + ' objList.SubItems.Add(arraySize2) + + ' End If + ' x += 1 + ' End While + ' End If + ' End If + + + ' x += 1 + ' End While + 'End Sub @@ -6143,7 +6143,7 @@ Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles MyBase.Load - rTBCode.Text = vbCrLf & vbCrLf & vbCrLf + 'rTBCode.Text = vbCrLf & vbCrLf & vbCrLf End Sub Private Sub rTBCode_TextChanged(sender As Object, e As EventArgs) Handles rTBCode.TextChanged From 6128491ed04cd7b14827828f08ebc3869e2f1cbc Mon Sep 17 00:00:00 2001 From: darylcaguia Date: Mon, 13 Feb 2017 23:01:40 +0800 Subject: [PATCH 09/10] Fixed void function syntax --- Syntax Analyzer/SyntaxParser.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Syntax Analyzer/SyntaxParser.cs b/Syntax Analyzer/SyntaxParser.cs index da41e23..18f1152 100644 --- a/Syntax Analyzer/SyntaxParser.cs +++ b/Syntax Analyzer/SyntaxParser.cs @@ -1102,7 +1102,7 @@ private void CreatePatterns() { alt.AddToken((int) SyntaxConstants.ODC, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_FUNC_INSIDE, 0, 1); alt.AddToken((int) SyntaxConstants.CDC, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_SUB_FUNCTION, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_SUB_FUNCTION, 0, 1); pattern.AddAlternative(alt); AddPattern(pattern); From 878f7a05f246929fb1cf13cdd7574220cce1b0bb Mon Sep 17 00:00:00 2001 From: Mark Daryl Caguia Date: Wed, 15 Feb 2017 08:51:44 +0800 Subject: [PATCH 10/10] Fixed Clear and Return Methods --- CodeGeneration/CodeTranslator.cs | 83 +++++++++++++++----- Core Library/Core Library/SyntaxConstants.cs | 5 +- Syntax Analyzer/SyntaxAnalyzer.cs | 48 +++++++++++ Syntax Analyzer/SyntaxConstants.cs | 5 +- Syntax Analyzer/SyntaxParser.cs | 13 ++- 5 files changed, 130 insertions(+), 24 deletions(-) diff --git a/CodeGeneration/CodeTranslator.cs b/CodeGeneration/CodeTranslator.cs index 9342daf..d048115 100644 --- a/CodeGeneration/CodeTranslator.cs +++ b/CodeGeneration/CodeTranslator.cs @@ -102,6 +102,7 @@ public int getCode() private bool isFunctVar = false; private bool isFunctArgs = false; private bool isSemiDone; + private int size; public string Start() { @@ -254,7 +255,7 @@ public override Node ExitWipe(Token node) { if (isAdd) { - code += "Console.Clear"; + code += "Console.Clear()"; isAdd = false; } return node; @@ -1233,10 +1234,17 @@ public override void ChildProdVarDec(Production node, Node child) { if(!hasDeclared) { + if (!isFirstDec) + { + if(!(code.ElementAt(code.Length - 1) == '\n' && code.ElementAt(code.Length - 2) == ';')) + code += ";\n"; + } code += "public static " + vardtype + " " + varid ; } isIdentVar = true; - code += ";\n"; + + if (!(code.ElementAt(code.Length - 1) == '\n' && code.ElementAt(code.Length - 2) == ';')) + code += ";\n"; } } @@ -1360,13 +1368,6 @@ public override void ChildProdNext2var(Production node, Node child) { code += "public static "; } - Node val = child.GetChildAt(1).GetChildAt(0); - if (val.GetName() == "NEWTLIT") - { - Tokens tval = new Tokens(); - tval = GetTokens(val.GetStartLine(), child.GetStartColumn()); - arrval = tval.getLexemes(); - } } else if(node.GetChildCount() == 1 && child.GetName() == "EQUAL") { @@ -1442,8 +1443,8 @@ public override void ChildProdNext2varTail(Production node, Node child) if (!hasDeclared) { if (!isFirstDec) - code += ";\n"; - else + // code += ";\n"; + //else { isFirstDec = false; } @@ -1580,12 +1581,50 @@ public override void EnterProdArray1d(Production node) public override Node ExitProdArray1d(Production node) { - isArrayDec = false; - isArray = false; - //var size = " "; - //var input_size = 0; - //Node arrsize = node.GetChildAt(1); - //Node arrval = arrsize.GetChildAt(0).GetValue(Int32.Parse(size, out input_size)); + string dtype = ""; + string size1 = ""; + string size2 = ""; + bool isMultiD = false; + if (node.GetChildCount() == 4) + { + isMultiD = true; + } + Node size_1 = node.GetChildAt(1); + Tokens t = new Tokens(); + t = GetTokens(size_1.GetStartLine(), size_1.GetStartColumn()); + size1 = t.getLexemes(); + + switch (dtype) + { + case "Int": dtype = "int"; break; + case "Double": dtype = "double"; break; + case "String": dtype = "string"; break; + case "Char": dtype = "char"; break; + case "Boolean": dtype = "bool"; break; + } + + if (isMultiD) + { + Node multi = node.GetChildAt(3); + if (multi.GetName() == "prod_elem1D_next") + { + Node size_2 = multi.GetChildAt(1); + t = GetTokens(size_2.GetStartLine(), size_2.GetStartColumn()); + size2 = t.getLexemes(); + code += vardtype + "[][] " + varid + " = new " + vardtype + "[" + size1 + "][];\n"; + for (int i = 0; i < Int32.Parse(size1); i++) + { + code += varid + "[" + i + "] = new " + vardtype + "[" + size2 + "];\n"; + } + code = code.Remove(code.Length - 2, 2); + isArray = true; + } + } + else + { + code += vardtype + "[] " + varid + " = new " + vardtype + "[" + size1 + "]"; + isArray = true; + } return node; } @@ -1919,14 +1958,22 @@ public override Node ExitProdLocalDec(Production node) public override void ChildProdLocalDec(Production node, Node child) { node.AddChild(child); + if (child.GetName() == "TERMI") { if (!hasDeclared) { + if (!isFirstDec) + { + if (!(code.ElementAt(code.Length - 1) == '\n' && code.ElementAt(code.Length - 2) == ';')) + code += ";\n"; + } code += vardtype + " " + varid; } isIdentVar = true; - code += ";\n"; + + if (!(code.ElementAt(code.Length - 1) == '\n' && code.ElementAt(code.Length - 2) == ';')) + code += ";\n"; } } diff --git a/Core Library/Core Library/SyntaxConstants.cs b/Core Library/Core Library/SyntaxConstants.cs index bd9ddfd..5034ba8 100644 --- a/Core Library/Core Library/SyntaxConstants.cs +++ b/Core Library/Core Library/SyntaxConstants.cs @@ -170,6 +170,7 @@ public enum SyntaxConstants PROD_FUNC_ARGS = 2089, PROD_MULTIFUNC_ARGS = 2090, PROD_RESULT = 2091, - PROD_FIG_TAIL = 2092, - PROD_RESULT_TAIL = 2093 + PROD_RESULT_MATH = 2092, + PROD_FIG_TAIL = 2093, + PROD_RESULT_TAIL = 2094 } diff --git a/Syntax Analyzer/SyntaxAnalyzer.cs b/Syntax Analyzer/SyntaxAnalyzer.cs index c0bf992..9cba5a6 100644 --- a/Syntax Analyzer/SyntaxAnalyzer.cs +++ b/Syntax Analyzer/SyntaxAnalyzer.cs @@ -499,6 +499,9 @@ public override void Enter(Node node) { case (int) SyntaxConstants.PROD_RESULT: EnterProdResult((Production) node); break; + case (int) SyntaxConstants.PROD_RESULT_MATH: + EnterProdResultMath((Production) node); + break; case (int) SyntaxConstants.PROD_FIG_TAIL: EnterProdFigTail((Production) node); break; @@ -839,6 +842,8 @@ public override Node Exit(Node node) { return ExitProdMultifuncArgs((Production) node); case (int) SyntaxConstants.PROD_RESULT: return ExitProdResult((Production) node); + case (int) SyntaxConstants.PROD_RESULT_MATH: + return ExitProdResultMath((Production) node); case (int) SyntaxConstants.PROD_FIG_TAIL: return ExitProdFigTail((Production) node); case (int) SyntaxConstants.PROD_RESULT_TAIL: @@ -1132,6 +1137,9 @@ public override void Child(Production node, Node child) { case (int) SyntaxConstants.PROD_RESULT: ChildProdResult(node, child); break; + case (int) SyntaxConstants.PROD_RESULT_MATH: + ChildProdResultMath(node, child); + break; case (int) SyntaxConstants.PROD_FIG_TAIL: ChildProdFigTail(node, child); break; @@ -6549,6 +6557,46 @@ public virtual void ChildProdResult(Production node, Node child) { node.AddChild(child); } + /** + * Called when entering a parse tree node. + * + * the node being entered + * + * if the node analysis + * discovered errors + */ + public virtual void EnterProdResultMath(Production node) { + } + + /** + * Called when exiting a parse tree node. + * + * the node being exited + * + * the node to add to the parse tree, or + * null if no parse tree should be created + * + * if the node analysis + * discovered errors + */ + public virtual Node ExitProdResultMath(Production node) { + return node; + } + + /** + * Called when adding a child to a parse tree + * node. + * + * the parent node + * the child node, or null + * + * if the node analysis + * discovered errors + */ + public virtual void ChildProdResultMath(Production node, Node child) { + node.AddChild(child); + } + /** * Called when entering a parse tree node. * diff --git a/Syntax Analyzer/SyntaxConstants.cs b/Syntax Analyzer/SyntaxConstants.cs index 3d1010d..7904b5f 100644 --- a/Syntax Analyzer/SyntaxConstants.cs +++ b/Syntax Analyzer/SyntaxConstants.cs @@ -169,6 +169,7 @@ public enum SyntaxConstants { PROD_FUNC_ARGS = 2089, PROD_MULTIFUNC_ARGS = 2090, PROD_RESULT = 2091, - PROD_FIG_TAIL = 2092, - PROD_RESULT_TAIL = 2093 + PROD_RESULT_MATH = 2092, + PROD_FIG_TAIL = 2093, + PROD_RESULT_TAIL = 2094 } diff --git a/Syntax Analyzer/SyntaxParser.cs b/Syntax Analyzer/SyntaxParser.cs index 18f1152..68a7a46 100644 --- a/Syntax Analyzer/SyntaxParser.cs +++ b/Syntax Analyzer/SyntaxParser.cs @@ -431,11 +431,9 @@ private void CreatePatterns() { alt = new ProductionPatternAlternative(); alt.AddProduction((int) SyntaxConstants.PROD_LOCAL_DEC, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 0, 1); - alt.AddProduction((int) SyntaxConstants.PROD_RETURN, 0, 1); pattern.AddAlternative(alt); alt = new ProductionPatternAlternative(); alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 1, 1); - alt.AddProduction((int) SyntaxConstants.PROD_RETURN, 0, 1); pattern.AddAlternative(alt); AddPattern(pattern); @@ -480,6 +478,10 @@ private void CreatePatterns() { alt.AddProduction((int) SyntaxConstants.PROD_CLRSCR, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 0, 1); pattern.AddAlternative(alt); + alt = new ProductionPatternAlternative(); + alt.AddProduction((int) SyntaxConstants.PROD_RETURN, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_STATEMENT, 0, 1); + pattern.AddAlternative(alt); AddPattern(pattern); pattern = new ProductionPattern((int) SyntaxConstants.PROD_STATE_NEXT, @@ -1147,6 +1149,13 @@ private void CreatePatterns() { pattern.AddAlternative(alt); alt = new ProductionPatternAlternative(); alt.AddToken((int) SyntaxConstants.NEWTLIT, 1, 1); + alt.AddProduction((int) SyntaxConstants.PROD_RESULT_MATH, 0, 1); + pattern.AddAlternative(alt); + AddPattern(pattern); + + pattern = new ProductionPattern((int) SyntaxConstants.PROD_RESULT_MATH, + "prod_result_math"); + alt = new ProductionPatternAlternative(); alt.AddProduction((int) SyntaxConstants.PROD_MATH_OP, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_LOOP_FIG1, 1, 1); alt.AddProduction((int) SyntaxConstants.PROD_FIG_TAIL, 0, 1);