Files
bds.mr.dpg/doc/tutorial/calc/calcLexer.g
T
2026-01-03 18:31:15 +01:00

50 lines
1.2 KiB
Plaintext

// ============================================================================
// Demo lexer for four operator calculator
// ============================================================================
unit calcLexer;
lexer TcalcLexer;
options
{
exportVocab = calcLexer;
}
// ============================================================================
// Simple tokens
// ============================================================================
LPAREN : '(';
RPAREN : ')';
PLUS : '+';
MINUS : '-';
STAR : '*';
SLASH : '/';
SEMI : ';';
// ============================================================================
// INT
// ============================================================================
INT : ('0'..'9')+;
// ============================================================================
// White space
// ============================================================================
WS
:
(
options
{
generateAmbigWarnings = false;
}
: '\r' '\n' { newLine; }
| '\r' { newLine; }
| '\n' { newLine; }
| '\t' { tab; }
| ' '
)
{
_ttype := TT_SKIP;
}
;