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

92 lines
2.4 KiB
Plaintext

unit hocLexer;
// ============================================================================
// Lexer class declaration
// ============================================================================
lexer ThocLexer;
// ----------------------------------------------------------------------------
// Lexer options
// ----------------------------------------------------------------------------
options
{
k = 2;
exportVocab = hocLexer;
caseSensitive = false;
}
// ============================================================================
// Begin rule definitions
//
// Remember: All lexer rule names must begin with UPPERCASE letter!
// ============================================================================
// ----------------------------------------------------------------------------
// Simple tokens
// ----------------------------------------------------------------------------
LPAREN : '(';
RPAREN : ')';
PLUS : '+';
MINUS : '-';
STAR : '*';
SLASH : '/';
// ----------------------------------------------------------------------------
// NUMBER
// ----------------------------------------------------------------------------
UNUMBER
: UINT ('.' UINT)?
;
// ----------------------------------------------------------------------------
// UINT
// ----------------------------------------------------------------------------
protected
UINT
: (DIGIT)+
;
// ----------------------------------------------------------------------------
// DIGIT
// ----------------------------------------------------------------------------
protected
DIGIT
: '0'..'9'
;
// ----------------------------------------------------------------------------
// NEWLINE
// ----------------------------------------------------------------------------
NEWLINE
:
(
options
{
generateAmbigWarnings = false;
}
: '\r' '\n' { newLine; }
| '\r' { newLine; }
| '\n' { newLine; }
)
;
// ----------------------------------------------------------------------------
// WHITESPACE
// ----------------------------------------------------------------------------
WHITESPACE
:
(
' '
| '\t' { tab; }
)
{
_ttype := TT_SKIP;
}
;
// ============================================================================
// End rule definitions
// ============================================================================