def visitExp7(self,ctx:MCParser.Exp7Context):
     if ctx.getChildCount() == 1:
         return self.visit(ctx.exp8())
     else:
         op = ctx.getChild(0).getText()
         body = self.visit(ctx.exp7())
         return UnaryOp(op, body)
Exemplo n.º 2
0
 def visitExp7(self, ctx: MCParser.Exp7Context):
     if ctx.SUB():
         return UnaryOp("-", self.visit(ctx.exp7()))
     elif ctx.NOT():
         return UnaryOp("!", self.visit(ctx.exp7()))
     else:
         return self.visit(ctx.exp8())
Exemplo n.º 3
0
 def visitExp7(self, ctx: MCParser.Exp7Context):
     if ctx.OP_NEG():
         return UnaryOp(ctx.OP_NEG().getText(), self.visit(ctx.exp8()))
     elif ctx.OP_NOT():
         return UnaryOp(ctx.OP_NOT().getText(), self.visit(ctx.exp8()))
     else:
         return self.visit(ctx.exp8())
Exemplo n.º 4
0
 def visitExp7(self, ctx: MCParser.Exp7Context):
     # exp7: (SUB|NOT) exp7 | exp8;
     if (ctx.SUB()):
         return UnaryOp(ctx.SUB().getText(), self.visit(ctx.exp7()))
     elif (ctx.NOT()):
         return UnaryOp(ctx.NOT().getText(), self.visit(ctx.exp7()))
     else:
         return self.visit(ctx.exp8())
Exemplo n.º 5
0
 def visitExp7(self, ctx: MCParser.Exp7Context):
     if (ctx.getChildCount() == 2):
         return UnaryOp(ctx.getChild(0).getText(), self.visit(ctx.exp7()))
     return self.visit(ctx.exp8())
Exemplo n.º 6
0
 def visitExp7(self, ctx: MCParser.Exp7Context):
     if ctx.getChildCount() == 2:
         return UnaryOp(ctx.getChild(0).getText(), self.visit(ctx.exp7()))
     else:
         return self.visit(ctx.indexexp())
Exemplo n.º 7
0
 def visitExp7(self, ctx: MCParser.Exp7Context):
     return UnaryOp(ctx.getChild(0).getText(), self.visit(
         ctx.exp7())) if ctx.exp7() else self.visit(ctx.exp8())
Exemplo n.º 8
0
 def visitExp7(self, ctx: MCParser.Exp7Context):
     '''exp7: operand ;'''
     return self.visit(ctx.operand())