2024-09-23 11:04:28 +02:00
|
|
|
//define a lexical analyser called Example1
|
|
|
|
|
|
|
|
lexer grammar Example1;
|
|
|
|
|
|
|
|
OP : '+'| '*' | '-' | '/' ;
|
|
|
|
DIGIT : [0-9] ;
|
2024-09-30 14:32:21 +02:00
|
|
|
LPAR : '(' ;
|
|
|
|
RPAR : ')' ;
|
2024-09-23 11:04:28 +02:00
|
|
|
LETTER : [A-Za-z] ;
|
|
|
|
ID : LETTER (LETTER | DIGIT)* ; // match idents
|
|
|
|
WS : [ \t\r\n]+ -> skip ; // skip spaces, tabs, newlines
|