调整g4语法,增加test文件
This commit is contained in:
parent
005558e29c
commit
31b36053ca
|
@ -151,3 +151,9 @@ cython_debug/
|
|||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
.idea/
|
||||
test.py
|
||||
|
||||
# antlr tempory files
|
||||
.antlr/
|
||||
|
||||
# pyc files
|
||||
__pycache__/
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
sequence:
|
||||
select:
|
||||
selector:
|
||||
cond CoffeeCupFound()
|
||||
act FindCoffeeCup()
|
||||
select:
|
||||
task FindCoffeeCup()
|
||||
sequence:
|
||||
cond SeqTest()
|
||||
task Move()
|
||||
selector:
|
||||
cond CoffeeCupGrasped()
|
||||
act GraspCoffeeCup()
|
||||
select:
|
||||
task GraspCoffeeCup()
|
||||
selector:
|
||||
cond DestinationAReached()
|
||||
act ReachDestinationA()
|
||||
select:
|
||||
task ReachDestinationA()
|
||||
selector:
|
||||
cond CoffeeCupPlaced()
|
||||
act PlaceCoffeeCup()
|
||||
task PlaceCoffeeCup()
|
|
@ -1,8 +1,10 @@
|
|||
grammar ptml;
|
||||
|
||||
tree : internal_node ':' (action_sign|tree)+ EOF;
|
||||
root : tree+ EOF;
|
||||
|
||||
tree : internal_node ':' (action_sign|tree)+ ;
|
||||
internal_node : 'sequence' | 'selector' | 'parallel' Integer | 'decorator' ;
|
||||
action_sign : ('act'|'cond') Names '(' action_parm? ')';
|
||||
action_sign : ('task'|'cond') 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' ;
|
||||
|
|
|
@ -5,7 +5,7 @@ null
|
|||
'selector'
|
||||
'parallel'
|
||||
'decorator'
|
||||
'act'
|
||||
'task'
|
||||
'cond'
|
||||
'('
|
||||
')'
|
||||
|
@ -47,6 +47,7 @@ LINE_COMMENT
|
|||
WS
|
||||
|
||||
rule names:
|
||||
root
|
||||
tree
|
||||
internal_node
|
||||
action_sign
|
||||
|
@ -57,4 +58,4 @@ boolean
|
|||
|
||||
|
||||
atn:
|
||||
[4, 1, 21, 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, 3, 1, 0, 6, 7, 1, 0, 11, 14, 1, 0, 15, 16, 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, 18, 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, 7, 0, 0, 0, 32, 33, 5, 17, 0, 0, 33, 35, 5, 8, 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, 9, 0, 0, 38, 5, 1, 0, 0, 0, 39, 44, 3, 8, 4, 0, 40, 44, 5, 18, 0, 0, 41, 44, 5, 19, 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, 10, 0, 0, 46, 51, 3, 8, 4, 0, 47, 51, 5, 18, 0, 0, 48, 51, 5, 19, 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, 17, 0, 0, 59, 9, 1, 0, 0, 0, 60, 61, 7, 1, 0, 0, 61, 11, 1, 0, 0, 0, 62, 63, 7, 2, 0, 0, 63, 13, 1, 0, 0, 0, 7, 18, 20, 29, 35, 43, 50, 54]
|
||||
[4, 1, 21, 72, 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, 1, 0, 4, 0, 18, 8, 0, 11, 0, 12, 0, 19, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, 28, 8, 1, 11, 1, 12, 1, 29, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 3, 2, 37, 8, 2, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 43, 8, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 3, 4, 51, 8, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 3, 4, 58, 8, 4, 5, 4, 60, 8, 4, 10, 4, 12, 4, 63, 9, 4, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 0, 0, 8, 0, 2, 4, 6, 8, 10, 12, 14, 0, 3, 1, 0, 6, 7, 1, 0, 11, 14, 1, 0, 15, 16, 77, 0, 17, 1, 0, 0, 0, 2, 23, 1, 0, 0, 0, 4, 36, 1, 0, 0, 0, 6, 38, 1, 0, 0, 0, 8, 50, 1, 0, 0, 0, 10, 64, 1, 0, 0, 0, 12, 67, 1, 0, 0, 0, 14, 69, 1, 0, 0, 0, 16, 18, 3, 2, 1, 0, 17, 16, 1, 0, 0, 0, 18, 19, 1, 0, 0, 0, 19, 17, 1, 0, 0, 0, 19, 20, 1, 0, 0, 0, 20, 21, 1, 0, 0, 0, 21, 22, 5, 0, 0, 1, 22, 1, 1, 0, 0, 0, 23, 24, 3, 4, 2, 0, 24, 27, 5, 1, 0, 0, 25, 28, 3, 6, 3, 0, 26, 28, 3, 2, 1, 0, 27, 25, 1, 0, 0, 0, 27, 26, 1, 0, 0, 0, 28, 29, 1, 0, 0, 0, 29, 27, 1, 0, 0, 0, 29, 30, 1, 0, 0, 0, 30, 3, 1, 0, 0, 0, 31, 37, 5, 2, 0, 0, 32, 37, 5, 3, 0, 0, 33, 34, 5, 4, 0, 0, 34, 37, 5, 18, 0, 0, 35, 37, 5, 5, 0, 0, 36, 31, 1, 0, 0, 0, 36, 32, 1, 0, 0, 0, 36, 33, 1, 0, 0, 0, 36, 35, 1, 0, 0, 0, 37, 5, 1, 0, 0, 0, 38, 39, 7, 0, 0, 0, 39, 40, 5, 17, 0, 0, 40, 42, 5, 8, 0, 0, 41, 43, 3, 8, 4, 0, 42, 41, 1, 0, 0, 0, 42, 43, 1, 0, 0, 0, 43, 44, 1, 0, 0, 0, 44, 45, 5, 9, 0, 0, 45, 7, 1, 0, 0, 0, 46, 51, 3, 10, 5, 0, 47, 51, 5, 18, 0, 0, 48, 51, 5, 19, 0, 0, 49, 51, 3, 14, 7, 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, 61, 1, 0, 0, 0, 52, 57, 5, 10, 0, 0, 53, 58, 3, 10, 5, 0, 54, 58, 5, 18, 0, 0, 55, 58, 5, 19, 0, 0, 56, 58, 3, 14, 7, 0, 57, 53, 1, 0, 0, 0, 57, 54, 1, 0, 0, 0, 57, 55, 1, 0, 0, 0, 57, 56, 1, 0, 0, 0, 58, 60, 1, 0, 0, 0, 59, 52, 1, 0, 0, 0, 60, 63, 1, 0, 0, 0, 61, 59, 1, 0, 0, 0, 61, 62, 1, 0, 0, 0, 62, 9, 1, 0, 0, 0, 63, 61, 1, 0, 0, 0, 64, 65, 3, 12, 6, 0, 65, 66, 5, 17, 0, 0, 66, 11, 1, 0, 0, 0, 67, 68, 7, 1, 0, 0, 68, 13, 1, 0, 0, 0, 69, 70, 7, 2, 0, 0, 70, 15, 1, 0, 0, 0, 8, 19, 27, 29, 36, 42, 50, 57, 61]
|
|
@ -24,7 +24,7 @@ WS=21
|
|||
'selector'=3
|
||||
'parallel'=4
|
||||
'decorator'=5
|
||||
'act'=6
|
||||
'task'=6
|
||||
'cond'=7
|
||||
'('=8
|
||||
')'=9
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -10,75 +10,75 @@ else:
|
|||
|
||||
def serializedATN():
|
||||
return [
|
||||
4,0,21,193,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,
|
||||
4,0,21,194,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,2,20,7,20,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,6,1,6,1,6,1,7,1,7,1,8,1,8,1,9,1,9,1,10,1,10,1,10,1,10,1,11,1,11,
|
||||
1,11,1,11,1,11,1,11,1,12,1,12,1,12,1,12,1,12,1,13,1,13,1,13,1,13,
|
||||
1,13,1,13,1,13,1,14,1,14,1,14,1,14,1,14,1,15,1,15,1,15,1,15,1,15,
|
||||
1,15,1,16,1,16,5,16,133,8,16,10,16,12,16,136,9,16,1,17,3,17,139,
|
||||
8,17,1,17,1,17,5,17,143,8,17,10,17,12,17,146,9,17,1,17,3,17,149,
|
||||
8,17,1,18,4,18,152,8,18,11,18,12,18,153,1,18,1,18,5,18,158,8,18,
|
||||
10,18,12,18,161,9,18,1,18,1,18,4,18,165,8,18,11,18,12,18,166,3,18,
|
||||
169,8,18,1,19,1,19,1,19,1,19,5,19,175,8,19,10,19,12,19,178,9,19,
|
||||
1,19,3,19,181,8,19,1,19,1,19,1,19,1,19,1,20,4,20,188,8,20,11,20,
|
||||
12,20,189,1,20,1,20,1,176,0,21,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,41,21,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,203,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,0,41,1,0,0,0,1,43,
|
||||
1,0,0,0,3,45,1,0,0,0,5,54,1,0,0,0,7,63,1,0,0,0,9,72,1,0,0,0,11,82,
|
||||
1,0,0,0,13,86,1,0,0,0,15,91,1,0,0,0,17,93,1,0,0,0,19,95,1,0,0,0,
|
||||
21,97,1,0,0,0,23,101,1,0,0,0,25,107,1,0,0,0,27,112,1,0,0,0,29,119,
|
||||
1,0,0,0,31,124,1,0,0,0,33,130,1,0,0,0,35,148,1,0,0,0,37,168,1,0,
|
||||
0,0,39,170,1,0,0,0,41,187,1,0,0,0,43,44,5,58,0,0,44,2,1,0,0,0,45,
|
||||
46,5,115,0,0,46,47,5,101,0,0,47,48,5,113,0,0,48,49,5,117,0,0,49,
|
||||
50,5,101,0,0,50,51,5,110,0,0,51,52,5,99,0,0,52,53,5,101,0,0,53,4,
|
||||
1,0,0,0,54,55,5,115,0,0,55,56,5,101,0,0,56,57,5,108,0,0,57,58,5,
|
||||
101,0,0,58,59,5,99,0,0,59,60,5,116,0,0,60,61,5,111,0,0,61,62,5,114,
|
||||
0,0,62,6,1,0,0,0,63,64,5,112,0,0,64,65,5,97,0,0,65,66,5,114,0,0,
|
||||
66,67,5,97,0,0,67,68,5,108,0,0,68,69,5,108,0,0,69,70,5,101,0,0,70,
|
||||
71,5,108,0,0,71,8,1,0,0,0,72,73,5,100,0,0,73,74,5,101,0,0,74,75,
|
||||
5,99,0,0,75,76,5,111,0,0,76,77,5,114,0,0,77,78,5,97,0,0,78,79,5,
|
||||
116,0,0,79,80,5,111,0,0,80,81,5,114,0,0,81,10,1,0,0,0,82,83,5,97,
|
||||
0,0,83,84,5,99,0,0,84,85,5,116,0,0,85,12,1,0,0,0,86,87,5,99,0,0,
|
||||
87,88,5,111,0,0,88,89,5,110,0,0,89,90,5,100,0,0,90,14,1,0,0,0,91,
|
||||
92,5,40,0,0,92,16,1,0,0,0,93,94,5,41,0,0,94,18,1,0,0,0,95,96,5,44,
|
||||
0,0,96,20,1,0,0,0,97,98,5,105,0,0,98,99,5,110,0,0,99,100,5,116,0,
|
||||
0,100,22,1,0,0,0,101,102,5,102,0,0,102,103,5,108,0,0,103,104,5,111,
|
||||
0,0,104,105,5,97,0,0,105,106,5,116,0,0,106,24,1,0,0,0,107,108,5,
|
||||
98,0,0,108,109,5,111,0,0,109,110,5,111,0,0,110,111,5,108,0,0,111,
|
||||
26,1,0,0,0,112,113,5,115,0,0,113,114,5,116,0,0,114,115,5,114,0,0,
|
||||
115,116,5,105,0,0,116,117,5,110,0,0,117,118,5,103,0,0,118,28,1,0,
|
||||
0,0,119,120,5,84,0,0,120,121,5,114,0,0,121,122,5,117,0,0,122,123,
|
||||
5,101,0,0,123,30,1,0,0,0,124,125,5,70,0,0,125,126,5,97,0,0,126,127,
|
||||
5,108,0,0,127,128,5,115,0,0,128,129,5,101,0,0,129,32,1,0,0,0,130,
|
||||
134,7,0,0,0,131,133,7,1,0,0,132,131,1,0,0,0,133,136,1,0,0,0,134,
|
||||
132,1,0,0,0,134,135,1,0,0,0,135,34,1,0,0,0,136,134,1,0,0,0,137,139,
|
||||
5,45,0,0,138,137,1,0,0,0,138,139,1,0,0,0,139,140,1,0,0,0,140,144,
|
||||
7,2,0,0,141,143,7,3,0,0,142,141,1,0,0,0,143,146,1,0,0,0,144,142,
|
||||
1,0,0,0,144,145,1,0,0,0,145,149,1,0,0,0,146,144,1,0,0,0,147,149,
|
||||
5,48,0,0,148,138,1,0,0,0,148,147,1,0,0,0,149,36,1,0,0,0,150,152,
|
||||
7,3,0,0,151,150,1,0,0,0,152,153,1,0,0,0,153,151,1,0,0,0,153,154,
|
||||
1,0,0,0,154,155,1,0,0,0,155,159,5,46,0,0,156,158,7,3,0,0,157,156,
|
||||
1,0,0,0,158,161,1,0,0,0,159,157,1,0,0,0,159,160,1,0,0,0,160,169,
|
||||
1,0,0,0,161,159,1,0,0,0,162,164,5,46,0,0,163,165,7,3,0,0,164,163,
|
||||
1,0,0,0,165,166,1,0,0,0,166,164,1,0,0,0,166,167,1,0,0,0,167,169,
|
||||
1,0,0,0,168,151,1,0,0,0,168,162,1,0,0,0,169,38,1,0,0,0,170,171,5,
|
||||
47,0,0,171,172,5,47,0,0,172,176,1,0,0,0,173,175,9,0,0,0,174,173,
|
||||
1,0,0,0,175,178,1,0,0,0,176,177,1,0,0,0,176,174,1,0,0,0,177,180,
|
||||
1,0,0,0,178,176,1,0,0,0,179,181,5,13,0,0,180,179,1,0,0,0,180,181,
|
||||
1,0,0,0,181,182,1,0,0,0,182,183,5,10,0,0,183,184,1,0,0,0,184,185,
|
||||
6,19,0,0,185,40,1,0,0,0,186,188,7,4,0,0,187,186,1,0,0,0,188,189,
|
||||
1,0,0,0,189,187,1,0,0,0,189,190,1,0,0,0,190,191,1,0,0,0,191,192,
|
||||
6,20,0,0,192,42,1,0,0,0,12,0,134,138,144,148,153,159,166,168,176,
|
||||
180,189,1,6,0,0
|
||||
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,5,1,6,
|
||||
1,6,1,6,1,6,1,6,1,7,1,7,1,8,1,8,1,9,1,9,1,10,1,10,1,10,1,10,1,11,
|
||||
1,11,1,11,1,11,1,11,1,11,1,12,1,12,1,12,1,12,1,12,1,13,1,13,1,13,
|
||||
1,13,1,13,1,13,1,13,1,14,1,14,1,14,1,14,1,14,1,15,1,15,1,15,1,15,
|
||||
1,15,1,15,1,16,1,16,5,16,134,8,16,10,16,12,16,137,9,16,1,17,3,17,
|
||||
140,8,17,1,17,1,17,5,17,144,8,17,10,17,12,17,147,9,17,1,17,3,17,
|
||||
150,8,17,1,18,4,18,153,8,18,11,18,12,18,154,1,18,1,18,5,18,159,8,
|
||||
18,10,18,12,18,162,9,18,1,18,1,18,4,18,166,8,18,11,18,12,18,167,
|
||||
3,18,170,8,18,1,19,1,19,1,19,1,19,5,19,176,8,19,10,19,12,19,179,
|
||||
9,19,1,19,3,19,182,8,19,1,19,1,19,1,19,1,19,1,20,4,20,189,8,20,11,
|
||||
20,12,20,190,1,20,1,20,1,177,0,21,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,41,21,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,204,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,0,41,1,0,0,0,1,
|
||||
43,1,0,0,0,3,45,1,0,0,0,5,54,1,0,0,0,7,63,1,0,0,0,9,72,1,0,0,0,11,
|
||||
82,1,0,0,0,13,87,1,0,0,0,15,92,1,0,0,0,17,94,1,0,0,0,19,96,1,0,0,
|
||||
0,21,98,1,0,0,0,23,102,1,0,0,0,25,108,1,0,0,0,27,113,1,0,0,0,29,
|
||||
120,1,0,0,0,31,125,1,0,0,0,33,131,1,0,0,0,35,149,1,0,0,0,37,169,
|
||||
1,0,0,0,39,171,1,0,0,0,41,188,1,0,0,0,43,44,5,58,0,0,44,2,1,0,0,
|
||||
0,45,46,5,115,0,0,46,47,5,101,0,0,47,48,5,113,0,0,48,49,5,117,0,
|
||||
0,49,50,5,101,0,0,50,51,5,110,0,0,51,52,5,99,0,0,52,53,5,101,0,0,
|
||||
53,4,1,0,0,0,54,55,5,115,0,0,55,56,5,101,0,0,56,57,5,108,0,0,57,
|
||||
58,5,101,0,0,58,59,5,99,0,0,59,60,5,116,0,0,60,61,5,111,0,0,61,62,
|
||||
5,114,0,0,62,6,1,0,0,0,63,64,5,112,0,0,64,65,5,97,0,0,65,66,5,114,
|
||||
0,0,66,67,5,97,0,0,67,68,5,108,0,0,68,69,5,108,0,0,69,70,5,101,0,
|
||||
0,70,71,5,108,0,0,71,8,1,0,0,0,72,73,5,100,0,0,73,74,5,101,0,0,74,
|
||||
75,5,99,0,0,75,76,5,111,0,0,76,77,5,114,0,0,77,78,5,97,0,0,78,79,
|
||||
5,116,0,0,79,80,5,111,0,0,80,81,5,114,0,0,81,10,1,0,0,0,82,83,5,
|
||||
116,0,0,83,84,5,97,0,0,84,85,5,115,0,0,85,86,5,107,0,0,86,12,1,0,
|
||||
0,0,87,88,5,99,0,0,88,89,5,111,0,0,89,90,5,110,0,0,90,91,5,100,0,
|
||||
0,91,14,1,0,0,0,92,93,5,40,0,0,93,16,1,0,0,0,94,95,5,41,0,0,95,18,
|
||||
1,0,0,0,96,97,5,44,0,0,97,20,1,0,0,0,98,99,5,105,0,0,99,100,5,110,
|
||||
0,0,100,101,5,116,0,0,101,22,1,0,0,0,102,103,5,102,0,0,103,104,5,
|
||||
108,0,0,104,105,5,111,0,0,105,106,5,97,0,0,106,107,5,116,0,0,107,
|
||||
24,1,0,0,0,108,109,5,98,0,0,109,110,5,111,0,0,110,111,5,111,0,0,
|
||||
111,112,5,108,0,0,112,26,1,0,0,0,113,114,5,115,0,0,114,115,5,116,
|
||||
0,0,115,116,5,114,0,0,116,117,5,105,0,0,117,118,5,110,0,0,118,119,
|
||||
5,103,0,0,119,28,1,0,0,0,120,121,5,84,0,0,121,122,5,114,0,0,122,
|
||||
123,5,117,0,0,123,124,5,101,0,0,124,30,1,0,0,0,125,126,5,70,0,0,
|
||||
126,127,5,97,0,0,127,128,5,108,0,0,128,129,5,115,0,0,129,130,5,101,
|
||||
0,0,130,32,1,0,0,0,131,135,7,0,0,0,132,134,7,1,0,0,133,132,1,0,0,
|
||||
0,134,137,1,0,0,0,135,133,1,0,0,0,135,136,1,0,0,0,136,34,1,0,0,0,
|
||||
137,135,1,0,0,0,138,140,5,45,0,0,139,138,1,0,0,0,139,140,1,0,0,0,
|
||||
140,141,1,0,0,0,141,145,7,2,0,0,142,144,7,3,0,0,143,142,1,0,0,0,
|
||||
144,147,1,0,0,0,145,143,1,0,0,0,145,146,1,0,0,0,146,150,1,0,0,0,
|
||||
147,145,1,0,0,0,148,150,5,48,0,0,149,139,1,0,0,0,149,148,1,0,0,0,
|
||||
150,36,1,0,0,0,151,153,7,3,0,0,152,151,1,0,0,0,153,154,1,0,0,0,154,
|
||||
152,1,0,0,0,154,155,1,0,0,0,155,156,1,0,0,0,156,160,5,46,0,0,157,
|
||||
159,7,3,0,0,158,157,1,0,0,0,159,162,1,0,0,0,160,158,1,0,0,0,160,
|
||||
161,1,0,0,0,161,170,1,0,0,0,162,160,1,0,0,0,163,165,5,46,0,0,164,
|
||||
166,7,3,0,0,165,164,1,0,0,0,166,167,1,0,0,0,167,165,1,0,0,0,167,
|
||||
168,1,0,0,0,168,170,1,0,0,0,169,152,1,0,0,0,169,163,1,0,0,0,170,
|
||||
38,1,0,0,0,171,172,5,47,0,0,172,173,5,47,0,0,173,177,1,0,0,0,174,
|
||||
176,9,0,0,0,175,174,1,0,0,0,176,179,1,0,0,0,177,178,1,0,0,0,177,
|
||||
175,1,0,0,0,178,181,1,0,0,0,179,177,1,0,0,0,180,182,5,13,0,0,181,
|
||||
180,1,0,0,0,181,182,1,0,0,0,182,183,1,0,0,0,183,184,5,10,0,0,184,
|
||||
185,1,0,0,0,185,186,6,19,0,0,186,40,1,0,0,0,187,189,7,4,0,0,188,
|
||||
187,1,0,0,0,189,190,1,0,0,0,190,188,1,0,0,0,190,191,1,0,0,0,191,
|
||||
192,1,0,0,0,192,193,6,20,0,0,193,42,1,0,0,0,12,0,135,139,145,149,
|
||||
154,160,167,169,177,181,190,1,6,0,0
|
||||
]
|
||||
|
||||
class ptmlLexer(Lexer):
|
||||
|
@ -115,7 +115,7 @@ class ptmlLexer(Lexer):
|
|||
|
||||
literalNames = [ "<INVALID>",
|
||||
"':'", "'sequence'", "'selector'", "'parallel'", "'decorator'",
|
||||
"'act'", "'cond'", "'('", "')'", "','", "'int'", "'float'",
|
||||
"'task'", "'cond'", "'('", "')'", "','", "'int'", "'float'",
|
||||
"'bool'", "'string'", "'True'", "'False'" ]
|
||||
|
||||
symbolicNames = [ "<INVALID>",
|
||||
|
|
|
@ -24,7 +24,7 @@ WS=21
|
|||
'selector'=3
|
||||
'parallel'=4
|
||||
'decorator'=5
|
||||
'act'=6
|
||||
'task'=6
|
||||
'cond'=7
|
||||
'('=8
|
||||
')'=9
|
||||
|
|
|
@ -8,6 +8,15 @@ else:
|
|||
# This class defines a complete listener for a parse tree produced by ptmlParser.
|
||||
class ptmlListener(ParseTreeListener):
|
||||
|
||||
# Enter a parse tree produced by ptmlParser#root.
|
||||
def enterRoot(self, ctx:ptmlParser.RootContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by ptmlParser#root.
|
||||
def exitRoot(self, ctx:ptmlParser.RootContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by ptmlParser#tree.
|
||||
def enterTree(self, ctx:ptmlParser.TreeContext):
|
||||
pass
|
||||
|
|
|
@ -10,27 +10,30 @@ else:
|
|||
|
||||
def serializedATN():
|
||||
return [
|
||||
4,1,21,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,
|
||||
3,1,0,6,7,1,0,11,14,1,0,15,16,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,18,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,7,0,0,0,32,33,
|
||||
5,17,0,0,33,35,5,8,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,9,0,0,38,5,1,0,0,0,39,44,3,8,4,0,40,44,5,18,
|
||||
0,0,41,44,5,19,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,10,0,0,46,51,3,8,
|
||||
4,0,47,51,5,18,0,0,48,51,5,19,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,17,0,0,59,9,1,0,0,0,60,61,7,1,0,0,61,
|
||||
11,1,0,0,0,62,63,7,2,0,0,63,13,1,0,0,0,7,18,20,29,35,43,50,54
|
||||
4,1,21,72,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,1,0,4,0,18,8,0,11,0,12,0,19,1,0,1,0,1,1,1,1,1,1,1,1,4,
|
||||
1,28,8,1,11,1,12,1,29,1,2,1,2,1,2,1,2,1,2,3,2,37,8,2,1,3,1,3,1,3,
|
||||
1,3,3,3,43,8,3,1,3,1,3,1,4,1,4,1,4,1,4,3,4,51,8,4,1,4,1,4,1,4,1,
|
||||
4,1,4,3,4,58,8,4,5,4,60,8,4,10,4,12,4,63,9,4,1,5,1,5,1,5,1,6,1,6,
|
||||
1,7,1,7,1,7,0,0,8,0,2,4,6,8,10,12,14,0,3,1,0,6,7,1,0,11,14,1,0,15,
|
||||
16,77,0,17,1,0,0,0,2,23,1,0,0,0,4,36,1,0,0,0,6,38,1,0,0,0,8,50,1,
|
||||
0,0,0,10,64,1,0,0,0,12,67,1,0,0,0,14,69,1,0,0,0,16,18,3,2,1,0,17,
|
||||
16,1,0,0,0,18,19,1,0,0,0,19,17,1,0,0,0,19,20,1,0,0,0,20,21,1,0,0,
|
||||
0,21,22,5,0,0,1,22,1,1,0,0,0,23,24,3,4,2,0,24,27,5,1,0,0,25,28,3,
|
||||
6,3,0,26,28,3,2,1,0,27,25,1,0,0,0,27,26,1,0,0,0,28,29,1,0,0,0,29,
|
||||
27,1,0,0,0,29,30,1,0,0,0,30,3,1,0,0,0,31,37,5,2,0,0,32,37,5,3,0,
|
||||
0,33,34,5,4,0,0,34,37,5,18,0,0,35,37,5,5,0,0,36,31,1,0,0,0,36,32,
|
||||
1,0,0,0,36,33,1,0,0,0,36,35,1,0,0,0,37,5,1,0,0,0,38,39,7,0,0,0,39,
|
||||
40,5,17,0,0,40,42,5,8,0,0,41,43,3,8,4,0,42,41,1,0,0,0,42,43,1,0,
|
||||
0,0,43,44,1,0,0,0,44,45,5,9,0,0,45,7,1,0,0,0,46,51,3,10,5,0,47,51,
|
||||
5,18,0,0,48,51,5,19,0,0,49,51,3,14,7,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,61,1,0,0,0,52,57,5,10,0,0,53,58,
|
||||
3,10,5,0,54,58,5,18,0,0,55,58,5,19,0,0,56,58,3,14,7,0,57,53,1,0,
|
||||
0,0,57,54,1,0,0,0,57,55,1,0,0,0,57,56,1,0,0,0,58,60,1,0,0,0,59,52,
|
||||
1,0,0,0,60,63,1,0,0,0,61,59,1,0,0,0,61,62,1,0,0,0,62,9,1,0,0,0,63,
|
||||
61,1,0,0,0,64,65,3,12,6,0,65,66,5,17,0,0,66,11,1,0,0,0,67,68,7,1,
|
||||
0,0,68,13,1,0,0,0,69,70,7,2,0,0,70,15,1,0,0,0,8,19,27,29,36,42,50,
|
||||
57,61
|
||||
]
|
||||
|
||||
class ptmlParser ( Parser ):
|
||||
|
@ -44,7 +47,7 @@ class ptmlParser ( Parser ):
|
|||
sharedContextCache = PredictionContextCache()
|
||||
|
||||
literalNames = [ "<INVALID>", "':'", "'sequence'", "'selector'", "'parallel'",
|
||||
"'decorator'", "'act'", "'cond'", "'('", "')'", "','",
|
||||
"'decorator'", "'task'", "'cond'", "'('", "')'", "','",
|
||||
"'int'", "'float'", "'bool'", "'string'", "'True'",
|
||||
"'False'" ]
|
||||
|
||||
|
@ -55,15 +58,16 @@ class ptmlParser ( Parser ):
|
|||
"<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
|
||||
RULE_root = 0
|
||||
RULE_tree = 1
|
||||
RULE_internal_node = 2
|
||||
RULE_action_sign = 3
|
||||
RULE_action_parm = 4
|
||||
RULE_var_decls = 5
|
||||
RULE_var_type = 6
|
||||
RULE_boolean = 7
|
||||
|
||||
ruleNames = [ "tree", "internal_node", "action_sign", "action_parm",
|
||||
ruleNames = [ "root", "tree", "internal_node", "action_sign", "action_parm",
|
||||
"var_decls", "var_type", "boolean" ]
|
||||
|
||||
EOF = Token.EOF
|
||||
|
@ -98,6 +102,67 @@ class ptmlParser ( Parser ):
|
|||
|
||||
|
||||
|
||||
class RootContext(ParserRuleContext):
|
||||
__slots__ = 'parser'
|
||||
|
||||
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
|
||||
super().__init__(parent, invokingState)
|
||||
self.parser = parser
|
||||
|
||||
def EOF(self):
|
||||
return self.getToken(ptmlParser.EOF, 0)
|
||||
|
||||
def tree(self, i:int=None):
|
||||
if i is None:
|
||||
return self.getTypedRuleContexts(ptmlParser.TreeContext)
|
||||
else:
|
||||
return self.getTypedRuleContext(ptmlParser.TreeContext,i)
|
||||
|
||||
|
||||
def getRuleIndex(self):
|
||||
return ptmlParser.RULE_root
|
||||
|
||||
def enterRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "enterRoot" ):
|
||||
listener.enterRoot(self)
|
||||
|
||||
def exitRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "exitRoot" ):
|
||||
listener.exitRoot(self)
|
||||
|
||||
|
||||
|
||||
|
||||
def root(self):
|
||||
|
||||
localctx = ptmlParser.RootContext(self, self._ctx, self.state)
|
||||
self.enterRule(localctx, 0, self.RULE_root)
|
||||
self._la = 0 # Token type
|
||||
try:
|
||||
self.enterOuterAlt(localctx, 1)
|
||||
self.state = 17
|
||||
self._errHandler.sync(self)
|
||||
_la = self._input.LA(1)
|
||||
while True:
|
||||
self.state = 16
|
||||
self.tree()
|
||||
self.state = 19
|
||||
self._errHandler.sync(self)
|
||||
_la = self._input.LA(1)
|
||||
if not ((((_la) & ~0x3f) == 0 and ((1 << _la) & 60) != 0)):
|
||||
break
|
||||
|
||||
self.state = 21
|
||||
self.match(ptmlParser.EOF)
|
||||
except RecognitionException as re:
|
||||
localctx.exception = re
|
||||
self._errHandler.reportError(self, re)
|
||||
self._errHandler.recover(self, re)
|
||||
finally:
|
||||
self.exitRule()
|
||||
return localctx
|
||||
|
||||
|
||||
class TreeContext(ParserRuleContext):
|
||||
__slots__ = 'parser'
|
||||
|
||||
|
@ -109,9 +174,6 @@ class ptmlParser ( Parser ):
|
|||
return self.getTypedRuleContext(ptmlParser.Internal_nodeContext,0)
|
||||
|
||||
|
||||
def EOF(self):
|
||||
return self.getToken(ptmlParser.EOF, 0)
|
||||
|
||||
def action_sign(self, i:int=None):
|
||||
if i is None:
|
||||
return self.getTypedRuleContexts(ptmlParser.Action_signContext)
|
||||
|
@ -143,40 +205,39 @@ class ptmlParser ( Parser ):
|
|||
def tree(self):
|
||||
|
||||
localctx = ptmlParser.TreeContext(self, self._ctx, self.state)
|
||||
self.enterRule(localctx, 0, self.RULE_tree)
|
||||
self._la = 0 # Token type
|
||||
self.enterRule(localctx, 2, self.RULE_tree)
|
||||
try:
|
||||
self.enterOuterAlt(localctx, 1)
|
||||
self.state = 14
|
||||
self.state = 23
|
||||
self.internal_node()
|
||||
self.state = 15
|
||||
self.state = 24
|
||||
self.match(ptmlParser.T__0)
|
||||
self.state = 18
|
||||
self.state = 27
|
||||
self._errHandler.sync(self)
|
||||
_la = self._input.LA(1)
|
||||
while True:
|
||||
self.state = 18
|
||||
self._errHandler.sync(self)
|
||||
token = self._input.LA(1)
|
||||
if token in [6, 7]:
|
||||
self.state = 16
|
||||
self.action_sign()
|
||||
pass
|
||||
elif token in [2, 3, 4, 5]:
|
||||
self.state = 17
|
||||
self.tree()
|
||||
pass
|
||||
_alt = 1
|
||||
while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
|
||||
if _alt == 1:
|
||||
self.state = 27
|
||||
self._errHandler.sync(self)
|
||||
token = self._input.LA(1)
|
||||
if token in [6, 7]:
|
||||
self.state = 25
|
||||
self.action_sign()
|
||||
pass
|
||||
elif token in [2, 3, 4, 5]:
|
||||
self.state = 26
|
||||
self.tree()
|
||||
pass
|
||||
else:
|
||||
raise NoViableAltException(self)
|
||||
|
||||
|
||||
else:
|
||||
raise NoViableAltException(self)
|
||||
|
||||
self.state = 20
|
||||
self.state = 29
|
||||
self._errHandler.sync(self)
|
||||
_la = self._input.LA(1)
|
||||
if not ((((_la) & ~0x3f) == 0 and ((1 << _la) & 252) != 0)):
|
||||
break
|
||||
_alt = self._interp.adaptivePredict(self._input,2,self._ctx)
|
||||
|
||||
self.state = 22
|
||||
self.match(ptmlParser.EOF)
|
||||
except RecognitionException as re:
|
||||
localctx.exception = re
|
||||
self._errHandler.reportError(self, re)
|
||||
|
@ -213,31 +274,31 @@ class ptmlParser ( Parser ):
|
|||
def internal_node(self):
|
||||
|
||||
localctx = ptmlParser.Internal_nodeContext(self, self._ctx, self.state)
|
||||
self.enterRule(localctx, 2, self.RULE_internal_node)
|
||||
self.enterRule(localctx, 4, self.RULE_internal_node)
|
||||
try:
|
||||
self.state = 29
|
||||
self.state = 36
|
||||
self._errHandler.sync(self)
|
||||
token = self._input.LA(1)
|
||||
if token in [2]:
|
||||
self.enterOuterAlt(localctx, 1)
|
||||
self.state = 24
|
||||
self.state = 31
|
||||
self.match(ptmlParser.T__1)
|
||||
pass
|
||||
elif token in [3]:
|
||||
self.enterOuterAlt(localctx, 2)
|
||||
self.state = 25
|
||||
self.state = 32
|
||||
self.match(ptmlParser.T__2)
|
||||
pass
|
||||
elif token in [4]:
|
||||
self.enterOuterAlt(localctx, 3)
|
||||
self.state = 26
|
||||
self.state = 33
|
||||
self.match(ptmlParser.T__3)
|
||||
self.state = 27
|
||||
self.state = 34
|
||||
self.match(ptmlParser.Integer)
|
||||
pass
|
||||
elif token in [5]:
|
||||
self.enterOuterAlt(localctx, 4)
|
||||
self.state = 28
|
||||
self.state = 35
|
||||
self.match(ptmlParser.T__4)
|
||||
pass
|
||||
else:
|
||||
|
@ -283,30 +344,30 @@ class ptmlParser ( Parser ):
|
|||
def action_sign(self):
|
||||
|
||||
localctx = ptmlParser.Action_signContext(self, self._ctx, self.state)
|
||||
self.enterRule(localctx, 4, self.RULE_action_sign)
|
||||
self.enterRule(localctx, 6, self.RULE_action_sign)
|
||||
self._la = 0 # Token type
|
||||
try:
|
||||
self.enterOuterAlt(localctx, 1)
|
||||
self.state = 31
|
||||
self.state = 38
|
||||
_la = self._input.LA(1)
|
||||
if not(_la==6 or _la==7):
|
||||
self._errHandler.recoverInline(self)
|
||||
else:
|
||||
self._errHandler.reportMatch(self)
|
||||
self.consume()
|
||||
self.state = 32
|
||||
self.state = 39
|
||||
self.match(ptmlParser.Names)
|
||||
self.state = 33
|
||||
self.state = 40
|
||||
self.match(ptmlParser.T__7)
|
||||
self.state = 35
|
||||
self.state = 42
|
||||
self._errHandler.sync(self)
|
||||
_la = self._input.LA(1)
|
||||
if (((_la) & ~0x3f) == 0 and ((1 << _la) & 915456) != 0):
|
||||
self.state = 34
|
||||
self.state = 41
|
||||
self.action_parm()
|
||||
|
||||
|
||||
self.state = 37
|
||||
self.state = 44
|
||||
self.match(ptmlParser.T__8)
|
||||
except RecognitionException as re:
|
||||
localctx.exception = re
|
||||
|
@ -367,61 +428,61 @@ class ptmlParser ( Parser ):
|
|||
def action_parm(self):
|
||||
|
||||
localctx = ptmlParser.Action_parmContext(self, self._ctx, self.state)
|
||||
self.enterRule(localctx, 6, self.RULE_action_parm)
|
||||
self.enterRule(localctx, 8, self.RULE_action_parm)
|
||||
self._la = 0 # Token type
|
||||
try:
|
||||
self.enterOuterAlt(localctx, 1)
|
||||
self.state = 43
|
||||
self.state = 50
|
||||
self._errHandler.sync(self)
|
||||
token = self._input.LA(1)
|
||||
if token in [11, 12, 13, 14]:
|
||||
self.state = 39
|
||||
self.state = 46
|
||||
self.var_decls()
|
||||
pass
|
||||
elif token in [18]:
|
||||
self.state = 40
|
||||
self.state = 47
|
||||
self.match(ptmlParser.Integer)
|
||||
pass
|
||||
elif token in [19]:
|
||||
self.state = 41
|
||||
self.state = 48
|
||||
self.match(ptmlParser.Float)
|
||||
pass
|
||||
elif token in [15, 16]:
|
||||
self.state = 42
|
||||
self.state = 49
|
||||
self.boolean()
|
||||
pass
|
||||
else:
|
||||
raise NoViableAltException(self)
|
||||
|
||||
self.state = 54
|
||||
self.state = 61
|
||||
self._errHandler.sync(self)
|
||||
_la = self._input.LA(1)
|
||||
while _la==10:
|
||||
self.state = 45
|
||||
self.state = 52
|
||||
self.match(ptmlParser.T__9)
|
||||
self.state = 50
|
||||
self.state = 57
|
||||
self._errHandler.sync(self)
|
||||
token = self._input.LA(1)
|
||||
if token in [11, 12, 13, 14]:
|
||||
self.state = 46
|
||||
self.state = 53
|
||||
self.var_decls()
|
||||
pass
|
||||
elif token in [18]:
|
||||
self.state = 47
|
||||
self.state = 54
|
||||
self.match(ptmlParser.Integer)
|
||||
pass
|
||||
elif token in [19]:
|
||||
self.state = 48
|
||||
self.state = 55
|
||||
self.match(ptmlParser.Float)
|
||||
pass
|
||||
elif token in [15, 16]:
|
||||
self.state = 49
|
||||
self.state = 56
|
||||
self.boolean()
|
||||
pass
|
||||
else:
|
||||
raise NoViableAltException(self)
|
||||
|
||||
self.state = 56
|
||||
self.state = 63
|
||||
self._errHandler.sync(self)
|
||||
_la = self._input.LA(1)
|
||||
|
||||
|
@ -465,12 +526,12 @@ class ptmlParser ( Parser ):
|
|||
def var_decls(self):
|
||||
|
||||
localctx = ptmlParser.Var_declsContext(self, self._ctx, self.state)
|
||||
self.enterRule(localctx, 8, self.RULE_var_decls)
|
||||
self.enterRule(localctx, 10, self.RULE_var_decls)
|
||||
try:
|
||||
self.enterOuterAlt(localctx, 1)
|
||||
self.state = 57
|
||||
self.state = 64
|
||||
self.var_type()
|
||||
self.state = 58
|
||||
self.state = 65
|
||||
self.match(ptmlParser.Names)
|
||||
except RecognitionException as re:
|
||||
localctx.exception = re
|
||||
|
@ -506,11 +567,11 @@ class ptmlParser ( Parser ):
|
|||
def var_type(self):
|
||||
|
||||
localctx = ptmlParser.Var_typeContext(self, self._ctx, self.state)
|
||||
self.enterRule(localctx, 10, self.RULE_var_type)
|
||||
self.enterRule(localctx, 12, self.RULE_var_type)
|
||||
self._la = 0 # Token type
|
||||
try:
|
||||
self.enterOuterAlt(localctx, 1)
|
||||
self.state = 60
|
||||
self.state = 67
|
||||
_la = self._input.LA(1)
|
||||
if not((((_la) & ~0x3f) == 0 and ((1 << _la) & 30720) != 0)):
|
||||
self._errHandler.recoverInline(self)
|
||||
|
@ -551,11 +612,11 @@ class ptmlParser ( Parser ):
|
|||
def boolean(self):
|
||||
|
||||
localctx = ptmlParser.BooleanContext(self, self._ctx, self.state)
|
||||
self.enterRule(localctx, 12, self.RULE_boolean)
|
||||
self.enterRule(localctx, 14, self.RULE_boolean)
|
||||
self._la = 0 # Token type
|
||||
try:
|
||||
self.enterOuterAlt(localctx, 1)
|
||||
self.state = 62
|
||||
self.state = 69
|
||||
_la = self._input.LA(1)
|
||||
if not(_la==15 or _la==16):
|
||||
self._errHandler.recoverInline(self)
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
import os
|
||||
import sys
|
||||
project_path = "/home/wu/RoboWaiter/ptml"
|
||||
sys.path.append(project_path)
|
||||
|
||||
from antlr4 import *
|
||||
from .ptmlListener import ptmlListener
|
||||
from .ptmlParser import ptmlParser
|
||||
from ptmlListener import ptmlListener
|
||||
from ptmlParser import ptmlParser
|
||||
from BT_api import BTAPI
|
||||
|
||||
class ptmlTranslator(ptmlListener):
|
||||
"""Translate the ptml language to BT.
|
||||
|
@ -11,6 +17,17 @@ class ptmlTranslator(ptmlListener):
|
|||
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
self.stack = []
|
||||
self.api = BTAPI()
|
||||
|
||||
|
||||
# Enter a parse tree produced by ptmlParser#root.
|
||||
def enterRoot(self, ctx:ptmlParser.RootContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by ptmlParser#root.
|
||||
def exitRoot(self, ctx:ptmlParser.RootContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by ptmlParser#tree.
|
||||
|
@ -24,7 +41,8 @@ class ptmlTranslator(ptmlListener):
|
|||
|
||||
# Enter a parse tree produced by ptmlParser#internal_node.
|
||||
def enterInternal_node(self, ctx:ptmlParser.Internal_nodeContext):
|
||||
pass
|
||||
type = str(ctx.children[0])
|
||||
print(type)
|
||||
|
||||
# Exit a parse tree produced by ptmlParser#internal_node.
|
||||
def exitInternal_node(self, ctx:ptmlParser.Internal_nodeContext):
|
||||
|
@ -73,4 +91,13 @@ class ptmlTranslator(ptmlListener):
|
|||
|
||||
# Exit a parse tree produced by ptmlParser#boolean.
|
||||
def exitBoolean(self, ctx:ptmlParser.BooleanContext):
|
||||
pass
|
||||
pass
|
||||
|
||||
|
||||
class BtNode():
|
||||
"""
|
||||
|
||||
"""
|
||||
def __init__(self, type:str='BtNode') -> None:
|
||||
self.type = type
|
||||
self.name:str = ''
|
|
@ -0,0 +1,25 @@
|
|||
import os
|
||||
import sys
|
||||
project_path = "/home/wu/RoboWaiter/ptml"
|
||||
sys.path.append(project_path)
|
||||
|
||||
from antlr4 import *
|
||||
from ptmlTranslator import ptmlTranslator
|
||||
from ptmlParser import ptmlParser as Parser
|
||||
from ptmlLexer import ptmlLexer as Lexer
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
text_path = os.path.join(project_path, 'CoffeeDelivery.ptml')
|
||||
input_stream = FileStream(text_path, encoding='utf-8')
|
||||
|
||||
# testing lexer & parser
|
||||
lexer = Lexer(input_stream)
|
||||
stream = CommonTokenStream(lexer)
|
||||
parser = Parser(stream)
|
||||
tree = parser.root()
|
||||
|
||||
walker = ParseTreeWalker()
|
||||
ptml = ptmlTranslator() # listener mode
|
||||
walker.walk(ptml, tree)
|
Loading…
Reference in New Issue