[antlr-interest] Skipping grammar
pwolleba
pwolleba at yahoo.no
Tue Oct 7 00:18:58 PDT 2003
I am pretty new to ANTLR so maybe this question is very trivial, if
so even better then maybe it is a simple solution to my problem.
Anyway I am struggling with writing a new parser in ANTLR to replace
and old implementation in Flex/Bison, this to make a product that are
open for implementation from both C++ as well as Java.
The parser will parse a language that we are using to build
databases, and it must support this language 100% if to be accepted.
Here is the code cutting that I am struggling with.
method name{
SomeText!()text[];
if(a < b && b < c){
SomeText()!()[];
}
else{
SomeText()!()[];
};
};
I am not interesting in the expression that is inside the name
method, I just want ANTLR to grab the text for me, and put it as a
node inside the tree. The problem is the fact that the if/else
statement is ending with a "};" which is the same token as the method
end token, and I have no guarantee that there could be more that one
inside the method. A solution would be to make a counter that will
increase for each "{" and decrease for each "}", then I would know
when the method ends. To my frustration I don't know how I should
make such a counter in ANTRL, that still supports implement in both
Java or C++ code.
I would be really really happy if someone could help me with this
problem!
Best reagards,
Per
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list