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
示例#2
0
 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):
     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)))
示例#4
0
 def visitVariable(self, ctx: MCParser.VariableContext):
     return ctx.ID().getText() if ctx.getChildCount() == 1 else [
         ctx.ID().getText(),
         int(ctx.INTLIT().getText())
     ]
示例#5
0
 def visitVariable(self, ctx:MCParser.VariableContext):
     # variable : ID | array ;
     return ctx.ID().getText() if ctx.ID() else self.visit(ctx.array())
示例#6
0
 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())
示例#7
0
 def visitVariable(self, ctx: MCParser.VariableContext):
     return ctx.ID().getText(), (int(ctx.INTLIT().getText())
                                 if ctx.INTLIT() else -1)
示例#8
0
 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()))