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

47 lines
1.1 KiB
Plaintext

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