-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
553a70f
commit d8cdfbf
Showing
29 changed files
with
1,703 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
__pychache__ | ||
errors.txt | ||
declarations.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
grammar Declaration; | ||
|
||
|
||
WS: [ \t\r\n]+ -> skip ; | ||
|
||
VAR: 'var' ; | ||
FUNC: 'func' ; | ||
STRUCT: 'struct' ; | ||
ENUM: 'enum' ; | ||
ALIAS: 'alias' ; | ||
MEMBER: 'memb' ; | ||
|
||
ID: [a-zA-Z0-9_]+('[]' | '*')* ; | ||
|
||
start : declaration* ; | ||
|
||
declaration | ||
: type=ALIAS name=ID ':' typename=ID | ||
| type=VAR name=ID ':' typename=ID | ||
| type=FUNC name=ID ':' return_typename=ID ('->' arg_typenames+=ID (',' arg_typenames+=ID)* )? | ||
| type=STRUCT name=ID ':' member* | ||
| type=ENUM name=ID ':' enum_values+=ID (',' enum_values+=ID)* | ||
; | ||
|
||
member | ||
: MEMBER name=ID ':' typename=ID ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
token literal names: | ||
null | ||
':' | ||
'->' | ||
',' | ||
null | ||
'var' | ||
'func' | ||
'struct' | ||
'enum' | ||
'alias' | ||
'memb' | ||
null | ||
|
||
token symbolic names: | ||
null | ||
null | ||
null | ||
null | ||
WS | ||
VAR | ||
FUNC | ||
STRUCT | ||
ENUM | ||
ALIAS | ||
MEMBER | ||
ID | ||
|
||
rule names: | ||
start | ||
declaration | ||
member | ||
|
||
|
||
atn: | ||
[4, 1, 11, 63, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 1, 0, 5, 0, 8, 8, 0, 10, 0, 12, 0, 11, 9, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 29, 8, 1, 10, 1, 12, 1, 32, 9, 1, 3, 1, 34, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 40, 8, 1, 10, 1, 12, 1, 43, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 51, 8, 1, 10, 1, 12, 1, 54, 9, 1, 3, 1, 56, 8, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 0, 0, 3, 0, 2, 4, 0, 0, 68, 0, 9, 1, 0, 0, 0, 2, 55, 1, 0, 0, 0, 4, 57, 1, 0, 0, 0, 6, 8, 3, 2, 1, 0, 7, 6, 1, 0, 0, 0, 8, 11, 1, 0, 0, 0, 9, 7, 1, 0, 0, 0, 9, 10, 1, 0, 0, 0, 10, 1, 1, 0, 0, 0, 11, 9, 1, 0, 0, 0, 12, 13, 5, 9, 0, 0, 13, 14, 5, 11, 0, 0, 14, 15, 5, 1, 0, 0, 15, 56, 5, 11, 0, 0, 16, 17, 5, 5, 0, 0, 17, 18, 5, 11, 0, 0, 18, 19, 5, 1, 0, 0, 19, 56, 5, 11, 0, 0, 20, 21, 5, 6, 0, 0, 21, 22, 5, 11, 0, 0, 22, 23, 5, 1, 0, 0, 23, 33, 5, 11, 0, 0, 24, 25, 5, 2, 0, 0, 25, 30, 5, 11, 0, 0, 26, 27, 5, 3, 0, 0, 27, 29, 5, 11, 0, 0, 28, 26, 1, 0, 0, 0, 29, 32, 1, 0, 0, 0, 30, 28, 1, 0, 0, 0, 30, 31, 1, 0, 0, 0, 31, 34, 1, 0, 0, 0, 32, 30, 1, 0, 0, 0, 33, 24, 1, 0, 0, 0, 33, 34, 1, 0, 0, 0, 34, 56, 1, 0, 0, 0, 35, 36, 5, 7, 0, 0, 36, 37, 5, 11, 0, 0, 37, 41, 5, 1, 0, 0, 38, 40, 3, 4, 2, 0, 39, 38, 1, 0, 0, 0, 40, 43, 1, 0, 0, 0, 41, 39, 1, 0, 0, 0, 41, 42, 1, 0, 0, 0, 42, 56, 1, 0, 0, 0, 43, 41, 1, 0, 0, 0, 44, 45, 5, 8, 0, 0, 45, 46, 5, 11, 0, 0, 46, 47, 5, 1, 0, 0, 47, 52, 5, 11, 0, 0, 48, 49, 5, 3, 0, 0, 49, 51, 5, 11, 0, 0, 50, 48, 1, 0, 0, 0, 51, 54, 1, 0, 0, 0, 52, 50, 1, 0, 0, 0, 52, 53, 1, 0, 0, 0, 53, 56, 1, 0, 0, 0, 54, 52, 1, 0, 0, 0, 55, 12, 1, 0, 0, 0, 55, 16, 1, 0, 0, 0, 55, 20, 1, 0, 0, 0, 55, 35, 1, 0, 0, 0, 55, 44, 1, 0, 0, 0, 56, 3, 1, 0, 0, 0, 57, 58, 5, 10, 0, 0, 58, 59, 5, 11, 0, 0, 59, 60, 5, 1, 0, 0, 60, 61, 5, 11, 0, 0, 61, 5, 1, 0, 0, 0, 6, 9, 30, 33, 41, 52, 55] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
T__0=1 | ||
T__1=2 | ||
T__2=3 | ||
WS=4 | ||
VAR=5 | ||
FUNC=6 | ||
STRUCT=7 | ||
ENUM=8 | ||
ALIAS=9 | ||
MEMBER=10 | ||
ID=11 | ||
':'=1 | ||
'->'=2 | ||
','=3 | ||
'var'=5 | ||
'func'=6 | ||
'struct'=7 | ||
'enum'=8 | ||
'alias'=9 | ||
'memb'=10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
token literal names: | ||
null | ||
':' | ||
'->' | ||
',' | ||
null | ||
'var' | ||
'func' | ||
'struct' | ||
'enum' | ||
'alias' | ||
'memb' | ||
null | ||
|
||
token symbolic names: | ||
null | ||
null | ||
null | ||
null | ||
WS | ||
VAR | ||
FUNC | ||
STRUCT | ||
ENUM | ||
ALIAS | ||
MEMBER | ||
ID | ||
|
||
rule names: | ||
T__0 | ||
T__1 | ||
T__2 | ||
WS | ||
VAR | ||
FUNC | ||
STRUCT | ||
ENUM | ||
ALIAS | ||
MEMBER | ||
ID | ||
|
||
channel names: | ||
DEFAULT_TOKEN_CHANNEL | ||
HIDDEN | ||
|
||
mode names: | ||
DEFAULT_MODE | ||
|
||
atn: | ||
[4, 0, 11, 82, 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, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 4, 3, 32, 8, 3, 11, 3, 12, 3, 33, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 10, 4, 10, 71, 8, 10, 11, 10, 12, 10, 72, 1, 10, 1, 10, 1, 10, 5, 10, 78, 8, 10, 10, 10, 12, 10, 81, 9, 10, 0, 0, 11, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 1, 0, 2, 3, 0, 9, 10, 13, 13, 32, 32, 4, 0, 48, 57, 65, 90, 95, 95, 97, 122, 85, 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, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 1, 23, 1, 0, 0, 0, 3, 25, 1, 0, 0, 0, 5, 28, 1, 0, 0, 0, 7, 31, 1, 0, 0, 0, 9, 37, 1, 0, 0, 0, 11, 41, 1, 0, 0, 0, 13, 46, 1, 0, 0, 0, 15, 53, 1, 0, 0, 0, 17, 58, 1, 0, 0, 0, 19, 64, 1, 0, 0, 0, 21, 70, 1, 0, 0, 0, 23, 24, 5, 58, 0, 0, 24, 2, 1, 0, 0, 0, 25, 26, 5, 45, 0, 0, 26, 27, 5, 62, 0, 0, 27, 4, 1, 0, 0, 0, 28, 29, 5, 44, 0, 0, 29, 6, 1, 0, 0, 0, 30, 32, 7, 0, 0, 0, 31, 30, 1, 0, 0, 0, 32, 33, 1, 0, 0, 0, 33, 31, 1, 0, 0, 0, 33, 34, 1, 0, 0, 0, 34, 35, 1, 0, 0, 0, 35, 36, 6, 3, 0, 0, 36, 8, 1, 0, 0, 0, 37, 38, 5, 118, 0, 0, 38, 39, 5, 97, 0, 0, 39, 40, 5, 114, 0, 0, 40, 10, 1, 0, 0, 0, 41, 42, 5, 102, 0, 0, 42, 43, 5, 117, 0, 0, 43, 44, 5, 110, 0, 0, 44, 45, 5, 99, 0, 0, 45, 12, 1, 0, 0, 0, 46, 47, 5, 115, 0, 0, 47, 48, 5, 116, 0, 0, 48, 49, 5, 114, 0, 0, 49, 50, 5, 117, 0, 0, 50, 51, 5, 99, 0, 0, 51, 52, 5, 116, 0, 0, 52, 14, 1, 0, 0, 0, 53, 54, 5, 101, 0, 0, 54, 55, 5, 110, 0, 0, 55, 56, 5, 117, 0, 0, 56, 57, 5, 109, 0, 0, 57, 16, 1, 0, 0, 0, 58, 59, 5, 97, 0, 0, 59, 60, 5, 108, 0, 0, 60, 61, 5, 105, 0, 0, 61, 62, 5, 97, 0, 0, 62, 63, 5, 115, 0, 0, 63, 18, 1, 0, 0, 0, 64, 65, 5, 109, 0, 0, 65, 66, 5, 101, 0, 0, 66, 67, 5, 109, 0, 0, 67, 68, 5, 98, 0, 0, 68, 20, 1, 0, 0, 0, 69, 71, 7, 1, 0, 0, 70, 69, 1, 0, 0, 0, 71, 72, 1, 0, 0, 0, 72, 70, 1, 0, 0, 0, 72, 73, 1, 0, 0, 0, 73, 79, 1, 0, 0, 0, 74, 75, 5, 91, 0, 0, 75, 78, 5, 93, 0, 0, 76, 78, 5, 42, 0, 0, 77, 74, 1, 0, 0, 0, 77, 76, 1, 0, 0, 0, 78, 81, 1, 0, 0, 0, 79, 77, 1, 0, 0, 0, 79, 80, 1, 0, 0, 0, 80, 22, 1, 0, 0, 0, 81, 79, 1, 0, 0, 0, 5, 0, 33, 72, 77, 79, 1, 6, 0, 0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# Generated from Declaration.g4 by ANTLR 4.13.1 | ||
from antlr4 import * | ||
from io import StringIO | ||
import sys | ||
if sys.version_info[1] > 5: | ||
from typing import TextIO | ||
else: | ||
from typing.io import TextIO | ||
|
||
|
||
def serializedATN(): | ||
return [ | ||
4,0,11,82,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,2, | ||
6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,1,0,1,0,1,1,1,1,1,1,1,2, | ||
1,2,1,3,4,3,32,8,3,11,3,12,3,33,1,3,1,3,1,4,1,4,1,4,1,4,1,5,1,5, | ||
1,5,1,5,1,5,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,7,1,7,1,7,1,7,1,7,1,8, | ||
1,8,1,8,1,8,1,8,1,8,1,9,1,9,1,9,1,9,1,9,1,10,4,10,71,8,10,11,10, | ||
12,10,72,1,10,1,10,1,10,5,10,78,8,10,10,10,12,10,81,9,10,0,0,11, | ||
1,1,3,2,5,3,7,4,9,5,11,6,13,7,15,8,17,9,19,10,21,11,1,0,2,3,0,9, | ||
10,13,13,32,32,4,0,48,57,65,90,95,95,97,122,85,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,0,13,1,0, | ||
0,0,0,15,1,0,0,0,0,17,1,0,0,0,0,19,1,0,0,0,0,21,1,0,0,0,1,23,1,0, | ||
0,0,3,25,1,0,0,0,5,28,1,0,0,0,7,31,1,0,0,0,9,37,1,0,0,0,11,41,1, | ||
0,0,0,13,46,1,0,0,0,15,53,1,0,0,0,17,58,1,0,0,0,19,64,1,0,0,0,21, | ||
70,1,0,0,0,23,24,5,58,0,0,24,2,1,0,0,0,25,26,5,45,0,0,26,27,5,62, | ||
0,0,27,4,1,0,0,0,28,29,5,44,0,0,29,6,1,0,0,0,30,32,7,0,0,0,31,30, | ||
1,0,0,0,32,33,1,0,0,0,33,31,1,0,0,0,33,34,1,0,0,0,34,35,1,0,0,0, | ||
35,36,6,3,0,0,36,8,1,0,0,0,37,38,5,118,0,0,38,39,5,97,0,0,39,40, | ||
5,114,0,0,40,10,1,0,0,0,41,42,5,102,0,0,42,43,5,117,0,0,43,44,5, | ||
110,0,0,44,45,5,99,0,0,45,12,1,0,0,0,46,47,5,115,0,0,47,48,5,116, | ||
0,0,48,49,5,114,0,0,49,50,5,117,0,0,50,51,5,99,0,0,51,52,5,116,0, | ||
0,52,14,1,0,0,0,53,54,5,101,0,0,54,55,5,110,0,0,55,56,5,117,0,0, | ||
56,57,5,109,0,0,57,16,1,0,0,0,58,59,5,97,0,0,59,60,5,108,0,0,60, | ||
61,5,105,0,0,61,62,5,97,0,0,62,63,5,115,0,0,63,18,1,0,0,0,64,65, | ||
5,109,0,0,65,66,5,101,0,0,66,67,5,109,0,0,67,68,5,98,0,0,68,20,1, | ||
0,0,0,69,71,7,1,0,0,70,69,1,0,0,0,71,72,1,0,0,0,72,70,1,0,0,0,72, | ||
73,1,0,0,0,73,79,1,0,0,0,74,75,5,91,0,0,75,78,5,93,0,0,76,78,5,42, | ||
0,0,77,74,1,0,0,0,77,76,1,0,0,0,78,81,1,0,0,0,79,77,1,0,0,0,79,80, | ||
1,0,0,0,80,22,1,0,0,0,81,79,1,0,0,0,5,0,33,72,77,79,1,6,0,0 | ||
] | ||
|
||
class DeclarationLexer(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 | ||
WS = 4 | ||
VAR = 5 | ||
FUNC = 6 | ||
STRUCT = 7 | ||
ENUM = 8 | ||
ALIAS = 9 | ||
MEMBER = 10 | ||
ID = 11 | ||
|
||
channelNames = [ u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN" ] | ||
|
||
modeNames = [ "DEFAULT_MODE" ] | ||
|
||
literalNames = [ "<INVALID>", | ||
"':'", "'->'", "','", "'var'", "'func'", "'struct'", "'enum'", | ||
"'alias'", "'memb'" ] | ||
|
||
symbolicNames = [ "<INVALID>", | ||
"WS", "VAR", "FUNC", "STRUCT", "ENUM", "ALIAS", "MEMBER", "ID" ] | ||
|
||
ruleNames = [ "T__0", "T__1", "T__2", "WS", "VAR", "FUNC", "STRUCT", | ||
"ENUM", "ALIAS", "MEMBER", "ID" ] | ||
|
||
grammarFileName = "Declaration.g4" | ||
|
||
def __init__(self, input=None, output:TextIO = sys.stdout): | ||
super().__init__(input, output) | ||
self.checkVersion("4.13.1") | ||
self._interp = LexerATNSimulator(self, self.atn, self.decisionsToDFA, PredictionContextCache()) | ||
self._actions = None | ||
self._predicates = None | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
T__0=1 | ||
T__1=2 | ||
T__2=3 | ||
WS=4 | ||
VAR=5 | ||
FUNC=6 | ||
STRUCT=7 | ||
ENUM=8 | ||
ALIAS=9 | ||
MEMBER=10 | ||
ID=11 | ||
':'=1 | ||
'->'=2 | ||
','=3 | ||
'var'=5 | ||
'func'=6 | ||
'struct'=7 | ||
'enum'=8 | ||
'alias'=9 | ||
'memb'=10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Generated from Declaration.g4 by ANTLR 4.13.1 | ||
from antlr4 import * | ||
if "." in __name__: | ||
from .DeclarationParser import DeclarationParser | ||
else: | ||
from DeclarationParser import DeclarationParser | ||
|
||
# This class defines a complete listener for a parse tree produced by DeclarationParser. | ||
class DeclarationListener(ParseTreeListener): | ||
|
||
# Enter a parse tree produced by DeclarationParser#start. | ||
def enterStart(self, ctx:DeclarationParser.StartContext): | ||
pass | ||
|
||
# Exit a parse tree produced by DeclarationParser#start. | ||
def exitStart(self, ctx:DeclarationParser.StartContext): | ||
pass | ||
|
||
|
||
# Enter a parse tree produced by DeclarationParser#declaration. | ||
def enterDeclaration(self, ctx:DeclarationParser.DeclarationContext): | ||
pass | ||
|
||
# Exit a parse tree produced by DeclarationParser#declaration. | ||
def exitDeclaration(self, ctx:DeclarationParser.DeclarationContext): | ||
pass | ||
|
||
|
||
# Enter a parse tree produced by DeclarationParser#member. | ||
def enterMember(self, ctx:DeclarationParser.MemberContext): | ||
pass | ||
|
||
# Exit a parse tree produced by DeclarationParser#member. | ||
def exitMember(self, ctx:DeclarationParser.MemberContext): | ||
pass | ||
|
||
|
||
|
||
del DeclarationParser |
Oops, something went wrong.