Exemplo n.º 1
0
 public Token()
 {
     this.token   = "";
     this.lexema  = "";
     this.fila    = 0;
     this.columna = 0;
     this.tipo    = TipoToken.OTHER;
 }
Exemplo n.º 2
0
 public Token(string t, string l, int f, int c, TipoToken tipo)
 {
     this.token   = t;
     this.lexema  = l;
     this.fila    = f;
     this.columna = c;
     this.tipo    = tipo;
 }
Exemplo n.º 3
0
 public Tokens(string Lexema, int Idtoken, string tipo, int fila, int columna, TipoToken TIPO)
 {
     this.tipotoken = TIPO;
     this.Lexema    = Lexema;
     this.idToken   = Idtoken;
     this.tipo1     = tipo;
     this.columna   = columna;
     this.fila      = fila;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Este método verifica se o token atual é realmente o informado através dos parâmetros
 /// deste método e caso seja irá ignorar este token e passar para o token seguinte
 /// </summary>
 /// <param name="tipo"></param>
 /// <param name="valor"></param>
 private void pulaTokenEsperado(TipoToken tipo, string valor)
 {
     verificaFimInesperadoDoSql();
     if (!TokenAtual.Equals(tipo, valor))
     {
         throw new Exception(string.Format("Valor esperado: '{0}' diferente do encontrado:{1}", valor, TokenAtual.Valor));
     }
     leProximoToken();
 }
Exemplo n.º 5
0
 private bool proximoTokenIgualA(TipoToken tipo, string valor)
 {
     if (Tokens.Count > 0)
     {
         Token tk = Tokens.Peek();
         return(tk.Equals(tipo, valor));
     }
     return(false);
 }
Exemplo n.º 6
0
 static Token match(TipoToken tipo)
 {
     Token t = GetNextToken().Value;
     if (tipo == t.Tipo)
     {
         return t;
     }
     return null;
 }
Exemplo n.º 7
0
        private Token TokenEsperado(TipoToken tipoToken)
        {
            if (tokenAtual.Tipo == tipoToken)
            {
                return(tokenAtual);
            }

            throw new SintaticoException($"Sintáxe inválida. {tipoToken.ToString()} esperado, " +
                                         $"mas {tokenAtual.Tipo.ToString()} foi recebido.");
        }
Exemplo n.º 8
0
        public Token(TipoToken tipo, string valor)
        {
            if (valor == null)
            {
                throw new ArgumentNullException("valor do token");
            }

            Tipo  = tipo;
            Valor = valor.ToUpper();
        }
Exemplo n.º 9
0
        static Token match(TipoToken tipo)
        {
            Token t = GetNextToken().Value;

            if (tipo == t.Tipo)
            {
                return(t);
            }
            return(null);
        }
Exemplo n.º 10
0
 private void VerificarToken(TipoToken tipo)
 {
     if (tokenAtual.Tipo == tipo)
     {
         Status = true;
     }
     else
     {
         Status = false;
         Console.WriteLine($"Token {tipo} esperado. Erro na posição {scanner.Posicao}");
         tokenAtual = new Token(TipoToken.ERRO);
     }
 }
Exemplo n.º 11
0
        public Respuesta <Dato> TiempoExpiracionToken(TipoToken tipoToken)
        {
            JObject prms = new JObject();

            prms.Add("tipo_token", tipoToken.GetStringValue());

            string rsp = base.ProcesarOperacion(TipoOperacion.Servicio.GetStringValue(),
                                                NOMBRE_TIEMPO_EXPIRACION_TOKEN,
                                                DOMINIO_OPERACION,
                                                prms.ToString(Formatting.None));
            var entityRsp = JsonConvert.DeserializeObject <YRespuesta <YDato> >(rsp);

            return(EntitiesMapper.GetRespuestaFromEntity <Dato, YDato>(entityRsp, EntitiesMapper.GetModelFromEntity <Dato, YDato>(entityRsp.Datos)));
        }
Exemplo n.º 12
0
        private Token ProximoToken(TipoToken tipoToken)
        {
            if (tokenAtual.Tipo == tipoToken)
            {
                tokens++;
                Token token = new Token {
                    Tipo = tokenAtual.Tipo, Valor = tokenAtual.Valor
                };
                tokenAtual = listaTokens[tokens];
                return(token);
            }

            throw new SintaticoException($"Sintáxe inválida. {tipoToken.ToString()} esperado, " +
                                         $"mas {tokenAtual.Tipo.ToString()} foi recebido.");
        }
Exemplo n.º 13
0
        public static Token GetToken(string texto, string comparar, TipoToken tokenEsperado)
        {
            var textoF    = RemoverAcento(texto.ToLower().Replace(" ", ""));
            var compararF = RemoverAcento(comparar.ToLower().Replace(" ", ""));

            int  ini = 0, fim = 0, p = 0;
            bool achou = false;

            for (int i = 0; i < textoF.Length; i++)
            {
                ini = i;
                p   = i;
                for (int j = 0; j < compararF.Length; j++)
                {
                    if (textoF[p] == compararF[j])
                    {
                        achou = true;
                        p++;
                        if (p > textoF.Length - 1)
                        {
                            achou = false;
                            break;
                        }
                        continue;
                    }
                    else
                    {
                        achou = false;
                        break;
                    }
                }
                if (achou)
                {
                    fim = p;
                    var token = new Token
                    {
                        Inicio  = ini,
                        Fim     = fim,
                        Palavra = comparar,
                        Tipo    = tokenEsperado
                    };
                    return(token);
                }
                fim = i;
            }
            return(null);
        }
Exemplo n.º 14
0
        static Token Match(TipoToken tipo, bool parentesis)
        {
            Token token = GetNextToken().Value;

            if (token.Tipo == tipo && parentesis == false)
            {
                return(token);
            }
            else if (parentesis == true && (token.Tipo == TipoToken.OPEN_PARENS || token.Tipo == TipoToken.NUM))
            {
                return(token);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 15
0
        public TipoToken _tipodetoken(int estado)
        {
            TipoToken _tipo = TipoToken.SimboloSimple;

            if (estado == -1)
            {
                _tipo = TipoToken.Identificador;
            }
            else if (estado == -2)
            {
                _tipo = TipoToken.Entero;
            }
            else if (estado == -3)
            {
                _tipo = TipoToken.Decimal;
            }
            else if (estado == -4)
            {
                _tipo = TipoToken.Cadena;
            }
            else if (estado <= -5 && estado >= -11)
            {
                _tipo = TipoToken.OperadorAritmetico;
            }
            else if (estado <= -12 && estado >= -18)
            {
                _tipo = TipoToken.OperadorDeComparacion;
            }
            else if (estado <= -19 && estado >= -26)
            {
                _tipo = TipoToken.OperadorDeAsignacion;
            }
            else if (estado <= -100 && estado >= -136)
            {
                _tipo = TipoToken.PalabraReservada;
            }
            else
            {
                _tipo = TipoToken.SimboloSimple;
            }

            return(_tipo);
        }
Exemplo n.º 16
0
 public Token(TipoToken tipo, string valor)
 {
     Tipo = tipo;
     Valor = valor;
 }
Exemplo n.º 17
0
 public Token(TipoToken tipo, string valor)
 {
     Tipo  = tipo;
     Valor = valor;
 }
Exemplo n.º 18
0
 public Token(TipoToken tipo, char valor)
 {
     Tipo = tipo;
     Valor = valor;
 }
Exemplo n.º 19
0
 public Token(string cadena, TipoToken tipoToken)
 {
     this.cadena = cadena;
     this.tipoToken = tipoToken;
 }
Exemplo n.º 20
0
 public Token(string cadeia, TipoToken tipo, int linha)
 {
     Cadeia = cadeia;
     Tipo   = tipo;
     Linha  = linha;
 }
Exemplo n.º 21
0
 public Token(TipoToken tipo, string nome, double valor)
 {
     Tipo  = tipo;
     Nome  = nome;
     Valor = valor;
 }
Exemplo n.º 22
0
 public Token(TipoToken tipo)
 {
     Tipo = tipo;
 }
Exemplo n.º 23
0
 //Constructor de la funcion
 //Se asignan los parametros del token
 public Token(int idT, string nombreT, TipoToken tipoT)
 {
     id = idT;
     nombre = nombreT;
     tipoToken = tipoT;
 }
Exemplo n.º 24
0
 public bool Equals(TipoToken tipo, string valor) =>
 Tipo == tipo && Valor == valor;
Exemplo n.º 25
0
        static Token Match(TipoToken ElTipo)
        {
            Token t = GetNextToken().Value;

            if (t.Tipo==ElTipo)
            {
                return t;
            }

            return null;
        }
Exemplo n.º 26
0
 public Token(string Lex, TipoToken Tip, int Lin, int Col)
 {
     Lexema = Lex;
     Tipo = Tip;
     Linea = Lin;
     Columna = Col;
 }
Exemplo n.º 27
0
 private Token AddToken(TipoToken tipo) => new Token
 {
     Tipo = tipo, Valor = caractereAtual.ToString()
 };
Exemplo n.º 28
0
 public Token(TipoToken tipo, string nome)
 {
     Tipo = tipo;
     Nome = nome;
 }
Exemplo n.º 29
0
 public Token()
 {
     Tipo  = TipoToken.Vazio;
     Valor = string.Empty;
 }
Exemplo n.º 30
0
 public Token(TipoToken tipo, string nome, string valor)
 {
     Tipo        = tipo;
     Nome        = nome;
     ValorString = valor;
 }
Exemplo n.º 31
0
 public Token(TipoToken tipo, char valor)
 {
     Tipo  = tipo;
     Valor = valor;
 }
Exemplo n.º 32
0
 public bool Equals(TipoToken tipo, string valor)
 {
     return(Tipo == tipo && Valor == valor);
 }
Exemplo n.º 33
0
 static Token Match(TipoToken tipo, bool parentesis)
 {
     Token token = GetNextToken().Value;
     if (token.Tipo == tipo && parentesis == false)
         return token;
     else if (parentesis == true && (token.Tipo == TipoToken.OPEN_PARENS || token.Tipo == TipoToken.NUM))
         return token;
     else
         return null;
 }