Beispiel #1
0
 def visitIndex_exp(self, ctx: MPParser.Index_expContext):
     if ctx.ID():
         arr = Id(ctx.ID().getText())
     else:
         arr = self.visit(ctx.call_exp())
     idx = self.visit(ctx.exp())
     return ArrayCell(arr, idx)
 def visitIndex_exp(self, ctx: MPParser.Index_expContext):
     indexExpCxt = 0
     if ctx.STRINGLIT():
         arr = StringLiteral(ctx.STRINGLIT().getText())
     elif ctx.REALLIT():
         arr = FloatLiteral(float(ctx.REALLIT().getText()))
     elif ctx.INTLIT():
         arr = IntLiteral(int(ctx.INTLIT().getText()))
     elif ctx.TRUE():
         arr = BooleanLiteral(True)
     elif ctx.FALSE():
         arr = BooleanLiteral(False)
     elif ctx.IDEN():
         arr = Id(ctx.IDEN().getText())
     elif ctx.call_exp():
         arr = self.visit(ctx.call_exp())
     elif ctx.index_exp():
         arr = self.visit(ctx.index_exp())
     else:
         arr = self.visit(ctx.exp(0))
         indexExpCxt = 1
     return ArrayCell(arr, self.visit(ctx.exp(indexExpCxt)))