%{
/************** VHDL scanner in fLEX format **********
*
* Version 1.0 Wed May 21, 2005
*
* This scanner is derived from a scanner of the ALLIANCE CAD toolset,
* release 1.1. That toolset was written from:
* MASI/CAO-VLSI CAD Team
* Laboratoire MASI/CAO-VLSI
* Tour 55-65, 2eme etage, Porte 13
* Universite Pierre et Marie Curie (PARIS VI)
* 4, place Jussieu 75252 PARIS Cedex 05, FRANCE
* The ALLIANCE CAD Toolset can be obtained from ftp site : ftp-masi.ibp.fr
*
* This scanner is avail at: ftp://ftp.cs.utwente.nl/ in pub/src/VHDL/Grammar
* A corresponding Yacc grammar is available at the same site
*
* author of this derived scanner version:
* Denis Kochanov
* Unifide Institute of informatica problems NAS Belarus
* Dept. of Logic Design
* e-mail: everden@mail.ru
*
****************************************************************
*
* This file is intended not to be used for commercial purposes
*
* NOTE THAT THERE IS NO WARRANTY FOR CORRECTNES, COMPLETENESS, SUPPORT
* OR ANYTHING ELSE.
*******************************************************/
#include
#include “bison.hpp”
#include “stype.h”
#include “lexer.h”
#define YY_DECL int yylex(SType *yylval)
#define ECHO //fprintf( stdout, yytext);
%}
%option noyywrap
upper_case_letter [A-Z]
digit [0-9]
special_character [#&'()*+,-./:;<=>_|]
space_character [ t]
format_effector [tvrlf]
end_of_line n
lower_case_letter [a-z]
other_special_character [!$@?[\]^`{}~]
graphic_character ({basic_graphic_character}|{lower_case_letter}|{other_special_character})
basic_graphic_character ({upper_case_letter}|{digit}|{special_character}|{space_character})
letter ({upper_case_letter}|{lower_case_letter})
letter_or_digit ({letter}|{digit})
decimal_literal {integer}(.{integer})?({exponent})?
integer {digit}(_?{digit})*
exponent ([eE][-+]?{integer})
base {integer}
based_integer {extended_digit}(_?{extended_digit})*
extended_digit ({digit}|[a-fA-F])
base_specifier (B|b|O|o|X|x)
%%
{space_character} {/* nothing */}
& { ECHO; yylval->integer = t_AMPERSAND; return(t_AMPERSAND); }
( { ECHO; yylval->integer = t_LP; return(t_LP); }
) { ECHO; yylval->integer = t_RP; return(t_RP); }
“**” { ECHO; yylval->integer = t_DoubleStar; return(t_DoubleStar); }
* { ECHO; yylval->integer = t_STAR; return(t_STAR); }
+ { ECHO; yylval->integer = t_PLUS; return(t_PLUS); }
, { ECHO; yylval->integer = t_COMMA; return(t_COMMA); }
. { ECHO; yylval->integer = t_DOT; return(t_DOT); }
– { ECHO; yylval->integer = t_MINUS; return(t_MINUS); }
: { ECHO; yylval->integer = t_COLON; return(t_COLON); }
; { ECHO; yylval->integer = t_SEMICOLON; return(t_SEMICOLON); }
“<=” { ECHO; yylval->integer = t_LESym; return(t_LESym); }
“=>” { ECHO; yylval->integer = t_ARROW; return(t_ARROW); }
“>=” { ECHO; yylval->integer = t_GESym; return(t_GESym); }
< { ECHO; yylval->integer = t_LTSym; return(t_LTSym); }
> { ECHO; yylval->integer = t_GTSym; return(t_GTSym); }
= { ECHO; yylval->integer = t_EQSym; return(t_EQSym); }
/= { ECHO; yylval->integer = t_NESym; return(t_NESym); }
\ { ECHO; yylval->integer = t_SLASH; return(t_SLASH); }
{letter}(_?{letter_or_digit})* {
int itoken;
itoken = lexer::find_mc(yytext);
if (itoken== -1){
ECHO;
strcpy(yylval->str, yytext);
return ( t_IDENTIFIER );
}
else{
ECHO;
yylval->integer = itoken;
return ( itoken );
}
}
({decimal_literal})|({base}#{based_integer}(.{based_integer})?#({exponent})?)|({base}:{based_integer}(.{based_integer})?:({exponent})?) {
ECHO;
yylval->integer = atoi(yytext);
return ( t_ABSTRACTLIT );
}
‘({graphic_character}|”|%)’ {
ECHO;
strcpy(yylval->str, yytext);
return ( t_CHARACTERLIT );
}
(“({graphic_character}|(“”)|%)*”)|(%({graphic_character}|(%%)|”)*%) {
ECHO;
strcpy(yylval->str, yytext);
return ( t_STRINGLIT );
}
{base_specifier}(“{extended_digit}(_?{extended_digit})*”|%{extended_digit}(_?{extended_digit})*%) {
ECHO;
strcpy(yylval->str, yytext);
return ( t_BITSTRINGLIT );
}
n {
ECHO; ++lexer::MVL_LINNUM;
/*return(t_NEWLINE);*/
}
–.*$ {
/* comment */
#ifndef BASE_REPRESENTATION
ECHO;
#endif
/*return(t_COMMENT);*/
}
. {
ECHO; /*return (t_UNKNOWN);*/
}
%%
|