Ejemplo n.º 1
0
        public Interpreter(string code, Builtins builtins)
        {
            errorBag = new CodeErrorBag();

            var inputStream = new AntlrInputStream(code);
            var lexer       = new PigeonLexer(inputStream);
            var tokenStream = new CommonTokenStream(lexer);

            parser = new PigeonParser(tokenStream);
            var errorListener = new CodeErrorListener(errorBag);

            parser.AddErrorListener(errorListener);
            tree = parser.program();

            var walker      = new ParseTreeWalker();
            var globalScope = new GlobalScope();

            builtins.Register(globalScope);
            var functionDeclarator = new FunctionDeclarator(errorBag, globalScope);

            walker.Walk(functionDeclarator, tree);

            analyser = new SemanticAnalyser(errorBag, globalScope);
            walker.Walk(analyser, tree);
        }
Ejemplo n.º 2
0
 internal Evaluator(SemanticAnalyser analyser)
 {
     this.analyser = analyser;
 }