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.

Add support for picking fields with `@`

See original GitHub issue

as discussed at https://github.com/pegjs/pegjs/issues/11,

foo = @bar _ @baz
bar = $"bar"i
baz = $"baz"i
_ = " "*
parse('barbaz') // returns [ 'bar', 'baz' ]

I use this syntax frequently when it’s available.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:27 (26 by maintainers)

github_iconTop GitHub Comments

1reaction
hildjjcommented, Apr 21, 2021

PR #89 is pretty close at this point. Now it’s time to decide if we like it enough to land it.

I do like it; I use @ enough that i’ve gone out of my way in a couple of non-production projects to rely on odd versions of pegjs in the past. The implementation is adequate (if a little confusing because of the way the stack manipulation has to happen). Tests gave adequate coverage. I’ve prototyped ahead the few other places I might like us to use @ and am not concerned about overlaps from a grammar perspective.

Note that the example I added to the end of the documentation is:

list = head:word tail:(_ "," _ @word)* { return [head].concat(tail); }
word = $[a-z]i+
_ = [ \t]*

which shows off how @ can pluck from parens, which is its killer feature, imo.

1reaction
Minguncommented, Apr 16, 2021

Another possible way of evolution – change how the rule rule itself is defined and thus make it impossible to create clash.

At least two options can be suggested:

  • change the rule definition to something like this (the https://github.com/kevinmehall/rust-peg way):
    rule rule_name() = ...
    
    The empty brackets are not allowed in the current grammar, so no clash.
  • the other way is just make the optional semicolon in the end of the rule definition required. Personally I think that is easest and right way to solve this problem, because modern JS rules also requires semicolons to make syntax consistent.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Use the Field List to arrange fields in a PivotTable
Rearrange fields in your PivotTable (pivot table) by using the Field List, and show the Field List again when it disappears.
Read more >
Create Custom Fields - Salesforce Help
Want to add and arrange a new field while viewing an individual record for an object? This short video walks you through creating...
Read more >
Adding Custom Help Desk Fields - Zoho Cares
Zoho Desk allows adding more industry-specific custom fields according to the help desk process. ... Other fields (Multi-select Pick List and Multi Line)...
Read more >
Picking - Fishbowl Advanced
The Picking module, located in the Sales group, facilitates the process of picking, or gathering items from their storage locations.
Read more >
PDF form fields | Add tooltips, data and time, reqired/optional ...
Learn how to use form fields properties to add tooltip, ... Meaningful tooltips can help users fill your form easily. To add ......
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