Пример #1
0
    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)
Пример #2
0
 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())))
Пример #3
0
 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)
Пример #4
0
 def visitArray_lit(self, ctx: BKITParser.Array_litContext):
     return ArrayLiteral(self.visit(ctx.array_lits()))
Пример #5
0
 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)
Пример #7
0
 def visitArray_lit(self, ctx: BKITParser.Array_litContext):
     return ArrayLiteral(self.visit(ctx.getChild(1)))