ohmjs / ohm

A library and language for building parsers, interpreters, compilers, etc.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature Request] Support for repeatition range

MuhammedZakir opened this issue · comments

As in regex : e {start,end}. Of course, syntax can be different.

Specifically, I want to choose the rules based on the count of next element. For now, I hardcode the repeatition and use alternative expression. But that seems suboptimal?

Sorry, I didn't know there was already a discussion about this [1]. I see you have mentioned to usek semantic action. I personally think having a repeatition range operator inside grammar is better. Using semantic actions for this feel a bit "hacky" to me. For now, I am okay using semantic action.

When using AST transformer for cases like this, can I use functions/conditions to change the node type?

[1] #280


Edit: closing this as there is already an open issue about this. #215

@MuhammedZakir Can you add some more details about your use case to #215?