//[ConfigConsoleAspect] private static void Main(string[] args) { try { const string grammarFile = "grammar(0).txt"; const string inputFile = "input(0).txt"; var grammar = Read("Grammar", $"grammars/{grammarFile}"); var input = Read("Input", $"inputs/{inputFile}"); var parser = new TopDownParser(grammar); parser.Parser(input); var codeGenerator = new TmCodeGenerator(parser, input); codeGenerator.Generator(); codeGenerator.Export(); codeGenerator.ExecuteVM(); } catch (Exception e) { Logger.PrintLn(e); } Console.ReadLine(); }
public void BeforeEveryTest() { var grammar = new ContextFreeGrammar('S'); grammar.Produce("S", "t2"); grammar.Produce("S", "vA", "vT"); grammar.Produce("A", "t0"); grammar.Produce("T", "vS", "vB"); grammar.Produce("B", "t1"); _parser = new TopDownParser(grammar); }
public TmCodeGenerator(TopDownParser parser, string input) { _parser = parser; _input = input; Tokenization = new TopDownTokenization(_parser.NonTerminals, input); Instructions = new List <string>(); Registradores = new int[8]; VarDictionary = new Dictionary <Token, int>(); Stack = new Stack <Token>(); IfBackpack = new Stack <IfBackpackItem>(); RepeatBackpack = new Stack <RepeatBackpack>(); }
public CmsCodeGenerator(TopDownParser parser, string input) { _parser = parser; _input = input; Codes = new List <CmsCode>(); Tokenization = new TopDownTokenization(_parser.NonTerminals, input); VariableArea = new Dictionary <string, CmsCode>(); StopReference = new CmsCode(0X0000); TokenStack = new Stack <Token>(); AttributionTokenStack = new Stack <Token>(); JFCodeReferenceStack = new Stack <CmsCodeReference>(); StartWhileCodeReference = new Stack <CmsCodeReference>(); RepeatReferenceStack = new Stack <CmsCode>(); }
//[ConfigConsoleAspect] private static void Main(string[] args) { ConfigConsole(); try { var grammar = Read("Grammar", GrammarMocks.Grammar1); var input = Read("Code", CodeMocks.Input1); var parser = new TopDownParser(grammar); parser.Parser(input); var codeGenerator = new CmsCodeGenerator(parser, input); codeGenerator.Generator(); codeGenerator.Export(); codeGenerator.ExecuteVM(); } catch (Exception e) { Logger.PrintLn(e); } Console.ReadLine(); }