Beispiel #1
0
 def visitIndex_exp(self, ctx: MPParser.Index_expContext):
     log('visitIndex_exp')
     arr = self.visit(ctx.operands())
     log1(arr)
     idx = self.visit(ctx.postfix_array_exp())
     log1(idx)
     return ArrayCell(arr, idx)
Beispiel #2
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)
Beispiel #3
0
 def visitIndex_exp(self, ctx: MPParser.Index_expContext):
     #index_exp : (STRING_LIT | INT_LIT | FLOAT_LIT | BOOL_LIT | ID | invo_exp | LB exp RB) (LSB exp RSB)| index_exp LSB exp RSB;
     if (ctx.getChildCount() == 4):
         if ctx.STRING_LIT():
             arr = StringLiteral(ctx.STRING_LIT().getText())
         elif ctx.INT_LIT():
             arr = IntLiteral(int(ctx.INT_LIT().getText()))
         elif ctx.FLOAT_LIT():
             arr = FloatLiteral(float(ctx.FLOAT_LIT().getText()))
         elif ctx.BOOL_LIT():
             mText = ctx.BOOL_LIT().getText().upper()
             arr = BooleanLiteral('TRUE' == mText)
         elif ctx.ID():
             arr = Id(ctx.ID().getText())
         elif ctx.invo_exp():
             arr = self.visit(ctx.invo_exp())
         elif ctx.index_exp():
             arr = self.visit(ctx.index_exp())
         index = self.visit(ctx.exp(0))
     else:
         arr = self.visit(ctx.exp(0))
         index = self.visit(ctx.exp(1))
     return ArrayCell(arr, index)
 def visitIndex_exp(self, ctx: MPParser.Index_expContext):
     return ArrayCell(self.visit(ctx.exp(0)), self.visit(ctx.exp(1)))
 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)))