public override void BuildAst(LanguageData language, ParseTree parseTree) {
   var opHandler = new OperatorHandler(language.Grammar.CaseSensitive);
   Util.Check(!parseTree.HasErrors(), "ParseTree has errors, cannot build AST.");
   var astContext = new InterpreterAstContext(language, opHandler);
   var astBuilder = new AstBuilder(astContext);
   astBuilder.BuildAst(parseTree);
 }
Ejemplo n.º 2
0
 public virtual void BuildAst(LanguageData language, ParseTree parseTree)
 {
     if (!LanguageFlags.IsSet(LanguageFlags.CreateAst))
         return;
     var astContext = new AstContext(language);
     var astBuilder = new AstBuilder(astContext);
     astBuilder.BuildAst(parseTree);
 }
Ejemplo n.º 3
0
        /// <summary>Builds the AST for the specified language data and parse tree.</summary>
        /// <param name="language">The language data.</param>
        /// <param name="parseTree">The parse tree to build the AST against.</param>
        public override void BuildAst(LanguageData language, ParseTree parseTree)
        {
            if (!LanguageFlags.IsSet(LanguageFlags.CreateAst))
                return;

            var astContext=new InterpreterAstContext(language, _OperatorHandler);
            astContext.DefaultNodeType=typeof(NotSupportedNode);
            var astBuilder=new AstBuilder(astContext);
            astBuilder.BuildAst(parseTree);
        }
Ejemplo n.º 4
0
        private ISqlNode ParseNode(string sqlSource, ICollection<SqlParseError> errors, out long parseTime)
        {
            var tree = parser.Parse(sqlSource);
            parseTime = tree.ParseTimeMilliseconds;

            if (tree.Status == ParseTreeStatus.Error) {
                BuildErrors(tree, errors, tree.ParserMessages);
                return null;
            }

            var astContext = new AstContext(languageData) {
                DefaultNodeType = typeof (SqlNode),
                DefaultIdentifierNodeType = typeof (IdentifierNode)
            };

            var astCompiler = new AstBuilder(astContext);
            astCompiler.BuildAst(tree);

            if (tree.HasErrors())
                BuildErrors(tree, errors, tree.ParserMessages);

            var node = (ISqlNode) tree.Root.AstNode;
            if (node.NodeName == "root")
                node = node.ChildNodes.FirstOrDefault();

            return node;
        }