Hello everyone,
I'm working on a grammar for a Java-like language and I'm stuck at this one
part. I'm looking to write the tree grammar from this parser grammar:
callExpression
: (primary -> primary) (s=selector -> ^(CALL $callExpression $s))*
;
The code would look like:
nodeObject.getLeft().getValue();
And the tree would look like:
( CALL ( CALL nodeObject getLeft ) getValue )
...or in other words:
( CALL ( CALL primary selector ) selector )
Theoretically, the tree should be as deep as it needs to be.
My initial two attempts at the tree grammar were these:
callExpression
: primary (^(CALL callExpression selector))*
;
callExpression
: ( ^( CALL ( primary | callExpression ) selector? ) )
;
But after giving them some thought, they don't make sense. Am I at least on
the right track?
So my questions are:
A) Is there a way to translate my parser grammar into a tree grammar?
B) If not, Is there a better way to write my parser grammar?
Ugh, now I'm beginning to doubt my parser grammar isn't even correct.
Any thoughts?
Oh, and for the sake of completeness, here is my tree grammars for primary
and selector
primary
: THIS
| TRUE
| FALSE
| INTLIT
| ID
| ^( CREATE OBJECT ID )
;
selector
: ^( ID ( ( expression )+ )? )
;
As you probably can tell, the only types I have are int, boolean and
objects.
//Thanks for you time,
//DW
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---
List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address