This commit is contained in:
Chris Jones 2009-08-19 15:50:46 -05:00
Родитель e818dde5b1
Коммит a9da331f2d
2 изменённых файлов: 14 добавлений и 1 удалений

Просмотреть файл

@ -269,7 +269,7 @@ def p_NamespacedProtocolDefn(p):
p[0] = protocol
def p_ProtocolDefn(p):
"""ProtocolDefn : OptionalSendSemanticsQual PROTOCOL ID '{' ManagerStmtOpt ManagesStmts MessageDecls TransitionStmts '}' ';'"""
"""ProtocolDefn : OptionalSendSemanticsQual PROTOCOL ID '{' ManagerStmtOpt ManagesStmts OptionalMessageDecls TransitionStmts '}' ';'"""
protocol = Protocol(locFromTok(p, 2))
protocol.name = p[3]
protocol.sendSemantics = p[1]
@ -300,6 +300,14 @@ def p_ManagesStmt(p):
"""ManagesStmt : MANAGES ID ';'"""
p[0] = ManagesStmt(locFromTok(p, 1), p[2])
def p_OptionalMessageDecls(p):
"""OptionalMessageDecls : MessageDecls
| """
if 2 == len(p):
p[0] = p[1]
else:
p[0] = [ ]
def p_MessageDecls(p):
"""MessageDecls : MessageDecls MessageDeclThing
| MessageDeclThing"""

Просмотреть файл

@ -437,6 +437,11 @@ class GatherDecls(TcheckVisitor):
managed.manager = p
managed.accept(self)
if p.manager is None and 0 == len(p.messageDecls):
self.error(p.loc,
"top-level protocol `%s' cannot be empty",
p.name)
setattr(self, 'currentProtocolDecl', p.decl)
for msg in p.messageDecls:
msg.accept(self)