You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Manually inserting whitespace rules is somewhat cumbersome & error-prone, especially for larger grammars with 100s of rules. One of the nicest features of Perl's grammar-parsing package, Regexp::Grammars, is its implicit whitespace rule.
Essentially, Regexp::Grammars has two types of rules, "tokens" and "rules." In rule definitions, most sequences of whitespace are treated as implicit invocations of the <.ws> rule, which is automatically predefined to \s* & captures nothing (since matching whitespace is often useless). In token definitions, whitespace is ignored as in PEG.js.
It would be nice if PEG.js had an alternate rule type, like ::=, that implicitly matched whitespace.
The text was updated successfully, but these errors were encountered:
This has been bought up before (see #11), but before I tackle this, I want #256 to be implemented first. Would also prefer #311 and #523 to be done first, but they just ease the use of this feature request.
As for an alternative rule type invoked by syntax sugar like ::=, after #256 is done, it should be easier to implement (quite simply, it would just enable the rule annotation for ignoring whitespace, e.g @ignore(...ruleNames)).
I've made do with the _ rule for now. Since regex anchors like \b are missing from pegjs, I had to cook up a &[^A-Za-z0-9_] rule to terminate words with instead.
Issue type
Description
Manually inserting whitespace rules is somewhat cumbersome & error-prone, especially for larger grammars with 100s of rules. One of the nicest features of Perl's grammar-parsing package, Regexp::Grammars, is its implicit whitespace rule.
Essentially, Regexp::Grammars has two types of rules, "tokens" and "rules." In rule definitions, most sequences of whitespace are treated as implicit invocations of the
<.ws>
rule, which is automatically predefined to\s*
& captures nothing (since matching whitespace is often useless). In token definitions, whitespace is ignored as in PEG.js.It would be nice if PEG.js had an alternate rule type, like
::=
, that implicitly matched whitespace.The text was updated successfully, but these errors were encountered: