//*******************************************************************************
//lexer.h
//*******************************************************************************
//This file is part of the Orb compiler,
//Copyright (C) 2007 Adrian Fraga Fernandez
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
//*******************************************************************************

/***********************************************************************/
/* Analisis lexico                                                     */
/***********************************************************************/

#ifndef __LEXER_H
#define __LEXER_H

#ifndef __ERROR_H
	#include "error.h"
#endif
#ifndef __AST_H
	#include "ast.h"
#endif

/***********************************************************************/
/* Estructura de datos TOKEN                                           */
/***********************************************************************/

typedef struct L_TOKEN {
	
		/* Posicion del token */

	E_POSICION posicion;	

		/* Atributos obtenidos durante la fase de analisis lexico */

	union{
		int i;		/* literal entero */
		double f;	/* literal real */
		char *s;	/* literal de cadena */
		char *id;	/* identificador */
	};
	
		/* Atributos sintetizados durante la fase de analisis sintactico */

	A_NODO *nodo;
		
} L_TOKEN;

/***********************************************************************/
/* Analisis léxico                                                     */
/***********************************************************************/

void l_init(char *ficheroEntrada);	/* inicializar lexer */
int l_lex(void);			/* procesar siguiente token */
void l_close(void);			/* finalizar lexer */

/***********************************************************************/
/* Obtener informacion del estado del analisis                         */
/***********************************************************************/

char* 		l_texto(void);		/* texto del token actual */
E_POSICION*	l_posicion(void);	/* posicion del token actual */
L_TOKEN*	l_token(void);		/* estructura TOKEN del token actual */

#endif
