Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disambiguate 'unexpected term type' panic messages #84

Merged
merged 3 commits into from
Jun 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ast/counter.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,6 @@ func (ctrs counters) termCountChildren(term parser.Term, parent counter) {
case parser.ExtRef:
ctrs.count(string(t), parent)
default:
panic(fmt.Errorf("unexpected term type: %v %[1]T", t))
panic(fmt.Errorf("counters.termCountChildren: unexpected term type: %v %[1]T", t))
}
}
2 changes: 1 addition & 1 deletion ast/from_parsernode.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,6 @@ func (b Branch) fromParserNode(g parser.Grammar, term parser.Term, ctrs counters
}
}
default:
panic(fmt.Errorf("unexpected term type: %v %[1]T", t))
panic(fmt.Errorf("branch.fromParserNode: unexpected term type: %v %[1]T", t))
}
}
2 changes: 1 addition & 1 deletion ast/to_parsernode.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,6 @@ func (b Branch) toParserNode(g parser.Grammar, term parser.Term, ctrs counters)
case parser.CutPoint:
return b.toParserNode(g, t.Term, ctrs)
default:
panic(fmt.Errorf("unexpected term type: %v %[1]T", t))
panic(fmt.Errorf("branch.toParserNode: unexpected term type: %v %[1]T", t))
}
}
2 changes: 1 addition & 1 deletion cmd/codegen/grammar.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func walkTerm(term parser.Term) GoNode {
case parser.ExtRef:
node = stringNode("parser.ExtRef(`%s`)", safeString(string(t)))
default:
panic(fmt.Errorf("unexpected term type: %v %[1]T", t))
panic(fmt.Errorf("walkTerm: unexpected term type: %v %[1]T", t))
}

return node
Expand Down
4 changes: 2 additions & 2 deletions wbnf/cutpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func findUniqueStrings(g parser.Grammar) frozen.Set {
out = out.Merge(forTerm(t.Term), mergeFn)
case parser.RE, parser.Rule, parser.ExtRef: // do nothing
default:
panic(fmt.Errorf("unexpected term type: %v %[1]T", t))
panic(fmt.Errorf("findUniqueStrings: unexpected term type: %v %[1]T", t))
}
return out
}
Expand Down Expand Up @@ -166,6 +166,6 @@ func fixTerm(term parser.Term, callback func(t parser.Term) parser.Term) parser.
case parser.S, parser.REF, parser.RE, parser.Rule, parser.ExtRef:
return callback(term)
default:
panic(fmt.Errorf("unexpected term type: %v %[1]T", t))
panic(fmt.Errorf("fixTerm: unexpected term type: %v %[1]T", t))
}
}