2007-11-19 02:36:03 +01:00
|
|
|
|
|
|
|
|
%option never-interactive
|
2008-01-04 20:33:03 +01:00
|
|
|
%option nounput
|
2008-01-05 04:21:26 +01:00
|
|
|
%option noinput
|
2007-11-19 02:36:03 +01:00
|
|
|
|
|
|
|
|
%{
|
|
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2007 Stephen Williams (steve@icarus.com)
|
|
|
|
|
*
|
|
|
|
|
* This source code is free software; you can redistribute it
|
|
|
|
|
* and/or modify it in source code form under the terms of the GNU
|
|
|
|
|
* General Public License as published by the Free Software
|
|
|
|
|
* Foundation; either version 2 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, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
# include "sdf_priv.h"
|
|
|
|
|
# include "sdf_parse_priv.h"
|
|
|
|
|
# include "sdf_parse.h"
|
|
|
|
|
# include <stdlib.h>
|
|
|
|
|
# include <strings.h>
|
2007-11-21 07:20:22 +01:00
|
|
|
# include <assert.h>
|
2007-11-19 02:36:03 +01:00
|
|
|
|
|
|
|
|
static void process_quoted_string(void);
|
|
|
|
|
static int lookup_keyword(const char*text);
|
|
|
|
|
const char*sdf_parse_path = 0;
|
|
|
|
|
|
|
|
|
|
static int yywrap(void)
|
|
|
|
|
{
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# define yylval sdflval
|
|
|
|
|
%}
|
|
|
|
|
|
2007-11-27 02:59:53 +01:00
|
|
|
%x CCOMMENT
|
|
|
|
|
|
2007-11-19 02:36:03 +01:00
|
|
|
%%
|
|
|
|
|
|
2007-11-27 02:59:53 +01:00
|
|
|
/* Skip C++-style comments. */
|
|
|
|
|
"//".* { sdflloc.first_line += 1; }
|
|
|
|
|
|
|
|
|
|
/* Skip C-style comments. */
|
|
|
|
|
"/*" { BEGIN(CCOMMENT); }
|
|
|
|
|
<CCOMMENT>. { yymore(); }
|
|
|
|
|
<CCOMMENT>\n { sdflloc.first_line += 1; yymore(); }
|
|
|
|
|
<CCOMMENT>"*/" { BEGIN(0); }
|
|
|
|
|
|
2007-11-19 02:36:03 +01:00
|
|
|
[ \m\t] { /* Skip white space. */; }
|
|
|
|
|
|
|
|
|
|
/* Count lines so that the parser can assign line numbers. */
|
|
|
|
|
\n { sdflloc.first_line += 1; }
|
|
|
|
|
|
|
|
|
|
/* Real values */
|
|
|
|
|
[0-9]+(\.[0-9]+)?([Ee][+-]?[0-9]+)? {
|
|
|
|
|
yylval.real_val = strtod(yytext, 0);
|
|
|
|
|
return REAL_NUMBER;
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-29 03:05:32 +01:00
|
|
|
[a-zA-Z_][a-zA-Z0-9$_]* {
|
2007-11-19 02:36:03 +01:00
|
|
|
return lookup_keyword(yytext);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
\"[^\"]*\" {
|
|
|
|
|
process_quoted_string();
|
|
|
|
|
return QSTRING;
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-28 05:53:48 +01:00
|
|
|
/* The HCHAR (hierarchy separator) is set by the SDF file itself. We
|
|
|
|
|
recognize here the HCHAR. */
|
|
|
|
|
[./] {
|
|
|
|
|
if (sdf_use_hchar==yytext[0])
|
|
|
|
|
return HCHAR;
|
|
|
|
|
else
|
|
|
|
|
return yytext[0];
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-19 02:36:03 +01:00
|
|
|
. { return yytext[0]; }
|
|
|
|
|
|
|
|
|
|
%%
|
|
|
|
|
|
|
|
|
|
static struct {
|
|
|
|
|
const char*name;
|
|
|
|
|
int code;
|
|
|
|
|
} keywords[] = {
|
|
|
|
|
{ "ABSOLUTE", K_ABSOLUTE },
|
|
|
|
|
{ "CELL", K_CELL },
|
|
|
|
|
{ "CELLTYPE", K_CELLTYPE },
|
|
|
|
|
{ "DATE", K_DATE },
|
|
|
|
|
{ "DELAY", K_DELAY },
|
|
|
|
|
{ "DELAYFILE", K_DELAYFILE },
|
|
|
|
|
{ "DESIGN", K_DESIGN },
|
|
|
|
|
{ "DIVIDER", K_DIVIDER },
|
2007-11-28 05:53:48 +01:00
|
|
|
{ "HOLD", K_HOLD },
|
2007-11-19 02:36:03 +01:00
|
|
|
{ "INCREMENT", K_INCREMENT },
|
2007-11-28 05:53:48 +01:00
|
|
|
{ "INTERCONNECT",K_INTERCONNECT },
|
2007-11-19 02:36:03 +01:00
|
|
|
{ "INSTANCE", K_INSTANCE },
|
|
|
|
|
{ "IOPATH", K_IOPATH },
|
2007-12-14 05:42:06 +01:00
|
|
|
{ "NEGEDGE", K_NEGEDGE },
|
|
|
|
|
{ "POSEDGE", K_POSEDGE },
|
2007-11-19 02:36:03 +01:00
|
|
|
{ "PROCESS", K_PROCESS },
|
|
|
|
|
{ "PROGRAM", K_PROGRAM },
|
2007-11-28 05:53:48 +01:00
|
|
|
{ "RECOVERY", K_RECOVERY },
|
|
|
|
|
{ "REMOVAL", K_REMOVAL },
|
2007-11-19 02:36:03 +01:00
|
|
|
{ "SDFVERSION", K_SDFVERSION },
|
2007-11-28 05:53:48 +01:00
|
|
|
{ "SETUP", K_SETUP },
|
|
|
|
|
{ "SETUPHOLD", K_SETUPHOLD },
|
2007-11-19 02:36:03 +01:00
|
|
|
{ "TEMPERATURE",K_TEMPERATURE },
|
|
|
|
|
{ "TIMESCALE", K_TIMESCALE },
|
2007-11-28 05:53:48 +01:00
|
|
|
{ "TIMINGCHECK",K_TIMINGCHECK },
|
2007-11-19 02:36:03 +01:00
|
|
|
{ "VENDOR", K_VENDOR },
|
|
|
|
|
{ "VERSION", K_VERSION },
|
|
|
|
|
{ "VOLTAGE", K_VOLTAGE },
|
2007-11-28 05:53:48 +01:00
|
|
|
{ "WIDTH", K_WIDTH },
|
2007-11-19 02:36:03 +01:00
|
|
|
{ 0, IDENTIFIER }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static int lookup_keyword(const char*text)
|
|
|
|
|
{
|
|
|
|
|
int idx;
|
|
|
|
|
for (idx = 0 ; keywords[idx].name ; idx += 1) {
|
|
|
|
|
if (strcasecmp(text, keywords[idx].name) == 0)
|
|
|
|
|
return keywords[idx].code;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
yylval.string_val = strdup(yytext);
|
|
|
|
|
return IDENTIFIER;
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-21 07:20:22 +01:00
|
|
|
/*
|
|
|
|
|
* Create a string witout the leading and trailing quotes.
|
|
|
|
|
*/
|
2007-11-19 02:36:03 +01:00
|
|
|
static void process_quoted_string(void)
|
|
|
|
|
{
|
2007-11-21 07:20:22 +01:00
|
|
|
yylval.string_val = strdup(yytext+1);
|
|
|
|
|
char*endp = yylval.string_val+strlen(yylval.string_val);
|
|
|
|
|
assert(endp[-1] == '"');
|
|
|
|
|
endp[-1] = 0;
|
2007-11-19 02:36:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extern int sdfparse(void);
|
|
|
|
|
void sdf_process_file(FILE*fd, const char*path)
|
|
|
|
|
{
|
|
|
|
|
yyrestart(fd);
|
|
|
|
|
|
|
|
|
|
sdf_parse_path = path;
|
|
|
|
|
sdfparse();
|
|
|
|
|
sdf_parse_path = 0;
|
|
|
|
|
}
|