question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

disclude `undefined` from data array, provide notreegen

See original GitHub issue

Related 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:open
  • Created 8 years ago
  • Comments:20 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
kachcommented, May 8, 2015

As a global flag, it would look like this:

_ -> whitespacechar:*
__ -> whitespacechar:+
comment -> "/*" commentchar:+ "*/" | "//" commentchar:+ "\n"
@no-tree _
@no-tree __
@no-tree comment

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.

0reactions
bojidar-bgcommented, Sep 10, 2015

Just my two cents (and my opinion about all the previous discussions…)

//(explicit, rule-bound) A prefix
@no-tree-or-no-output-or-just-match-or-whatever __ -> [\s] | __ [\s]

I somewhat like it, it is quite readable, and understandable, but as @Hardmath123 said, it can be confusing with multiple non-piped declarations.

//(explicit, rule-bound) Global configuration
__ -> [\s] | __ [\s]
@no-tree-or-no-output-or-just-match-or-whatever __

I actually dislike it, because the configuration is too much out of the context of the rule.

//(explicit, rule-bound) Changed arrow
__ -!> [\s] | __ [\s] //(This arrow looks better than !-> or -]> IMHO)

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.

//(explicit, use-bound)
a -> number !__ number {% /*now d is like [3,5], and not like [3,null,5]*/ %}

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…

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found