完善ptml语法,加入注释和参数传递支持
This commit is contained in:
parent
c9e7e7c957
commit
3e3d4ebdf9
22
ptml/ptml.g4
22
ptml/ptml.g4
|
@ -1,6 +1,20 @@
|
|||
grammar ptml;
|
||||
|
||||
tree : internal_node (Names|tree)+
|
||||
;
|
||||
internal_node : 'sequence' | 'selector' | 'parallel' | 'decorator';
|
||||
Names : [a-zA-Z_][a-zA-Z_0-9]* ;
|
||||
tree : internal_node ':' (action_sign|tree)+ EOF;
|
||||
internal_node : 'sequence' | 'selector' | 'parallel' Integer | 'decorator' ;
|
||||
action_sign : 'act' Names '(' action_parm? ')';
|
||||
action_parm : (var_decls|Integer|Float|boolean) (',' (var_decls|Integer|Float|boolean))* ;
|
||||
var_decls : var_type Names ;
|
||||
var_type : 'int' | 'float' | 'bool' | 'string' ;
|
||||
boolean : 'True' | 'False' ;
|
||||
|
||||
Names : [a-zA-Z_][a-zA-Z_0-9]* ;
|
||||
Integer : '-'?[1-9][0-9]* | '0' ;
|
||||
Float : [0-9]+'.'[0-9]* | '.'[0-9]+ ;
|
||||
|
||||
|
||||
|
||||
// comments
|
||||
LINE_COMMENT : '//' .*? '\r'?'\n' -> skip ;
|
||||
// useless
|
||||
WS : [ \t\u000C\r\n]+ -> skip ;
|
||||
|
|
|
@ -1,9 +1,24 @@
|
|||
token literal names:
|
||||
null
|
||||
':'
|
||||
'sequence'
|
||||
'selector'
|
||||
'parallel'
|
||||
'decorator'
|
||||
'act'
|
||||
'('
|
||||
')'
|
||||
','
|
||||
'int'
|
||||
'float'
|
||||
'bool'
|
||||
'string'
|
||||
'True'
|
||||
'False'
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
|
||||
token symbolic names:
|
||||
|
@ -12,12 +27,32 @@ null
|
|||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
Names
|
||||
Integer
|
||||
Float
|
||||
LINE_COMMENT
|
||||
WS
|
||||
|
||||
rule names:
|
||||
tree
|
||||
internal_node
|
||||
action_sign
|
||||
action_parm
|
||||
var_decls
|
||||
var_type
|
||||
boolean
|
||||
|
||||
|
||||
atn:
|
||||
[4, 1, 5, 14, 2, 0, 7, 0, 2, 1, 7, 1, 1, 0, 1, 0, 1, 0, 4, 0, 8, 8, 0, 11, 0, 12, 0, 9, 1, 1, 1, 1, 1, 1, 0, 0, 2, 0, 2, 0, 1, 1, 0, 1, 4, 13, 0, 4, 1, 0, 0, 0, 2, 11, 1, 0, 0, 0, 4, 7, 3, 2, 1, 0, 5, 8, 5, 5, 0, 0, 6, 8, 3, 0, 0, 0, 7, 5, 1, 0, 0, 0, 7, 6, 1, 0, 0, 0, 8, 9, 1, 0, 0, 0, 9, 7, 1, 0, 0, 0, 9, 10, 1, 0, 0, 0, 10, 1, 1, 0, 0, 0, 11, 12, 7, 0, 0, 0, 12, 3, 1, 0, 0, 0, 2, 7, 9]
|
||||
[4, 1, 20, 65, 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, 1, 0, 1, 0, 1, 0, 1, 0, 4, 0, 19, 8, 0, 11, 0, 12, 0, 20, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 30, 8, 1, 1, 2, 1, 2, 1, 2, 1, 2, 3, 2, 36, 8, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 44, 8, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 51, 8, 3, 5, 3, 53, 8, 3, 10, 3, 12, 3, 56, 9, 3, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 0, 0, 7, 0, 2, 4, 6, 8, 10, 12, 0, 2, 1, 0, 10, 13, 1, 0, 14, 15, 70, 0, 14, 1, 0, 0, 0, 2, 29, 1, 0, 0, 0, 4, 31, 1, 0, 0, 0, 6, 43, 1, 0, 0, 0, 8, 57, 1, 0, 0, 0, 10, 60, 1, 0, 0, 0, 12, 62, 1, 0, 0, 0, 14, 15, 3, 2, 1, 0, 15, 18, 5, 1, 0, 0, 16, 19, 3, 4, 2, 0, 17, 19, 3, 0, 0, 0, 18, 16, 1, 0, 0, 0, 18, 17, 1, 0, 0, 0, 19, 20, 1, 0, 0, 0, 20, 18, 1, 0, 0, 0, 20, 21, 1, 0, 0, 0, 21, 22, 1, 0, 0, 0, 22, 23, 5, 0, 0, 1, 23, 1, 1, 0, 0, 0, 24, 30, 5, 2, 0, 0, 25, 30, 5, 3, 0, 0, 26, 27, 5, 4, 0, 0, 27, 30, 5, 17, 0, 0, 28, 30, 5, 5, 0, 0, 29, 24, 1, 0, 0, 0, 29, 25, 1, 0, 0, 0, 29, 26, 1, 0, 0, 0, 29, 28, 1, 0, 0, 0, 30, 3, 1, 0, 0, 0, 31, 32, 5, 6, 0, 0, 32, 33, 5, 16, 0, 0, 33, 35, 5, 7, 0, 0, 34, 36, 3, 6, 3, 0, 35, 34, 1, 0, 0, 0, 35, 36, 1, 0, 0, 0, 36, 37, 1, 0, 0, 0, 37, 38, 5, 8, 0, 0, 38, 5, 1, 0, 0, 0, 39, 44, 3, 8, 4, 0, 40, 44, 5, 17, 0, 0, 41, 44, 5, 18, 0, 0, 42, 44, 3, 12, 6, 0, 43, 39, 1, 0, 0, 0, 43, 40, 1, 0, 0, 0, 43, 41, 1, 0, 0, 0, 43, 42, 1, 0, 0, 0, 44, 54, 1, 0, 0, 0, 45, 50, 5, 9, 0, 0, 46, 51, 3, 8, 4, 0, 47, 51, 5, 17, 0, 0, 48, 51, 5, 18, 0, 0, 49, 51, 3, 12, 6, 0, 50, 46, 1, 0, 0, 0, 50, 47, 1, 0, 0, 0, 50, 48, 1, 0, 0, 0, 50, 49, 1, 0, 0, 0, 51, 53, 1, 0, 0, 0, 52, 45, 1, 0, 0, 0, 53, 56, 1, 0, 0, 0, 54, 52, 1, 0, 0, 0, 54, 55, 1, 0, 0, 0, 55, 7, 1, 0, 0, 0, 56, 54, 1, 0, 0, 0, 57, 58, 3, 10, 5, 0, 58, 59, 5, 16, 0, 0, 59, 9, 1, 0, 0, 0, 60, 61, 7, 0, 0, 0, 61, 11, 1, 0, 0, 0, 62, 63, 7, 1, 0, 0, 63, 13, 1, 0, 0, 0, 7, 18, 20, 29, 35, 43, 50, 54]
|
|
@ -2,8 +2,34 @@ T__0=1
|
|||
T__1=2
|
||||
T__2=3
|
||||
T__3=4
|
||||
Names=5
|
||||
'sequence'=1
|
||||
'selector'=2
|
||||
'parallel'=3
|
||||
'decorator'=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
|
||||
Names=16
|
||||
Integer=17
|
||||
Float=18
|
||||
LINE_COMMENT=19
|
||||
WS=20
|
||||
':'=1
|
||||
'sequence'=2
|
||||
'selector'=3
|
||||
'parallel'=4
|
||||
'decorator'=5
|
||||
'act'=6
|
||||
'('=7
|
||||
')'=8
|
||||
','=9
|
||||
'int'=10
|
||||
'float'=11
|
||||
'bool'=12
|
||||
'string'=13
|
||||
'True'=14
|
||||
'False'=15
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -10,24 +10,72 @@ else:
|
|||
|
||||
def serializedATN():
|
||||
return [
|
||||
4,0,5,55,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,1,0,1,0,1,
|
||||
0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||
2,1,2,1,2,1,2,1,2,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,3,1,3,1,4,1,4,5,4,51,8,4,10,4,12,4,54,9,4,0,0,5,1,1,3,2,5,3,
|
||||
7,4,9,5,1,0,2,3,0,65,90,95,95,97,122,4,0,48,57,65,90,95,95,97,122,
|
||||
55,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,1,
|
||||
11,1,0,0,0,3,20,1,0,0,0,5,29,1,0,0,0,7,38,1,0,0,0,9,48,1,0,0,0,11,
|
||||
12,5,115,0,0,12,13,5,101,0,0,13,14,5,113,0,0,14,15,5,117,0,0,15,
|
||||
16,5,101,0,0,16,17,5,110,0,0,17,18,5,99,0,0,18,19,5,101,0,0,19,2,
|
||||
1,0,0,0,20,21,5,115,0,0,21,22,5,101,0,0,22,23,5,108,0,0,23,24,5,
|
||||
101,0,0,24,25,5,99,0,0,25,26,5,116,0,0,26,27,5,111,0,0,27,28,5,114,
|
||||
0,0,28,4,1,0,0,0,29,30,5,112,0,0,30,31,5,97,0,0,31,32,5,114,0,0,
|
||||
32,33,5,97,0,0,33,34,5,108,0,0,34,35,5,108,0,0,35,36,5,101,0,0,36,
|
||||
37,5,108,0,0,37,6,1,0,0,0,38,39,5,100,0,0,39,40,5,101,0,0,40,41,
|
||||
5,99,0,0,41,42,5,111,0,0,42,43,5,114,0,0,43,44,5,97,0,0,44,45,5,
|
||||
116,0,0,45,46,5,111,0,0,46,47,5,114,0,0,47,8,1,0,0,0,48,52,7,0,0,
|
||||
0,49,51,7,1,0,0,50,49,1,0,0,0,51,54,1,0,0,0,52,50,1,0,0,0,52,53,
|
||||
1,0,0,0,53,10,1,0,0,0,54,52,1,0,0,0,2,0,52,0
|
||||
4,0,20,186,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,2,11,7,11,2,12,7,12,2,
|
||||
13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,
|
||||
19,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,2,1,2,1,2,1,
|
||||
2,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,3,1,4,1,4,1,
|
||||
4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,5,1,5,1,5,1,5,1,6,1,6,1,7,1,7,1,
|
||||
8,1,8,1,9,1,9,1,9,1,9,1,10,1,10,1,10,1,10,1,10,1,10,1,11,1,11,1,
|
||||
11,1,11,1,11,1,12,1,12,1,12,1,12,1,12,1,12,1,12,1,13,1,13,1,13,1,
|
||||
13,1,13,1,14,1,14,1,14,1,14,1,14,1,14,1,15,1,15,5,15,126,8,15,10,
|
||||
15,12,15,129,9,15,1,16,3,16,132,8,16,1,16,1,16,5,16,136,8,16,10,
|
||||
16,12,16,139,9,16,1,16,3,16,142,8,16,1,17,4,17,145,8,17,11,17,12,
|
||||
17,146,1,17,1,17,5,17,151,8,17,10,17,12,17,154,9,17,1,17,1,17,4,
|
||||
17,158,8,17,11,17,12,17,159,3,17,162,8,17,1,18,1,18,1,18,1,18,5,
|
||||
18,168,8,18,10,18,12,18,171,9,18,1,18,3,18,174,8,18,1,18,1,18,1,
|
||||
18,1,18,1,19,4,19,181,8,19,11,19,12,19,182,1,19,1,19,1,169,0,20,
|
||||
1,1,3,2,5,3,7,4,9,5,11,6,13,7,15,8,17,9,19,10,21,11,23,12,25,13,
|
||||
27,14,29,15,31,16,33,17,35,18,37,19,39,20,1,0,5,3,0,65,90,95,95,
|
||||
97,122,4,0,48,57,65,90,95,95,97,122,1,0,49,57,1,0,48,57,3,0,9,10,
|
||||
12,13,32,32,196,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,0,23,1,0,0,0,0,25,1,0,0,0,0,27,1,0,0,0,
|
||||
0,29,1,0,0,0,0,31,1,0,0,0,0,33,1,0,0,0,0,35,1,0,0,0,0,37,1,0,0,0,
|
||||
0,39,1,0,0,0,1,41,1,0,0,0,3,43,1,0,0,0,5,52,1,0,0,0,7,61,1,0,0,0,
|
||||
9,70,1,0,0,0,11,80,1,0,0,0,13,84,1,0,0,0,15,86,1,0,0,0,17,88,1,0,
|
||||
0,0,19,90,1,0,0,0,21,94,1,0,0,0,23,100,1,0,0,0,25,105,1,0,0,0,27,
|
||||
112,1,0,0,0,29,117,1,0,0,0,31,123,1,0,0,0,33,141,1,0,0,0,35,161,
|
||||
1,0,0,0,37,163,1,0,0,0,39,180,1,0,0,0,41,42,5,58,0,0,42,2,1,0,0,
|
||||
0,43,44,5,115,0,0,44,45,5,101,0,0,45,46,5,113,0,0,46,47,5,117,0,
|
||||
0,47,48,5,101,0,0,48,49,5,110,0,0,49,50,5,99,0,0,50,51,5,101,0,0,
|
||||
51,4,1,0,0,0,52,53,5,115,0,0,53,54,5,101,0,0,54,55,5,108,0,0,55,
|
||||
56,5,101,0,0,56,57,5,99,0,0,57,58,5,116,0,0,58,59,5,111,0,0,59,60,
|
||||
5,114,0,0,60,6,1,0,0,0,61,62,5,112,0,0,62,63,5,97,0,0,63,64,5,114,
|
||||
0,0,64,65,5,97,0,0,65,66,5,108,0,0,66,67,5,108,0,0,67,68,5,101,0,
|
||||
0,68,69,5,108,0,0,69,8,1,0,0,0,70,71,5,100,0,0,71,72,5,101,0,0,72,
|
||||
73,5,99,0,0,73,74,5,111,0,0,74,75,5,114,0,0,75,76,5,97,0,0,76,77,
|
||||
5,116,0,0,77,78,5,111,0,0,78,79,5,114,0,0,79,10,1,0,0,0,80,81,5,
|
||||
97,0,0,81,82,5,99,0,0,82,83,5,116,0,0,83,12,1,0,0,0,84,85,5,40,0,
|
||||
0,85,14,1,0,0,0,86,87,5,41,0,0,87,16,1,0,0,0,88,89,5,44,0,0,89,18,
|
||||
1,0,0,0,90,91,5,105,0,0,91,92,5,110,0,0,92,93,5,116,0,0,93,20,1,
|
||||
0,0,0,94,95,5,102,0,0,95,96,5,108,0,0,96,97,5,111,0,0,97,98,5,97,
|
||||
0,0,98,99,5,116,0,0,99,22,1,0,0,0,100,101,5,98,0,0,101,102,5,111,
|
||||
0,0,102,103,5,111,0,0,103,104,5,108,0,0,104,24,1,0,0,0,105,106,5,
|
||||
115,0,0,106,107,5,116,0,0,107,108,5,114,0,0,108,109,5,105,0,0,109,
|
||||
110,5,110,0,0,110,111,5,103,0,0,111,26,1,0,0,0,112,113,5,84,0,0,
|
||||
113,114,5,114,0,0,114,115,5,117,0,0,115,116,5,101,0,0,116,28,1,0,
|
||||
0,0,117,118,5,70,0,0,118,119,5,97,0,0,119,120,5,108,0,0,120,121,
|
||||
5,115,0,0,121,122,5,101,0,0,122,30,1,0,0,0,123,127,7,0,0,0,124,126,
|
||||
7,1,0,0,125,124,1,0,0,0,126,129,1,0,0,0,127,125,1,0,0,0,127,128,
|
||||
1,0,0,0,128,32,1,0,0,0,129,127,1,0,0,0,130,132,5,45,0,0,131,130,
|
||||
1,0,0,0,131,132,1,0,0,0,132,133,1,0,0,0,133,137,7,2,0,0,134,136,
|
||||
7,3,0,0,135,134,1,0,0,0,136,139,1,0,0,0,137,135,1,0,0,0,137,138,
|
||||
1,0,0,0,138,142,1,0,0,0,139,137,1,0,0,0,140,142,5,48,0,0,141,131,
|
||||
1,0,0,0,141,140,1,0,0,0,142,34,1,0,0,0,143,145,7,3,0,0,144,143,1,
|
||||
0,0,0,145,146,1,0,0,0,146,144,1,0,0,0,146,147,1,0,0,0,147,148,1,
|
||||
0,0,0,148,152,5,46,0,0,149,151,7,3,0,0,150,149,1,0,0,0,151,154,1,
|
||||
0,0,0,152,150,1,0,0,0,152,153,1,0,0,0,153,162,1,0,0,0,154,152,1,
|
||||
0,0,0,155,157,5,46,0,0,156,158,7,3,0,0,157,156,1,0,0,0,158,159,1,
|
||||
0,0,0,159,157,1,0,0,0,159,160,1,0,0,0,160,162,1,0,0,0,161,144,1,
|
||||
0,0,0,161,155,1,0,0,0,162,36,1,0,0,0,163,164,5,47,0,0,164,165,5,
|
||||
47,0,0,165,169,1,0,0,0,166,168,9,0,0,0,167,166,1,0,0,0,168,171,1,
|
||||
0,0,0,169,170,1,0,0,0,169,167,1,0,0,0,170,173,1,0,0,0,171,169,1,
|
||||
0,0,0,172,174,5,13,0,0,173,172,1,0,0,0,173,174,1,0,0,0,174,175,1,
|
||||
0,0,0,175,176,5,10,0,0,176,177,1,0,0,0,177,178,6,18,0,0,178,38,1,
|
||||
0,0,0,179,181,7,4,0,0,180,179,1,0,0,0,181,182,1,0,0,0,182,180,1,
|
||||
0,0,0,182,183,1,0,0,0,183,184,1,0,0,0,184,185,6,19,0,0,185,40,1,
|
||||
0,0,0,12,0,127,131,137,141,146,152,159,161,169,173,182,1,6,0,0
|
||||
]
|
||||
|
||||
class ptmlLexer(Lexer):
|
||||
|
@ -40,19 +88,39 @@ class ptmlLexer(Lexer):
|
|||
T__1 = 2
|
||||
T__2 = 3
|
||||
T__3 = 4
|
||||
Names = 5
|
||||
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
|
||||
Names = 16
|
||||
Integer = 17
|
||||
Float = 18
|
||||
LINE_COMMENT = 19
|
||||
WS = 20
|
||||
|
||||
channelNames = [ u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN" ]
|
||||
|
||||
modeNames = [ "DEFAULT_MODE" ]
|
||||
|
||||
literalNames = [ "<INVALID>",
|
||||
"'sequence'", "'selector'", "'parallel'", "'decorator'" ]
|
||||
"':'", "'sequence'", "'selector'", "'parallel'", "'decorator'",
|
||||
"'act'", "'('", "')'", "','", "'int'", "'float'", "'bool'",
|
||||
"'string'", "'True'", "'False'" ]
|
||||
|
||||
symbolicNames = [ "<INVALID>",
|
||||
"Names" ]
|
||||
"Names", "Integer", "Float", "LINE_COMMENT", "WS" ]
|
||||
|
||||
ruleNames = [ "T__0", "T__1", "T__2", "T__3", "Names" ]
|
||||
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", "Names", "Integer", "Float", "LINE_COMMENT",
|
||||
"WS" ]
|
||||
|
||||
grammarFileName = "ptml.g4"
|
||||
|
||||
|
|
|
@ -2,8 +2,34 @@ T__0=1
|
|||
T__1=2
|
||||
T__2=3
|
||||
T__3=4
|
||||
Names=5
|
||||
'sequence'=1
|
||||
'selector'=2
|
||||
'parallel'=3
|
||||
'decorator'=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
|
||||
Names=16
|
||||
Integer=17
|
||||
Float=18
|
||||
LINE_COMMENT=19
|
||||
WS=20
|
||||
':'=1
|
||||
'sequence'=2
|
||||
'selector'=3
|
||||
'parallel'=4
|
||||
'decorator'=5
|
||||
'act'=6
|
||||
'('=7
|
||||
')'=8
|
||||
','=9
|
||||
'int'=10
|
||||
'float'=11
|
||||
'bool'=12
|
||||
'string'=13
|
||||
'True'=14
|
||||
'False'=15
|
||||
|
|
|
@ -26,5 +26,50 @@ class ptmlListener(ParseTreeListener):
|
|||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by ptmlParser#action_sign.
|
||||
def enterAction_sign(self, ctx:ptmlParser.Action_signContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by ptmlParser#action_sign.
|
||||
def exitAction_sign(self, ctx:ptmlParser.Action_signContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by ptmlParser#action_parm.
|
||||
def enterAction_parm(self, ctx:ptmlParser.Action_parmContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by ptmlParser#action_parm.
|
||||
def exitAction_parm(self, ctx:ptmlParser.Action_parmContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by ptmlParser#var_decls.
|
||||
def enterVar_decls(self, ctx:ptmlParser.Var_declsContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by ptmlParser#var_decls.
|
||||
def exitVar_decls(self, ctx:ptmlParser.Var_declsContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by ptmlParser#var_type.
|
||||
def enterVar_type(self, ctx:ptmlParser.Var_typeContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by ptmlParser#var_type.
|
||||
def exitVar_type(self, ctx:ptmlParser.Var_typeContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by ptmlParser#boolean.
|
||||
def enterBoolean(self, ctx:ptmlParser.BooleanContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by ptmlParser#boolean.
|
||||
def exitBoolean(self, ctx:ptmlParser.BooleanContext):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
del ptmlParser
|
|
@ -10,11 +10,27 @@ else:
|
|||
|
||||
def serializedATN():
|
||||
return [
|
||||
4,1,5,14,2,0,7,0,2,1,7,1,1,0,1,0,1,0,4,0,8,8,0,11,0,12,0,9,1,1,1,
|
||||
1,1,1,0,0,2,0,2,0,1,1,0,1,4,13,0,4,1,0,0,0,2,11,1,0,0,0,4,7,3,2,
|
||||
1,0,5,8,5,5,0,0,6,8,3,0,0,0,7,5,1,0,0,0,7,6,1,0,0,0,8,9,1,0,0,0,
|
||||
9,7,1,0,0,0,9,10,1,0,0,0,10,1,1,0,0,0,11,12,7,0,0,0,12,3,1,0,0,0,
|
||||
2,7,9
|
||||
4,1,20,65,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,1,0,1,0,1,0,1,0,4,0,19,8,0,11,0,12,0,20,1,0,1,0,1,1,1,1,1,1,1,
|
||||
1,1,1,3,1,30,8,1,1,2,1,2,1,2,1,2,3,2,36,8,2,1,2,1,2,1,3,1,3,1,3,
|
||||
1,3,3,3,44,8,3,1,3,1,3,1,3,1,3,1,3,3,3,51,8,3,5,3,53,8,3,10,3,12,
|
||||
3,56,9,3,1,4,1,4,1,4,1,5,1,5,1,6,1,6,1,6,0,0,7,0,2,4,6,8,10,12,0,
|
||||
2,1,0,10,13,1,0,14,15,70,0,14,1,0,0,0,2,29,1,0,0,0,4,31,1,0,0,0,
|
||||
6,43,1,0,0,0,8,57,1,0,0,0,10,60,1,0,0,0,12,62,1,0,0,0,14,15,3,2,
|
||||
1,0,15,18,5,1,0,0,16,19,3,4,2,0,17,19,3,0,0,0,18,16,1,0,0,0,18,17,
|
||||
1,0,0,0,19,20,1,0,0,0,20,18,1,0,0,0,20,21,1,0,0,0,21,22,1,0,0,0,
|
||||
22,23,5,0,0,1,23,1,1,0,0,0,24,30,5,2,0,0,25,30,5,3,0,0,26,27,5,4,
|
||||
0,0,27,30,5,17,0,0,28,30,5,5,0,0,29,24,1,0,0,0,29,25,1,0,0,0,29,
|
||||
26,1,0,0,0,29,28,1,0,0,0,30,3,1,0,0,0,31,32,5,6,0,0,32,33,5,16,0,
|
||||
0,33,35,5,7,0,0,34,36,3,6,3,0,35,34,1,0,0,0,35,36,1,0,0,0,36,37,
|
||||
1,0,0,0,37,38,5,8,0,0,38,5,1,0,0,0,39,44,3,8,4,0,40,44,5,17,0,0,
|
||||
41,44,5,18,0,0,42,44,3,12,6,0,43,39,1,0,0,0,43,40,1,0,0,0,43,41,
|
||||
1,0,0,0,43,42,1,0,0,0,44,54,1,0,0,0,45,50,5,9,0,0,46,51,3,8,4,0,
|
||||
47,51,5,17,0,0,48,51,5,18,0,0,49,51,3,12,6,0,50,46,1,0,0,0,50,47,
|
||||
1,0,0,0,50,48,1,0,0,0,50,49,1,0,0,0,51,53,1,0,0,0,52,45,1,0,0,0,
|
||||
53,56,1,0,0,0,54,52,1,0,0,0,54,55,1,0,0,0,55,7,1,0,0,0,56,54,1,0,
|
||||
0,0,57,58,3,10,5,0,58,59,5,16,0,0,59,9,1,0,0,0,60,61,7,0,0,0,61,
|
||||
11,1,0,0,0,62,63,7,1,0,0,63,13,1,0,0,0,7,18,20,29,35,43,50,54
|
||||
]
|
||||
|
||||
class ptmlParser ( Parser ):
|
||||
|
@ -27,23 +43,48 @@ class ptmlParser ( Parser ):
|
|||
|
||||
sharedContextCache = PredictionContextCache()
|
||||
|
||||
literalNames = [ "<INVALID>", "'sequence'", "'selector'", "'parallel'",
|
||||
"'decorator'" ]
|
||||
literalNames = [ "<INVALID>", "':'", "'sequence'", "'selector'", "'parallel'",
|
||||
"'decorator'", "'act'", "'('", "')'", "','", "'int'",
|
||||
"'float'", "'bool'", "'string'", "'True'", "'False'" ]
|
||||
|
||||
symbolicNames = [ "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
|
||||
"<INVALID>", "Names" ]
|
||||
"<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
|
||||
"<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
|
||||
"<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
|
||||
"Names", "Integer", "Float", "LINE_COMMENT", "WS" ]
|
||||
|
||||
RULE_tree = 0
|
||||
RULE_internal_node = 1
|
||||
RULE_action_sign = 2
|
||||
RULE_action_parm = 3
|
||||
RULE_var_decls = 4
|
||||
RULE_var_type = 5
|
||||
RULE_boolean = 6
|
||||
|
||||
ruleNames = [ "tree", "internal_node" ]
|
||||
ruleNames = [ "tree", "internal_node", "action_sign", "action_parm",
|
||||
"var_decls", "var_type", "boolean" ]
|
||||
|
||||
EOF = Token.EOF
|
||||
T__0=1
|
||||
T__1=2
|
||||
T__2=3
|
||||
T__3=4
|
||||
Names=5
|
||||
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
|
||||
Names=16
|
||||
Integer=17
|
||||
Float=18
|
||||
LINE_COMMENT=19
|
||||
WS=20
|
||||
|
||||
def __init__(self, input:TokenStream, output:TextIO = sys.stdout):
|
||||
super().__init__(input, output)
|
||||
|
@ -65,11 +106,15 @@ class ptmlParser ( Parser ):
|
|||
return self.getTypedRuleContext(ptmlParser.Internal_nodeContext,0)
|
||||
|
||||
|
||||
def Names(self, i:int=None):
|
||||
def EOF(self):
|
||||
return self.getToken(ptmlParser.EOF, 0)
|
||||
|
||||
def action_sign(self, i:int=None):
|
||||
if i is None:
|
||||
return self.getTokens(ptmlParser.Names)
|
||||
return self.getTypedRuleContexts(ptmlParser.Action_signContext)
|
||||
else:
|
||||
return self.getToken(ptmlParser.Names, i)
|
||||
return self.getTypedRuleContext(ptmlParser.Action_signContext,i)
|
||||
|
||||
|
||||
def tree(self, i:int=None):
|
||||
if i is None:
|
||||
|
@ -96,36 +141,39 @@ class ptmlParser ( Parser ):
|
|||
|
||||
localctx = ptmlParser.TreeContext(self, self._ctx, self.state)
|
||||
self.enterRule(localctx, 0, self.RULE_tree)
|
||||
self._la = 0 # Token type
|
||||
try:
|
||||
self.enterOuterAlt(localctx, 1)
|
||||
self.state = 4
|
||||
self.state = 14
|
||||
self.internal_node()
|
||||
self.state = 7
|
||||
self.state = 15
|
||||
self.match(ptmlParser.T__0)
|
||||
self.state = 18
|
||||
self._errHandler.sync(self)
|
||||
_alt = 1
|
||||
while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
|
||||
if _alt == 1:
|
||||
self.state = 7
|
||||
self._errHandler.sync(self)
|
||||
token = self._input.LA(1)
|
||||
if token in [5]:
|
||||
self.state = 5
|
||||
self.match(ptmlParser.Names)
|
||||
pass
|
||||
elif token in [1, 2, 3, 4]:
|
||||
self.state = 6
|
||||
self.tree()
|
||||
pass
|
||||
else:
|
||||
raise NoViableAltException(self)
|
||||
|
||||
|
||||
_la = self._input.LA(1)
|
||||
while True:
|
||||
self.state = 18
|
||||
self._errHandler.sync(self)
|
||||
token = self._input.LA(1)
|
||||
if token in [6]:
|
||||
self.state = 16
|
||||
self.action_sign()
|
||||
pass
|
||||
elif token in [2, 3, 4, 5]:
|
||||
self.state = 17
|
||||
self.tree()
|
||||
pass
|
||||
else:
|
||||
raise NoViableAltException(self)
|
||||
self.state = 9
|
||||
self._errHandler.sync(self)
|
||||
_alt = self._interp.adaptivePredict(self._input,1,self._ctx)
|
||||
|
||||
self.state = 20
|
||||
self._errHandler.sync(self)
|
||||
_la = self._input.LA(1)
|
||||
if not ((((_la) & ~0x3f) == 0 and ((1 << _la) & 124) != 0)):
|
||||
break
|
||||
|
||||
self.state = 22
|
||||
self.match(ptmlParser.EOF)
|
||||
except RecognitionException as re:
|
||||
localctx.exception = re
|
||||
self._errHandler.reportError(self, re)
|
||||
|
@ -142,6 +190,8 @@ class ptmlParser ( Parser ):
|
|||
super().__init__(parent, invokingState)
|
||||
self.parser = parser
|
||||
|
||||
def Integer(self):
|
||||
return self.getToken(ptmlParser.Integer, 0)
|
||||
|
||||
def getRuleIndex(self):
|
||||
return ptmlParser.RULE_internal_node
|
||||
|
@ -161,12 +211,345 @@ class ptmlParser ( Parser ):
|
|||
|
||||
localctx = ptmlParser.Internal_nodeContext(self, self._ctx, self.state)
|
||||
self.enterRule(localctx, 2, self.RULE_internal_node)
|
||||
try:
|
||||
self.state = 29
|
||||
self._errHandler.sync(self)
|
||||
token = self._input.LA(1)
|
||||
if token in [2]:
|
||||
self.enterOuterAlt(localctx, 1)
|
||||
self.state = 24
|
||||
self.match(ptmlParser.T__1)
|
||||
pass
|
||||
elif token in [3]:
|
||||
self.enterOuterAlt(localctx, 2)
|
||||
self.state = 25
|
||||
self.match(ptmlParser.T__2)
|
||||
pass
|
||||
elif token in [4]:
|
||||
self.enterOuterAlt(localctx, 3)
|
||||
self.state = 26
|
||||
self.match(ptmlParser.T__3)
|
||||
self.state = 27
|
||||
self.match(ptmlParser.Integer)
|
||||
pass
|
||||
elif token in [5]:
|
||||
self.enterOuterAlt(localctx, 4)
|
||||
self.state = 28
|
||||
self.match(ptmlParser.T__4)
|
||||
pass
|
||||
else:
|
||||
raise NoViableAltException(self)
|
||||
|
||||
except RecognitionException as re:
|
||||
localctx.exception = re
|
||||
self._errHandler.reportError(self, re)
|
||||
self._errHandler.recover(self, re)
|
||||
finally:
|
||||
self.exitRule()
|
||||
return localctx
|
||||
|
||||
|
||||
class Action_signContext(ParserRuleContext):
|
||||
__slots__ = 'parser'
|
||||
|
||||
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
|
||||
super().__init__(parent, invokingState)
|
||||
self.parser = parser
|
||||
|
||||
def Names(self):
|
||||
return self.getToken(ptmlParser.Names, 0)
|
||||
|
||||
def action_parm(self):
|
||||
return self.getTypedRuleContext(ptmlParser.Action_parmContext,0)
|
||||
|
||||
|
||||
def getRuleIndex(self):
|
||||
return ptmlParser.RULE_action_sign
|
||||
|
||||
def enterRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "enterAction_sign" ):
|
||||
listener.enterAction_sign(self)
|
||||
|
||||
def exitRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "exitAction_sign" ):
|
||||
listener.exitAction_sign(self)
|
||||
|
||||
|
||||
|
||||
|
||||
def action_sign(self):
|
||||
|
||||
localctx = ptmlParser.Action_signContext(self, self._ctx, self.state)
|
||||
self.enterRule(localctx, 4, self.RULE_action_sign)
|
||||
self._la = 0 # Token type
|
||||
try:
|
||||
self.enterOuterAlt(localctx, 1)
|
||||
self.state = 11
|
||||
self.state = 31
|
||||
self.match(ptmlParser.T__5)
|
||||
self.state = 32
|
||||
self.match(ptmlParser.Names)
|
||||
self.state = 33
|
||||
self.match(ptmlParser.T__6)
|
||||
self.state = 35
|
||||
self._errHandler.sync(self)
|
||||
_la = self._input.LA(1)
|
||||
if not((((_la) & ~0x3f) == 0 and ((1 << _la) & 30) != 0)):
|
||||
if (((_la) & ~0x3f) == 0 and ((1 << _la) & 457728) != 0):
|
||||
self.state = 34
|
||||
self.action_parm()
|
||||
|
||||
|
||||
self.state = 37
|
||||
self.match(ptmlParser.T__7)
|
||||
except RecognitionException as re:
|
||||
localctx.exception = re
|
||||
self._errHandler.reportError(self, re)
|
||||
self._errHandler.recover(self, re)
|
||||
finally:
|
||||
self.exitRule()
|
||||
return localctx
|
||||
|
||||
|
||||
class Action_parmContext(ParserRuleContext):
|
||||
__slots__ = 'parser'
|
||||
|
||||
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
|
||||
super().__init__(parent, invokingState)
|
||||
self.parser = parser
|
||||
|
||||
def var_decls(self, i:int=None):
|
||||
if i is None:
|
||||
return self.getTypedRuleContexts(ptmlParser.Var_declsContext)
|
||||
else:
|
||||
return self.getTypedRuleContext(ptmlParser.Var_declsContext,i)
|
||||
|
||||
|
||||
def Integer(self, i:int=None):
|
||||
if i is None:
|
||||
return self.getTokens(ptmlParser.Integer)
|
||||
else:
|
||||
return self.getToken(ptmlParser.Integer, i)
|
||||
|
||||
def Float(self, i:int=None):
|
||||
if i is None:
|
||||
return self.getTokens(ptmlParser.Float)
|
||||
else:
|
||||
return self.getToken(ptmlParser.Float, i)
|
||||
|
||||
def boolean(self, i:int=None):
|
||||
if i is None:
|
||||
return self.getTypedRuleContexts(ptmlParser.BooleanContext)
|
||||
else:
|
||||
return self.getTypedRuleContext(ptmlParser.BooleanContext,i)
|
||||
|
||||
|
||||
def getRuleIndex(self):
|
||||
return ptmlParser.RULE_action_parm
|
||||
|
||||
def enterRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "enterAction_parm" ):
|
||||
listener.enterAction_parm(self)
|
||||
|
||||
def exitRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "exitAction_parm" ):
|
||||
listener.exitAction_parm(self)
|
||||
|
||||
|
||||
|
||||
|
||||
def action_parm(self):
|
||||
|
||||
localctx = ptmlParser.Action_parmContext(self, self._ctx, self.state)
|
||||
self.enterRule(localctx, 6, self.RULE_action_parm)
|
||||
self._la = 0 # Token type
|
||||
try:
|
||||
self.enterOuterAlt(localctx, 1)
|
||||
self.state = 43
|
||||
self._errHandler.sync(self)
|
||||
token = self._input.LA(1)
|
||||
if token in [10, 11, 12, 13]:
|
||||
self.state = 39
|
||||
self.var_decls()
|
||||
pass
|
||||
elif token in [17]:
|
||||
self.state = 40
|
||||
self.match(ptmlParser.Integer)
|
||||
pass
|
||||
elif token in [18]:
|
||||
self.state = 41
|
||||
self.match(ptmlParser.Float)
|
||||
pass
|
||||
elif token in [14, 15]:
|
||||
self.state = 42
|
||||
self.boolean()
|
||||
pass
|
||||
else:
|
||||
raise NoViableAltException(self)
|
||||
|
||||
self.state = 54
|
||||
self._errHandler.sync(self)
|
||||
_la = self._input.LA(1)
|
||||
while _la==9:
|
||||
self.state = 45
|
||||
self.match(ptmlParser.T__8)
|
||||
self.state = 50
|
||||
self._errHandler.sync(self)
|
||||
token = self._input.LA(1)
|
||||
if token in [10, 11, 12, 13]:
|
||||
self.state = 46
|
||||
self.var_decls()
|
||||
pass
|
||||
elif token in [17]:
|
||||
self.state = 47
|
||||
self.match(ptmlParser.Integer)
|
||||
pass
|
||||
elif token in [18]:
|
||||
self.state = 48
|
||||
self.match(ptmlParser.Float)
|
||||
pass
|
||||
elif token in [14, 15]:
|
||||
self.state = 49
|
||||
self.boolean()
|
||||
pass
|
||||
else:
|
||||
raise NoViableAltException(self)
|
||||
|
||||
self.state = 56
|
||||
self._errHandler.sync(self)
|
||||
_la = self._input.LA(1)
|
||||
|
||||
except RecognitionException as re:
|
||||
localctx.exception = re
|
||||
self._errHandler.reportError(self, re)
|
||||
self._errHandler.recover(self, re)
|
||||
finally:
|
||||
self.exitRule()
|
||||
return localctx
|
||||
|
||||
|
||||
class Var_declsContext(ParserRuleContext):
|
||||
__slots__ = 'parser'
|
||||
|
||||
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
|
||||
super().__init__(parent, invokingState)
|
||||
self.parser = parser
|
||||
|
||||
def var_type(self):
|
||||
return self.getTypedRuleContext(ptmlParser.Var_typeContext,0)
|
||||
|
||||
|
||||
def Names(self):
|
||||
return self.getToken(ptmlParser.Names, 0)
|
||||
|
||||
def getRuleIndex(self):
|
||||
return ptmlParser.RULE_var_decls
|
||||
|
||||
def enterRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "enterVar_decls" ):
|
||||
listener.enterVar_decls(self)
|
||||
|
||||
def exitRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "exitVar_decls" ):
|
||||
listener.exitVar_decls(self)
|
||||
|
||||
|
||||
|
||||
|
||||
def var_decls(self):
|
||||
|
||||
localctx = ptmlParser.Var_declsContext(self, self._ctx, self.state)
|
||||
self.enterRule(localctx, 8, self.RULE_var_decls)
|
||||
try:
|
||||
self.enterOuterAlt(localctx, 1)
|
||||
self.state = 57
|
||||
self.var_type()
|
||||
self.state = 58
|
||||
self.match(ptmlParser.Names)
|
||||
except RecognitionException as re:
|
||||
localctx.exception = re
|
||||
self._errHandler.reportError(self, re)
|
||||
self._errHandler.recover(self, re)
|
||||
finally:
|
||||
self.exitRule()
|
||||
return localctx
|
||||
|
||||
|
||||
class Var_typeContext(ParserRuleContext):
|
||||
__slots__ = 'parser'
|
||||
|
||||
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
|
||||
super().__init__(parent, invokingState)
|
||||
self.parser = parser
|
||||
|
||||
|
||||
def getRuleIndex(self):
|
||||
return ptmlParser.RULE_var_type
|
||||
|
||||
def enterRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "enterVar_type" ):
|
||||
listener.enterVar_type(self)
|
||||
|
||||
def exitRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "exitVar_type" ):
|
||||
listener.exitVar_type(self)
|
||||
|
||||
|
||||
|
||||
|
||||
def var_type(self):
|
||||
|
||||
localctx = ptmlParser.Var_typeContext(self, self._ctx, self.state)
|
||||
self.enterRule(localctx, 10, self.RULE_var_type)
|
||||
self._la = 0 # Token type
|
||||
try:
|
||||
self.enterOuterAlt(localctx, 1)
|
||||
self.state = 60
|
||||
_la = self._input.LA(1)
|
||||
if not((((_la) & ~0x3f) == 0 and ((1 << _la) & 15360) != 0)):
|
||||
self._errHandler.recoverInline(self)
|
||||
else:
|
||||
self._errHandler.reportMatch(self)
|
||||
self.consume()
|
||||
except RecognitionException as re:
|
||||
localctx.exception = re
|
||||
self._errHandler.reportError(self, re)
|
||||
self._errHandler.recover(self, re)
|
||||
finally:
|
||||
self.exitRule()
|
||||
return localctx
|
||||
|
||||
|
||||
class BooleanContext(ParserRuleContext):
|
||||
__slots__ = 'parser'
|
||||
|
||||
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
|
||||
super().__init__(parent, invokingState)
|
||||
self.parser = parser
|
||||
|
||||
|
||||
def getRuleIndex(self):
|
||||
return ptmlParser.RULE_boolean
|
||||
|
||||
def enterRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "enterBoolean" ):
|
||||
listener.enterBoolean(self)
|
||||
|
||||
def exitRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "exitBoolean" ):
|
||||
listener.exitBoolean(self)
|
||||
|
||||
|
||||
|
||||
|
||||
def boolean(self):
|
||||
|
||||
localctx = ptmlParser.BooleanContext(self, self._ctx, self.state)
|
||||
self.enterRule(localctx, 12, self.RULE_boolean)
|
||||
self._la = 0 # Token type
|
||||
try:
|
||||
self.enterOuterAlt(localctx, 1)
|
||||
self.state = 62
|
||||
_la = self._input.LA(1)
|
||||
if not(_la==14 or _la==15):
|
||||
self._errHandler.recoverInline(self)
|
||||
else:
|
||||
self._errHandler.reportMatch(self)
|
||||
|
|
Loading…
Reference in New Issue