aboutsummaryrefslogtreecommitdiff
path: root/spec/test/parser.go
diff options
context:
space:
mode:
Diffstat (limited to 'spec/test/parser.go')
-rw-r--r--spec/test/parser.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/spec/test/parser.go b/spec/test/parser.go
index 33e035b..e9c557d 100644
--- a/spec/test/parser.go
+++ b/spec/test/parser.go
@@ -289,6 +289,14 @@ func formatSyntaxError(synErr *SyntaxError, gram Grammar, lineOffset int) []byte
}
func (tp *treeParser) genTree(node *Node) (*Tree, error) {
+ // A node labeled 'error' cannot have children. It always must be (error).
+ if sym := node.Children[0]; sym.Text == "error" {
+ if len(node.Children) > 1 {
+ return nil, fmt.Errorf("%v:%v: error node cannot take children", tp.lineOffset+sym.Row+1, sym.Col+1)
+ }
+ return NewTerminalNode(sym.Text, ""), nil
+ }
+
if len(node.Children) == 2 && node.Children[1].KindName == "string" {
var text string
str := node.Children[1].Children[0]