>On Feb 6, 2009, at 11:01 AM, Andreas Meyer wrote:
>
>> Hi!
>>
>> I am using ANTLR 3.1 and I want to compose tree grammars in a way,  
>> that I have one “base” grammar that contains all rules, in order to  
>> define a traversal, but without actions/rewrites. Then, a second  
>> grammar imports the “base” grammar, and overrides only some rules.  
>> Now, if I try to use the second grammar on the input,
>
>hi. what does that mean?
>Ter
>

Ok, I have 

* a base grammar SimpleC.g
* a tree grammar SimpleCWalker.g with a set of rules, mirroring the base 
grammar's result tree
* a tree grammar SimpleCWalker2.g that imports SimpleCWalker and overrides one 
rule (variable), 
* in Main.java, I call the start rule from SimpleCWalker, namely "program", but 
using the SimpleCWalker2:

SimpleCWalker2 walker = new SimpleCWalker2(nodes);
walker.program();

Btw, when generating SimpleCWalker2, ANTLR complains:

warning(138): SimpleCWalker2.g:0:0: grammar SimpleCWalker2: no start rule (no 
rule can obviously be followed by EOF)

When using the input file "input" from the example, eventually, the rule 
"program" calls the overridden rule "variable", where the ANTLR runtimes 
complain about some mismatched input:

$ java Main input
tree=(VAR_DEF char c) (VAR_DEF int x) (FUNC_DECL (FUNC_HDR void bar (ARG_DEF 
int x))) (FUNC_DEF (FUNC_HDR int foo (ARG_DEF int y) (ARG_DEF c
DEF int i) (for (= i 0) (< i 3) (= i (+ i 1)) (BLOCK (= x 3) (= y 5)))))
SimpleCWalker.g: node from line 1:0 mismatched input 'char' expecting set null

Debugging showed that the ANTLR runtimes expected an identifier, whereas the 
input stream (containing the generated tree nodes from the parser) still has a 
LT(1) of VAR_DEF.

I attach the (modified) simpleCTreewalker example in case you want to test it.

Thanks a lot for any hint!
A.Meyer
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Attachment: simplecTreeParser2.tgz
Description: Binary data

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

Reply via email to