disclude `undefined` from data array, provide notreegen
See original GitHub issueRelated to post processing and eliminating nodes, is there a value I can return from a matched token that will eliminate it from output automatically?
For example, it would be nice if I could just drop optional whitespace, such that–
selector _ combinator _ element
– would return an array of 3 elements instead of 5. I thought I could write:
_ -> null
– but then that just returned an actual null value. I can see why I might want to post-process based on null, so I’m not sure what to suggest, maybe a special nearley token? Like: %null% or something?
Issue Analytics
- State:
- Created 8 years ago
- Comments:20 (10 by maintainers)
Top Results From Across the Web
Removing undefined values from Array - Stack Overflow
To use Array.prototype.filter here might be obvious. So to remove only undefined values we could call var data = [42, 21, undefined, 50,...
Read more >JavaScript tips — Remove undefined values from an array
The built-in filter method on #javascript arrays makes it easy to remove undefined values.To only removed undefined values, ...
Read more >JavaScript array: Remove null, 0, blank, false, undefined and ...
Got it! This site uses cookies to deliver our services and to show you relevant ads. By using our site, you acknowledge that...
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 Free
Top 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
As a global flag, it would look like this:
I prefer this because (1) you can enumerate no-tree nonterminals in one place, (2) you can’t accidentally create a conflict where only some, but not all, rules for a non-terminal are no-tree’d, (3) you can quickly toggle no-tree-ness for a nonterminal without having to change it in multiple places.
Just my two cents (and my opinion about all the previous discussions…)
I somewhat like it, it is quite readable, and understandable, but as @Hardmath123 said, it can be confusing with multiple non-piped declarations.
I actually dislike it, because the configuration is too much out of the context of the rule.
That’s the one I like the most, as it is more readable than (1). About the multiple non-piped declarations argument, I will say that it might be required to use only
-!>
or->
for a single rule.Tolerable, but it can be emulated by all the other variations by just changing the rule name. Also it might break existing grammars…
BTW, why >60% of this discussion have nothing to do with the issue topic? If you ask me, this issue should be split in at least 3 issues…