Пример #1
0
 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())
Пример #2
0
 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)
Пример #3
0
 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())
Пример #4
0
    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)
Пример #5
0
 def visitStmtForBlock(self, stmtForBlock):
     #print('visitStmtForBlock')
     st.beginScope(st.FOR)
     stmtForBlock.Block.accept(self)
     st.varCheck(st.endScope())
Пример #6
0
 def visitStmtForRange(self, stmtForRange):
     #print('visitStmtForRange')
     st.beginScope(st.FOR)
     stmtForRange.RangeClause.accept(self)
     stmtForRange.Block.accept(self)
     st.varCheck(st.endScope())
Пример #7
0
 def visitStmtFor(self, stmtFor):
     #print('visitStmtFor')
     st.beginScope(st.FOR)
     stmtFor.Condition.accept(self)
     stmtFor.Block.accept(self)
     st.varCheck(st.endScope())
Пример #8
0
 def __init__(self):
     self.printer = Visitor()
     st.beginScope('main')
Пример #9
0
 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())