Hi All,
I am still thinking about how to write the grammer ,after some research ,i
found the grammer is always too complicated cause it need to parse the
complicated sources ,so surely we need to write the grammer all manually .
but how about the tree grammer ? can I simply copy all the grammer into the
tree grammer file and include them by ^( ),also add an imaginary node . like
this :
//here is a grammer which meet a class or an interface of Java source
classOrInterace:
PUBLIC? (INTERFACE | CLASS ) IDENTIFIER '{'
classOrInterfaceBody
'}'
;
so here can I write a tree grammer for this rule as below ?
classOrInterace:
PUBLIC? (INTERFACE | CLASS ) IDENTIFIER '{'
classOrInterfaceBody
'}'
-> ^( CLASS_OR_INTERFACE PUBLIC? (INTERFACE | CLASS ) IDENTIFIER
classOrInterfaceBody)
;
the green are the grammer ,and the blue and red are the tree grammer !!!
repeat again ,no matter how the grammer looks like ,i just copy all of them
,and add the ^( ) also an imaginary node , can I do it ?
the reason why I wanna do like this ? cause sometime I dont care about the
efficiency ,i just wanna find a general way which I can write a program to
generate all the code for me , sure the best way is write the tree grammer
manually too , but because now I am not so familiar with the tree grammer and
this wonderful antlr project ,so I am learning it and also trying to find a way
to write an demo of an translator .
can somebody here tell me whether i can do it as i just described ,and more
important thing is what should it learn if i wanna write the tree grammer
manually !!
it there a conclusion of antlr which can as an dictionary ? as a newbie of
antlr ,i am not sure i learned all of the features of antlr ,
Thanks
b...@20009
--~--~---------~--~----~------------~-------~--~----~
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/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address