private void TestParser(string source, StatementNodeBuilder expected) { // When parsing, the tree always starts with a magical "swix" node... var swixNode = new StatementNodeBuilder(); swixNode.StatementNode(-1, StatementType.Object, Token(ParserTokenType.Object, "swix"), expected); RtypeParser parser = new RtypeParser("test"); var actual = parser.Parse(source); Assert.Equal(swixNode.First(), actual, this.statementNodeComparer); }
public StatementNodeBuilder StatementNode(int indent, StatementType type, TokenListBuilder<ParserTokenType> tokens, StatementNodeBuilder children = null) { var statement = new Statement<StatementType, ParserTokenType>(type, tokens, tokens); var statementNode = new StatementNode(indent, null, statement); this.statementNodes.Add(statementNode); if (children != null) { foreach (var child in children) { statementNode.Add(child); } } return this; }
private static StatementNodeBuilder StatementNode(int indent, StatementType type, TokenListBuilder<ParserTokenType> tokens, StatementNodeBuilder children = null) { var builder = new StatementNodeBuilder(); return builder.StatementNode(indent, type, tokens, children); }