Padrões léxicos típicos

Token categoryPossible implementation

Identifiers

ID: LETTER (LETTER | DIGIT)+ ; fragment LETTER: 'a'..'z' | 'A'..'Z' | '_'; // same as: [a-zA-Z] fragment DIGIT: '0'..'9'; // same as: [0-9]

Numbers

INT: DIGIT+; FLOAT: DIGIT+ ' . ' DIGIT+ | ' . ' DIGIT+;

Strings

STRING: ' " ' (ESC | . ) * Z ' " '; fragment ESC: ' \\" ' | ' \\\\ ';

Comments

LINE_COMMENT: ' // ' .*? '\n' -> skip; COMMENT: '/*' .*? '*/' -> skip;

Whitespace

WS: [ \t \n \r ]+ -> skip;

Last updated