ruby: slicc: slight change to rule for transitions
It had an unnecessary pairs token which is being removed.
This commit is contained in:
parent
a1570f544f
commit
183100b8cb
4 changed files with 14 additions and 15 deletions
|
@ -28,7 +28,7 @@
|
||||||
from slicc.ast.AST import AST
|
from slicc.ast.AST import AST
|
||||||
|
|
||||||
class DeclAST(AST):
|
class DeclAST(AST):
|
||||||
def __init__(self, slicc, pairs):
|
def __init__(self, slicc, pairs = None):
|
||||||
super(DeclAST, self).__init__(slicc, pairs)
|
super(DeclAST, self).__init__(slicc, pairs)
|
||||||
|
|
||||||
def files(self, parent=None):
|
def files(self, parent=None):
|
||||||
|
|
|
@ -29,9 +29,9 @@ from slicc.ast.DeclAST import DeclAST
|
||||||
from slicc.symbols import Transition
|
from slicc.symbols import Transition
|
||||||
|
|
||||||
class TransitionDeclAST(DeclAST):
|
class TransitionDeclAST(DeclAST):
|
||||||
def __init__(self, slicc, request_types, states, events, next_state, pairs,
|
def __init__(self, slicc, request_types, states, events, next_state,
|
||||||
actions):
|
actions):
|
||||||
super(TransitionDeclAST, self).__init__(slicc, pairs)
|
super(TransitionDeclAST, self).__init__(slicc)
|
||||||
|
|
||||||
self.request_types = request_types
|
self.request_types = request_types
|
||||||
self.states = states
|
self.states = states
|
||||||
|
@ -69,6 +69,5 @@ class TransitionDeclAST(DeclAST):
|
||||||
self.error("Invalid event: %s is not part of machine: %s" % \
|
self.error("Invalid event: %s is not part of machine: %s" % \
|
||||||
(event, machine))
|
(event, machine))
|
||||||
t = Transition(self.symtab, machine, state, event, next_state,
|
t = Transition(self.symtab, machine, state, event, next_state,
|
||||||
self.actions, self.request_types, self.location,
|
self.actions, self.request_types, self.location)
|
||||||
self.pairs)
|
|
||||||
machine.addTransition(t)
|
machine.addTransition(t)
|
||||||
|
|
|
@ -278,20 +278,20 @@ class SLICC(Grammar):
|
||||||
p[0] = ast.OutPortDeclAST(self, p[3], p[5], p[7], p[8])
|
p[0] = ast.OutPortDeclAST(self, p[3], p[5], p[7], p[8])
|
||||||
|
|
||||||
def p_decl__trans0(self, p):
|
def p_decl__trans0(self, p):
|
||||||
"decl : TRANS '(' idents ',' idents ',' ident pairs ')' idents"
|
"decl : TRANS '(' idents ',' idents ',' ident ')' idents"
|
||||||
p[0] = ast.TransitionDeclAST(self, [], p[3], p[5], p[7], p[8], p[10])
|
p[0] = ast.TransitionDeclAST(self, [], p[3], p[5], p[7], p[9])
|
||||||
|
|
||||||
def p_decl__trans1(self, p):
|
def p_decl__trans1(self, p):
|
||||||
"decl : TRANS '(' idents ',' idents pairs ')' idents"
|
"decl : TRANS '(' idents ',' idents ')' idents"
|
||||||
p[0] = ast.TransitionDeclAST(self, [], p[3], p[5], None, p[6], p[8])
|
p[0] = ast.TransitionDeclAST(self, [], p[3], p[5], None, p[7])
|
||||||
|
|
||||||
def p_decl__trans2(self, p):
|
def p_decl__trans2(self, p):
|
||||||
"decl : TRANS '(' idents ',' idents ',' ident pairs ')' idents idents"
|
"decl : TRANS '(' idents ',' idents ',' ident ')' idents idents"
|
||||||
p[0] = ast.TransitionDeclAST(self, p[10], p[3], p[5], p[7], p[8], p[11])
|
p[0] = ast.TransitionDeclAST(self, p[9], p[3], p[5], p[7], p[10])
|
||||||
|
|
||||||
def p_decl__trans3(self, p):
|
def p_decl__trans3(self, p):
|
||||||
"decl : TRANS '(' idents ',' idents pairs ')' idents idents"
|
"decl : TRANS '(' idents ',' idents ')' idents idents"
|
||||||
p[0] = ast.TransitionDeclAST(self, p[8], p[3], p[5], None, p[6], p[9])
|
p[0] = ast.TransitionDeclAST(self, p[7], p[3], p[5], None, p[8])
|
||||||
|
|
||||||
def p_decl__extern0(self, p):
|
def p_decl__extern0(self, p):
|
||||||
"decl : EXTERN_TYPE '(' type pairs ')' SEMI"
|
"decl : EXTERN_TYPE '(' type pairs ')' SEMI"
|
||||||
|
|
|
@ -29,9 +29,9 @@ from slicc.symbols.Symbol import Symbol
|
||||||
|
|
||||||
class Transition(Symbol):
|
class Transition(Symbol):
|
||||||
def __init__(self, table, machine, state, event, nextState, actions,
|
def __init__(self, table, machine, state, event, nextState, actions,
|
||||||
request_types, location, pairs):
|
request_types, location):
|
||||||
ident = "%s|%s" % (state, event)
|
ident = "%s|%s" % (state, event)
|
||||||
super(Transition, self).__init__(table, ident, location, pairs)
|
super(Transition, self).__init__(table, ident, location)
|
||||||
|
|
||||||
self.state = machine.states[state]
|
self.state = machine.states[state]
|
||||||
self.event = machine.events[event]
|
self.event = machine.events[event]
|
||||||
|
|
Loading…
Reference in a new issue