Hi There, Can some1 help me with this, please? Thanks!
-----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Sarnath K - ERS, HCLTech Sent: Friday, August 20, 2010 2:23 PM To: [email protected] Subject: [antlr-interest] Confusion: Understanding gap or Tree Grammar Bug Grammar to parse the "Hi" statement of this e-mail: --------------------------------------------------- all: cM | cF | 'There'; cM: 'Chitparan'; // Sanskrit word meaning "One who inspires the mind" - Male cF: 'Chitpari'; // Sanskrit word meaning "One who inspires the mind" - Female --------------------------------------------------- Hi "all", We are new to ANTLR and we all love this tool! Thanks to Terrence! \__/ We are trying to write a C2C converter. However, we are stuck with the handling of the "block statement" in the Tree Grammar part. Though we have a workaround, we would like to know whether this is an ANTLR bug (or) a gap in our understanding. I have written a concise grammar that captures the problem. Kindly see the attachment. The problem is very simple: A compound statement is a 'statement' that starts with '{', has zero or more variable declarations, followed by zero or more 'statements' and ends with '}' In the grammar above, 'v' stands for variable declaration, 's' stands for a statement. When I run this project , I get the following output. ------------------------------- Console ------------------------------- {vs{s}} Tree = ({ v s ({ s }) }) Tree Grammar Output = {vs{vs} } -------------------------------- Now look at "Tree Grammar Output". It carries over the "v" from the previous level. However if I re-write the grammar as below, I don't have this problem. b->'{' '}' | '{' v '}' | '{' s '}' | '{' v+ s+ '}' Kindly advice me on what is the right way to do things! Are we missing something? (like... RTFM?) Thanks, Best Regards, Sarnath List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address -- 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.
