コード例 #1
0
 def visitExp4(self, ctx: MPParser.Exp4Context):
     if ctx.exp4() is None:
         return self.visit(ctx.exp5())
     else:
         return BinaryOp(
             ctx.getChild(1).getText(), self.visit(ctx.exp4()),
             self.visit(ctx.exp5()))
コード例 #2
0
 def visitExp4(self, ctx:MPParser.Exp4Context):
     if ctx.getChildCount() == 2:
         op = ctx.getChild(0).getText()
         body = self.visit(ctx.exp4())
         return UnaryOp(op,body)
     else:
         return self.visit(ctx.exp6())
コード例 #3
0
 def visitExp4(self,ctx:MPParser.Exp4Context):
     if ctx.getChildCount() == 1:
         return self.visit(ctx.exp5()) 
     else:
         return UnaryOp(ctx.getChild(0).getText(),self.visit(ctx.exp4()))
コード例 #4
0
ファイル: ASTGeneration.py プロジェクト: ThaoTrinh/PPL
 def visitExp4(self, ctx: MPParser.Exp4Context):
     if ctx.getChildCount() == 1:
         return self.visit(ctx.exp5())
     op = ctx.getChild(0).getText()
     exp4 = self.visit(ctx.exp4())
     return UnaryOp(op, exp4)
コード例 #5
0
 def visitExp4(self, ctx: MPParser.Exp4Context):
     '''exp4: SUB exp4 | NOT exp4 | exp5;'''
     return UnaryOp(ctx.getChild(0).getText(), self.visit(
         ctx.exp4())) if ctx.getChildCount() == 2 else self.visit(
             ctx.exp5())