def visitVariable(self, ctx: MCParser.VariableContext): if ctx.getChildCount() == 1: return [1, (ctx.ID().getText())] elif ctx.getChildCount() == 4: return [2, (ctx.ID().getText()), int(ctx.INTLIT().getText())] elif ctx.getChildCount() == 3: return [3, (ctx.ID().getText())]
def visitVariable(self, ctx: MCParser.VariableContext): if ctx.INT_LIT(): variableDeclaration = lambda mcType: VarDecl( ctx.ID().getText(), ArrayType(int(ctx.INT_LIT()), mcType)) else: variableDeclaration = lambda mcType: VarDecl( ctx.ID().getText(), mcType) return variableDeclaration
def visitVariable(self, ctx: MCParser.VariableContext): return (lambda x: VarDecl(Id(ctx.ID().getText()), x) ) if ctx.getChildCount() == 1 else (lambda x: VarDecl( Id(ctx.ID().getText()), ArrayType(IntLiteral(int(ctx.INTLIT().getText())), x)))
def visitVariable(self, ctx: MCParser.VariableContext): return ctx.ID().getText() if ctx.getChildCount() == 1 else [ ctx.ID().getText(), int(ctx.INTLIT().getText()) ]
def visitVariable(self, ctx:MCParser.VariableContext): # variable : ID | array ; return ctx.ID().getText() if ctx.ID() else self.visit(ctx.array())
def visitVariable(self, ctx: MCParser.VariableContext): return ArrayCell(Id(ctx.ID().getText()), IntLiteral(int( ctx.INTLIT().getText()))) if ctx.INTLIT() else Id( ctx.ID().getText())
def visitVariable(self, ctx: MCParser.VariableContext): return ctx.ID().getText(), (int(ctx.INTLIT().getText()) if ctx.INTLIT() else -1)
def visitVariable(self, ctx: MCParser.VariableContext): '''variable: ID | ID LSB INTLIT RSB ;''' if ctx.getChildCount() == 1: return (ctx.ID().getText(), -1) else: return (ctx.ID().getText(), int(ctx.INTLIT().getText()))