Posted By:
Joseph_Corazza
Posted On:
Tuesday, March 18, 2003 03:51 PM
int i=1; // sample code block Is it possible to pass a token to the parser from a filter rule? In my filter rule I make calls to various functions to determine if the text string qualifies as a token which I have specified in the parser using the tokens{} construct. If it does, I set the token to the correct type using the $setType() function. However, the token doesn't seem to pass to the parser. Is this because I'm calling $setType() from within a protected rule? I'm am trying to do this in order to eliminate some nondeterminism warnings. Setting the rule as protected and using it as a filter eliminates the warnings. For example, a key word, if followed by additional variable name characters, should no longer be conside
More>>
int i=1; // sample code block
Is it possible to pass a token to the parser from a filter rule?
In my filter rule I make calls to various functions to determine if the text string qualifies as a token which I have specified in the parser using the tokens{} construct. If it does, I set the token to the correct type using the $setType() function. However, the token doesn't seem to pass to the parser. Is this because I'm calling $setType() from within a protected rule? I'm am trying to do this in order to eliminate some nondeterminism warnings. Setting the rule as protected and using it as a filter eliminates the warnings.
For example, a key word, if followed by additional variable name characters, should no longer be considered a key word and should be treated as a variable name instead.
In Parser:
token {
OBJ_NAME;
}
In Lexer:
filter = OBJ_NAME_PROTECTED;
CASE : ("case" (CHARACTER | DIGIT)) => "case" (CHARACTER | DIGIT)+ {$setType(OBJ_NAME);}
| "case";
protected OBJ_NAME_PROTECTED: ...$setType(OBJ_NAME);...
<<Less