/*
$Id$
Copyright 1989-2016 MINES ParisTech
This file is part of Linear/C3 Library.
Linear/C3 Library is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
any later version.
Linear/C3 Library 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Linear/C3 Library. If not, see .
*/
%option nounput
%START COMMENT TEXT
%{
/*
Grammaire lex necessaire pour l'analyse lexicale d'un systeme
d'assertions. Les tokens renvoyes sont commentes dans le fichier
"sc_gram.y".
*/
#include
#include
#include
#include /* flex uses isatty */
#include "boolean.h"
#include "arithmetique.h"
#include "vecteur.h"
#include "sc_gram.h"
#define RETURN(x) /* fprintf(stderr, "lex: %d\n", x); */ return x
char * sc_internal_symbol_table(char *);
extern int syst_error(char *);
%}
%%
"VAR" { RETURN(VAR); }
[.A-Za-z_]['A-Za-z0-9_:#.]* { syst_lval.Variable = (Variable) sc_internal_symbol_table(syst_text); /*'*/
RETURN(IDENT); }
\'[A-Za-z0-9_:#?. ]*\' { syst_lval.Variable = (Variable) sc_internal_symbol_table(syst_text); /*'*/
RETURN(IDENT); }
[0-9]*[.DEe][0-9DEe\-]* { syst_lval.Variable = (Variable) sc_internal_symbol_table(syst_text); /*'*/
RETURN(IDENT); }
[0-9]* { sscan_Value(syst_text,&syst_lval.Value);
RETURN(CONSTANTE); }
"==" { RETURN(EGAL); }
"=" { RETURN(EGAL); }
"," { RETURN(VIRG); }
"+" { RETURN(PLUS); }
"-" { RETURN(MOINS); }
">" { RETURN(SUP); }
">=" { RETURN(SUPEGAL); }
"<" { RETURN(INF); }
"<=" { RETURN(INFEGAL); }
"{" { RETURN(ACCOUVR); }
"}" { RETURN(ACCFERM); }
[ \t\r\n]* ;
"#" {BEGIN COMMENT;}
\n {BEGIN TEXT;}
[^\n]* ;
. { syst_error("unexpected character"); }
%%
#define SYMBOLS_SIZE (10)
char * sc_internal_symbol_table(char * name)
{
static int size = 0;
static int index = 0; /* next available chunk */
static char ** symbols = NULL;
int i;
if (index==size) {
size += SYMBOLS_SIZE;
if (symbols) symbols = (char**) realloc(symbols, sizeof(char*) * size);
else symbols = (char**) malloc(sizeof(char*) * size);
}
for (i=0; i