Hello antlr users,
I am rewriting our parser and I have a question :
I have a HostParser and I call other subparsers when specific constructions are
detected. Then, I build a tree like this :
Program
BlockList
Construct1 ... // sublanguage1 block
Construct2 ... // sublanguage2 block
Construct1 ...
Construct42 ... // sublanguage1 block
...
HostBlock
...
A HostBlock is a block of host code (for instance Java). I do not want neither
to parse nor to modify it, I only want to keep it without any other treatment :
(BlockList
(...)
(HostBlock <big string representing a host code block> )
(...)
)
In our previous antlr2 parser, we used the filter option in a combined grammar :
Lexer part :
options{
filter=TARGET;
}
...
protected
TARGET
:
( . )
{target.append($getText);}
;
where target is a StringBuffer.
Parser part :
private String getCode() {
String result = lexer.target.toString();
lexer.clearTarget();
return result;
}
Then, we only called getCode() when building a HostBlock node.
Is it still possible with antlr3 ? I have noted a change, the option has to be
filter=true;
Since I am using a combined grammar (one file containing my parser and my
lexer), I am not sure how to use this option. How can I precise that it is a
lexer option ? (in global options, it does not work, because it applies only on
lexer). Do I have to add this option in the lexer rule ? (and how ?) :
fragment
TARGETĀ : ( . ) {<my Java code>}
I tried to add the filter option in the rule, but I obtain errors, as if the
option did not exist.
Thanks in advance,
JC
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.