[antlr-interest] V2->v3 help
Des Hartman
des at deshartman.com
Fri Mar 13 15:47:12 PDT 2009
Can anyone help me with this conversion? I need to convert this section of
the code from V2 to V3. I have figured out the changes from V2 import lexer
to lexer, the protected to fragment and setType to $Type=, but the part I am
stumped on is how the code in ALPHABETICAL sets the definitions for FUNCTION
and CELL_REF.
I tried the v3me conversion, but it fails, so I reckon this is not handled
in there.
function_call
: FUNCTION^ ( comparison ( SEMI! comparison )* )? RPAR!;
reference
: CELL_REF ( ( COLON^ ) CELL_REF )? | NAME;
{import formula.lang.Language;}
class FormulaLexer extends Lexer;
options {
k = 4;
caseSensitive = false;
caseSensitiveLiterals = false;
}
protected LETTER: ('a'..'z') ;
ALPHABETICAL
: ( ( LETTER )+ LPAR ) => ( LETTER )+ LPAR! {
if (Language.getInstance().hasFunction(#getText())) {
$setType(FUNCTION);
} else
throw new RecognitionException();
}
| ( ABS )? LETTER ( LETTER )?
( ABS )? ( DIGIT )+ {
$setType(CELL_REF);
}
;
Thanks
Des
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090314/3ec61dbc/attachment.html
More information about the antlr-interest
mailing list