public void Setup()
 {
     lexer  = new PascalLexer();
     ast    = new PascalAst();
     table  = new PascalSemanticAnalyzer();
     cSharp = new PascalToCSharp();
 }
 public void Setup()
 {
     lexer        = new PascalLexer();
     ast          = new PascalAst();
     analyzer     = new PascalSemanticAnalyzer();
     threeAddress = new PascalToThreeAddress();
 }
Example #3
0
        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();
        }
Example #4
0
 public void Setup()
 {
     console     = new ConsoleModel();
     interpreter = new PascalInterpreter(null, console);
     lexer       = new PascalLexer();
     ast         = new PascalAst();
     analyzer    = new PascalSemanticAnalyzer();
 }
Example #5
0
 public void Setup()
 {
     logger      = new LoggerMock();
     interpreter = new PascalInterpreter(logger);
     lexer       = new PascalLexer();
     ast         = new PascalAst();
     analyzer    = new PascalSemanticAnalyzer(logger);
 }
        public string VisitProgram(PascalProgramNode program)
        {
            var zero = new ScopedSymbolTable(program.ProgramName);

            PascalSemanticAnalyzer.DefineBuiltIns(zero);
            CurrentScope = zero;
            var programStr = VisitProgramBlockNode(program);

            return(programStr);
        }
Example #7
0
        public override bool Execute()
        {
            try
            {
                var text = File.ReadAllText(FileName);

                var lexer  = new PascalLexer();
                var tokens = lexer.Tokenize(text);

                var ast = new PascalAst();

                var node = ast.Evaluate(tokens);

                var syntaxChecker = new PascalSemanticAnalyzer();
                syntaxChecker.CheckSyntax(node);

                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
            //System.Diagnostics.Debugger.Launch();
        }
 public PascalSourceToSourceCompiler(ILogger logger)
 {
     lexer = new PascalLexer();
     ast   = new PascalAst();
     table = new PascalSemanticAnalyzer(logger);
 }