Loading lib/parsing/CFG.g4 +8 −1 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ grammar CFG; /* Parser Rules */ start: (onerule NEWLINE+)* onerule (NEWLINE+ | ); start: (onerule NEWLINE+)* onerule (NEWLINE+ | ) comment; onerule: nonterminal ARROW (rewrite DELIMITER)* rewrite; Loading @@ -14,6 +14,10 @@ nonterminal: (CAPS | (LEFT_ANGLE symbol+ RIGHT_ANGLE (APOSTROPHE*)) | (symbo symbol: (TERMINAL | CAPS | UNDERSCORE); comment: (HASH anyvalue* | ); anyvalue: LEFT_ANGLE | RIGHT_ANGLE | APOSTROPHE | UNDERSCORE | TERMINAL | CAPS | ARROW | EPSILON | DELIMITER | NEWLINE| ANYCHAR; /* Lexer Rules */ /* Tokens */ Loading @@ -28,6 +32,9 @@ ARROW : ('→' | '->'); EPSILON : ('ε' | '\\''e'); DELIMITER : '|'; NEWLINE : ('\n' | ';' | ','); HASH : '#'; /* Characters to be ignored */ WS : [ \r\t]+ -> skip ; ANYCHAR : .; lib/parsing/CFGLexer.py +32 −27 Original line number Diff line number Diff line # Generated from CFG.g4 by ANTLR 4.8 # Generated from lib/parsing/CFG.g4 by ANTLR 4.8 from antlr4 import * from io import StringIO from typing.io import TextIO Loading @@ -8,28 +8,30 @@ import sys def serializedATN(): with StringIO() as buf: buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2\r") buf.write(":\b\1\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7") buf.write("\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\4\f\t\f\3\2\3\2\3\3") buf.write("\3\3\3\4\3\4\3\5\3\5\3\6\3\6\3\7\3\7\3\b\3\b\3\b\5\b)") buf.write("\n\b\3\t\3\t\3\t\5\t.\n\t\3\n\3\n\3\13\3\13\3\f\6\f\65") buf.write("\n\f\r\f\16\f\66\3\f\3\f\2\2\r\3\3\5\4\7\5\t\6\13\7\r") buf.write("\b\17\t\21\n\23\13\25\f\27\r\3\2\6\4\2\62;c|\3\2C\\\5") buf.write("\2\f\f..==\5\2\13\13\17\17\"\"\2<\2\3\3\2\2\2\2\5\3\2") buf.write("\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\2") buf.write("\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2") buf.write("\27\3\2\2\2\3\31\3\2\2\2\5\33\3\2\2\2\7\35\3\2\2\2\t\37") buf.write("\3\2\2\2\13!\3\2\2\2\r#\3\2\2\2\17(\3\2\2\2\21-\3\2\2") buf.write("\2\23/\3\2\2\2\25\61\3\2\2\2\27\64\3\2\2\2\31\32\7>\2") buf.write("\2\32\4\3\2\2\2\33\34\7@\2\2\34\6\3\2\2\2\35\36\7)\2\2") buf.write("\36\b\3\2\2\2\37 \7a\2\2 \n\3\2\2\2!\"\t\2\2\2\"\f\3\2") buf.write("\2\2#$\t\3\2\2$\16\3\2\2\2%)\7\u2194\2\2&\'\7/\2\2\')") buf.write("\7@\2\2(%\3\2\2\2(&\3\2\2\2)\20\3\2\2\2*.\7\u03b7\2\2") buf.write("+,\7^\2\2,.\7g\2\2-*\3\2\2\2-+\3\2\2\2.\22\3\2\2\2/\60") buf.write("\7~\2\2\60\24\3\2\2\2\61\62\t\4\2\2\62\26\3\2\2\2\63\65") buf.write("\t\5\2\2\64\63\3\2\2\2\65\66\3\2\2\2\66\64\3\2\2\2\66") buf.write("\67\3\2\2\2\678\3\2\2\289\b\f\2\29\30\3\2\2\2\6\2(-\66") buf.write("\3\b\2\2") buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2\17") buf.write("B\b\1\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7") buf.write("\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\4\f\t\f\4\r\t\r\4\16") buf.write("\t\16\3\2\3\2\3\3\3\3\3\4\3\4\3\5\3\5\3\6\3\6\3\7\3\7") buf.write("\3\b\3\b\3\b\5\b-\n\b\3\t\3\t\3\t\5\t\62\n\t\3\n\3\n\3") buf.write("\13\3\13\3\f\3\f\3\r\6\r;\n\r\r\r\16\r<\3\r\3\r\3\16\3") buf.write("\16\2\2\17\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\3\2\6\4\2\62;c|\3\2C\\\5\2\f\f..=") buf.write("=\5\2\13\13\17\17\"\"\2D\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3") buf.write("\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2") buf.write("\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2") buf.write("\2\31\3\2\2\2\2\33\3\2\2\2\3\35\3\2\2\2\5\37\3\2\2\2\7") buf.write("!\3\2\2\2\t#\3\2\2\2\13%\3\2\2\2\r\'\3\2\2\2\17,\3\2\2") buf.write("\2\21\61\3\2\2\2\23\63\3\2\2\2\25\65\3\2\2\2\27\67\3\2") buf.write("\2\2\31:\3\2\2\2\33@\3\2\2\2\35\36\7>\2\2\36\4\3\2\2\2") buf.write("\37 \7@\2\2 \6\3\2\2\2!\"\7)\2\2\"\b\3\2\2\2#$\7a\2\2") buf.write("$\n\3\2\2\2%&\t\2\2\2&\f\3\2\2\2\'(\t\3\2\2(\16\3\2\2") buf.write("\2)-\7\u2194\2\2*+\7/\2\2+-\7@\2\2,)\3\2\2\2,*\3\2\2\2") buf.write("-\20\3\2\2\2.\62\7\u03b7\2\2/\60\7^\2\2\60\62\7g\2\2\61") buf.write(".\3\2\2\2\61/\3\2\2\2\62\22\3\2\2\2\63\64\7~\2\2\64\24") buf.write("\3\2\2\2\65\66\t\4\2\2\66\26\3\2\2\2\678\7%\2\28\30\3") buf.write("\2\2\29;\t\5\2\2:9\3\2\2\2;<\3\2\2\2<:\3\2\2\2<=\3\2\2") buf.write("\2=>\3\2\2\2>?\b\r\2\2?\32\3\2\2\2@A\13\2\2\2A\34\3\2") buf.write("\2\2\6\2,\61<\3\b\2\2") return buf.getvalue() Loading @@ -49,22 +51,25 @@ class CFGLexer(Lexer): EPSILON = 8 DELIMITER = 9 NEWLINE = 10 WS = 11 HASH = 11 WS = 12 ANYCHAR = 13 channelNames = [ u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN" ] modeNames = [ "DEFAULT_MODE" ] literalNames = [ "<INVALID>", "'<'", "'>'", "'''", "'_'", "'|'" ] "'<'", "'>'", "'''", "'_'", "'|'", "'#'" ] symbolicNames = [ "<INVALID>", "LEFT_ANGLE", "RIGHT_ANGLE", "APOSTROPHE", "UNDERSCORE", "TERMINAL", "CAPS", "ARROW", "EPSILON", "DELIMITER", "NEWLINE", "WS" ] "CAPS", "ARROW", "EPSILON", "DELIMITER", "NEWLINE", "HASH", "WS", "ANYCHAR" ] ruleNames = [ "LEFT_ANGLE", "RIGHT_ANGLE", "APOSTROPHE", "UNDERSCORE", "TERMINAL", "CAPS", "ARROW", "EPSILON", "DELIMITER", "NEWLINE", "WS" ] "HASH", "WS", "ANYCHAR" ] grammarFileName = "CFG.g4" Loading lib/parsing/CFGListener.py +19 −1 Original line number Diff line number Diff line # Generated from CFG.g4 by ANTLR 4.8 # Generated from lib/parsing/CFG.g4 by ANTLR 4.8 from antlr4 import * if __name__ is not None and "." in __name__: from .CFGParser import CFGParser Loading Loading @@ -62,5 +62,23 @@ class CFGListener(ParseTreeListener): pass # Enter a parse tree produced by CFGParser#comment. def enterComment(self, ctx:CFGParser.CommentContext): pass # Exit a parse tree produced by CFGParser#comment. def exitComment(self, ctx:CFGParser.CommentContext): pass # Enter a parse tree produced by CFGParser#anyvalue. def enterAnyvalue(self, ctx:CFGParser.AnyvalueContext): pass # Exit a parse tree produced by CFGParser#anyvalue. def exitAnyvalue(self, ctx:CFGParser.AnyvalueContext): pass del CFGParser No newline at end of file lib/parsing/CFGParser.py +235 −75 File changed.Preview size limit exceeded, changes collapsed. Show changes lib/parsing/DFA.g4 +9 −2 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ grammar DFA; /* Parser Rules */ start: init production* final; start: init production* final comment; init: (INIT EQUALS statename | ); Loading @@ -12,6 +12,10 @@ final: FINAL EQUALS LEFT_BRACKET (statename (COMMA statename)* | ) RIGHT_B statename: STATE; comment: (HASH anyvalue* | ); anyvalue: INIT | EQUALS | LEFT_PARENTHESIS | RIGHT_PARENTHESIS | LEFT_BRACKET | RIGHT_BRACKET | COMMA | FINAL | STATE | ANYCHAR; /* Lexer Rules */ /* Tokens */ Loading @@ -24,7 +28,10 @@ LEFT_BRACKET : '{'; RIGHT_BRACKET : '}'; COMMA : ','; FINAL : 'final'; STATE : ([a-zA-Z0-9] | '_' | '\'')+; STATE : ([a-zA-Z0-9] | '_' | '\'' | '<' | '>')+; HASH : '#'; /* Characters to be ignored */ WS : [ \r\t\n]+ -> skip ; ANYCHAR : .; Loading
lib/parsing/CFG.g4 +8 −1 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ grammar CFG; /* Parser Rules */ start: (onerule NEWLINE+)* onerule (NEWLINE+ | ); start: (onerule NEWLINE+)* onerule (NEWLINE+ | ) comment; onerule: nonterminal ARROW (rewrite DELIMITER)* rewrite; Loading @@ -14,6 +14,10 @@ nonterminal: (CAPS | (LEFT_ANGLE symbol+ RIGHT_ANGLE (APOSTROPHE*)) | (symbo symbol: (TERMINAL | CAPS | UNDERSCORE); comment: (HASH anyvalue* | ); anyvalue: LEFT_ANGLE | RIGHT_ANGLE | APOSTROPHE | UNDERSCORE | TERMINAL | CAPS | ARROW | EPSILON | DELIMITER | NEWLINE| ANYCHAR; /* Lexer Rules */ /* Tokens */ Loading @@ -28,6 +32,9 @@ ARROW : ('→' | '->'); EPSILON : ('ε' | '\\''e'); DELIMITER : '|'; NEWLINE : ('\n' | ';' | ','); HASH : '#'; /* Characters to be ignored */ WS : [ \r\t]+ -> skip ; ANYCHAR : .;
lib/parsing/CFGLexer.py +32 −27 Original line number Diff line number Diff line # Generated from CFG.g4 by ANTLR 4.8 # Generated from lib/parsing/CFG.g4 by ANTLR 4.8 from antlr4 import * from io import StringIO from typing.io import TextIO Loading @@ -8,28 +8,30 @@ import sys def serializedATN(): with StringIO() as buf: buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2\r") buf.write(":\b\1\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7") buf.write("\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\4\f\t\f\3\2\3\2\3\3") buf.write("\3\3\3\4\3\4\3\5\3\5\3\6\3\6\3\7\3\7\3\b\3\b\3\b\5\b)") buf.write("\n\b\3\t\3\t\3\t\5\t.\n\t\3\n\3\n\3\13\3\13\3\f\6\f\65") buf.write("\n\f\r\f\16\f\66\3\f\3\f\2\2\r\3\3\5\4\7\5\t\6\13\7\r") buf.write("\b\17\t\21\n\23\13\25\f\27\r\3\2\6\4\2\62;c|\3\2C\\\5") buf.write("\2\f\f..==\5\2\13\13\17\17\"\"\2<\2\3\3\2\2\2\2\5\3\2") buf.write("\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\2") buf.write("\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2") buf.write("\27\3\2\2\2\3\31\3\2\2\2\5\33\3\2\2\2\7\35\3\2\2\2\t\37") buf.write("\3\2\2\2\13!\3\2\2\2\r#\3\2\2\2\17(\3\2\2\2\21-\3\2\2") buf.write("\2\23/\3\2\2\2\25\61\3\2\2\2\27\64\3\2\2\2\31\32\7>\2") buf.write("\2\32\4\3\2\2\2\33\34\7@\2\2\34\6\3\2\2\2\35\36\7)\2\2") buf.write("\36\b\3\2\2\2\37 \7a\2\2 \n\3\2\2\2!\"\t\2\2\2\"\f\3\2") buf.write("\2\2#$\t\3\2\2$\16\3\2\2\2%)\7\u2194\2\2&\'\7/\2\2\')") buf.write("\7@\2\2(%\3\2\2\2(&\3\2\2\2)\20\3\2\2\2*.\7\u03b7\2\2") buf.write("+,\7^\2\2,.\7g\2\2-*\3\2\2\2-+\3\2\2\2.\22\3\2\2\2/\60") buf.write("\7~\2\2\60\24\3\2\2\2\61\62\t\4\2\2\62\26\3\2\2\2\63\65") buf.write("\t\5\2\2\64\63\3\2\2\2\65\66\3\2\2\2\66\64\3\2\2\2\66") buf.write("\67\3\2\2\2\678\3\2\2\289\b\f\2\29\30\3\2\2\2\6\2(-\66") buf.write("\3\b\2\2") buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2\17") buf.write("B\b\1\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7") buf.write("\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\4\f\t\f\4\r\t\r\4\16") buf.write("\t\16\3\2\3\2\3\3\3\3\3\4\3\4\3\5\3\5\3\6\3\6\3\7\3\7") buf.write("\3\b\3\b\3\b\5\b-\n\b\3\t\3\t\3\t\5\t\62\n\t\3\n\3\n\3") buf.write("\13\3\13\3\f\3\f\3\r\6\r;\n\r\r\r\16\r<\3\r\3\r\3\16\3") buf.write("\16\2\2\17\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\3\2\6\4\2\62;c|\3\2C\\\5\2\f\f..=") buf.write("=\5\2\13\13\17\17\"\"\2D\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3") buf.write("\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2") buf.write("\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2") buf.write("\2\31\3\2\2\2\2\33\3\2\2\2\3\35\3\2\2\2\5\37\3\2\2\2\7") buf.write("!\3\2\2\2\t#\3\2\2\2\13%\3\2\2\2\r\'\3\2\2\2\17,\3\2\2") buf.write("\2\21\61\3\2\2\2\23\63\3\2\2\2\25\65\3\2\2\2\27\67\3\2") buf.write("\2\2\31:\3\2\2\2\33@\3\2\2\2\35\36\7>\2\2\36\4\3\2\2\2") buf.write("\37 \7@\2\2 \6\3\2\2\2!\"\7)\2\2\"\b\3\2\2\2#$\7a\2\2") buf.write("$\n\3\2\2\2%&\t\2\2\2&\f\3\2\2\2\'(\t\3\2\2(\16\3\2\2") buf.write("\2)-\7\u2194\2\2*+\7/\2\2+-\7@\2\2,)\3\2\2\2,*\3\2\2\2") buf.write("-\20\3\2\2\2.\62\7\u03b7\2\2/\60\7^\2\2\60\62\7g\2\2\61") buf.write(".\3\2\2\2\61/\3\2\2\2\62\22\3\2\2\2\63\64\7~\2\2\64\24") buf.write("\3\2\2\2\65\66\t\4\2\2\66\26\3\2\2\2\678\7%\2\28\30\3") buf.write("\2\2\29;\t\5\2\2:9\3\2\2\2;<\3\2\2\2<:\3\2\2\2<=\3\2\2") buf.write("\2=>\3\2\2\2>?\b\r\2\2?\32\3\2\2\2@A\13\2\2\2A\34\3\2") buf.write("\2\2\6\2,\61<\3\b\2\2") return buf.getvalue() Loading @@ -49,22 +51,25 @@ class CFGLexer(Lexer): EPSILON = 8 DELIMITER = 9 NEWLINE = 10 WS = 11 HASH = 11 WS = 12 ANYCHAR = 13 channelNames = [ u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN" ] modeNames = [ "DEFAULT_MODE" ] literalNames = [ "<INVALID>", "'<'", "'>'", "'''", "'_'", "'|'" ] "'<'", "'>'", "'''", "'_'", "'|'", "'#'" ] symbolicNames = [ "<INVALID>", "LEFT_ANGLE", "RIGHT_ANGLE", "APOSTROPHE", "UNDERSCORE", "TERMINAL", "CAPS", "ARROW", "EPSILON", "DELIMITER", "NEWLINE", "WS" ] "CAPS", "ARROW", "EPSILON", "DELIMITER", "NEWLINE", "HASH", "WS", "ANYCHAR" ] ruleNames = [ "LEFT_ANGLE", "RIGHT_ANGLE", "APOSTROPHE", "UNDERSCORE", "TERMINAL", "CAPS", "ARROW", "EPSILON", "DELIMITER", "NEWLINE", "WS" ] "HASH", "WS", "ANYCHAR" ] grammarFileName = "CFG.g4" Loading
lib/parsing/CFGListener.py +19 −1 Original line number Diff line number Diff line # Generated from CFG.g4 by ANTLR 4.8 # Generated from lib/parsing/CFG.g4 by ANTLR 4.8 from antlr4 import * if __name__ is not None and "." in __name__: from .CFGParser import CFGParser Loading Loading @@ -62,5 +62,23 @@ class CFGListener(ParseTreeListener): pass # Enter a parse tree produced by CFGParser#comment. def enterComment(self, ctx:CFGParser.CommentContext): pass # Exit a parse tree produced by CFGParser#comment. def exitComment(self, ctx:CFGParser.CommentContext): pass # Enter a parse tree produced by CFGParser#anyvalue. def enterAnyvalue(self, ctx:CFGParser.AnyvalueContext): pass # Exit a parse tree produced by CFGParser#anyvalue. def exitAnyvalue(self, ctx:CFGParser.AnyvalueContext): pass del CFGParser No newline at end of file
lib/parsing/CFGParser.py +235 −75 File changed.Preview size limit exceeded, changes collapsed. Show changes
lib/parsing/DFA.g4 +9 −2 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ grammar DFA; /* Parser Rules */ start: init production* final; start: init production* final comment; init: (INIT EQUALS statename | ); Loading @@ -12,6 +12,10 @@ final: FINAL EQUALS LEFT_BRACKET (statename (COMMA statename)* | ) RIGHT_B statename: STATE; comment: (HASH anyvalue* | ); anyvalue: INIT | EQUALS | LEFT_PARENTHESIS | RIGHT_PARENTHESIS | LEFT_BRACKET | RIGHT_BRACKET | COMMA | FINAL | STATE | ANYCHAR; /* Lexer Rules */ /* Tokens */ Loading @@ -24,7 +28,10 @@ LEFT_BRACKET : '{'; RIGHT_BRACKET : '}'; COMMA : ','; FINAL : 'final'; STATE : ([a-zA-Z0-9] | '_' | '\'')+; STATE : ([a-zA-Z0-9] | '_' | '\'' | '<' | '>')+; HASH : '#'; /* Characters to be ignored */ WS : [ \r\t\n]+ -> skip ; ANYCHAR : .;