[antlr-interest] Lexer problem ( add ALLCHARS )
max murmel
oczy at hotmail.com
Mon Mar 5 12:18:45 PST 2007
Dear antlr-interests,
i trying to add to a lexer ALLCHARS but it do not work.
hir is my Lexer wich i use:
class UMLLexer extends Lexer;
options {
k=4;
defaultErrorHandler=false;
}
tokens {
DIDENTIFIER;
DIGITS;
//ALLCHAR;
}
COLON: ':';
EQ: '=';
PLUS: '+';
POINTS: "..";
BRACKET_O: '(';
BRACKET_C: ')';
SQBRACKET_O: '[';
SQBRACKET_C: ']';
COMMA:',';
ID_START: "<?";
ID_END:'>';
NOT: "{not}";
INFINITE: "-1";
EXCLAMATIONMARK: '!';
OR: "|";
PUBLIC: "+";
PROTECTED: "#";
PACKAGE: "~";
RET: "^";
INTERSECT: "&&";
QUESTIONMARK: "?";
STEREOYTPE_START: "<<";
STEREOYTPE_END: ">>";
SPECIALS: "\\d"|"\\D"|"\\s"|"\\S"|"\\w"|"\\W"|".";
STAR: "*";
/*
IDENTIFIER: // geht noch nicht:|"<?" |"{not}"|'>'|'{'|'}'|
//('_' | 'a'..'z' | 'A'..'Z')
(NOT| 'a'..'z' | 'A'..'Z' | '0'..'9'|'*'|'!'|'['|']'|POINTS|ID_START
(IDENTIFIER)* ID_END)+;
*/
IDENTIFIER:
('_' | 'a'..'z' | 'A'..'Z')
('_' | 'a'..'z' | 'A'..'Z' | '0'..'9')*;
RANGED:
((('a'..'z') '-' ('a'..'z'))|
(('A'..'Z') '-' ('A'..'Z'))|
(('0'..'9') '-' ('0'..'9'))) (RANGED | IDENTIFIER)*;
DHANDLER:
(('0'..'9')+ (IDENTIFIER)+)
=> (('0'..'9')+ (IDENTIFIER)+) { $setType(DIDENTIFIER); }
| (('0'..'9')+ { $setType(DIGITS); });
PRIVATE: "-";
UNDERSCORE: "_";
ARBITARYLITERAL:
'"' (~('"'|'\n'|'\r'))* '"';
WS : (' ') {$setType(Token.SKIP);};
NEWLINE
: '\r' '\n' // DOS
| '\n' // UNIX
;
ALLCHARS: // <-- this is the funtion which I
want add
( 'a'..'z' | 'A'..'Z' |
'0'..'9'|'*'|'!'|'['|']'|NOT|POINTS|ID_START|ID_END)+
( 'a'..'z' | 'A'..'Z' |
'0'..'9'|'*'|'!'|'['|']'|NOT|POINTS|ID_START|ID_END)*;
i get always this error:
line 1:1: expecting ALLCHARS, found 'aa'
at antlr.Parser.match(Parser.java:211)
at
de.unidue.icb.dawis.jpdd.textparser.parser.UMLParser.getAssociationEnds(UMLParser.java:1546)
at
de.unidue.icb.dawis.jpdd.textparser.parser.Parser.parseAssociationEnd(Parser.java:101)
at
de.unidue.icb.dawis.jpdd.textparser.test.Main.parseAssociation(Main.java:308)
at de.unidue.icb.dawis.jpdd.textparser.test.Main.main(Main.java:125)
line 1:1: expecting ALLCHARS, found 'a'
at antlr.Parser.match(Parser.java:211)
at
de.unidue.icb.dawis.jpdd.textparser.parser.UMLParser.getAssociationEnds(UMLParser.java:1546)
for the input aa and a
thanks for your help max pfeiffer
_________________________________________________________________
Die neue MSN Suche Toolbar mit Windows-Desktopsuche. Suchen Sie gleichzeitig
im Web, Ihren E-Mails und auf Ihrem PC! Jetzt neu! http://desktop.msn.de/
Jetzt gratis downloaden!
More information about the antlr-interest
mailing list