def visitExprSwitch(self, exprSwitch):
     #print('visitExprSwitch')
     st.beginScope(st.SWITCH)
     tipo = exprSwitch.switchStmt_Head.accept(self)
     st.symbolTable[-1][st.SWITCHTYPE] = tipo
     exprSwitch.switchStmt_Body.accept(self)
     st.varCheck(st.endScope())
 def visitCompIfElse(self, compIfElse):
     #print('visitCompIfElse')
     st.beginScope(st.IF)
     compIfElse.Expression.accept(self)
     compIfElse.Block.accept(self)
     st.varCheck(st.endScope())
     compIfElse.IfStmt.accept(self)
 def visitIfElse(self, ifElse):
     #print('visitIfElse')
     st.beginScope(st.IF)
     ifElse.Expression.accept(self)
     ifElse.Block.accept(self)
     st.varCheck(st.endScope())
     st.beginScope(st.ELSE)
     ifElse.Block1.accept(self)
     st.varCheck(st.endScope())
    def visitDefinirFuncBody(self, definirFuncBody):
        parametrosRetorno = definirFuncBody.Signature.accept(self)
        st.addFunction(definirFuncBody.ID, parametrosRetorno[0:-1],
                       parametrosRetorno[-1])
        st.beginScope(definirFuncBody.ID)
        if (parametrosRetorno[0] != None):
            for k in range(0, len(parametrosRetorno[0:-1]), 2):
                st.addVar(parametrosRetorno[0:-1][k],
                          parametrosRetorno[0:-1][k + 1])

        definirFuncBody.FunctionBody.accept(self)
 def visitStmtForBlock(self, stmtForBlock):
     #print('visitStmtForBlock')
     st.beginScope(st.FOR)
     stmtForBlock.Block.accept(self)
     st.varCheck(st.endScope())
 def visitStmtForRange(self, stmtForRange):
     #print('visitStmtForRange')
     st.beginScope(st.FOR)
     stmtForRange.RangeClause.accept(self)
     stmtForRange.Block.accept(self)
     st.varCheck(st.endScope())
 def visitStmtFor(self, stmtFor):
     #print('visitStmtFor')
     st.beginScope(st.FOR)
     stmtFor.Condition.accept(self)
     stmtFor.Block.accept(self)
     st.varCheck(st.endScope())
 def __init__(self):
     self.printer = Visitor()
     st.beginScope('main')
 def visitExprSwitchSimple(self, exprSwitchSimple):
     #print('visitExprSwitchSimple')
     st.beginScope(st.SWITCH)
     st.symbolTable[-1][st.SWITCHTYPE] = ''
     exprSwitchSimple.switchStmt_Body.accept(self)
     st.varCheck(st.endScope())
示例#10
0
 def visitSimpleIf(self, simpleIf):
     #print('visitSimpleIf')
     st.beginScope(st.IF)
     simpleIf.Expression.accept(self)
     simpleIf.Block.accept(self)
     st.varCheck(st.endScope())