修正not

This commit is contained in:
wuziji 2024-01-09 20:35:49 +08:00
parent 0f2e1d0ea2
commit 7ad8ef01ab
8 changed files with 39 additions and 39 deletions

View File

@ -4,7 +4,7 @@ root : tree+ EOF;
tree : internal_node '{' (action_sign|tree)* '}' ;
internal_node : 'sequence' | 'selector' | 'parallel' Integer ;
action_sign : 'not'? ('act'|'cond') String '(' action_parm? ')';
action_sign : ('act'|'cond') 'Not'? String '(' action_parm? ')';
action_parm : (Integer|Float|boolean|String) (',' (Integer|Float|boolean|String))* ;
// var_decls : var_type Names ;
// var_type : 'int' | 'float' | 'bool' | 'string' ;

View File

@ -5,9 +5,9 @@ null
'sequence'
'selector'
'parallel'
'not'
'act'
'cond'
'Not'
'('
')'
','
@ -50,4 +50,4 @@ boolean
atn:
[4, 1, 18, 68, 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, 5, 1, 24, 8, 1, 10, 1, 12, 1, 27, 9, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 3, 2, 35, 8, 2, 1, 3, 3, 3, 38, 8, 3, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 44, 8, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 3, 4, 52, 8, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 3, 4, 59, 8, 4, 5, 4, 61, 8, 4, 10, 4, 12, 4, 64, 9, 4, 1, 5, 1, 5, 1, 5, 0, 0, 6, 0, 2, 4, 6, 8, 10, 0, 2, 1, 0, 7, 8, 1, 0, 12, 13, 75, 0, 13, 1, 0, 0, 0, 2, 19, 1, 0, 0, 0, 4, 34, 1, 0, 0, 0, 6, 37, 1, 0, 0, 0, 8, 51, 1, 0, 0, 0, 10, 65, 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, 25, 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, 27, 1, 0, 0, 0, 25, 23, 1, 0, 0, 0, 25, 26, 1, 0, 0, 0, 26, 28, 1, 0, 0, 0, 27, 25, 1, 0, 0, 0, 28, 29, 5, 2, 0, 0, 29, 3, 1, 0, 0, 0, 30, 35, 5, 3, 0, 0, 31, 35, 5, 4, 0, 0, 32, 33, 5, 5, 0, 0, 33, 35, 5, 15, 0, 0, 34, 30, 1, 0, 0, 0, 34, 31, 1, 0, 0, 0, 34, 32, 1, 0, 0, 0, 35, 5, 1, 0, 0, 0, 36, 38, 5, 6, 0, 0, 37, 36, 1, 0, 0, 0, 37, 38, 1, 0, 0, 0, 38, 39, 1, 0, 0, 0, 39, 40, 7, 0, 0, 0, 40, 41, 5, 14, 0, 0, 41, 43, 5, 9, 0, 0, 42, 44, 3, 8, 4, 0, 43, 42, 1, 0, 0, 0, 43, 44, 1, 0, 0, 0, 44, 45, 1, 0, 0, 0, 45, 46, 5, 10, 0, 0, 46, 7, 1, 0, 0, 0, 47, 52, 5, 15, 0, 0, 48, 52, 5, 16, 0, 0, 49, 52, 3, 10, 5, 0, 50, 52, 5, 14, 0, 0, 51, 47, 1, 0, 0, 0, 51, 48, 1, 0, 0, 0, 51, 49, 1, 0, 0, 0, 51, 50, 1, 0, 0, 0, 52, 62, 1, 0, 0, 0, 53, 58, 5, 11, 0, 0, 54, 59, 5, 15, 0, 0, 55, 59, 5, 16, 0, 0, 56, 59, 3, 10, 5, 0, 57, 59, 5, 14, 0, 0, 58, 54, 1, 0, 0, 0, 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2, 0, 20, 25, 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, 27, 1, 0, 0, 0, 25, 23, 1, 0, 0, 0, 25, 26, 1, 0, 0, 0, 26, 28, 1, 0, 0, 0, 27, 25, 1, 0, 0, 0, 28, 29, 5, 2, 0, 0, 29, 3, 1, 0, 0, 0, 30, 35, 5, 3, 0, 0, 31, 35, 5, 4, 0, 0, 32, 33, 5, 5, 0, 0, 33, 35, 5, 15, 0, 0, 34, 30, 1, 0, 0, 0, 34, 31, 1, 0, 0, 0, 34, 32, 1, 0, 0, 0, 35, 5, 1, 0, 0, 0, 36, 38, 7, 0, 0, 0, 37, 39, 5, 8, 0, 0, 38, 37, 1, 0, 0, 0, 38, 39, 1, 0, 0, 0, 39, 40, 1, 0, 0, 0, 40, 41, 5, 14, 0, 0, 41, 43, 5, 9, 0, 0, 42, 44, 3, 8, 4, 0, 43, 42, 1, 0, 0, 0, 43, 44, 1, 0, 0, 0, 44, 45, 1, 0, 0, 0, 45, 46, 5, 10, 0, 0, 46, 7, 1, 0, 0, 0, 47, 52, 5, 15, 0, 0, 48, 52, 5, 16, 0, 0, 49, 52, 3, 10, 5, 0, 50, 52, 5, 14, 0, 0, 51, 47, 1, 0, 0, 0, 51, 48, 1, 0, 0, 0, 51, 49, 1, 0, 0, 0, 51, 50, 1, 0, 0, 0, 52, 62, 1, 0, 0, 0, 53, 58, 5, 11, 0, 0, 54, 59, 5, 15, 0, 0, 55, 59, 5, 16, 0, 0, 56, 59, 3, 10, 5, 0, 57, 59, 5, 14, 0, 0, 58, 54, 1, 0, 0, 0, 58, 55, 1, 0, 0, 0, 58, 56, 1, 0, 0, 0, 58, 57, 1, 0, 0, 0, 59, 61, 1, 0, 0, 0, 60, 53, 1, 0, 0, 0, 61, 64, 1, 0, 0, 0, 62, 60, 1, 0, 0, 0, 62, 63, 1, 0, 0, 0, 63, 9, 1, 0, 0, 0, 64, 62, 1, 0, 0, 0, 65, 66, 7, 1, 0, 0, 66, 11, 1, 0, 0, 0, 9, 15, 23, 25, 34, 38, 43, 51, 58, 62]

View File

@ -21,9 +21,9 @@ WS=18
'sequence'=3
'selector'=4
'parallel'=5
'not'=6
'act'=7
'cond'=8
'act'=6
'cond'=7
'Not'=8
'('=9
')'=10
','=11

File diff suppressed because one or more lines are too long

View File

@ -15,7 +15,7 @@ def serializedATN():
13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,1,0,1,0,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,5,1,5,1,5,1,5,1,6,
1,6,1,6,1,6,1,7,1,7,1,7,1,7,1,7,1,8,1,8,1,9,1,9,1,10,1,10,1,11,1,
1,6,1,6,1,6,1,6,1,7,1,7,1,7,1,7,1,8,1,8,1,9,1,9,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,13,1,13,5,13,101,
8,13,10,13,12,13,104,9,13,1,14,3,14,107,8,14,1,14,1,14,5,14,111,
8,14,10,14,12,14,114,9,14,1,14,3,14,117,8,14,1,15,4,15,120,8,15,
@ -31,7 +31,7 @@ def serializedATN():
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,1,37,1,0,0,0,3,39,1,0,0,
0,5,41,1,0,0,0,7,50,1,0,0,0,9,59,1,0,0,0,11,68,1,0,0,0,13,72,1,0,
0,0,15,76,1,0,0,0,17,81,1,0,0,0,19,83,1,0,0,0,21,85,1,0,0,0,23,87,
0,0,15,77,1,0,0,0,17,81,1,0,0,0,19,83,1,0,0,0,21,85,1,0,0,0,23,87,
1,0,0,0,25,92,1,0,0,0,27,98,1,0,0,0,29,116,1,0,0,0,31,136,1,0,0,
0,33,138,1,0,0,0,35,155,1,0,0,0,37,38,5,123,0,0,38,2,1,0,0,0,39,
40,5,125,0,0,40,4,1,0,0,0,41,42,5,115,0,0,42,43,5,101,0,0,43,44,
@ -41,9 +41,9 @@ def serializedATN():
0,56,57,5,111,0,0,57,58,5,114,0,0,58,8,1,0,0,0,59,60,5,112,0,0,60,
61,5,97,0,0,61,62,5,114,0,0,62,63,5,97,0,0,63,64,5,108,0,0,64,65,
5,108,0,0,65,66,5,101,0,0,66,67,5,108,0,0,67,10,1,0,0,0,68,69,5,
110,0,0,69,70,5,111,0,0,70,71,5,116,0,0,71,12,1,0,0,0,72,73,5,97,
0,0,73,74,5,99,0,0,74,75,5,116,0,0,75,14,1,0,0,0,76,77,5,99,0,0,
77,78,5,111,0,0,78,79,5,110,0,0,79,80,5,100,0,0,80,16,1,0,0,0,81,
97,0,0,69,70,5,99,0,0,70,71,5,116,0,0,71,12,1,0,0,0,72,73,5,99,0,
0,73,74,5,111,0,0,74,75,5,110,0,0,75,76,5,100,0,0,76,14,1,0,0,0,
77,78,5,78,0,0,78,79,5,111,0,0,79,80,5,116,0,0,80,16,1,0,0,0,81,
82,5,40,0,0,82,18,1,0,0,0,83,84,5,41,0,0,84,20,1,0,0,0,85,86,5,44,
0,0,86,22,1,0,0,0,87,88,5,84,0,0,88,89,5,114,0,0,89,90,5,117,0,0,
90,91,5,101,0,0,91,24,1,0,0,0,92,93,5,70,0,0,93,94,5,97,0,0,94,95,
@ -100,8 +100,8 @@ class ptmlLexer(Lexer):
modeNames = [ "DEFAULT_MODE" ]
literalNames = [ "<INVALID>",
"'{'", "'}'", "'sequence'", "'selector'", "'parallel'", "'not'",
"'act'", "'cond'", "'('", "')'", "','", "'True'", "'False'" ]
"'{'", "'}'", "'sequence'", "'selector'", "'parallel'", "'act'",
"'cond'", "'Not'", "'('", "')'", "','", "'True'", "'False'" ]
symbolicNames = [ "<INVALID>",
"String", "Integer", "Float", "LINE_COMMENT", "WS" ]

View File

@ -21,9 +21,9 @@ WS=18
'sequence'=3
'selector'=4
'parallel'=5
'not'=6
'act'=7
'cond'=8
'act'=6
'cond'=7
'Not'=8
'('=9
')'=10
','=11

View File

@ -12,19 +12,19 @@ def serializedATN():
return [
4,1,18,68,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,5,1,24,8,1,10,1,12,
1,27,9,1,1,1,1,1,1,2,1,2,1,2,1,2,3,2,35,8,2,1,3,3,3,38,8,3,1,3,1,
1,27,9,1,1,1,1,1,1,2,1,2,1,2,1,2,3,2,35,8,2,1,3,1,3,3,3,39,8,3,1,
3,1,3,1,3,3,3,44,8,3,1,3,1,3,1,4,1,4,1,4,1,4,3,4,52,8,4,1,4,1,4,
1,4,1,4,1,4,3,4,59,8,4,5,4,61,8,4,10,4,12,4,64,9,4,1,5,1,5,1,5,0,
0,6,0,2,4,6,8,10,0,2,1,0,7,8,1,0,12,13,75,0,13,1,0,0,0,2,19,1,0,
0,0,4,34,1,0,0,0,6,37,1,0,0,0,8,51,1,0,0,0,10,65,1,0,0,0,12,14,3,
0,6,0,2,4,6,8,10,0,2,1,0,6,7,1,0,12,13,75,0,13,1,0,0,0,2,19,1,0,
0,0,4,34,1,0,0,0,6,36,1,0,0,0,8,51,1,0,0,0,10,65,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,25,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,27,
1,0,0,0,25,23,1,0,0,0,25,26,1,0,0,0,26,28,1,0,0,0,27,25,1,0,0,0,
28,29,5,2,0,0,29,3,1,0,0,0,30,35,5,3,0,0,31,35,5,4,0,0,32,33,5,5,
0,0,33,35,5,15,0,0,34,30,1,0,0,0,34,31,1,0,0,0,34,32,1,0,0,0,35,
5,1,0,0,0,36,38,5,6,0,0,37,36,1,0,0,0,37,38,1,0,0,0,38,39,1,0,0,
0,39,40,7,0,0,0,40,41,5,14,0,0,41,43,5,9,0,0,42,44,3,8,4,0,43,42,
5,1,0,0,0,36,38,7,0,0,0,37,39,5,8,0,0,38,37,1,0,0,0,38,39,1,0,0,
0,39,40,1,0,0,0,40,41,5,14,0,0,41,43,5,9,0,0,42,44,3,8,4,0,43,42,
1,0,0,0,43,44,1,0,0,0,44,45,1,0,0,0,45,46,5,10,0,0,46,7,1,0,0,0,
47,52,5,15,0,0,48,52,5,16,0,0,49,52,3,10,5,0,50,52,5,14,0,0,51,47,
1,0,0,0,51,48,1,0,0,0,51,49,1,0,0,0,51,50,1,0,0,0,52,62,1,0,0,0,
@ -32,7 +32,7 @@ def serializedATN():
5,14,0,0,58,54,1,0,0,0,58,55,1,0,0,0,58,56,1,0,0,0,58,57,1,0,0,0,
59,61,1,0,0,0,60,53,1,0,0,0,61,64,1,0,0,0,62,60,1,0,0,0,62,63,1,
0,0,0,63,9,1,0,0,0,64,62,1,0,0,0,65,66,7,1,0,0,66,11,1,0,0,0,9,15,
23,25,34,37,43,51,58,62
23,25,34,38,43,51,58,62
]
class ptmlParser ( Parser ):
@ -46,7 +46,7 @@ class ptmlParser ( Parser ):
sharedContextCache = PredictionContextCache()
literalNames = [ "<INVALID>", "'{'", "'}'", "'sequence'", "'selector'",
"'parallel'", "'not'", "'act'", "'cond'", "'('", "')'",
"'parallel'", "'act'", "'cond'", "'Not'", "'('", "')'",
"','", "'True'", "'False'" ]
symbolicNames = [ "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
@ -208,11 +208,11 @@ class ptmlParser ( Parser ):
self.state = 25
self._errHandler.sync(self)
_la = self._input.LA(1)
while (((_la) & ~0x3f) == 0 and ((1 << _la) & 504) != 0):
while (((_la) & ~0x3f) == 0 and ((1 << _la) & 248) != 0):
self.state = 23
self._errHandler.sync(self)
token = self._input.LA(1)
if token in [6, 7, 8]:
if token in [6, 7]:
self.state = 21
self.action_sign()
pass
@ -334,21 +334,21 @@ class ptmlParser ( Parser ):
self._la = 0 # Token type
try:
self.enterOuterAlt(localctx, 1)
self.state = 37
self._errHandler.sync(self)
self.state = 36
_la = self._input.LA(1)
if _la==6:
self.state = 36
self.match(ptmlParser.T__5)
self.state = 39
_la = self._input.LA(1)
if not(_la==7 or _la==8):
if not(_la==6 or _la==7):
self._errHandler.recoverInline(self)
else:
self._errHandler.reportMatch(self)
self.consume()
self.state = 38
self._errHandler.sync(self)
_la = self._input.LA(1)
if _la==8:
self.state = 37
self.match(ptmlParser.T__7)
self.state = 40
self.match(ptmlParser.String)
self.state = 41

View File

@ -99,8 +99,8 @@ class ptmlTranslator(ptmlListener):
node.set_scene(self.scene)
# if have 'not' decorator
if str(ctx.children[0]) == 'not':
upper_node = ptree.decorators.Inverter(node)
if str(ctx.children[1]) == 'Not':
upper_node = ptree.decorators.Inverter(name="Inverter", child=node)
# connect
self.stack[-1].add_child(upper_node)
else: