-
Notifications
You must be signed in to change notification settings - Fork 77
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
syntax role modifiers #1835
base: main
Are you sure you want to change the base?
syntax role modifiers #1835
Conversation
…d dead commented code
I'll start reviewing this soon. or are you still writing it @jurgenvinju ? |
Impressive, if you ignore the generated code, it's actually quite compact. |
|
||
test bool useOfDifferentModifierTypesWithinASingleScope() { | ||
data[A] anExample = a(); | ||
syntax[A] anotherExample = [syntax[A]] "a"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it also legal to write parse(#syntax[A], "a")
? and how does this relate to start[A]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent question!
syntax[X]
is equivalent to X
in any context. So #X
produces the same as #syntax[X]
as long as X
is not ambiguous.
If X is ambiguous then it could happen that #X
produces an ADT definition instead of a syntax definition.
For X
you can substitute other non-terminal forms; like syntax[start[X]]
and syntax[A*]
but that is implemented on a different branch. In the current branch you can type start[syntax[X]]
to get start[X]
while syntax[start[X]]
is undefined. Also syntax[A*]
is undefined here. With -ea
asserts enabled, during the tests such an application will fail. In a deployed interpreter, without -ea
, the unsupported combinations will be idempotent. In other words, syntax[A*]
will simply reduce to A*
, and it will behave as it as always behaved.
On the other branch, after we have this one working, and merged into it, we can use syntax[A*]
to introduce layout symbols in all the right places, and also to pattern match on lexical lists, mutually exclusively with context-free lists: i.e. int size(syntax[&T*] l)
and int size(lexical[&T*] l)
would be two different overloads to handle the different way of counting elements in either kind of list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah interresting. I would have expected syntax[start[A]]
to be valid indeed. good that it's incoming as well.
…to a Production representation
The util::Explode code is actually more of a integration test; the rest should be almost done. Because of bootstrapping issues, where the standard library needs to be type-checking correctly, before we can release the new code, I think I have to park that use of the new feature until after we have extended the type-checker. IOW: I'll merge this without |
… does not know about yet
…and added missing cases to \data modifier in Type and regenerated the Rascal parser with Arnold's bugfixes
This PR implements syntax role modifiers.
SyntaxModifiers.pdf