protected override async Task OnInitializedAsync() { lexer = new PascalLexer(this); ast = new PascalAst(this); analyzer = new PascalSemanticAnalyzer(this); csharp = new PascalToCSharp(); con = new ConsoleModel(); interpreter = new PascalInterpreter(console: con); Examples.Add("Hello World", @"program hello; begin writeln('hello world!'); end."); Examples.Add("Simple Program", @"program test; begin end."); Examples.Add("Math", @"program math; var a,b,c : integer; begin a := 10; b := 20; c := 30; writeln(a + c - b); end."); //Compile(); base.OnInitialized(); }
public void Setup() { console = new ConsoleModel(); interpreter = new PascalInterpreter(null, console); lexer = new PascalLexer(); ast = new PascalAst(); analyzer = new PascalSemanticAnalyzer(); }
public void Setup() { logger = new LoggerMock(); interpreter = new PascalInterpreter(logger); lexer = new PascalLexer(); ast = new PascalAst(); analyzer = new PascalSemanticAnalyzer(logger); }
public void Evaluate_Test(string input, double output) { var lex = new RegexLexer(); SuperBasicMathAst.AddMathTokens(lex); var tree = new SuperBasicMathAst(lex.Tokenize(input)); var t = tree.Evaluate(); var inter = new PascalInterpreter(); var r = inter.VisitNode(t); r.Should().Be(output); }