1
0
Fork 0

grammar has stabilized. distribute antlr files.

This commit is contained in:
Kevin Matz 2018-10-20 18:25:04 -04:00
parent 2bd3fa30bd
commit b94a5e16b3
5 changed files with 1614 additions and 4 deletions

3
.gitignore vendored
View File

@ -1,9 +1,6 @@
# Antlr4
*.interp
*.tokens
CommentMacroLexer.py
CommentMacroListener.py
CommentMacroParser.py
# Byte-compiled / optimized / DLL files
__pycache__/

207
CommentMacroLexer.py Normal file
View File

@ -0,0 +1,207 @@
# Generated from CommentMacro.g4 by ANTLR 4.7.1
from antlr4 import *
from io import StringIO
from typing.io import TextIO
import sys
def serializedATN():
with StringIO() as buf:
buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2-")
buf.write("\u0111\b\1\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7")
buf.write("\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\4\f\t\f\4\r\t\r")
buf.write("\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22\4\23")
buf.write("\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30")
buf.write("\4\31\t\31\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36")
buf.write("\t\36\4\37\t\37\4 \t \4!\t!\4\"\t\"\4#\t#\4$\t$\4%\t%")
buf.write("\4&\t&\4\'\t\'\4(\t(\4)\t)\4*\t*\4+\t+\4,\t,\4-\t-\3\2")
buf.write("\3\2\3\3\3\3\3\3\3\4\3\4\3\4\3\5\3\5\3\5\3\6\3\6\3\6\3")
buf.write("\7\3\7\3\7\3\b\3\b\3\b\3\t\3\t\3\t\3\n\3\n\3\n\3\n\3\13")
buf.write("\3\13\3\13\3\f\3\f\3\f\3\r\3\r\3\r\3\16\3\16\3\16\3\17")
buf.write("\3\17\3\17\3\20\3\20\3\20\3\21\3\21\3\21\3\22\3\22\3\22")
buf.write("\3\23\3\23\3\23\3\24\3\24\3\24\3\25\3\25\3\25\3\26\3\26")
buf.write("\3\26\3\27\3\27\3\27\3\30\3\30\3\30\3\31\3\31\3\31\3\32")
buf.write("\3\32\3\32\3\33\3\33\3\33\3\34\3\34\3\34\3\35\3\35\3\35")
buf.write("\3\36\3\36\3\37\3\37\3 \6 \u00b5\n \r \16 \u00b6\3 \3")
buf.write(" \6 \u00bb\n \r \16 \u00bc\5 \u00bf\n \3!\3!\3\"\3\"\3")
buf.write("#\3#\3$\3$\3%\3%\3&\3&\3\'\3\'\3(\3(\3)\3)\3)\3)\3*\5")
buf.write("*\u00d6\n*\3*\3*\3+\6+\u00db\n+\r+\16+\u00dc\3+\3+\3,")
buf.write("\3,\3,\3,\3,\3,\7,\u00e7\n,\f,\16,\u00ea\13,\3,\3,\3,")
buf.write("\3,\3,\3,\3,\7,\u00f3\n,\f,\16,\u00f6\13,\3,\3,\5,\u00fa")
buf.write("\n,\3,\3,\3-\3-\3-\3-\7-\u0102\n-\f-\16-\u0105\13-\3-")
buf.write("\3-\7-\u0109\n-\f-\16-\u010c\13-\5-\u010e\n-\3-\3-\4\u00e8")
buf.write("\u00f4\2.\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21\n\23\13\25")
buf.write("\f\27\r\31\16\33\17\35\20\37\21!\22#\23%\24\'\25)\26+")
buf.write("\27-\30/\31\61\32\63\33\65\34\67\359\36;\37=\2? A!C\"")
buf.write("E#G$I%K&M\'O(Q)S*U+W,Y-\3\2\7\3\2\62;\4\2JJjj\4\2FFff")
buf.write("\4\2\13\13\"\"\4\2\f\f\17\17\2\u011a\2\3\3\2\2\2\2\5\3")
buf.write("\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2")
buf.write("\2\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2")
buf.write("\2\27\3\2\2\2\2\31\3\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2\2")
buf.write("\37\3\2\2\2\2!\3\2\2\2\2#\3\2\2\2\2%\3\2\2\2\2\'\3\2\2")
buf.write("\2\2)\3\2\2\2\2+\3\2\2\2\2-\3\2\2\2\2/\3\2\2\2\2\61\3")
buf.write("\2\2\2\2\63\3\2\2\2\2\65\3\2\2\2\2\67\3\2\2\2\29\3\2\2")
buf.write("\2\2;\3\2\2\2\2?\3\2\2\2\2A\3\2\2\2\2C\3\2\2\2\2E\3\2")
buf.write("\2\2\2G\3\2\2\2\2I\3\2\2\2\2K\3\2\2\2\2M\3\2\2\2\2O\3")
buf.write("\2\2\2\2Q\3\2\2\2\2S\3\2\2\2\2U\3\2\2\2\2W\3\2\2\2\2Y")
buf.write("\3\2\2\2\3[\3\2\2\2\5]\3\2\2\2\7`\3\2\2\2\tc\3\2\2\2\13")
buf.write("f\3\2\2\2\ri\3\2\2\2\17l\3\2\2\2\21o\3\2\2\2\23r\3\2\2")
buf.write("\2\25v\3\2\2\2\27y\3\2\2\2\31|\3\2\2\2\33\177\3\2\2\2")
buf.write("\35\u0082\3\2\2\2\37\u0085\3\2\2\2!\u0088\3\2\2\2#\u008b")
buf.write("\3\2\2\2%\u008e\3\2\2\2\'\u0091\3\2\2\2)\u0094\3\2\2\2")
buf.write("+\u0097\3\2\2\2-\u009a\3\2\2\2/\u009d\3\2\2\2\61\u00a0")
buf.write("\3\2\2\2\63\u00a3\3\2\2\2\65\u00a6\3\2\2\2\67\u00a9\3")
buf.write("\2\2\29\u00ac\3\2\2\2;\u00af\3\2\2\2=\u00b1\3\2\2\2?\u00b4")
buf.write("\3\2\2\2A\u00c0\3\2\2\2C\u00c2\3\2\2\2E\u00c4\3\2\2\2")
buf.write("G\u00c6\3\2\2\2I\u00c8\3\2\2\2K\u00ca\3\2\2\2M\u00cc\3")
buf.write("\2\2\2O\u00ce\3\2\2\2Q\u00d0\3\2\2\2S\u00d5\3\2\2\2U\u00da")
buf.write("\3\2\2\2W\u00f9\3\2\2\2Y\u010d\3\2\2\2[\\\7<\2\2\\\4\3")
buf.write("\2\2\2]^\7I\2\2^_\7O\2\2_\6\3\2\2\2`a\7J\2\2ab\7O\2\2")
buf.write("b\b\3\2\2\2cd\7C\2\2de\7O\2\2e\n\3\2\2\2fg\7T\2\2gh\7")
buf.write("O\2\2h\f\3\2\2\2ij\7T\2\2jk\7C\2\2k\16\3\2\2\2lm\7T\2")
buf.write("\2mn\7Q\2\2n\20\3\2\2\2op\7H\2\2pq\7O\2\2q\22\3\2\2\2")
buf.write("rs\7H\2\2st\7I\2\2tu\7O\2\2u\24\3\2\2\2vw\7E\2\2wx\7O")
buf.write("\2\2x\26\3\2\2\2yz\7I\2\2z{\7N\2\2{\30\3\2\2\2|}\7J\2")
buf.write("\2}~\7N\2\2~\32\3\2\2\2\177\u0080\7C\2\2\u0080\u0081\7")
buf.write("N\2\2\u0081\34\3\2\2\2\u0082\u0083\7T\2\2\u0083\u0084")
buf.write("\7N\2\2\u0084\36\3\2\2\2\u0085\u0086\7I\2\2\u0086\u0087")
buf.write("\7D\2\2\u0087 \3\2\2\2\u0088\u0089\7J\2\2\u0089\u008a")
buf.write("\7D\2\2\u008a\"\3\2\2\2\u008b\u008c\7C\2\2\u008c\u008d")
buf.write("\7D\2\2\u008d$\3\2\2\2\u008e\u008f\7T\2\2\u008f\u0090")
buf.write("\7D\2\2\u0090&\3\2\2\2\u0091\u0092\7I\2\2\u0092\u0093")
buf.write("\7U\2\2\u0093(\3\2\2\2\u0094\u0095\7J\2\2\u0095\u0096")
buf.write("\7U\2\2\u0096*\3\2\2\2\u0097\u0098\7C\2\2\u0098\u0099")
buf.write("\7U\2\2\u0099,\3\2\2\2\u009a\u009b\7T\2\2\u009b\u009c")
buf.write("\7U\2\2\u009c.\3\2\2\2\u009d\u009e\7E\2\2\u009e\u009f")
buf.write("\7R\2\2\u009f\60\3\2\2\2\u00a0\u00a1\7T\2\2\u00a1\u00a2")
buf.write("\7X\2\2\u00a2\62\3\2\2\2\u00a3\u00a4\7T\2\2\u00a4\u00a5")
buf.write("\7P\2\2\u00a5\64\3\2\2\2\u00a6\u00a7\7I\2\2\u00a7\u00a8")
buf.write("\7M\2\2\u00a8\66\3\2\2\2\u00a9\u00aa\7J\2\2\u00aa\u00ab")
buf.write("\7M\2\2\u00ab8\3\2\2\2\u00ac\u00ad\7T\2\2\u00ad\u00ae")
buf.write("\7M\2\2\u00ae:\3\2\2\2\u00af\u00b0\7.\2\2\u00b0<\3\2\2")
buf.write("\2\u00b1\u00b2\t\2\2\2\u00b2>\3\2\2\2\u00b3\u00b5\5=\37")
buf.write("\2\u00b4\u00b3\3\2\2\2\u00b5\u00b6\3\2\2\2\u00b6\u00b4")
buf.write("\3\2\2\2\u00b6\u00b7\3\2\2\2\u00b7\u00be\3\2\2\2\u00b8")
buf.write("\u00ba\7\60\2\2\u00b9\u00bb\5=\37\2\u00ba\u00b9\3\2\2")
buf.write("\2\u00bb\u00bc\3\2\2\2\u00bc\u00ba\3\2\2\2\u00bc\u00bd")
buf.write("\3\2\2\2\u00bd\u00bf\3\2\2\2\u00be\u00b8\3\2\2\2\u00be")
buf.write("\u00bf\3\2\2\2\u00bf@\3\2\2\2\u00c0\u00c1\7\61\2\2\u00c1")
buf.write("B\3\2\2\2\u00c2\u00c3\7@\2\2\u00c3D\3\2\2\2\u00c4\u00c5")
buf.write("\7-\2\2\u00c5F\3\2\2\2\u00c6\u00c7\7/\2\2\u00c7H\3\2\2")
buf.write("\2\u00c8\u00c9\7,\2\2\u00c9J\3\2\2\2\u00ca\u00cb\7v\2")
buf.write("\2\u00cbL\3\2\2\2\u00cc\u00cd\t\3\2\2\u00cdN\3\2\2\2\u00ce")
buf.write("\u00cf\t\4\2\2\u00cfP\3\2\2\2\u00d0\u00d1\7K\2\2\u00d1")
buf.write("\u00d2\7Q\2\2\u00d2\u00d3\7R\2\2\u00d3R\3\2\2\2\u00d4")
buf.write("\u00d6\7\17\2\2\u00d5\u00d4\3\2\2\2\u00d5\u00d6\3\2\2")
buf.write("\2\u00d6\u00d7\3\2\2\2\u00d7\u00d8\7\f\2\2\u00d8T\3\2")
buf.write("\2\2\u00d9\u00db\t\5\2\2\u00da\u00d9\3\2\2\2\u00db\u00dc")
buf.write("\3\2\2\2\u00dc\u00da\3\2\2\2\u00dc\u00dd\3\2\2\2\u00dd")
buf.write("\u00de\3\2\2\2\u00de\u00df\b+\2\2\u00dfV\3\2\2\2\u00e0")
buf.write("\u00e1\7>\2\2\u00e1\u00e2\7#\2\2\u00e2\u00e3\7/\2\2\u00e3")
buf.write("\u00e4\7/\2\2\u00e4\u00e8\3\2\2\2\u00e5\u00e7\13\2\2\2")
buf.write("\u00e6\u00e5\3\2\2\2\u00e7\u00ea\3\2\2\2\u00e8\u00e9\3")
buf.write("\2\2\2\u00e8\u00e6\3\2\2\2\u00e9\u00eb\3\2\2\2\u00ea\u00e8")
buf.write("\3\2\2\2\u00eb\u00ec\7/\2\2\u00ec\u00ed\7/\2\2\u00ed\u00fa")
buf.write("\7@\2\2\u00ee\u00ef\7\61\2\2\u00ef\u00f0\7,\2\2\u00f0")
buf.write("\u00f4\3\2\2\2\u00f1\u00f3\13\2\2\2\u00f2\u00f1\3\2\2")
buf.write("\2\u00f3\u00f6\3\2\2\2\u00f4\u00f5\3\2\2\2\u00f4\u00f2")
buf.write("\3\2\2\2\u00f5\u00f7\3\2\2\2\u00f6\u00f4\3\2\2\2\u00f7")
buf.write("\u00f8\7,\2\2\u00f8\u00fa\7\61\2\2\u00f9\u00e0\3\2\2\2")
buf.write("\u00f9\u00ee\3\2\2\2\u00fa\u00fb\3\2\2\2\u00fb\u00fc\b")
buf.write(",\2\2\u00fcX\3\2\2\2\u00fd\u00fe\7\61\2\2\u00fe\u00ff")
buf.write("\7\61\2\2\u00ff\u0103\3\2\2\2\u0100\u0102\n\6\2\2\u0101")
buf.write("\u0100\3\2\2\2\u0102\u0105\3\2\2\2\u0103\u0101\3\2\2\2")
buf.write("\u0103\u0104\3\2\2\2\u0104\u010e\3\2\2\2\u0105\u0103\3")
buf.write("\2\2\2\u0106\u010a\7%\2\2\u0107\u0109\n\6\2\2\u0108\u0107")
buf.write("\3\2\2\2\u0109\u010c\3\2\2\2\u010a\u0108\3\2\2\2\u010a")
buf.write("\u010b\3\2\2\2\u010b\u010e\3\2\2\2\u010c\u010a\3\2\2\2")
buf.write("\u010d\u00fd\3\2\2\2\u010d\u0106\3\2\2\2\u010e\u010f\3")
buf.write("\2\2\2\u010f\u0110\b-\2\2\u0110Z\3\2\2\2\16\2\u00b6\u00bc")
buf.write("\u00be\u00d5\u00dc\u00e8\u00f4\u00f9\u0103\u010a\u010d")
buf.write("\3\b\2\2")
return buf.getvalue()
class CommentMacroLexer(Lexer):
atn = ATNDeserializer().deserialize(serializedATN())
decisionsToDFA = [ DFA(ds, i) for i, ds in enumerate(atn.decisionToState) ]
T__0 = 1
T__1 = 2
T__2 = 3
T__3 = 4
T__4 = 5
T__5 = 6
T__6 = 7
T__7 = 8
T__8 = 9
T__9 = 10
T__10 = 11
T__11 = 12
T__12 = 13
T__13 = 14
T__14 = 15
T__15 = 16
T__16 = 17
T__17 = 18
T__18 = 19
T__19 = 20
T__20 = 21
T__21 = 22
T__22 = 23
T__23 = 24
T__24 = 25
T__25 = 26
T__26 = 27
T__27 = 28
T__28 = 29
NUMBER = 30
SLASH = 31
THRU = 32
NEXT = 33
PREV = 34
CURRENT = 35
TIME = 36
WHOLEHOG = 37
DP8K = 38
IOP = 39
NEWLINE = 40
WS = 41
COMMENT = 42
LINE_COMMENT = 43
channelNames = [ u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN" ]
modeNames = [ "DEFAULT_MODE" ]
literalNames = [ "<INVALID>",
"':'", "'GM'", "'HM'", "'AM'", "'RM'", "'RA'", "'RO'", "'FM'",
"'FGM'", "'CM'", "'GL'", "'HL'", "'AL'", "'RL'", "'GB'", "'HB'",
"'AB'", "'RB'", "'GS'", "'HS'", "'AS'", "'RS'", "'CP'", "'RV'",
"'RN'", "'GK'", "'HK'", "'RK'", "','", "'/'", "'>'", "'+'",
"'-'", "'*'", "'t'", "'IOP'" ]
symbolicNames = [ "<INVALID>",
"NUMBER", "SLASH", "THRU", "NEXT", "PREV", "CURRENT", "TIME",
"WHOLEHOG", "DP8K", "IOP", "NEWLINE", "WS", "COMMENT", "LINE_COMMENT" ]
ruleNames = [ "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6",
"T__7", "T__8", "T__9", "T__10", "T__11", "T__12", "T__13",
"T__14", "T__15", "T__16", "T__17", "T__18", "T__19",
"T__20", "T__21", "T__22", "T__23", "T__24", "T__25",
"T__26", "T__27", "T__28", "DIGIT", "NUMBER", "SLASH",
"THRU", "NEXT", "PREV", "CURRENT", "TIME", "WHOLEHOG",
"DP8K", "IOP", "NEWLINE", "WS", "COMMENT", "LINE_COMMENT" ]
grammarFileName = "CommentMacro.g4"
def __init__(self, input=None, output:TextIO = sys.stdout):
super().__init__(input, output)
self.checkVersion("4.7.1")
self._interp = LexerATNSimulator(self, self.atn, self.decisionsToDFA, PredictionContextCache())
self._actions = None
self._predicates = None

100
CommentMacroListener.py Normal file
View File

@ -0,0 +1,100 @@
# Generated from CommentMacro.g4 by ANTLR 4.7.1
from antlr4 import *
if __name__ is not None and "." in __name__:
from .CommentMacroParser import CommentMacroParser
else:
from CommentMacroParser import CommentMacroParser
# This class defines a complete listener for a parse tree produced by CommentMacroParser.
class CommentMacroListener(ParseTreeListener):
# Enter a parse tree produced by CommentMacroParser#prog.
def enterProg(self, ctx:CommentMacroParser.ProgContext):
pass
# Exit a parse tree produced by CommentMacroParser#prog.
def exitProg(self, ctx:CommentMacroParser.ProgContext):
pass
# Enter a parse tree produced by CommentMacroParser#statement.
def enterStatement(self, ctx:CommentMacroParser.StatementContext):
pass
# Exit a parse tree produced by CommentMacroParser#statement.
def exitStatement(self, ctx:CommentMacroParser.StatementContext):
pass
# Enter a parse tree produced by CommentMacroParser#macro.
def enterMacro(self, ctx:CommentMacroParser.MacroContext):
pass
# Exit a parse tree produced by CommentMacroParser#macro.
def exitMacro(self, ctx:CommentMacroParser.MacroContext):
pass
# Enter a parse tree produced by CommentMacroParser#master.
def enterMaster(self, ctx:CommentMacroParser.MasterContext):
pass
# Exit a parse tree produced by CommentMacroParser#master.
def exitMaster(self, ctx:CommentMacroParser.MasterContext):
pass
# Enter a parse tree produced by CommentMacroParser#time.
def enterTime(self, ctx:CommentMacroParser.TimeContext):
pass
# Exit a parse tree produced by CommentMacroParser#time.
def exitTime(self, ctx:CommentMacroParser.TimeContext):
pass
# Enter a parse tree produced by CommentMacroParser#device.
def enterDevice(self, ctx:CommentMacroParser.DeviceContext):
pass
# Exit a parse tree produced by CommentMacroParser#device.
def exitDevice(self, ctx:CommentMacroParser.DeviceContext):
pass
# Enter a parse tree produced by CommentMacroParser#nodeType.
def enterNodeType(self, ctx:CommentMacroParser.NodeTypeContext):
pass
# Exit a parse tree produced by CommentMacroParser#nodeType.
def exitNodeType(self, ctx:CommentMacroParser.NodeTypeContext):
pass
# Enter a parse tree produced by CommentMacroParser#target.
def enterTarget(self, ctx:CommentMacroParser.TargetContext):
pass
# Exit a parse tree produced by CommentMacroParser#target.
def exitTarget(self, ctx:CommentMacroParser.TargetContext):
pass
# Enter a parse tree produced by CommentMacroParser#span.
def enterSpan(self, ctx:CommentMacroParser.SpanContext):
pass
# Exit a parse tree produced by CommentMacroParser#span.
def exitSpan(self, ctx:CommentMacroParser.SpanContext):
pass
# Enter a parse tree produced by CommentMacroParser#number.
def enterNumber(self, ctx:CommentMacroParser.NumberContext):
pass
# Exit a parse tree produced by CommentMacroParser#number.
def exitNumber(self, ctx:CommentMacroParser.NumberContext):
pass

1303
CommentMacroParser.py Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,7 @@
include comment.py
include CommentMacro.g4
include CommentMacroLexer.py
include CommentMacroListener.py
include CommentMacroParser.py
include OscCommentMacroListener.py
include LICENSE.md
include README.md