コード例 #1
0
 def visitOperands(self, ctx: MCParser.OperandsContext):
     if ctx.lit():
         return self.visit(ctx.lit())
     elif ctx.ID():
         return Id(ctx.ID().getText())
     else:
         return self.visit(ctx.func_call())
コード例 #2
0
ファイル: ASTGeneration.py プロジェクト: tranhoi199/PPL2019
 def visitOperands(self, ctx: MCParser.OperandsContext):
     if ctx.getChildCount() == 1:
         if ctx.IDEN():
             return Id(ctx.IDEN().getText())
         elif ctx.call_func():
             return self.visit(ctx.call_func())
         elif ctx.literal():
             return self.visit(ctx.literal())
     else:
         return ArrayCell(self.visit(ctx.operands()),
                          self.visit(ctx.postfix_array()))
コード例 #3
0
ファイル: ASTGeneration.py プロジェクト: 147phuc23/PPL_ASS
 def visitOperands(self, ctx: MCParser.OperandsContext):
     if (ctx.ID()): return Id(ctx.ID().getText())
     return self.visit(ctx.getChild(0)) if ctx.getChildCount() == 1 else self.visit(ctx.expr())
コード例 #4
0
 def visitOperands(self,ctx:MCParser.OperandsContext):
     if (ctx.INTLIT()):
         return IntLiteral(int(ctx.INTLIT().getText()))
     elif (ctx.STRINGLIT()):
         return StringLiteral(ctx.STRINGLIT().getText())
     elif (ctx.bool_lit()):
         return self.visit(ctx.bool_lit())      
     elif (ctx.ID()):
         return Id(ctx.ID().getText())
     elif (ctx.FLOATLIT()):
         return FloatLiteral(float(ctx.FLOATLIT().getText()))
     elif (ctx.func_call()):
         return self.visit(ctx.func_call()) 
     else:
         return self.visit(ctx.exp())