def visitArray_lit(self, ctx: BKITParser.Array_litContext): value = [] if ctx.literal(): for x in ctx.literal(): value.append(self.visitLiteral(x)) return ArrayLiteral(value)
def visitArray_lit(self, ctx: BKITParser.Array_litContext): if ctx.primitive_data(): return ArrayLiteral( list( map(lambda datum: self.visitPrimitive_data(datum), ctx.primitive_data()))) else: return ArrayLiteral( list( map(lambda datum: self.visitArray_lit(datum), ctx.array_lit())))
def visitArray_lit(self, ctx:BKITParser.Array_litContext): temp = [] for x in ctx.array_lit_cell(): # temp.extend(self.visitArray_lit_cell(x)) valueCell = self.visitArray_lit_cell(x) if isinstance(valueCell, list): temp.extend(valueCell if valueCell else []) else: temp.append(valueCell) return ArrayLiteral(temp)
def visitArray_lit(self, ctx: BKITParser.Array_litContext): return ArrayLiteral(self.visit(ctx.array_lits()))
def visitArray_lit(self, ctx: BKITParser.Array_litContext): return ArrayLiteral(ctx.literal_list().accept(self))
def visitArray_lit(self, ctx: BKITParser.Array_litContext): res = [] indexINT = 0 indexFLOAT = 0 indexSTRING = 0 indexBOOL = 0 for i in range(1, ctx.getChildCount() - 1, 2): temp = ctx.getChild(i) if isinstance(temp, BKITParser.Array_litContext): res = res + [self.visit(ctx.getChild(i))] else: if ctx.getChild(i) == ctx.INT_LIT(indexINT): res = res + [ IntLiteral( self.IntegerStandardization( ctx.INT_LIT(indexINT).getText())) ] indexINT += 1 elif ctx.getChild(i) == ctx.FLOAT_LIT(indexFLOAT): res = res + [ FloatLiteral(float( ctx.FLOAT_LIT(indexFLOAT).getText())) ] indexFLOAT += 1 elif ctx.getChild(i) == ctx.BOOL_LIT(indexBOOL): temp = ctx.BOOL_LIT(indexBOOL).getText() if temp == 'True': res = res + [BooleanLiteral(True)] else: res = res + [BooleanLiteral(False)] indexBOOL += 1 else: res = res + [ StringLiteral(ctx.STRING_LIT(indexSTRING).getText()) ] indexSTRING += 1 return ArrayLiteral(res)
def visitArray_lit(self, ctx: BKITParser.Array_litContext): return ArrayLiteral(self.visit(ctx.getChild(1)))