public void TestConflictGrammarWithHintsOnRules() { var grammar = new ConflictGrammarWithHintsInRules(); var parser = new Parser(grammar); Assert.True(parser.Language.Errors.Count == 0); // Field sample var sample = FieldSample; var tree = parser.Parse(sample); Assert.NotNull(tree); Assert.False(tree.HasErrors()); Assert.NotNull(tree.Root); var term = tree.Root.Term as NonTerminal; Assert.NotNull(term); Assert.Equal("definition", term.Name); Assert.Equal(1, tree.Root.ChildNodes.Count); var modNode = tree.Root.ChildNodes[0].ChildNodes[0]; Assert.Equal("fieldModifier", modNode.Term.Name); //Property sample = PropertySample; tree = parser.Parse(sample); Assert.NotNull(tree); Assert.False(tree.HasErrors()); Assert.NotNull(tree.Root); term = tree.Root.Term as NonTerminal; Assert.NotNull(term); Assert.Equal("definition", term.Name); Assert.Equal(1, tree.Root.ChildNodes.Count); modNode = tree.Root.ChildNodes[0].ChildNodes[0]; Assert.Equal("propModifier", modNode.Term.Name); }
public void TestConflictGrammarWithHintsOnRules() { var grammar = new ConflictGrammarWithHintsInRules(); var parser = new Parser(grammar); Assert.True(parser.Language.Errors.Count == 0); // Field sample var sample = FieldSample; var tree = parser.Parse(sample); Assert.NotNull(tree); Assert.False(tree.HasErrors()); Assert.NotNull(tree.Root); var term = tree.Root.Term as NonTerminal; Assert.NotNull(term); Assert.Equal("definition", term.Name); Assert.Single(tree.Root.ChildNodes); var modNode = tree.Root.ChildNodes[0].ChildNodes[0]; Assert.Equal("fieldModifier", modNode.Term.Name); //Property sample = PropertySample; tree = parser.Parse(sample); Assert.NotNull(tree); Assert.False(tree.HasErrors()); Assert.NotNull(tree.Root); term = tree.Root.Term as NonTerminal; Assert.NotNull(term); Assert.Equal("definition", term.Name); Assert.Single(tree.Root.ChildNodes); modNode = tree.Root.ChildNodes[0].ChildNodes[0]; Assert.Equal("propModifier", modNode.Term.Name); }