-
Notifications
You must be signed in to change notification settings - Fork 78
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
Feature Request: Inverse for syntax exclusion #518
Comments
The following is an example from the JavaScript grammar we are working on. We want a few specific types of statements to match and exclude the rest, without altering syntax or creating redundant depth/overhead in our tree.
|
If some small part of a nonterminal is needed relatively often, it could make sense to promote it to a different nonterminal, which would eliminate the problem entirely. Exclusion is a stretch for small hacks. |
or an alias could also be nice. I think Sander does not want to change the On Thu, Mar 13, 2014 at 1:42 PM, Vadim Zaytsev notifications@github.comwrote:
Jurgen Vinju
|
I faced the same problem Sander has when I was working with the OCaml grammar, so I think it's good to have this feature inn Rascal. Semantically, adding a nonterminal makes sense, but in addition to changing the parse tree, introducing a new nonterminal will also affect the performance of parsing: GSS calls to the original nonterminal and SPPF nodes with the same label as the original nonterminal are not shared. I think the alias idea is nice. I was thinking of something like this:
or just simply
|
During development of a javascript grammar for rascal, exclusion is widely used to only search for 'specific' types of statements. For now, we are getting huge lines like;
Statement!c!d!e!f!g!h!i!j!k....
etcetera, forstatements
to be just oftype
or labellabel/type 'a' and 'b'
. In that case it would be more efficient (but more importantly, easier to understand and maintain) to use a form likeStatement#a#b
orStatement/a/b
, where we only expect to match on a and b. This would be the inverse of the exclusion.The text was updated successfully, but these errors were encountered: