Ejemplo n.º 1
0
    def TipoPrimitivo(self):
        # TipoPrimitivo -> "bool" | "integer" | "String" | "double" | "void"
        noTipoPrimitivo = No()
        if (self.token.getNome() == Tag.KW_BOOL):
            self.eat(Tag.KW_BOOL)

            noTipoPrimitivo.tipo = Tag.TIPO_LOGICO

        elif (self.token.getNome() == Tag.KW_INTEGER):
            self.eat(Tag.KW_INTEGER)

            noTipoPrimitivo.tipo = Tag.TIPO_INT

        elif (self.token.getNome() == Tag.KW_STRING):
            self.eat(Tag.KW_STRING)

            noTipoPrimitivo.tipo = Tag.TIPO_STRING

        elif (self.token.getNome() == Tag.KW_DOUBLE):
            self.eat(Tag.KW_DOUBLE)

            noTipoPrimitivo.tipo = Tag.TIPO_DOUBLE

        elif (self.token.getNome() == Tag.KW_VOID):
            self.eat(Tag.KW_VOID)

            noTipoPrimitivo.tipo = Tag.TIPO_VAZIO

        else:
            self.sinalizaErroSintatico(
                "Esperado \"'bool' ou 'integer' ou 'String' ou 'double' ou 'void'\"; encontrado "
                + "\"" + self.token.getLexema() + "\"")

        return noTipoPrimitivo
Ejemplo n.º 2
0
 def expression(self):
     noExp = No()
     noSimpleExp = self.simpleExpr()
     noExpLinha = self.expressionLinha()
     if noExpLinha.tipo == Tag.TIPO_VAZIO:
         noExp.tipo = noSimpleExp.tipo
     elif noExpLinha.tipo == noSimpleExp.tipo and noSimpleExp.tipo == Tag.TIPO_LOGICO:
         noExp.tipo = Tag.TIPO_LOGICO
     else:
         noExp.tipo = Tag.TIPO_ERRO
     return noExp
Ejemplo n.º 3
0
 def simpleExpr(self):
     simpExp = No()
     term = self.term()
     simExpLinha = self.simpleExprLinha()
     if simExpLinha.tipo == Tag.TIPO_VAZIO:
         simpExp.tipo = term.tipo
     elif simExpLinha.tipo == term.tipo and simExpLinha.tipo == Tag.TIPO_NUMERO:
         simpExp.tipo = Tag.TIPO_LOGICO
     else:
         simpExp.tipo = Tag.TIPO_ERRO
     return simpExp
Ejemplo n.º 4
0
 def term(self):
     term = No()
     factoB = self.factorB()
     termLinha = self.termLinha()
     if termLinha.tipo == Tag.TIPO_VAZIO:
         term.tipo = factoB.tipo
     elif termLinha.tipo == factoB.tipo and termLinha.tipo == Tag.TIPO_NUMERO:
         term.tipo = Tag.TIPO_NUMERO
     else:
         term.tipo = Tag.TIPO_ERRO
     return term
Ejemplo n.º 5
0
 def factorB(self):
     factorB = No()
     factorA = self.factorA()
     factorBLinha = self.factorBLinha()
     if factorBLinha.tipo == Tag.TIPO_VAZIO:
         factorB.tipo = factorA.tipo
     elif factorBLinha.tipo == factorA.tipo and factorBLinha.tipo == Tag.TIPO_NUMERO:
         factorB.tipo = Tag.TIPO_NUMERO
     else:
         factorB.tipo = Tag.TIPO_ERRO
     return factorB
Ejemplo n.º 6
0
 def constant(self):
     constant = No()
     if self.conferirToken([Tag.NUM_CONST]):
         constant.tipo = Tag.TIPO_NUMERO
         self.advance()
     elif self.conferirToken([Tag.CHAR_CONST]):
         constant.tipo = Tag.TIPO_LITERAL
         self.advance()
     else:
         self.sinalizaErroSintatico("Constante esperada'")
     return constant
Ejemplo n.º 7
0
 def type(self):
     type = No()
     if self.conferirToken([Tag.KW_NUM]):
         type.tipo = Tag.TIPO_NUMERO
         self.advance()
     elif self.conferirToken([Tag.KW_CHAR]):
         type.tipo = Tag.TIPO_LITERAL
         self.advance()
     else:
         self.sinalizaErroSintatico("Aguardando 'num' ou 'char'")
     return type
Ejemplo n.º 8
0
 def termLinha(self):
     termLinha = No()
     if self.conferirToken([Tag.OP_AD, Tag.OP_MIN]):
         self.addOp()
         factorB = self.factorB()
         termLinhaFilho = self.termLinha()
         if termLinhaFilho.tipo == Tag.TIPO_VAZIO and factorB.tipo == Tag.TIPO_NUMERO:
             termLinha.tipo = Tag.TIPO_NUMERO
         elif termLinhaFilho == factorB.tipo and factorB.tipo == Tag.TIPO_NUMERO:
             termLinha.tipo = Tag.TIPO_NUMERO
         else:
             termLinha.tipo = Tag.TIPO_ERRO
     return termLinha
Ejemplo n.º 9
0
 def expressionLinha(self):
     expLinha = No()
     if self.conferirToken([Tag.KW_OR, Tag.KW_AND]):
         self.logop()
         simpleExpres = self.simpleExpr()
         exprLinhaFilho = self.expressionLinha()
         if exprLinhaFilho.tipo == Tag.TIPO_VAZIO and simpleExpres.tipo == Tag.TIPO_LOGICO:
             expLinha.tipo = Tag.TIPO_LOGICO
         elif exprLinhaFilho.tipo == simpleExpres.tipo and simpleExpres.tipo == Tag.TIPO_LOGICO:
             expLinha.tipo = Tag.TIPO_LOGICO
         else:
             expLinha.tipo = Tag.TIPO_ERRO
     return expLinha
Ejemplo n.º 10
0
 def factorBLinha(self):
     factorBlinha = No()
     if self.conferirToken([Tag.OP_DIV, Tag.OP_MUL]):
         self.mulop()
         factorA = self.factorA()
         factorBlinhaFilho = self.factorBLinha()
         if factorBlinhaFilho.tipo == Tag.TIPO_VAZIO and factorA.tipo == Tag.TIPO_NUMERO:
             factorBlinha.tipo = Tag.TIPO_NUMERO
         elif factorBlinhaFilho.tipo == factorA.tipo and factorA.tipo == Tag.TIPO_NUMERO:
             factorBlinha.tipo = Tag.TIPO_NUMERO
         else:
             factorBlinha.tipo = Tag.TIPO_ERRO
     return factorBlinha
Ejemplo n.º 11
0
    def factorA(self):
        factorA = No()
        if self.conferirToken([Tag.KW_NOT]):
            self.advance()
            factor = self.factor()
            if factor.tipo != Tag.TIPO_LOGICO:
                factorA.tipo = Tag.TIPO_ERRO
            else:
                factorA.tipo = Tag.TIPO_LOGICO
        else:
            factor = self.factor()
            factorA.tipo = factor.tipo

        return factorA
Ejemplo n.º 12
0
    def OpUnario(self):
        #OpUnario -> "-" | "!"
        noOpUnario = No()
        if (self.eat(Tag.OP_INVERSOR)):
            noOpUnario.tipo = Tag.TIPO_LOGICO

        elif (self.eat(Tag.OP_NEGACAO)):
            noOpUnario.tipo = Tag.TIPO_INT

        else:
            self.sinalizaErroSintatico("Esperado \"'-' ou '!'\"; encontrado " +
                                       "\"" + self.token.getLexema() + "\"")
            sys.exit(0)

        return noOpUnario
Ejemplo n.º 13
0
 def simpleExprLinha(self):
     simpleExprLinha = No()
     if self.conferirToken(
         [Tag.OP_EQ, Tag.OP_GT, Tag.OP_GE, Tag.OP_LT, Tag.OP_LE,
          Tag.OP_NE]):
         self.relop()
         term = self.term()
         simpleExprLinhaFilho = self.simpleExprLinha()
         if simpleExprLinhaFilho.tipo == Tag.TIPO_VAZIO and term.tipo == Tag.TIPO_NUMERO:
             simpleExprLinha.tipo = Tag.TIPO_NUMERO
         elif simpleExprLinhaFilho.tipo == term.tipo and term.tipo == Tag.TIPO_NUMERO:
             simpleExprLinha.tipo = Tag.TIPO_NUMERO
         else:
             simpleExprLinha.tipo = Tag.TIPO_ERRO
     return simpleExprLinha
Ejemplo n.º 14
0
   def E(self):
      noE = No()
      if(self.token.getNome() == Tag.ID or self.token.getNome() == Tag.INT or self.token.getNome() == Tag.DOUBLE):
        noF = self.F()
        noELinha = self.ELinha()

        if noELinha.tipo == Tag.TIPO_VAZIO:
          noE.tipo = noF.tipo
        elif noELinha.tipo == noF.tipo and (noF.tipo == Tag.TIPO_INT or noF.tipo == Tag.TIPO_DOUBLE):
          noE.tipo = Tag.TIPO_LOGICO
        else:
          noE.tipo = Tag.TIPO_ERRO
        return noE
      else:
         self.sinalizaErroSintatico("Esperado \"id, int, double\", encontrado " + "\"" + self.token.getLexema() + "\"")
         sys.exit(0)
Ejemplo n.º 15
0
    def Retorno(self):
        # Retorno -> "return" Expressao ";" | ε
        noRetorno = No()
        if (self.eat(Tag.KW_RETURN)):
            noExpressao = self.Expressao()
            if (not self.eat(Tag.PV)):
                self.sinalizaErroSintatico("Esperado \";\"; encontrado " +
                                           "\"" + self.token.getLexema() +
                                           "\"")
                sys.exit(0)
            noRetorno.tipo = noExpressao.tipo

            return noRetorno
        else:
            noRetorno.tipo = Tag.TIPO_VAZIO
            return noRetorno
Ejemplo n.º 16
0
   def F(self):
      noF = No()
      if(self.token.getNome() == Tag.ID or self.token.getNome() == Tag.INT or self.token.getNome() == Tag.DOUBLE):
        noT = self.T()
        noFLinha = self.FLinha()

        if noFLinha.tipo == Tag.TIPO_VAZIO:
          noF.tipo = noT.tipo
        elif noFLinha.tipo == noT.tipo and (noT.tipo == Tag.TIPO_INT or noT.tipo == Tag.TIPO_DOUBLE):
          noF.tipo = noT.tipo
        else:
          noF.tipo = Tag.TIPO_ERRO
        return noF
      else:
         self.skip("Esperado \"id, int, double\", encontrado " + "\"" + self.token.getLexema() + "\"")
         sys.exit(0)
Ejemplo n.º 17
0
 def TipoPrimitivo(self):
     noTipoPrimitivo = No()
     if self.eat(Tag.KW_BOOL):
         noTipoPrimitivo.tipo = Tag.TIPO_LOGICO
         return noTipoPrimitivo
     elif self.eat(Tag.KW_INTEGER):
         noTipoPrimitivo.tipo = Tag.TIPO_INT
         return noTipoPrimitivo
     elif self.eat(Tag.KW_STRING):
         noTipoPrimitivo.tipo = Tag.TIPO_STRING
         return noTipoPrimitivo
     elif self.eat(Tag.KW_DOUBLE):
         noTipoPrimitivo.tipo = Tag.TIPO_DOUBLE
         return noTipoPrimitivo
     elif self.eat(Tag.KW_VOID):
         noTipoPrimitivo.tipo = Tag.TIPO_VAZIO
         return noTipoPrimitivo
Ejemplo n.º 18
0
    def Expressao(self):
        # Expressao -> Exp1 Exp’

        noExpressao = No()

        noExp1 = self.Exp1()
        noExpLinha = self.ExpLinha()

        if (noExpLinha.tipo == Tag.TIPO_VAZIO):
            noExpressao.tipo = noExp1.tipo

        elif (noExpLinha.tipo == noExp1.tipo
              and noExpLinha.tipo == Tag.TIPO_LOGICO):
            noExpressao.tipo = Tag.TIPO_LOGICO

        else:
            noExpressao.tipo = Tag.TIPO_ERRO

        return noExpressao
Ejemplo n.º 19
0
   def T(self):
      noT = No()
      tempToken = copy.copy(self.token) # armazena token corrente (necessario para id da primeira regra)

      if(self.eat(Tag.ID)):
        if tempToken.getTipo() == Tag.TIPO_VAZIO:
          self.sinalizaErroSemantico("Variavel " + "\"" + tempToken.getLexema() + "\"" + " nao definida.")
          noT.tipo = Tag.TIPO_ERRO
        else:
          noT.tipo = tempToken.getTipo()
      elif(self.eat(Tag.INT)):
        noT.tipo = Tag.TIPO_INT
      elif(self.eat(Tag.DOUBLE)):
        noT.tipo = Tag.TIPO_DOUBLE
      else:
        self.skip("Esperado \"int, double, id\", encontrado "  + "\"" + token.getLexema() + "\"");
        sys.exit(0)

      return noT
Ejemplo n.º 20
0
    def Exp1(self):
        # Exp1 -> Exp2 Exp1’
        noExp1 = No()

        noExp2 = self.Exp2()
        noExp1Linha = self.Exp1Linha()

        if (noExp1Linha.tipo == Tag.TIPO_VAZIO):
            noExp1.tipo = noExp2.tipo

        elif (noExp1Linha.tipo == noExp2.tipo
              and (noExp1Linha.tipo == Tag.TIPO_INT
                   or noExp1Linha.tipo == Tag.TIPO_DOUBLE)):
            noExp1.tipo = Tag.TIPO_LOGICO

        else:
            noExp1.tipo = Tag.TIPO_ERRO

        return noExp1
Ejemplo n.º 21
0
    def CmdAtribFunc(self):
        # CmdAtribFunc -> CmdAtribui | CmdFuncao
        noCmdAtribFunc = No()

        if (self.token.getNome() == Tag.CP):
            noCmdAtribui = self.CmdAtribui()
            noCmdAtribFunc.tipo = noCmdAtribui.tipo

            return noCmdAtribFunc

        elif (self.token.getNome() == Tag.AP):
            self.CmdFuncao()
            noCmdAtribFunc.tipo = Tag.TIPO_VAZIO

            return noCmdAtribFunc

        else:
            self.sinalizaErroSintatico("Esperado \"'=' ou '('\"; encontrado " +
                                       "\"" + self.token.getLexema() + "\"")
            sys.exit(0)
Ejemplo n.º 22
0
   def ELinha(self):
      noELinhaPai = No()

      if(self.eat(Tag.OP_MAIOR) or self.eat(Tag.OP_MENOR) or self.eat(Tag.OP_MAIOR_IGUAL) or 
         self.eat(Tag.OP_MENOR_IGUAL) or self.eat(Tag.OP_IGUAL) or self.eat(Tag.OP_DIFERENTE)):
        noF = self.F()
        noELinhaFilho = self.ELinha()

        if noELinhaFilho.tipo == Tag.TIPO_VAZIO and (noF.tipo == Tag.TIPO_INT or noF.tipo == Tag.TIPO_DOUBLE):
          noELinhaPai.tipo = noF.tipo
        elif noELinhaFilho.tipo == noF.tipo and (noF.tipo == Tag.TIPO_INT or noF.tipo == Tag.TIPO_DOUBLE):
          noELinhaPai.tipo = noF.tipo
        else:
          noELinhaPai.tipo = Tag.TIPO_ERRO
        return noELinhaPai
      elif(self.token.getNome() == Tag.KW_THEN):
         return noELinhaPai
      else:
         self.skip("Esperado \">, <, >=, <=, ==, !=, then\", encontrado " + "\"" + self.token.getLexema() + "\"")
         sys.exit(0)
Ejemplo n.º 23
0
    def Exp3(self):
        # Exp3 -> Exp4 Exp3’
        noExp3 = No()

        noExp4 = self.Exp4()
        noExp3Linha = self.Exp3Linha()

        if (noExp3Linha.tipo == Tag.TIPO_VAZIO):
            noExp3.tipo = noExp4.tipo

        elif (noExp3Linha == noExp4.tipo and noExp3Linha.tipo == Tag.TIPO_INT):
            noExp3.tipo = Tag.TIPO_INT

        elif (noExp3Linha == noExp4.tipo
              and noExp3Linha.tipo == Tag.TIPO_DOUBLE):
            noExp3.tipo = Tag.TIPO_DOUBLE

        else:
            noExp3Linha.tipo = Tag.TIPO_ERRO

        return noExp3
Ejemplo n.º 24
0
    def Exp1Linha(self):
        # Exp1’ -> "<" Exp2 Exp1’ | "<=" Exp2 Exp1’ | ">" Exp2 Exp1’ | ">=" Exp2 Exp1’ | "==" Exp2 Exp1’ | "!=" Exp2 Exp1’ | ε
        noExp1Linha = No()

        if (self.eat(Tag.OP_MENOR) or self.eat(Tag.OP_MAIOR_IGUAL)
                or self.eat(Tag.OP_MENOR_IGUAL) or self.eat(Tag.OP_MAIOR)
                or self.eat(Tag.OP_IGUAL) or self.eat(Tag.OP_DIFERENTE)):
            noExp2 = self.Exp2()
            noExp1LinhaFilho = self.Exp1Linha()

            if (noExp1LinhaFilho.tipo == Tag.TIPO_VAZIO
                    and noExp2.tipo == Tag.TIPO_INT):
                noExp1Linha.tipo = Tag.TIPO_INT

            elif (noExp1LinhaFilho.tipo == Tag.TIPO_VAZIO
                  and noExp2.tipo == Tag.TIPO_DOUBLE):
                noExp1Linha.tipo = Tag.TIPO_DOUBLE

            elif (noExp1LinhaFilho.tipo == noExp2.tipo
                  and noExp2.tipo == Tag.TIPO_INT):
                noExp1Linha.tipo = Tag.TIPO_INT

            elif (noExp1LinhaFilho.tipo == noExp2.tipo
                  and noExp2.tipo == Tag.TIPO_DOUBLE):
                noExp1Linha.tipo = Tag.TIPO_DOUBLE

            else:
                noExp1Linha.tipo = Tag.TIPO_ERRO

            return noExp1Linha

        else:
            noExp1Linha.tipo = Tag.TIPO_VAZIO
            return noExp1Linha
Ejemplo n.º 25
0
    def Exp2Linha(self):
        # Exp2’ -> "+" Exp3 Exp2’ | "-" Exp3 Exp2’ | ε
        noExp2Linha = No()

        if (self.eat(Tag.OP_SOMA) or self.eat(Tag.OP_MENOR)):
            noExp3 = self.Exp3()
            noExp2LinhaFilho = self.Exp2Linha()

            if (noExp2LinhaFilho.tipo == Tag.TIPO_VAZIO
                    and noExp3.tipo == Tag.TIPO_INT):
                noExp2Linha.tipo = Tag.TIPO_INT

            elif (noExp2LinhaFilho.tipo == Tag.TIPO_VAZIO
                  and noExp3.tipo == Tag.TIPO_DOUBLE):
                noExp2Linha.tipo = Tag.TIPO_DOUBLE

            elif (noExp2LinhaFilho.tipo == noExp3.tipo
                  and noExp3.tipo == Tag.TIPO_INT):
                noExp2Linha.tipo = Tag.TIPO_INT

            elif (noExp2LinhaFilho.tipo == noExp3.tipo
                  and noExp3.tipo == Tag.TIPO_DOUBLE):
                noExp2Linha.tipo = Tag.TIPO_DOUBLE

            else:
                noExp2Linha.tipo = Tag.TIPO_ERRO

            return noExp2Linha

        else:
            noExp2Linha.tipo = Tag.TIPO_VAZIO
            return noExp2Linha
Ejemplo n.º 26
0
    def Exp3Linha(self):
        # Exp3’ -> "*" Exp4 Exp3’ | "/" Exp4 Exp3’ | ε
        noExp3Linha = No()

        if (self.eat(Tag.OP_MULTIPLICACAO) or self.eat(Tag.OP_DIVISAO)):
            noExp4 = self.Exp4()
            noExp3LinhaFilho = self.Exp3Linha()

            if (noExp3LinhaFilho.tipo == Tag.TIPO_VAZIO
                    and noExp4.tipo == Tag.TIPO_INT):
                noExp3Linha.tipo = Tag.TIPO_INT

            elif (noExp3LinhaFilho.tipo == Tag.TIPO_VAZIO
                  and noExp4.tipo == Tag.TIPO_DOUBLE):
                noExp3Linha.tipo = Tag.TIPO_DOUBLE

            elif (noExp3LinhaFilho.tipo == noExp4.tipo
                  and noExp4.tipo == Tag.TIPO_INT):
                noExp3Linha.tipo = Tag.TIPO_INT

            elif (noExp3LinhaFilho.tipo == noExp4.tipo
                  and noExp4.tipo == Tag.TIPO_DOUBLE):
                noExp3Linha.tipo = Tag.TIPO_DOUBLE

            else:
                noExp3Linha.tipo = Tag.TIPO_ERRO

            return noExp3Linha

        else:
            noExp3Linha.tipo = Tag.TIPO_VAZIO
            return noExp3Linha
Ejemplo n.º 27
0
    def ExpLinha(self):
        noExpLinha = No()
        # Exp’ -> "or" Exp1 Exp’ | "and" Exp1 Exp’ | ε
        if (self.eat(Tag.KW_OR) or self.eat(Tag.KW_AND)):
            noExp1 = self.Exp1()
            noExpLinhaFilho = self.ExpLinha()

            if (noExpLinhaFilho.tipo == Tag.TIPO_VAZIO
                    and noExp1.tipo == Tag.TIPO_LOGICO):
                noExpLinha.tipo = Tag.TIPO_LOGICO

            elif (noExpLinhaFilho.tipo == noExp1.tipo
                  and noExp1.tipo == Tag.TIPO_LOGICO):
                noExpLinha.tipo = Tag.TIPO_LOGICO

            else:
                noExpLinha.tipo = Tag.TIPO_ERRO

            return noExpLinha
        else:
            noExpLinha.tipo = Tag.TIPO_VAZIO
            return noExpLinha
Ejemplo n.º 28
0
    def Exp2(self):
        #Exp2 -> Exp3 Exp2’
        noExp2 = No()

        noExp3 = self.Exp3()
        noExp2Linha = self.Exp2Linha()

        if (noExp2Linha.tipo == Tag.TIPO_VAZIO):
            noExp2.tipo = noExp3.tipo

        elif (noExp2Linha.tipo == noExp3.tipo
              and noExp2Linha.tipo == Tag.TIPO_INT):
            noExp2.tipo = Tag.TIPO_INT

        elif (noExp2Linha.tipo == noExp3.tipo
              and noExp2Linha.tipo == Tag.TIPO_DOUBLE):
            noExp2.tipo = Tag.TIPO_DOUBLE

        else:
            noExp2.tipo = Tag.TIPO_ERRO

        return noExp2
Ejemplo n.º 29
0
   def FLinha(self):
      noFLinhaPai = No()
      if(self.eat(Tag.OP_SOMA) or self.eat(Tag.OP_SUB)):
        noT = self.T()
        noFLinhaFilho = self.FLinha()

        if noFLinhaFilho.tipo == Tag.TIPO_VAZIO and (noT.tipo == Tag.TIPO_INT or noT.tipo == Tag.TIPO_DOUBLE):
          noFLinhaPai.tipo = noT.tipo
        elif noFLinhaFilho.tipo == noT.tipo and (noT.tipo == Tag.TIPO_INT or noT.tipo == Tag.TIPO_DOUBLE):
          noFLinhaPai.tipo = noT.tipo
        else:
          noFLinhaPai.tipo = Tag.TIPO_ERRO
        return noFLinhaPai
      elif(self.token.getNome() == Tag.OP_MAIOR or self.token.getNome() == Tag.OP_MENOR or
           self.token.getNome() == Tag.OP_MAIOR_IGUAL or self.token.getNome() == Tag.OP_MENOR_IGUAL or
           self.token.getNome() == Tag.OP_DIFERENTE or self.token.getNome() == Tag.OP_IGUAL or
           self.token.getNome() == Tag.KW_THEN or self.token.getNome() == Tag.KW_IF or
           self.token.getNome() == Tag.KW_PRINT or self.token.getNome() == Tag.ID):
        return noFLinhaPai
      else:
         self.skip("Esperado \"+, -, >, <, >=, <=, ==, !=, then, if, print, id\", encontrado " + "\"" + self.token.getLexema() + "\"")
         sys.exit(0)
Ejemplo n.º 30
0
 def factor(self):
     factor = No()
     if self.conferirToken([Tag.ID]):
         factor.tipo = self.lexer.ts.getType(self.token.lexema)
         self.advance()
     elif self.conferirToken([Tag.SMB_OPA]):
         self.eat(Tag.SMB_OPA)
         factor = self.expression()
         self.eat(Tag.SMB_CPA)
     elif self.conferirToken([Tag.NUM_CONST, Tag.CHAR_CONST]):
         factor = self.constant()
     else:
         self.sinalizaErroSintatico("Fator inválido")
     return factor