-
Notifications
You must be signed in to change notification settings - Fork 33
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
Line number in "rule is not defined" error #19
Comments
If you look at SyntaxNode.prototype.message you will see a way to calculate a lineNumber for a given SyntaxNode. This should probably be factored out into something like SyntaxNode.prototype.lineNumber. After this you would want to add the defining node to the rule object in buildRulesFromSyntaxTree. This would actually go into the individual rule builders (e.g. https://github.com/tolmasky/language/blob/master/lib/compiledgrammar.js#L251 ). You would just add node:aNode to that object creation line. Now finally in traverseRulesAnchoredAtName when you throw you can just use rule.node.lineNumber() to get the line number in question. |
Thanks! The problem with your suggestion is that I decided to do it the other way, with Here's how the message looks like:
What do you think? |
Francisco, could you please comment on my patch? Is idea good or bad? I can completely rewrite my patch if needed. |
When referencing undefined symbol in the grammar rule, the following is throwed:
It's nice, but line number would be even better.
I tried implementing this, but got stuck at traverseRulesAnchoredAtName. At that point information about rule syntax nodes is lost. The function also seems to be highly optimized: uses its own stack instead of recursion.
Any suggestions on how to implement it?
The text was updated successfully, but these errors were encountered: