Exemple #1
0
        static void Run(string source)
        {
            var stmts = new List <Stmt>();

            try {
                var scanner = new Scanner(source);
                var tokens  = scanner.ScanTokens();
                var parser  = new Parser(tokens);
                stmts = parser.Parse();
                var resolve = new ResolutionVisitor(Interpreter);
                resolve.Resolve(stmts);
            } catch (LoxStaticErrorException loxStaticError) {
                StaticError(loxStaticError.Token.Line, loxStaticError.Message);
                return;
            }

            if (hadStaticError)
            {
                return;
            }


            Interpreter.Interpret(stmts);
        }
Exemple #2
0
 /// <summary>
 /// Set up this scopes lexically-declared fields
 /// </summary>
 public override void DeclareScope(ResolutionVisitor resolutionVisitor)
 {
     // only bind lexical declarations
     DefineLexicalDeclarations(resolutionVisitor);
 }