Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Label for separator in AT_LEAST_ONE_SEP/MANY_SEP #1131

Closed
tlrobinson opened this issue Feb 25, 2020 · 4 comments
Closed

Label for separator in AT_LEAST_ONE_SEP/MANY_SEP #1131

tlrobinson opened this issue Feb 25, 2020 · 4 comments

Comments

@tlrobinson
Copy link

tlrobinson commented Feb 25, 2020

As far as I can tell there's no way to label the SEP in AT_LEAST_ONE_SEP/MANY_SEP. Sometimes it would be convenient to do so.

Maybe something like SEP_LABEL or LABEL_SEP?

@bd82
Copy link
Member

bd82 commented Feb 26, 2020

I am actually interested in deprecating the _SEP variants.

This is because they could now be accomplished by composing the basic building blocks.

Maybe something like:

class Foo {
   MANY_SEP_LABEL(idx, {ELEMENT, SEP, LABEL}) {
       this.option(idx + 10, () => {
          ELEMENT();  
       }) 
       this.many(idx + 10, () => {
           this.consume(idx + 10, SEP, {LABEL:LABEL})
           ELEMENT();             
       })
   }
}
  • I did not actually try to run this code 😄

The tricky part is that while Chevrotain DSL is now composable the limitation on
having unique suffix indices still exists so collisions (within a single rule) must be avoided (why we do the +10)
There is also a limitation on the max indice size but I will need to locate it...

@bd82
Copy link
Member

bd82 commented Feb 26, 2020

Seems like the max indice is 255.

@tlrobinson
Copy link
Author

That makes sense. Feel free to close this if that's the way forward.

@bd82
Copy link
Member

bd82 commented Feb 26, 2020

That makes sense. Feel free to close this if that's the way forward.

Feel free to share/consult on your "macros" implementations particularly as there are no docs/examples for this yet.

@bd82 bd82 closed this as completed Feb 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants