Add ANTLR grammar for greetings and farewells with corresponding parser and listener implementations

This commit is contained in:
bobbert committed 2026-03-26 15:32:19 +00:00
1 parent 2027302cf1
commit 6205020013
30 files changed
+1109 -37

No files matched your search

+23 -13
View File
@@ -10,15 +10,22 @@ else:
def serializedATN():
return [
4,0,3,25,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,1,0,1,0,1,0,1,0,1,0,1,0,1,
1,4,1,15,8,1,11,1,12,1,16,1,2,4,2,20,8,2,11,2,12,2,21,1,2,1,2,0,
0,3,1,1,3,2,5,3,1,0,2,2,0,65,90,97,122,3,0,9,10,13,13,32,32,26,0,
1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,0,1,7,1,0,0,0,3,14,1,0,0,0,5,19,
1,0,0,0,7,8,5,104,0,0,8,9,5,101,0,0,9,10,5,108,0,0,10,11,5,108,0,
0,11,12,5,111,0,0,12,2,1,0,0,0,13,15,7,0,0,0,14,13,1,0,0,0,15,16,
1,0,0,0,16,14,1,0,0,0,16,17,1,0,0,0,17,4,1,0,0,0,18,20,7,1,0,0,19,
18,1,0,0,0,20,21,1,0,0,0,21,19,1,0,0,0,21,22,1,0,0,0,22,23,1,0,0,
0,23,24,6,2,0,0,24,6,1,0,0,0,3,0,16,21,1,6,0,0
4,0,6,46,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,1,
0,1,0,1,0,1,0,1,0,1,0,1,1,1,1,1,1,1,2,1,2,1,2,1,2,1,3,1,3,1,3,1,
3,1,3,1,3,1,3,1,3,1,4,4,4,36,8,4,11,4,12,4,37,1,5,4,5,41,8,5,11,
5,12,5,42,1,5,1,5,0,0,6,1,1,3,2,5,3,7,4,9,5,11,6,1,0,2,2,0,65,90,
97,122,3,0,9,10,13,13,32,32,47,0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,
0,0,7,1,0,0,0,0,9,1,0,0,0,0,11,1,0,0,0,1,13,1,0,0,0,3,19,1,0,0,0,
5,22,1,0,0,0,7,26,1,0,0,0,9,35,1,0,0,0,11,40,1,0,0,0,13,14,5,104,
0,0,14,15,5,101,0,0,15,16,5,108,0,0,16,17,5,108,0,0,17,18,5,111,
0,0,18,2,1,0,0,0,19,20,5,104,0,0,20,21,5,105,0,0,21,4,1,0,0,0,22,
23,5,98,0,0,23,24,5,121,0,0,24,25,5,101,0,0,25,6,1,0,0,0,26,27,5,
103,0,0,27,28,5,111,0,0,28,29,5,111,0,0,29,30,5,100,0,0,30,31,5,
98,0,0,31,32,5,121,0,0,32,33,5,101,0,0,33,8,1,0,0,0,34,36,7,0,0,
0,35,34,1,0,0,0,36,37,1,0,0,0,37,35,1,0,0,0,37,38,1,0,0,0,38,10,
1,0,0,0,39,41,7,1,0,0,40,39,1,0,0,0,41,42,1,0,0,0,42,40,1,0,0,0,
42,43,1,0,0,0,43,44,1,0,0,0,44,45,6,5,0,0,45,12,1,0,0,0,3,0,37,42,
1,6,0,0
]
class HelloLexer(Lexer):
@@ -28,20 +35,23 @@ class HelloLexer(Lexer):
decisionsToDFA = [ DFA(ds, i) for i, ds in enumerate(atn.decisionToState) ]
T__0 = 1
ID = 2
WS = 3
T__1 = 2
T__2 = 3
T__3 = 4
ID = 5
WS = 6
channelNames = [ u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN" ]
modeNames = [ "DEFAULT_MODE" ]
literalNames = [ "<INVALID>",
"'hello'" ]
"'hello'", "'hi'", "'bye'", "'goodbye'" ]
symbolicNames = [ "<INVALID>",
"ID", "WS" ]
ruleNames = [ "T__0", "ID", "WS" ]
ruleNames = [ "T__0", "T__1", "T__2", "T__3", "ID", "WS" ]
grammarFileName = "Hello.g4"