Grammars are the proverbial Swiss-army chain saw for parsing.
This is a preview of subscription content, access via your institution.
Like a Swiss-army knife, but with much more power.
At this point it is crucial that identifier does not parse its surrounding whitespace. Hence the principle that tokens do not care about whitespace, and the rules that call those tokens parse the whitespace.
In this case, this would be harmless, because no other rule could match the rest of the variable, leading to a parse error nonetheless. But in more complicated cases, this kind of unintended backtracking can lead to errors that are very puzzling for the maintainer of the grammar.
Rights and permissions
© 2017 Moritz Lenz
About this chapter
Cite this chapter
Lenz, M. (2017). Parsing with Grammars. In: Parsing with Perl 6 Regexes and Grammars. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-3228-6_9
Publisher Name: Apress, Berkeley, CA
Print ISBN: 978-1-4842-3227-9
Online ISBN: 978-1-4842-3228-6
eBook Packages: Professional and Applied ComputingProfessional and Applied Computing (R0)Apress Access Books