Exemplo n.º 1
0
        private object Evaluate(string input)
        {
            var tokens = lexer.Tokenize(input);
            var node   = ast.Evaluate(tokens);

            analyzer.CheckSyntax(node);

            var n = interpreter.Interpret(node);

            return(n);
        }
Exemplo n.º 2
0
        public void PascalInput_Should_CreateOutput(string input, string output)
        {
            var tokens = lexer.Tokenize(input.Trim());
            var node   = ast.Evaluate(tokens);

            table.CheckSyntax(node);
            var result = cSharp.VisitNode(node).Trim();

            //result.Should().Be(output.Trim());

            CompileCSharp.CompileExecutable2(output, "test").Should().BeTrue();
        }
        public string Convert(string pascalInput)
        {
            var tokens = lexer.Tokenize(pascalInput);
            var tree   = ast.Evaluate(tokens);

            table.CheckSyntax(tree);

            return(VisitNode(tree));
        }
Exemplo n.º 4
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();
        }
Exemplo n.º 5
0
        private Node CheckSyntaxAndReturnNode(string input)
        {
            var tokens = this.lexer.Tokenize(input);
            var node   = ast.Evaluate(tokens);

            analyzer.CheckSyntax(node);
            return(node);
        }