[antlr-interest] Parser rule to negate next token
bguillot_hit
guillot.bernard at hit.com.hk
Tue Jul 16 02:41:56 PDT 2002
Is it possible to generate a rule (Parser) that negate the following
Token ?
The Problem is all the rules I tried cannot resolve the ambiguity
between the rules. If I could use a rule like
mynegatingrule:
bp:BYPASS_START e:STRING_LITERAL l:STRING_LITERAL ~(c:STRING_LITERAL)
to allow a rule without the next token to be of a certain type.
This would remove the ambiguity, right ?
Any one of you ANTLR Gurus have any clues on this one ?
Thanks in advance.
Bernard.
Detail:
I want to detect and take different action when Parsing theses Lines.
//@ "ONE" "TWO" "THREE"
//@ "ONE" "TWO"
//@ "ONE"
//@
//@ is declared set in the lexer as BYPASS_START
the Strings are STRING_LITERAL (taken from java.g)
the first option (start with bp) if on it's own works perfectly to
detect line //@ "ONE" "TWO" "THREE" but crash for the others.
bypassDefinition!
: bp:BYPASS_START e:STRING_LITERAL l:STRING_LITERAL c:STRING_LITERAL
{
#bypassDefinition = #([BYPASS, "BYPASS"],
#([BYPASS_ERROR,"ERROR"], #e),
#([BYPASS_LOCATION,"LOCATION"], #l),
#([BYPASS_COMMENT, "COMMENT"], #c));
}
| bp2:BYPASS_START e2:STRING_LITERAL l2:STRING_LITERAL
{
#bypassDefinition = #([BYPASS, "BYPASS"],
#([BYPASS_ERROR,"ERROR"], #e2),
#([BYPASS_LOCATION,"LOCATION"], #l2));
}
| bp3:BYPASS_START e3:STRING_LITERAL
{
#bypassDefinition = #([BYPASS, "BYPASS"],
#([BYPASS_ERROR,"ERROR"], err3));
}
| bp4:BYPASS_START
{
#bypassDefinition = #([BYPASS, "BYPASS"],
#([BYPASS_ERROR,"ERROR"], "No Detail"));
System.out.println(" Parser Bypass: NO ERRORCODE");
}
;
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list