Feature: discard operator for terminals?
See original GitHub issuePlayed around with this on friday, and the biggest distraction while trying to develop a grammar, was whitespace and comment nodes, which generate a lot of noise.
It’s pretty common to need to allow optional whitespace (and/or comments) in or around various statements and blocks, and I suppose there could be other types of terminals (commas or other separators, string delimiters, etc.) which could be usefully discarded.
How about adding a discard operator?
Maybe something like a prefix operator @
to “mute” an expression - here’s a small portion of JSON grammar with whitespace and commas muted:
grammar CanopyJson
document <- @__ (object / array) @__
object <- "{" pair (@"," pair)* "}" / "{" @__ "}"
...
__ <- [\s]*
Would that work?
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
DISCARD TERMINAL - IBM
The DISCARD TERMINAL command removes the definition of a terminal from the local CICS® system, so that the system no longer has access...
Read more >Discards - unassigned discardable variables - Microsoft Learn
Discards are placeholder variables that are intentionally unused in application code. Discards are equivalent to unassigned variables; ...
Read more >discards qualifiers - c++ - Stack Overflow
The fix is to declare unsigned int TotalTimeInSeconds() const; , which says that the member function can be called via const references (and...
Read more >Operators (reactor-core 3.5.1)
Invoke a (local or global) hook that processes elements that get discarded. This includes elements that are dropped (for malformed sources), but also...
Read more >TCP/IP Distributed Systems Services Operations Guide - Unisys
The DISCARD command causes the unprocessed commands in a suspended load file to be discarded, but it does not remove the command file...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Could you please make a release with this feature? This is really hard do deal with whitespace/comments nodes
Hello.
I believe this never made it to production; npm’s latest release date is 3y ago and a quick try breaks the compilation on the
@
symbol. Is there any plan to release this feature?