Added Lexemes

Wrote some literals and keywords.
This commit is contained in:
Mandeep Moun
2025-09-19 23:25:40 -06:00
parent e75d3e5797
commit bc6c1027af
2 changed files with 48 additions and 0 deletions

48
lexerA1.g4 Normal file
View File

@@ -0,0 +1,48 @@
lexer grammar lexerA1;
// Literals
IntigerLiteral: ;
FloatingPointLiteral: ;
CharacterLiteral: '\'' SingleCharacter '\'' | '\'' EscapeSequence '\'';
fragment SingleCharacter:
[^'\\];
StringLiteral: '"' StringCharacters? '"';
fragment StringCharacters:
StringCharacter+;
fragment StringCharacter:
[^"\\] | EscapeSequence;
fragment EscapeSequence:
'\\' ('u0008' | 'u0009' | 'u000a' | 'u000c' | 'u000d' | 'u0022' | 'u0027' | 'u005c' | OctalEscape);
fragment OctalEscape:
'\\' OctalDigit | '\\' OctalDigit OctalDigit | '\\' ZeroToThree OctalDigit OctalDigit;
fragment OctalDigit:
[0-7];
fragment ZeroToThree:
[0-3];
BooleanLiteral: 'true' | 'false' ;
NullLiteral: 'null';
// Keywords
Public : 'public';
Protected: 'protected';
Private: 'private';
Static: 'static';
Abstract: 'abstract';
Final: 'final';
Native: 'native';
Synchronized: 'synchronized';
Transient: 'transient';
Volatile: 'volatile';
Strictfp: 'strictfp';
Assert: 'Assert';