// ============================================================================ // 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; } ;