public void NewYorkParse() { var grammar = GetGrammar(); BParser parser = new BParser(grammar); var cityNode = new VariableNode("CITY", new TerminalNode("York"), new TerminalNode("New")); var expected = new ParserTree(grammar, cityNode); var actual = parser.ParseStringToTree("New York"); Assert.Equal(expected, actual); }
public ParserTree ParseStringToTree(string input) { tokenizer = new BTokenizer(input); while (tokenizer.MoveNext()) { string currentToken = tokenizer.Current; _internalStack.DoPush(new TerminalNode(currentToken)); while (Reduce()) { } } ParserTree tree = new ParserTree(_grammar, _internalStack); return tree; }