Ejemplo n.º 1
0
 def visitArray(self, ctx: BKITParser.ArrayContext):
     if ctx.INTERGER():
         return ArrayLiteral(
             [IntLiteral(int(x.getText(), 0)) for x in ctx.INTERGER()])
     if ctx.FLOAT():
         return ArrayLiteral(
             [FloatLiteral(float(x.getText())) for x in ctx.FLOAT()])
     if ctx.STRING():
         return ArrayLiteral(
             [StringLiteral(x.getText()) for x in ctx.STRING()])
     if ctx.BOOLEAN():
         return ArrayLiteral(
             [BooleanLiteral(x.getText() == 'True') for x in ctx.BOOLEAN()])
     return ArrayLiteral([self.visit(x) for x in ctx.array()])
Ejemplo n.º 2
0
 def visitArray(self,ctx:BKITParser.ArrayContext):
     if ctx.DECIMAL():
         return IntLiteral(int(ctx.DECIMAL().getText(),0))
     elif ctx.OCTAL():
         return IntLiteral(int(ctx.OCTAL().getText(),0))
     elif ctx.HEXA():
         return IntLiteral(int(ctx.HEXA().getText(),0))
     elif ctx.FLOAT():
         return FloatLiteral(float(ctx.FLOAT().getText()))
     elif ctx.STRING():
         return StringLiteral(ctx.STRING().getText())
     elif ctx.BOOL():
         return BooleanLiteral(ctx.BOOL().getText())
     elif ctx.array_list():
         return self.visit(ctx.array_list())