Exemplo n.º 1
0
        public static Expression FromText(string source)
        {
            var lexer       = new FlowScriptLexer(new AntlrInputStream(source));
            var tokenStream = new CommonTokenStream(lexer);

            // parse expression
            var parser = new FlowScriptParser(tokenStream);

            parser.BuildParseTree = true;
            var expressionParseTree = parser.expression();

            // parse ast nodes
            var compilationUnitParser = new CompilationUnitParser();

            compilationUnitParser.TryParseExpression(expressionParseTree, out var expression);

            // resolve types
            var typeResolver = new TypeResolver();

            typeResolver.TryResolveTypesInExpression(expression);

            return(expression);
        }