Esempio n. 1
0
        public void Run(string source)
        {
            var scanner = new Scanner(source, this);
            var tokens  = scanner.ScanTokens();

            if (_hadError)
            {
                return;
            }

            var parser     = new Parser(tokens, this);
            var statements = parser.Parse();

            if (_hadError)
            {
                return;
            }

            var resolver = new Resolver(_interpreter, this);

            resolver.Resolve(statements);

            if (_hadError)
            {
                return;
            }

            _interpreter.Interpret(statements);
        }
Esempio n. 2
0
        private static void Run(string source, bool repl)
        {
            Scanner      scanner = new Scanner(source);
            List <Token> tokens  = scanner.ScanTokens();

            Parser      parser     = new Parser(tokens, repl);
            List <Stmt> statements = parser.Parse();

            // Stop if there was a syntax error
            if (hadError)
            {
                return;
            }

            Resolver resolver = new Resolver(interpreter);

            resolver.Resolve(statements);

            // Stop if there was a resolution error
            if (hadError)
            {
                return;
            }

            interpreter.Interpret(statements);
        }