public GrammarTree Generate(Config config, string content) { mConfig = config; if (!mConfig.Valid) { return(null); } DateTime t0 = DateTime.Now; mTokens = mScanner.Scan(this, content); mTree = GenerateTree(mConfig.grammar.root); ErrorReport(); TimeSpan span = new TimeSpan(DateTime.Now.Ticks - t0.Ticks); if (mConfig.msgHaneler != null) { mConfig.msgHaneler(string.Format("Time:{0:00}:{1:00}:{2:00}:{3:00}", span.Hours, span.Minutes, span.Seconds, span.Milliseconds)); } return(mTree); }
internal void AddContent(GrammarTree tree, List <Token> tokens, int n) { PropertyTreeNode node = new PropertyTreeNode(); node.propName = name; node.content = tokens[n].Word; tree.propertices.Add(node); }
internal void AddContent(GrammarTree tree) { if (!string.IsNullOrEmpty(name)) { GrammarTreeNode node = new GrammarTreeNode(); node.propName = name; tree.propertices.Add(node); } }
internal override bool Match(List <Token> tokens, ref int n, GrammarTree parentTree) { foreach (var child in children) { int offset = n; if (!child.Match(tokens, ref offset, parentTree)) { n = offset; return(true); } } return(false); }
GrammarTree GenerateTree(Production p) { GrammarTree tree = new GrammarTree(); tree.propName = p.ToString(); int offset = 0; if (p.Match(mTokens, ref offset, tree)) { mTree = tree; } return(mTree); }
internal override bool Match(List <Token> tokens, ref int n, GrammarTree parentTree) { return(false); //throw new Exception(); //if (tokens[n].Tag == tokenid) //{ // n++; // return true; //} //else //{ // return false; //} }
internal override bool Match(List <Token> tokens, ref int n, GrammarTree parentTree) { if (tokens[n] is EofToken) { return(true); } if (tokens[n].Word == content) { n++; return(true); } else { return(false); } }
internal override bool Match(List <Token> tokens, ref int n, GrammarTree parentTree) { if (node) { node.AddContent(parentTree); } int offset = n; foreach (var child in children) { if (!child.Match(tokens, ref offset, parentTree)) { parentTree.Clear(); return(false); } } n = offset; return(true); }
internal virtual bool Match(List <Token> tokens, ref int n, GrammarTree parentTree) { throw new Exception(); }
internal override bool Match(List <Token> tokens, ref int n, GrammarTree parentTree) { return(true); }