传参方式删除定义式(int a),仅保留参数传递
This commit is contained in:
parent
31b36053ca
commit
a7f5ec47df
|
@ -1,4 +1,5 @@
|
|||
import py_trees as bt
|
||||
import typing
|
||||
|
||||
class BTAPI():
|
||||
"""
|
||||
|
@ -15,3 +16,55 @@ class BTAPI():
|
|||
Returns:
|
||||
bt.trees.BehaviourTree: _description_
|
||||
"""
|
||||
|
||||
def newSequenceNode(self, tag: str='') -> None:
|
||||
"""_summary_
|
||||
|
||||
Args:
|
||||
tag (str, optional): _description_. Defaults to ''.
|
||||
"""
|
||||
return
|
||||
|
||||
def newSelectorNode(self, tag: str='') -> None:
|
||||
"""_summary_
|
||||
|
||||
Args:
|
||||
tag (str, optional): _description_. Defaults to ''.
|
||||
"""
|
||||
return
|
||||
|
||||
def newParallelNode(self, threshold:int) -> None:
|
||||
"""_summary_
|
||||
|
||||
Args:
|
||||
threshold (int): _description_
|
||||
"""
|
||||
return
|
||||
|
||||
def newDecoratorNode(self, tag: str='') -> None:
|
||||
"""_summary_
|
||||
|
||||
Args:
|
||||
tag (str, optional): _description_. Defaults to ''.
|
||||
"""
|
||||
return
|
||||
|
||||
def newBehaviourNode(self, name: str, args: typing.Optional[typing.List[str]]=[], tag:str='', isCond:bool=False) -> None:
|
||||
"""_summary_
|
||||
|
||||
Args:
|
||||
name (str): _description_
|
||||
args (typing.Optional[typing.List[str]], optional): _description_. Defaults to [].
|
||||
tag (str, optional): _description_. Defaults to ''.
|
||||
isCond (bool, optional): _description_. Defaults to False.
|
||||
"""
|
||||
return
|
||||
|
||||
def attach_to_parent(self, uuid_child:str, uuid_parent:str) -> None:
|
||||
"""_summary_
|
||||
|
||||
Args:
|
||||
uuid_child (str): _description_
|
||||
uuid_parent (str): _description_
|
||||
"""
|
||||
return
|
|
@ -5,9 +5,9 @@ root : tree+ EOF;
|
|||
tree : internal_node ':' (action_sign|tree)+ ;
|
||||
internal_node : 'sequence' | 'selector' | 'parallel' Integer | 'decorator' ;
|
||||
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' ;
|
||||
action_parm : (Integer|Float|boolean) (',' (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]* ;
|
||||
|
|
|
@ -10,10 +10,6 @@ null
|
|||
'('
|
||||
')'
|
||||
','
|
||||
'int'
|
||||
'float'
|
||||
'bool'
|
||||
'string'
|
||||
'True'
|
||||
'False'
|
||||
null
|
||||
|
@ -36,10 +32,6 @@ null
|
|||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
Names
|
||||
Integer
|
||||
Float
|
||||
|
@ -52,10 +44,8 @@ tree
|
|||
internal_node
|
||||
action_sign
|
||||
action_parm
|
||||
var_decls
|
||||
var_type
|
||||
boolean
|
||||
|
||||
|
||||
atn:
|
||||
[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]
|
||||
[4, 1, 17, 61, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 1, 0, 4, 0, 14, 8, 0, 11, 0, 12, 0, 15, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, 24, 8, 1, 11, 1, 12, 1, 25, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 3, 2, 33, 8, 2, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 39, 8, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 3, 4, 46, 8, 4, 1, 4, 1, 4, 1, 4, 1, 4, 3, 4, 52, 8, 4, 5, 4, 54, 8, 4, 10, 4, 12, 4, 57, 9, 4, 1, 5, 1, 5, 1, 5, 0, 0, 6, 0, 2, 4, 6, 8, 10, 0, 2, 1, 0, 6, 7, 1, 0, 11, 12, 66, 0, 13, 1, 0, 0, 0, 2, 19, 1, 0, 0, 0, 4, 32, 1, 0, 0, 0, 6, 34, 1, 0, 0, 0, 8, 45, 1, 0, 0, 0, 10, 58, 1, 0, 0, 0, 12, 14, 3, 2, 1, 0, 13, 12, 1, 0, 0, 0, 14, 15, 1, 0, 0, 0, 15, 13, 1, 0, 0, 0, 15, 16, 1, 0, 0, 0, 16, 17, 1, 0, 0, 0, 17, 18, 5, 0, 0, 1, 18, 1, 1, 0, 0, 0, 19, 20, 3, 4, 2, 0, 20, 23, 5, 1, 0, 0, 21, 24, 3, 6, 3, 0, 22, 24, 3, 2, 1, 0, 23, 21, 1, 0, 0, 0, 23, 22, 1, 0, 0, 0, 24, 25, 1, 0, 0, 0, 25, 23, 1, 0, 0, 0, 25, 26, 1, 0, 0, 0, 26, 3, 1, 0, 0, 0, 27, 33, 5, 2, 0, 0, 28, 33, 5, 3, 0, 0, 29, 30, 5, 4, 0, 0, 30, 33, 5, 14, 0, 0, 31, 33, 5, 5, 0, 0, 32, 27, 1, 0, 0, 0, 32, 28, 1, 0, 0, 0, 32, 29, 1, 0, 0, 0, 32, 31, 1, 0, 0, 0, 33, 5, 1, 0, 0, 0, 34, 35, 7, 0, 0, 0, 35, 36, 5, 13, 0, 0, 36, 38, 5, 8, 0, 0, 37, 39, 3, 8, 4, 0, 38, 37, 1, 0, 0, 0, 38, 39, 1, 0, 0, 0, 39, 40, 1, 0, 0, 0, 40, 41, 5, 9, 0, 0, 41, 7, 1, 0, 0, 0, 42, 46, 5, 14, 0, 0, 43, 46, 5, 15, 0, 0, 44, 46, 3, 10, 5, 0, 45, 42, 1, 0, 0, 0, 45, 43, 1, 0, 0, 0, 45, 44, 1, 0, 0, 0, 46, 55, 1, 0, 0, 0, 47, 51, 5, 10, 0, 0, 48, 52, 5, 14, 0, 0, 49, 52, 5, 15, 0, 0, 50, 52, 3, 10, 5, 0, 51, 48, 1, 0, 0, 0, 51, 49, 1, 0, 0, 0, 51, 50, 1, 0, 0, 0, 52, 54, 1, 0, 0, 0, 53, 47, 1, 0, 0, 0, 54, 57, 1, 0, 0, 0, 55, 53, 1, 0, 0, 0, 55, 56, 1, 0, 0, 0, 56, 9, 1, 0, 0, 0, 57, 55, 1, 0, 0, 0, 58, 59, 7, 1, 0, 0, 59, 11, 1, 0, 0, 0, 8, 15, 23, 25, 32, 38, 45, 51, 55]
|
|
@ -10,15 +10,11 @@ T__8=9
|
|||
T__9=10
|
||||
T__10=11
|
||||
T__11=12
|
||||
T__12=13
|
||||
T__13=14
|
||||
T__14=15
|
||||
T__15=16
|
||||
Names=17
|
||||
Integer=18
|
||||
Float=19
|
||||
LINE_COMMENT=20
|
||||
WS=21
|
||||
Names=13
|
||||
Integer=14
|
||||
Float=15
|
||||
LINE_COMMENT=16
|
||||
WS=17
|
||||
':'=1
|
||||
'sequence'=2
|
||||
'selector'=3
|
||||
|
@ -29,9 +25,5 @@ WS=21
|
|||
'('=8
|
||||
')'=9
|
||||
','=10
|
||||
'int'=11
|
||||
'float'=12
|
||||
'bool'=13
|
||||
'string'=14
|
||||
'True'=15
|
||||
'False'=16
|
||||
'True'=11
|
||||
'False'=12
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -10,75 +10,65 @@ else:
|
|||
|
||||
def serializedATN():
|
||||
return [
|
||||
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,
|
||||
4,0,17,164,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,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
|
||||
13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,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,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,10,1,11,1,11,1,11,1,11,1,11,1,11,1,12,1,
|
||||
12,5,12,104,8,12,10,12,12,12,107,9,12,1,13,3,13,110,8,13,1,13,1,
|
||||
13,5,13,114,8,13,10,13,12,13,117,9,13,1,13,3,13,120,8,13,1,14,4,
|
||||
14,123,8,14,11,14,12,14,124,1,14,1,14,5,14,129,8,14,10,14,12,14,
|
||||
132,9,14,1,14,1,14,4,14,136,8,14,11,14,12,14,137,3,14,140,8,14,1,
|
||||
15,1,15,1,15,1,15,5,15,146,8,15,10,15,12,15,149,9,15,1,15,3,15,152,
|
||||
8,15,1,15,1,15,1,15,1,15,1,16,4,16,159,8,16,11,16,12,16,160,1,16,
|
||||
1,16,1,147,0,17,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,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,174,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,1,35,1,0,0,0,3,37,1,0,0,0,5,46,
|
||||
1,0,0,0,7,55,1,0,0,0,9,64,1,0,0,0,11,74,1,0,0,0,13,79,1,0,0,0,15,
|
||||
84,1,0,0,0,17,86,1,0,0,0,19,88,1,0,0,0,21,90,1,0,0,0,23,95,1,0,0,
|
||||
0,25,101,1,0,0,0,27,119,1,0,0,0,29,139,1,0,0,0,31,141,1,0,0,0,33,
|
||||
158,1,0,0,0,35,36,5,58,0,0,36,2,1,0,0,0,37,38,5,115,0,0,38,39,5,
|
||||
101,0,0,39,40,5,113,0,0,40,41,5,117,0,0,41,42,5,101,0,0,42,43,5,
|
||||
110,0,0,43,44,5,99,0,0,44,45,5,101,0,0,45,4,1,0,0,0,46,47,5,115,
|
||||
0,0,47,48,5,101,0,0,48,49,5,108,0,0,49,50,5,101,0,0,50,51,5,99,0,
|
||||
0,51,52,5,116,0,0,52,53,5,111,0,0,53,54,5,114,0,0,54,6,1,0,0,0,55,
|
||||
56,5,112,0,0,56,57,5,97,0,0,57,58,5,114,0,0,58,59,5,97,0,0,59,60,
|
||||
5,108,0,0,60,61,5,108,0,0,61,62,5,101,0,0,62,63,5,108,0,0,63,8,1,
|
||||
0,0,0,64,65,5,100,0,0,65,66,5,101,0,0,66,67,5,99,0,0,67,68,5,111,
|
||||
0,0,68,69,5,114,0,0,69,70,5,97,0,0,70,71,5,116,0,0,71,72,5,111,0,
|
||||
0,72,73,5,114,0,0,73,10,1,0,0,0,74,75,5,116,0,0,75,76,5,97,0,0,76,
|
||||
77,5,115,0,0,77,78,5,107,0,0,78,12,1,0,0,0,79,80,5,99,0,0,80,81,
|
||||
5,111,0,0,81,82,5,110,0,0,82,83,5,100,0,0,83,14,1,0,0,0,84,85,5,
|
||||
40,0,0,85,16,1,0,0,0,86,87,5,41,0,0,87,18,1,0,0,0,88,89,5,44,0,0,
|
||||
89,20,1,0,0,0,90,91,5,84,0,0,91,92,5,114,0,0,92,93,5,117,0,0,93,
|
||||
94,5,101,0,0,94,22,1,0,0,0,95,96,5,70,0,0,96,97,5,97,0,0,97,98,5,
|
||||
108,0,0,98,99,5,115,0,0,99,100,5,101,0,0,100,24,1,0,0,0,101,105,
|
||||
7,0,0,0,102,104,7,1,0,0,103,102,1,0,0,0,104,107,1,0,0,0,105,103,
|
||||
1,0,0,0,105,106,1,0,0,0,106,26,1,0,0,0,107,105,1,0,0,0,108,110,5,
|
||||
45,0,0,109,108,1,0,0,0,109,110,1,0,0,0,110,111,1,0,0,0,111,115,7,
|
||||
2,0,0,112,114,7,3,0,0,113,112,1,0,0,0,114,117,1,0,0,0,115,113,1,
|
||||
0,0,0,115,116,1,0,0,0,116,120,1,0,0,0,117,115,1,0,0,0,118,120,5,
|
||||
48,0,0,119,109,1,0,0,0,119,118,1,0,0,0,120,28,1,0,0,0,121,123,7,
|
||||
3,0,0,122,121,1,0,0,0,123,124,1,0,0,0,124,122,1,0,0,0,124,125,1,
|
||||
0,0,0,125,126,1,0,0,0,126,130,5,46,0,0,127,129,7,3,0,0,128,127,1,
|
||||
0,0,0,129,132,1,0,0,0,130,128,1,0,0,0,130,131,1,0,0,0,131,140,1,
|
||||
0,0,0,132,130,1,0,0,0,133,135,5,46,0,0,134,136,7,3,0,0,135,134,1,
|
||||
0,0,0,136,137,1,0,0,0,137,135,1,0,0,0,137,138,1,0,0,0,138,140,1,
|
||||
0,0,0,139,122,1,0,0,0,139,133,1,0,0,0,140,30,1,0,0,0,141,142,5,47,
|
||||
0,0,142,143,5,47,0,0,143,147,1,0,0,0,144,146,9,0,0,0,145,144,1,0,
|
||||
0,0,146,149,1,0,0,0,147,148,1,0,0,0,147,145,1,0,0,0,148,151,1,0,
|
||||
0,0,149,147,1,0,0,0,150,152,5,13,0,0,151,150,1,0,0,0,151,152,1,0,
|
||||
0,0,152,153,1,0,0,0,153,154,5,10,0,0,154,155,1,0,0,0,155,156,6,15,
|
||||
0,0,156,32,1,0,0,0,157,159,7,4,0,0,158,157,1,0,0,0,159,160,1,0,0,
|
||||
0,160,158,1,0,0,0,160,161,1,0,0,0,161,162,1,0,0,0,162,163,6,16,0,
|
||||
0,163,34,1,0,0,0,12,0,105,109,115,119,124,130,137,139,147,151,160,
|
||||
1,6,0,0
|
||||
]
|
||||
|
||||
class ptmlLexer(Lexer):
|
||||
|
@ -99,15 +89,11 @@ class ptmlLexer(Lexer):
|
|||
T__9 = 10
|
||||
T__10 = 11
|
||||
T__11 = 12
|
||||
T__12 = 13
|
||||
T__13 = 14
|
||||
T__14 = 15
|
||||
T__15 = 16
|
||||
Names = 17
|
||||
Integer = 18
|
||||
Float = 19
|
||||
LINE_COMMENT = 20
|
||||
WS = 21
|
||||
Names = 13
|
||||
Integer = 14
|
||||
Float = 15
|
||||
LINE_COMMENT = 16
|
||||
WS = 17
|
||||
|
||||
channelNames = [ u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN" ]
|
||||
|
||||
|
@ -115,16 +101,14 @@ class ptmlLexer(Lexer):
|
|||
|
||||
literalNames = [ "<INVALID>",
|
||||
"':'", "'sequence'", "'selector'", "'parallel'", "'decorator'",
|
||||
"'task'", "'cond'", "'('", "')'", "','", "'int'", "'float'",
|
||||
"'bool'", "'string'", "'True'", "'False'" ]
|
||||
"'task'", "'cond'", "'('", "')'", "','", "'True'", "'False'" ]
|
||||
|
||||
symbolicNames = [ "<INVALID>",
|
||||
"Names", "Integer", "Float", "LINE_COMMENT", "WS" ]
|
||||
|
||||
ruleNames = [ "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6",
|
||||
"T__7", "T__8", "T__9", "T__10", "T__11", "T__12", "T__13",
|
||||
"T__14", "T__15", "Names", "Integer", "Float", "LINE_COMMENT",
|
||||
"WS" ]
|
||||
"T__7", "T__8", "T__9", "T__10", "T__11", "Names", "Integer",
|
||||
"Float", "LINE_COMMENT", "WS" ]
|
||||
|
||||
grammarFileName = "ptml.g4"
|
||||
|
||||
|
|
|
@ -10,15 +10,11 @@ T__8=9
|
|||
T__9=10
|
||||
T__10=11
|
||||
T__11=12
|
||||
T__12=13
|
||||
T__13=14
|
||||
T__14=15
|
||||
T__15=16
|
||||
Names=17
|
||||
Integer=18
|
||||
Float=19
|
||||
LINE_COMMENT=20
|
||||
WS=21
|
||||
Names=13
|
||||
Integer=14
|
||||
Float=15
|
||||
LINE_COMMENT=16
|
||||
WS=17
|
||||
':'=1
|
||||
'sequence'=2
|
||||
'selector'=3
|
||||
|
@ -29,9 +25,5 @@ WS=21
|
|||
'('=8
|
||||
')'=9
|
||||
','=10
|
||||
'int'=11
|
||||
'float'=12
|
||||
'bool'=13
|
||||
'string'=14
|
||||
'True'=15
|
||||
'False'=16
|
||||
'True'=11
|
||||
'False'=12
|
||||
|
|
|
@ -53,24 +53,6 @@ class ptmlListener(ParseTreeListener):
|
|||
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
|
||||
|
|
|
@ -10,30 +10,26 @@ else:
|
|||
|
||||
def serializedATN():
|
||||
return [
|
||||
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
|
||||
4,1,17,61,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,1,0,4,
|
||||
0,14,8,0,11,0,12,0,15,1,0,1,0,1,1,1,1,1,1,1,1,4,1,24,8,1,11,1,12,
|
||||
1,25,1,2,1,2,1,2,1,2,1,2,3,2,33,8,2,1,3,1,3,1,3,1,3,3,3,39,8,3,1,
|
||||
3,1,3,1,4,1,4,1,4,3,4,46,8,4,1,4,1,4,1,4,1,4,3,4,52,8,4,5,4,54,8,
|
||||
4,10,4,12,4,57,9,4,1,5,1,5,1,5,0,0,6,0,2,4,6,8,10,0,2,1,0,6,7,1,
|
||||
0,11,12,66,0,13,1,0,0,0,2,19,1,0,0,0,4,32,1,0,0,0,6,34,1,0,0,0,8,
|
||||
45,1,0,0,0,10,58,1,0,0,0,12,14,3,2,1,0,13,12,1,0,0,0,14,15,1,0,0,
|
||||
0,15,13,1,0,0,0,15,16,1,0,0,0,16,17,1,0,0,0,17,18,5,0,0,1,18,1,1,
|
||||
0,0,0,19,20,3,4,2,0,20,23,5,1,0,0,21,24,3,6,3,0,22,24,3,2,1,0,23,
|
||||
21,1,0,0,0,23,22,1,0,0,0,24,25,1,0,0,0,25,23,1,0,0,0,25,26,1,0,0,
|
||||
0,26,3,1,0,0,0,27,33,5,2,0,0,28,33,5,3,0,0,29,30,5,4,0,0,30,33,5,
|
||||
14,0,0,31,33,5,5,0,0,32,27,1,0,0,0,32,28,1,0,0,0,32,29,1,0,0,0,32,
|
||||
31,1,0,0,0,33,5,1,0,0,0,34,35,7,0,0,0,35,36,5,13,0,0,36,38,5,8,0,
|
||||
0,37,39,3,8,4,0,38,37,1,0,0,0,38,39,1,0,0,0,39,40,1,0,0,0,40,41,
|
||||
5,9,0,0,41,7,1,0,0,0,42,46,5,14,0,0,43,46,5,15,0,0,44,46,3,10,5,
|
||||
0,45,42,1,0,0,0,45,43,1,0,0,0,45,44,1,0,0,0,46,55,1,0,0,0,47,51,
|
||||
5,10,0,0,48,52,5,14,0,0,49,52,5,15,0,0,50,52,3,10,5,0,51,48,1,0,
|
||||
0,0,51,49,1,0,0,0,51,50,1,0,0,0,52,54,1,0,0,0,53,47,1,0,0,0,54,57,
|
||||
1,0,0,0,55,53,1,0,0,0,55,56,1,0,0,0,56,9,1,0,0,0,57,55,1,0,0,0,58,
|
||||
59,7,1,0,0,59,11,1,0,0,0,8,15,23,25,32,38,45,51,55
|
||||
]
|
||||
|
||||
class ptmlParser ( Parser ):
|
||||
|
@ -48,11 +44,9 @@ class ptmlParser ( Parser ):
|
|||
|
||||
literalNames = [ "<INVALID>", "':'", "'sequence'", "'selector'", "'parallel'",
|
||||
"'decorator'", "'task'", "'cond'", "'('", "')'", "','",
|
||||
"'int'", "'float'", "'bool'", "'string'", "'True'",
|
||||
"'False'" ]
|
||||
"'True'", "'False'" ]
|
||||
|
||||
symbolicNames = [ "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
|
||||
"<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
|
||||
"<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
|
||||
"<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
|
||||
"<INVALID>", "Names", "Integer", "Float", "LINE_COMMENT",
|
||||
|
@ -63,12 +57,10 @@ class ptmlParser ( Parser ):
|
|||
RULE_internal_node = 2
|
||||
RULE_action_sign = 3
|
||||
RULE_action_parm = 4
|
||||
RULE_var_decls = 5
|
||||
RULE_var_type = 6
|
||||
RULE_boolean = 7
|
||||
RULE_boolean = 5
|
||||
|
||||
ruleNames = [ "root", "tree", "internal_node", "action_sign", "action_parm",
|
||||
"var_decls", "var_type", "boolean" ]
|
||||
"boolean" ]
|
||||
|
||||
EOF = Token.EOF
|
||||
T__0=1
|
||||
|
@ -83,15 +75,11 @@ class ptmlParser ( Parser ):
|
|||
T__9=10
|
||||
T__10=11
|
||||
T__11=12
|
||||
T__12=13
|
||||
T__13=14
|
||||
T__14=15
|
||||
T__15=16
|
||||
Names=17
|
||||
Integer=18
|
||||
Float=19
|
||||
LINE_COMMENT=20
|
||||
WS=21
|
||||
Names=13
|
||||
Integer=14
|
||||
Float=15
|
||||
LINE_COMMENT=16
|
||||
WS=17
|
||||
|
||||
def __init__(self, input:TokenStream, output:TextIO = sys.stdout):
|
||||
super().__init__(input, output)
|
||||
|
@ -140,19 +128,19 @@ class ptmlParser ( Parser ):
|
|||
self._la = 0 # Token type
|
||||
try:
|
||||
self.enterOuterAlt(localctx, 1)
|
||||
self.state = 17
|
||||
self.state = 13
|
||||
self._errHandler.sync(self)
|
||||
_la = self._input.LA(1)
|
||||
while True:
|
||||
self.state = 16
|
||||
self.state = 12
|
||||
self.tree()
|
||||
self.state = 19
|
||||
self.state = 15
|
||||
self._errHandler.sync(self)
|
||||
_la = self._input.LA(1)
|
||||
if not ((((_la) & ~0x3f) == 0 and ((1 << _la) & 60) != 0)):
|
||||
break
|
||||
|
||||
self.state = 21
|
||||
self.state = 17
|
||||
self.match(ptmlParser.EOF)
|
||||
except RecognitionException as re:
|
||||
localctx.exception = re
|
||||
|
@ -208,24 +196,24 @@ class ptmlParser ( Parser ):
|
|||
self.enterRule(localctx, 2, self.RULE_tree)
|
||||
try:
|
||||
self.enterOuterAlt(localctx, 1)
|
||||
self.state = 23
|
||||
self.state = 19
|
||||
self.internal_node()
|
||||
self.state = 24
|
||||
self.state = 20
|
||||
self.match(ptmlParser.T__0)
|
||||
self.state = 27
|
||||
self.state = 23
|
||||
self._errHandler.sync(self)
|
||||
_alt = 1
|
||||
while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
|
||||
if _alt == 1:
|
||||
self.state = 27
|
||||
self.state = 23
|
||||
self._errHandler.sync(self)
|
||||
token = self._input.LA(1)
|
||||
if token in [6, 7]:
|
||||
self.state = 25
|
||||
self.state = 21
|
||||
self.action_sign()
|
||||
pass
|
||||
elif token in [2, 3, 4, 5]:
|
||||
self.state = 26
|
||||
self.state = 22
|
||||
self.tree()
|
||||
pass
|
||||
else:
|
||||
|
@ -234,7 +222,7 @@ class ptmlParser ( Parser ):
|
|||
|
||||
else:
|
||||
raise NoViableAltException(self)
|
||||
self.state = 29
|
||||
self.state = 25
|
||||
self._errHandler.sync(self)
|
||||
_alt = self._interp.adaptivePredict(self._input,2,self._ctx)
|
||||
|
||||
|
@ -276,29 +264,29 @@ class ptmlParser ( Parser ):
|
|||
localctx = ptmlParser.Internal_nodeContext(self, self._ctx, self.state)
|
||||
self.enterRule(localctx, 4, self.RULE_internal_node)
|
||||
try:
|
||||
self.state = 36
|
||||
self.state = 32
|
||||
self._errHandler.sync(self)
|
||||
token = self._input.LA(1)
|
||||
if token in [2]:
|
||||
self.enterOuterAlt(localctx, 1)
|
||||
self.state = 31
|
||||
self.state = 27
|
||||
self.match(ptmlParser.T__1)
|
||||
pass
|
||||
elif token in [3]:
|
||||
self.enterOuterAlt(localctx, 2)
|
||||
self.state = 32
|
||||
self.state = 28
|
||||
self.match(ptmlParser.T__2)
|
||||
pass
|
||||
elif token in [4]:
|
||||
self.enterOuterAlt(localctx, 3)
|
||||
self.state = 33
|
||||
self.state = 29
|
||||
self.match(ptmlParser.T__3)
|
||||
self.state = 34
|
||||
self.state = 30
|
||||
self.match(ptmlParser.Integer)
|
||||
pass
|
||||
elif token in [5]:
|
||||
self.enterOuterAlt(localctx, 4)
|
||||
self.state = 35
|
||||
self.state = 31
|
||||
self.match(ptmlParser.T__4)
|
||||
pass
|
||||
else:
|
||||
|
@ -348,26 +336,26 @@ class ptmlParser ( Parser ):
|
|||
self._la = 0 # Token type
|
||||
try:
|
||||
self.enterOuterAlt(localctx, 1)
|
||||
self.state = 38
|
||||
self.state = 34
|
||||
_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 = 39
|
||||
self.state = 35
|
||||
self.match(ptmlParser.Names)
|
||||
self.state = 40
|
||||
self.state = 36
|
||||
self.match(ptmlParser.T__7)
|
||||
self.state = 42
|
||||
self.state = 38
|
||||
self._errHandler.sync(self)
|
||||
_la = self._input.LA(1)
|
||||
if (((_la) & ~0x3f) == 0 and ((1 << _la) & 915456) != 0):
|
||||
self.state = 41
|
||||
if (((_la) & ~0x3f) == 0 and ((1 << _la) & 55296) != 0):
|
||||
self.state = 37
|
||||
self.action_parm()
|
||||
|
||||
|
||||
self.state = 44
|
||||
self.state = 40
|
||||
self.match(ptmlParser.T__8)
|
||||
except RecognitionException as re:
|
||||
localctx.exception = re
|
||||
|
@ -385,13 +373,6 @@ class ptmlParser ( Parser ):
|
|||
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)
|
||||
|
@ -432,57 +413,49 @@ class ptmlParser ( Parser ):
|
|||
self._la = 0 # Token type
|
||||
try:
|
||||
self.enterOuterAlt(localctx, 1)
|
||||
self.state = 50
|
||||
self.state = 45
|
||||
self._errHandler.sync(self)
|
||||
token = self._input.LA(1)
|
||||
if token in [11, 12, 13, 14]:
|
||||
self.state = 46
|
||||
self.var_decls()
|
||||
pass
|
||||
elif token in [18]:
|
||||
self.state = 47
|
||||
if token in [14]:
|
||||
self.state = 42
|
||||
self.match(ptmlParser.Integer)
|
||||
pass
|
||||
elif token in [19]:
|
||||
self.state = 48
|
||||
elif token in [15]:
|
||||
self.state = 43
|
||||
self.match(ptmlParser.Float)
|
||||
pass
|
||||
elif token in [15, 16]:
|
||||
self.state = 49
|
||||
elif token in [11, 12]:
|
||||
self.state = 44
|
||||
self.boolean()
|
||||
pass
|
||||
else:
|
||||
raise NoViableAltException(self)
|
||||
|
||||
self.state = 61
|
||||
self.state = 55
|
||||
self._errHandler.sync(self)
|
||||
_la = self._input.LA(1)
|
||||
while _la==10:
|
||||
self.state = 52
|
||||
self.state = 47
|
||||
self.match(ptmlParser.T__9)
|
||||
self.state = 57
|
||||
self.state = 51
|
||||
self._errHandler.sync(self)
|
||||
token = self._input.LA(1)
|
||||
if token in [11, 12, 13, 14]:
|
||||
self.state = 53
|
||||
self.var_decls()
|
||||
pass
|
||||
elif token in [18]:
|
||||
self.state = 54
|
||||
if token in [14]:
|
||||
self.state = 48
|
||||
self.match(ptmlParser.Integer)
|
||||
pass
|
||||
elif token in [19]:
|
||||
self.state = 55
|
||||
elif token in [15]:
|
||||
self.state = 49
|
||||
self.match(ptmlParser.Float)
|
||||
pass
|
||||
elif token in [15, 16]:
|
||||
self.state = 56
|
||||
elif token in [11, 12]:
|
||||
self.state = 50
|
||||
self.boolean()
|
||||
pass
|
||||
else:
|
||||
raise NoViableAltException(self)
|
||||
|
||||
self.state = 63
|
||||
self.state = 57
|
||||
self._errHandler.sync(self)
|
||||
_la = self._input.LA(1)
|
||||
|
||||
|
@ -495,98 +468,6 @@ class ptmlParser ( Parser ):
|
|||
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, 10, self.RULE_var_decls)
|
||||
try:
|
||||
self.enterOuterAlt(localctx, 1)
|
||||
self.state = 64
|
||||
self.var_type()
|
||||
self.state = 65
|
||||
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, 12, self.RULE_var_type)
|
||||
self._la = 0 # Token type
|
||||
try:
|
||||
self.enterOuterAlt(localctx, 1)
|
||||
self.state = 67
|
||||
_la = self._input.LA(1)
|
||||
if not((((_la) & ~0x3f) == 0 and ((1 << _la) & 30720) != 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'
|
||||
|
||||
|
@ -612,13 +493,13 @@ class ptmlParser ( Parser ):
|
|||
def boolean(self):
|
||||
|
||||
localctx = ptmlParser.BooleanContext(self, self._ctx, self.state)
|
||||
self.enterRule(localctx, 14, self.RULE_boolean)
|
||||
self.enterRule(localctx, 10, self.RULE_boolean)
|
||||
self._la = 0 # Token type
|
||||
try:
|
||||
self.enterOuterAlt(localctx, 1)
|
||||
self.state = 69
|
||||
self.state = 58
|
||||
_la = self._input.LA(1)
|
||||
if not(_la==15 or _la==16):
|
||||
if not(_la==11 or _la==12):
|
||||
self._errHandler.recoverInline(self)
|
||||
else:
|
||||
self._errHandler.reportMatch(self)
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import os
|
||||
import sys
|
||||
import uuid
|
||||
|
||||
project_path = "/home/wu/RoboWaiter/ptml"
|
||||
sys.path.append(project_path)
|
||||
|
||||
|
@ -41,8 +43,19 @@ class ptmlTranslator(ptmlListener):
|
|||
|
||||
# Enter a parse tree produced by ptmlParser#internal_node.
|
||||
def enterInternal_node(self, ctx:ptmlParser.Internal_nodeContext):
|
||||
|
||||
tag = str(uuid.uuid4())
|
||||
self.stack.append(tag)
|
||||
|
||||
type = str(ctx.children[0])
|
||||
print(type)
|
||||
if type == 'sequence':
|
||||
self.api.newSequenceNode(tag)
|
||||
elif type == 'selector':
|
||||
self.api.newSelectorNode(tag)
|
||||
elif type == 'parallel':
|
||||
self.api.newParallelNode(tag, threshold=int(ctx.children[1]))
|
||||
elif type == 'decorator':
|
||||
self.api.newDecoratorNode(tag)
|
||||
|
||||
# Exit a parse tree produced by ptmlParser#internal_node.
|
||||
def exitInternal_node(self, ctx:ptmlParser.Internal_nodeContext):
|
||||
|
@ -51,7 +64,20 @@ class ptmlTranslator(ptmlListener):
|
|||
|
||||
# Enter a parse tree produced by ptmlParser#action_sign.
|
||||
def enterAction_sign(self, ctx:ptmlParser.Action_signContext):
|
||||
pass
|
||||
# cond / task
|
||||
type = str(ctx.children[0])
|
||||
name = str(ctx.Names())
|
||||
|
||||
if len(ctx.children) > 4:
|
||||
# have params
|
||||
args = ctx.action_parm()
|
||||
|
||||
if type == 'cond':
|
||||
self.api.newBehaviourNode(name, cond=True)
|
||||
else:
|
||||
self.api.newBehaviourNode(name, cond=False)
|
||||
|
||||
|
||||
|
||||
# Exit a parse tree produced by ptmlParser#action_sign.
|
||||
def exitAction_sign(self, ctx:ptmlParser.Action_signContext):
|
||||
|
|
Loading…
Reference in New Issue