зеркало из https://github.com/mozilla/gecko-dev.git
allow empty sub-protocols
This commit is contained in:
Родитель
e818dde5b1
Коммит
a9da331f2d
|
@ -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)
|
||||
|
|
Загрузка…
Ссылка в новой задаче