indent the C code in .y and .l files

git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1553 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Rutger Hofman 16 years ago
parent d57bcb0c31
commit c1d0800d87

File diff suppressed because it is too large Load Diff

@ -140,7 +140,7 @@ LEGAL NOTICES:
#define YY_EXTRA_TYPE urj_bsdl_scan_extra_t *
static char *new_string( urj_bsdl_scan_extra_t *, const char * );
static char *new_string (urj_bsdl_scan_extra_t *, const char *);
#define BINARY 0
#define DECIMAL 1
@ -412,7 +412,9 @@ ISC_Illegal_Exit ISC_ILLEGAL_EXIT
if ( !YY_CURRENT_BUFFER )
yyterminate();
}
%%
/*****************************************************************************
* void *urj_bsdl_flex_init( int proc_mode )
*
@ -424,33 +426,37 @@ ISC_Illegal_Exit ISC_ILLEGAL_EXIT
* Returns
* pointer to newly initialized scanner structure
****************************************************************************/
void *urj_bsdl_flex_init( int proc_mode )
void *
urj_bsdl_flex_init (int proc_mode)
{
urj_bsdl_scan_extra_t *extra;
yyscan_t scanner;
/* get our scanner structure */
if (yylex_init(&scanner) != 0)
{
urj_bsdl_msg( proc_mode,
BSDL_MSG_FATAL, _("Scanner could not be initialized\n") );
return NULL;
}
if (!(extra = malloc( sizeof( urj_bsdl_scan_extra_t ) ))) {
urj_bsdl_msg( proc_mode,
BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), __FILE__, __LINE__ );
yylex_destroy( scanner );
return NULL;
}
extra->proc_mode = proc_mode;
extra->Compile_Errors = 0;
extra->Base = DECIMAL;
yyset_extra( extra, scanner );
return scanner;
urj_bsdl_scan_extra_t *extra;
yyscan_t scanner;
/* get our scanner structure */
if (yylex_init (&scanner) != 0)
{
urj_bsdl_msg (proc_mode,
BSDL_MSG_FATAL,
_("Scanner could not be initialized\n"));
return NULL;
}
if (!(extra = malloc (sizeof (urj_bsdl_scan_extra_t))))
{
urj_bsdl_msg (proc_mode,
BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"),
__FILE__, __LINE__);
yylex_destroy (scanner);
return NULL;
}
extra->proc_mode = proc_mode;
extra->Compile_Errors = 0;
extra->Base = DECIMAL;
yyset_extra (extra, scanner);
return scanner;
}
@ -465,17 +471,18 @@ void *urj_bsdl_flex_init( int proc_mode )
* Returns
* void
****************************************************************************/
void urj_bsdl_flex_deinit( void *scanner )
void
urj_bsdl_flex_deinit (void *scanner)
{
if (yyget_in( scanner ))
{
/* file might still be open so close it in any case
e.g. when a compile error occured and the parser didn't hit EOF/yywrap() */
fclose( yyget_in( scanner ) );
yyset_in( NULL, scanner );
}
free( yyget_extra( scanner ) );
yylex_destroy( scanner );
if (yyget_in (scanner))
{
/* file might still be open so close it in any case
e.g. when a compile error occured and the parser didn't hit EOF/yywrap() */
fclose (yyget_in (scanner));
yyset_in (NULL, scanner);
}
free (yyget_extra (scanner));
yylex_destroy (scanner);
}
@ -490,13 +497,15 @@ void urj_bsdl_flex_deinit( void *scanner )
* Returns
* 1
****************************************************************************/
int yywrap( yyscan_t scanner )
int
yywrap (yyscan_t scanner)
{
if (yyget_in( scanner )) {
fclose( yyget_in( scanner ) );
yyset_in( NULL, scanner );
}
return 1;
if (yyget_in (scanner))
{
fclose (yyget_in (scanner));
yyset_in (NULL, scanner);
}
return 1;
}
@ -512,22 +521,24 @@ int yywrap( yyscan_t scanner )
* Returns
* pointer to allocated and initialized string memory
****************************************************************************/
static char *new_string( urj_bsdl_scan_extra_t *extra, const char *str )
static char *
new_string (urj_bsdl_scan_extra_t *extra, const char *str)
{
char *n_str;
size_t n_str_size;
n_str_size = strlen( str ) + 1;
if ((n_str = malloc( n_str_size )))
{
strncpy( n_str, str, n_str_size-1 );
n_str[n_str_size-1] = '\0'; /* set very last element to EOS */
}
else
urj_bsdl_msg( extra->proc_mode,
BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), __FILE__, __LINE__ );
return(n_str);
char *n_str;
size_t n_str_size;
n_str_size = strlen (str) + 1;
if ((n_str = malloc (n_str_size)))
{
strncpy (n_str, str, n_str_size - 1);
n_str[n_str_size - 1] = '\0'; /* set very last element to EOS */
}
else
urj_bsdl_msg (extra->proc_mode,
BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"),
__FILE__, __LINE__);
return (n_str);
}
@ -544,21 +555,22 @@ static char *new_string( urj_bsdl_scan_extra_t *extra, const char *str )
* Returns
* void
****************************************************************************/
void urj_bsdl_flex_switch_buffer( yyscan_t scanner, const char *buffer, int lineno )
void
urj_bsdl_flex_switch_buffer (yyscan_t scanner, const char *buffer, int lineno)
{
/* ugly, ulgy, ugly
prepare yyg for later use of YY_CURRENT_BUFFER */
struct yyguts_t * yyg = (struct yyguts_t*)scanner;
/* yy_scan_string() switches to the string buffer internally,
so we must save the current buffer state explicitly by pushing the stack
and setting top of stack to the current buffer state again.
yy_scan_string() can then savely switch YY_CURRENT_BUFFER to the string buffer.
yypop_buffer_state() will delete the string buffer afterwards and pop the saved
current buffer state. */
yypush_buffer_state( YY_CURRENT_BUFFER, scanner );
yy_scan_string( buffer, scanner );
yyset_lineno( lineno, scanner );
/* ugly, ulgy, ugly
prepare yyg for later use of YY_CURRENT_BUFFER */
struct yyguts_t *yyg = (struct yyguts_t *) scanner;
/* yy_scan_string() switches to the string buffer internally,
so we must save the current buffer state explicitly by pushing the stack
and setting top of stack to the current buffer state again.
yy_scan_string() can then savely switch YY_CURRENT_BUFFER to the string buffer.
yypop_buffer_state() will delete the string buffer afterwards and pop the saved
current buffer state. */
yypush_buffer_state (YY_CURRENT_BUFFER, scanner);
yy_scan_string (buffer, scanner);
yyset_lineno (lineno, scanner);
}
@ -573,9 +585,10 @@ void urj_bsdl_flex_switch_buffer( yyscan_t scanner, const char *buffer, int line
* Returns
* void
****************************************************************************/
void urj_bsdl_flex_stop_buffer( yyscan_t scanner )
void
urj_bsdl_flex_stop_buffer (yyscan_t scanner)
{
yypop_buffer_state( scanner );
yypop_buffer_state (scanner);
// if ( !YY_CURRENT_BUFFER )
// yyterminate();
}
@ -592,10 +605,11 @@ void urj_bsdl_flex_stop_buffer( yyscan_t scanner )
* Returns
* number of compile errors
****************************************************************************/
int urj_bsdl_flex_get_compile_errors( yyscan_t scanner )
int
urj_bsdl_flex_get_compile_errors (yyscan_t scanner)
{
urj_bsdl_scan_extra_t *extra = yyget_extra( scanner );
return extra->Compile_Errors;
urj_bsdl_scan_extra_t *extra = yyget_extra (scanner);
return extra->Compile_Errors;
}
@ -611,10 +625,11 @@ int urj_bsdl_flex_get_compile_errors( yyscan_t scanner )
* Returns
* void
****************************************************************************/
static void urj_bsdl_flex_set_compile_errors( int n, yyscan_t scanner )
static void
urj_bsdl_flex_set_compile_errors (int n, yyscan_t scanner)
{
urj_bsdl_scan_extra_t *extra = yyget_extra( scanner );
extra->Compile_Errors = n;
urj_bsdl_scan_extra_t *extra = yyget_extra (scanner);
extra->Compile_Errors = n;
}
@ -629,12 +644,13 @@ static void urj_bsdl_flex_set_compile_errors( int n, yyscan_t scanner )
* Returns
* number of compile errors before increment
****************************************************************************/
int urj_bsdl_flex_postinc_compile_errors( yyscan_t scanner )
int
urj_bsdl_flex_postinc_compile_errors (yyscan_t scanner)
{
int errors = urj_bsdl_flex_get_compile_errors( scanner );
int errors = urj_bsdl_flex_get_compile_errors (scanner);
urj_bsdl_flex_set_compile_errors( errors+1, scanner );
return errors;
urj_bsdl_flex_set_compile_errors (errors + 1, scanner);
return errors;
}
@ -649,10 +665,11 @@ int urj_bsdl_flex_postinc_compile_errors( yyscan_t scanner )
* Returns
* void
****************************************************************************/
void urj_bsdl_flex_set_bin_x( yyscan_t scanner )
void
urj_bsdl_flex_set_bin_x (yyscan_t scanner)
{
urj_bsdl_scan_extra_t *extra = yyget_extra( scanner );
extra->Base = BIN_X;
urj_bsdl_scan_extra_t *extra = yyget_extra (scanner);
extra->Base = BIN_X;
}
@ -667,10 +684,11 @@ void urj_bsdl_flex_set_bin_x( yyscan_t scanner )
* Returns
* void
****************************************************************************/
void urj_bsdl_flex_set_hex( yyscan_t scanner )
void
urj_bsdl_flex_set_hex (yyscan_t scanner)
{
urj_bsdl_scan_extra_t *extra = yyget_extra( scanner );
extra->Base = HEX;
urj_bsdl_scan_extra_t *extra = yyget_extra (scanner);
extra->Base = HEX;
}
@ -685,10 +703,11 @@ void urj_bsdl_flex_set_hex( yyscan_t scanner )
* Returns
* void
****************************************************************************/
void urj_bsdl_flex_set_decimal( yyscan_t scanner )
void
urj_bsdl_flex_set_decimal (yyscan_t scanner)
{
urj_bsdl_scan_extra_t *extra = yyget_extra( scanner );
extra->Base = DECIMAL;
urj_bsdl_scan_extra_t *extra = yyget_extra (scanner);
extra->Base = DECIMAL;
}

File diff suppressed because it is too large Load Diff

@ -142,7 +142,7 @@ LEGAL NOTICES:
#define YY_EXTRA_TYPE urj_bsdl_scan_extra_t *
static char *new_string( urj_bsdl_scan_extra_t *, const char * );
static char *new_string (urj_bsdl_scan_extra_t *, const char *);
#define BINARY 0
#define DECIMAL 1
@ -240,109 +240,111 @@ Bsdl_Extension BSDL_EXTENSION
Std_1532_2001 STD_1532_2001
Std_1532_2002 STD_1532_2002
%%
{Entity} {return( ENTITY ); }
{Entity} {return (ENTITY); }
{Port} {yyextra->Base = DECIMAL; /* Default number base */
return( PORT ); }
{Generic} {yyextra->Base = DECIMAL; return( GENERIC ); }
{Use} {yyextra->Base = DECIMAL; return( USE ); }
{Attribute} {yyextra->Base = DECIMAL; return( ATTRIBUTE ); }
{Is} {return( IS ); }
{Constant} {yyextra->Base = DECIMAL; return( CONSTANT ); }
{String} {return( STRING ); }
return (PORT); }
{Generic} {yyextra->Base = DECIMAL; return (GENERIC); }
{Use} {yyextra->Base = DECIMAL; return (USE); }
{Attribute} {yyextra->Base = DECIMAL; return (ATTRIBUTE); }
{Is} {return (IS); }
{Constant} {yyextra->Base = DECIMAL; return (CONSTANT); }
{String} {return (STRING); }
{End} {yyextra->Base = DECIMAL;
BEGIN INITIAL; /* Turn off start conditions */
return( END ); }
{All} {return( ALL ); }
{Of} {return( OF ); }
{Physical_Pin_Map} {return( PHYSICAL_PIN_MAP ); }
{Pin_Map_String} {return( PIN_MAP_STRING ); }
{True} {return( TRUE ); }
{False} {return( FALSE ); }
{Signal} {return( SIGNAL ); }
{Low} {return( LOW ); }
{Both} {return( BOTH ); }
{In} {return( IN ); }
{Out} {return( OUT ); }
{Inout} {return( INOUT ); }
{Buffer} {return( BUFFER ); }
{Linkage} {return( LINKAGE ); }
{Bit} {return( BIT ); }
{Bit_Vector} {return( BIT_VECTOR ); }
{To} {return( TO ); }
{Downto} {return( DOWNTO ); }
{Package} {return( PACKAGE ); }
{Body} {return( BODY ); }
{Type} {return( TYPE ); }
{Subtype} {return( SUBTYPE ); }
{Record} {return( RECORD ); }
{Array} {yyextra->Base = DECIMAL; return( ARRAY ); }
{Positive} {return( POSITIVE ); }
{Range} {return( RANGE ); }
{Cell_Info} {BEGIN PAC; return( CELL_INFO ); }
{Bsdl_Extension} {return( BSDL_EXTENSION ); }
{Std_1532_2001} {return( STD_1532_2001 ); }
{Std_1532_2002} {return( STD_1532_2002 ); }
<BOU,PAC>{Input} {return( INPUT ); }
<BOU,PAC>{Output2} {return( OUTPUT2 ); }
<BOU,PAC>{Output3} {return( OUTPUT3 ); }
<BOU,PAC>{Controlr} {return( CONTROLR ); }
<BOU,PAC>{Control} {return( CONTROL ); }
<BOU,PAC>{Internal} {return( INTERNAL ); }
<BOU,PAC>{Clock} {return( CLOCK ); }
<BOU,PAC>{Observe_Only} {return( OBSERVE_ONLY ); }
<BOU>{Bidir} {return( BIDIR ); }
<PAC>{Bidir_In} {return( BIDIR_IN ); }
<PAC>{Bidir_Out} {return( BIDIR_OUT ); }
<PAC>{Extest} {return( EXTEST ); }
<PAC>{Sample} {return( SAMPLE ); }
<PAC>{Intest} {return( INTEST ); }
<PAC>{Runbist} {return( RUNBIST ); }
<PAC>{Pi} {return( PI ); }
<PAC>{Po} {return( PO ); }
<PAC>{Upd} {return( UPD ); }
<PAC>{Cap} {return( CAP ); }
<PAC>{X} {return( X ); }
<PAC>{Zero} {return( ZERO ); }
<PAC>{One} {return( ONE ); }
<BOU>{Z} {return( Z ); }
return (END); }
{All} {return (ALL); }
{Of} {return (OF); }
{Physical_Pin_Map} {return (PHYSICAL_PIN_MAP); }
{Pin_Map_String} {return (PIN_MAP_STRING); }
{True} {return (TRUE); }
{False} {return (FALSE); }
{Signal} {return (SIGNAL); }
{Low} {return (LOW); }
{Both} {return (BOTH); }
{In} {return (IN); }
{Out} {return (OUT); }
{Inout} {return (INOUT); }
{Buffer} {return (BUFFER); }
{Linkage} {return (LINKAGE); }
{Bit} {return (BIT); }
{Bit_Vector} {return (BIT_VECTOR); }
{To} {return (TO); }
{Downto} {return (DOWNTO); }
{Package} {return (PACKAGE); }
{Body} {return (BODY); }
{Type} {return (TYPE); }
{Subtype} {return (SUBTYPE); }
{Record} {return (RECORD); }
{Array} {yyextra->Base = DECIMAL; return (ARRAY); }
{Positive} {return (POSITIVE); }
{Range} {return (RANGE); }
{Cell_Info} {BEGIN PAC; return (CELL_INFO); }
{Bsdl_Extension} {return (BSDL_EXTENSION); }
{Std_1532_2001} {return (STD_1532_2001); }
{Std_1532_2002} {return (STD_1532_2002); }
<BOU,PAC>{Input} {return (INPUT); }
<BOU,PAC>{Output2} {return (OUTPUT2); }
<BOU,PAC>{Output3} {return (OUTPUT3); }
<BOU,PAC>{Controlr} {return (CONTROLR); }
<BOU,PAC>{Control} {return (CONTROL); }
<BOU,PAC>{Internal} {return (INTERNAL); }
<BOU,PAC>{Clock} {return (CLOCK); }
<BOU,PAC>{Observe_Only} {return (OBSERVE_ONLY); }
<BOU>{Bidir} {return (BIDIR); }
<PAC>{Bidir_In} {return (BIDIR_IN); }
<PAC>{Bidir_Out} {return (BIDIR_OUT); }
<PAC>{Extest} {return (EXTEST); }
<PAC>{Sample} {return (SAMPLE); }
<PAC>{Intest} {return (INTEST); }
<PAC>{Runbist} {return (RUNBIST); }
<PAC>{Pi} {return (PI); }
<PAC>{Po} {return (PO); }
<PAC>{Upd} {return (UPD); }
<PAC>{Cap} {return (CAP); }
<PAC>{X} {return (X); }
<PAC>{Zero} {return (ZERO); }
<PAC>{One} {return (ONE); }
<BOU>{Z} {return (Z); }
{Eol} {yylineno++; /* Count lines */}
{Comma} {return( COMMA ); }
{Lparen} {return( LPAREN );}
{Rparen} {return( RPAREN );}
{Period} {return( PERIOD ); }
{Colon} {return( COLON ); }
{Box} {return( BOX ); }
{Single_Quote} {yyextra->Base = BIN_X; return( SINGLE_QUOTE ); }
{Colon_Equal} {return( COLON_EQUAL ); }
{Comma} {return (COMMA); }
{Lparen} {return (LPAREN);}
{Rparen} {return (RPAREN);}
{Period} {return (PERIOD); }
{Colon} {return (COLON); }
{Box} {return (BOX); }
{Single_Quote} {yyextra->Base = BIN_X; return (SINGLE_QUOTE); }
{Colon_Equal} {return (COLON_EQUAL); }
{White} { /* Do Nothing on White Space */ }
{VHDL_Comment} { /* Do Nothing on Comments */ }
{Bin_X_Pattern} {if (yyextra->Base != BIN_X) REJECT;
yylval->str = new_string( yyextra, yytext );
return( BIN_X_PATTERN );}
{Identifier} {yylval->str = new_string( yyextra, yytext );
return( IDENTIFIER ); }
{Quoted_String} {yylval->str = new_string( yyextra, yytext );
return( QUOTED_STRING ); }
yylval->str = new_string (yyextra, yytext);
return (BIN_X_PATTERN);}
{Identifier} {yylval->str = new_string (yyextra, yytext);
return (IDENTIFIER); }
{Quoted_String} {yylval->str = new_string (yyextra, yytext);
return (QUOTED_STRING); }
{Decimal_Number} {if (yyextra->Base != DECIMAL) REJECT;
yylval->integer = atoi( (char *)yytext );
return( DECIMAL_NUMBER );}
{Real_Number} {yylval->str = new_string( yyextra, yytext );
return( REAL_NUMBER );}
{Concatenate} {return( CONCATENATE );}
{Semicolon} {return( SEMICOLON );}
{Illegal} {urj_bsdl_msg( yyextra->proc_mode,
yylval->integer = atoi ((char *)yytext);
return (DECIMAL_NUMBER);}
{Real_Number} {yylval->str = new_string (yyextra, yytext);
return (REAL_NUMBER);}
{Concatenate} {return (CONCATENATE);}
{Semicolon} {return (SEMICOLON);}
{Illegal} {urj_bsdl_msg (yyextra->proc_mode,
BSDL_MSG_ERR,
_("Illegal character %c (/%03o) at line %d:\n"),
(char)yytext[yyleng-1], (int)yytext[yyleng-1],
yylineno );
yylineno);
yyextra->Compile_Errors++;
return( ILLEGAL ); /* Will cause syntax error */}
return (ILLEGAL); /* Will cause syntax error */}
<<EOF>> {
yypop_buffer_state( yyscanner );
if ( !YY_CURRENT_BUFFER )
yypop_buffer_state (yyscanner);
if (!YY_CURRENT_BUFFER)
yyterminate();
}
%%
/*****************************************************************************
* void *urj_vhdl_flex_init( FILE *f, int mode )
*
@ -355,34 +357,37 @@ Std_1532_2002 STD_1532_2002
* Returns
* pointer to newly initialized scanner structure
****************************************************************************/
void *urj_vhdl_flex_init( FILE *f, int proc_mode )
void *
urj_vhdl_flex_init (FILE *f, int proc_mode)
{
urj_bsdl_scan_extra_t *extra;
yyscan_t scanner;
/* get our scanner structure */
if (yylex_init( &scanner ) != 0)
{
urj_bsdl_msg( proc_mode, BSDL_MSG_FATAL, _("Scanner could not be initialized\n") );
return NULL;
}
yyset_in( f, scanner );
if (!(extra = malloc( sizeof( urj_bsdl_scan_extra_t ) )))
{
urj_bsdl_msg( proc_mode,
BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), __FILE__, __LINE__ );
yylex_destroy( scanner );
return NULL;
}
extra->proc_mode = proc_mode;
extra->Compile_Errors = 0;
extra->Base = DECIMAL;
yyset_extra( extra, scanner );
return scanner;
urj_bsdl_scan_extra_t *extra;
yyscan_t scanner;
/* get our scanner structure */
if (yylex_init (&scanner) != 0)
{
urj_bsdl_msg (proc_mode, BSDL_MSG_FATAL,
_("Scanner could not be initialized\n"));
return NULL;
}
yyset_in (f, scanner);
if (!(extra = malloc (sizeof (urj_bsdl_scan_extra_t))))
{
urj_bsdl_msg (proc_mode,
BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"),
__FILE__, __LINE__);
yylex_destroy (scanner);
return NULL;
}
extra->proc_mode = proc_mode;
extra->Compile_Errors = 0;
extra->Base = DECIMAL;
yyset_extra (extra, scanner);
return scanner;
}
@ -397,17 +402,18 @@ void *urj_vhdl_flex_init( FILE *f, int proc_mode )
* Returns
* void
****************************************************************************/
void urj_vhdl_flex_deinit( void *scanner )
void
urj_vhdl_flex_deinit (void *scanner)
{
if (yyget_in( scanner ))
{
/* file might still be open so close it in any case
e.g. when a compile error occured and the parser didn't hit EOF/yywrap() */
fclose( yyget_in( scanner ) );
yyset_in( NULL, scanner );
}
free( yyget_extra( scanner ) );
yylex_destroy( scanner );
if (yyget_in (scanner))
{
/* file might still be open so close it in any case
e.g. when a compile error occured and the parser didn't hit EOF/yywrap() */
fclose (yyget_in (scanner));
yyset_in (NULL, scanner);
}
free (yyget_extra (scanner));
yylex_destroy (scanner);
}
@ -422,14 +428,15 @@ void urj_vhdl_flex_deinit( void *scanner )
* Returns
* 1
****************************************************************************/
int yywrap( yyscan_t scanner )
int
yywrap (yyscan_t scanner)
{
if (yyget_in( scanner ))
{
fclose( yyget_in( scanner ) );
yyset_in( NULL, scanner );
}
return 1;
if (yyget_in (scanner))
{
fclose (yyget_in (scanner));
yyset_in (NULL, scanner);
}
return 1;
}
@ -445,22 +452,24 @@ int yywrap( yyscan_t scanner )
* Returns
* pointer to allocated and initialized string memory
****************************************************************************/
static char *new_string( urj_bsdl_scan_extra_t *extra, const char *str )
static char *
new_string (urj_bsdl_scan_extra_t * extra, const char *str)
{
char *n_str;
size_t n_str_size;
n_str_size = strlen( str ) + 1;
if ((n_str = malloc( n_str_size )))
{
strncpy( n_str, str, n_str_size-1 );
n_str[n_str_size-1] = '\0'; /* set very last element to EOS */
}
else
urj_bsdl_msg( extra->proc_mode,
BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"), __FILE__, __LINE__ );
return n_str;
char *n_str;
size_t n_str_size;
n_str_size = strlen (str) + 1;
if ((n_str = malloc (n_str_size)))
{
strncpy (n_str, str, n_str_size - 1);
n_str[n_str_size - 1] = '\0'; /* set very last element to EOS */
}
else
urj_bsdl_msg (extra->proc_mode,
BSDL_MSG_FATAL, _("Out of memory, %s line %i\n"),
__FILE__, __LINE__);
return n_str;
}
@ -476,55 +485,56 @@ static char *new_string( urj_bsdl_scan_extra_t *extra, const char *str )
* Returns
* void
****************************************************************************/
void urj_vhdl_flex_switch_file( yyscan_t scanner, char *filename )
void
urj_vhdl_flex_switch_file (yyscan_t scanner, char *filename)
{
urj_bsdl_scan_extra_t *extra;
FILE *f;
char *s;
/* convert filename to all upper case */
s = filename;
while (*s)
{
if (islower( *s ))
*s = toupper( *s );
s++;
}
extra = yyget_extra( scanner );
/* file in current directory has precedence */
f = fopen( filename, "r" );
if (!f)
{
const char *db_path = urj_get_data_dir();
char *db_file;
if ((db_file = malloc( strlen( db_path ) +
1 + /* "/" */
4 + /* "bsdl" */
1 + /* "/" */
strlen( filename ) +
1 )))
urj_bsdl_scan_extra_t *extra;
FILE *f;
char *s;
/* convert filename to all upper case */
s = filename;
while (*s)
{
if (islower (*s))
*s = toupper (*s);
s++;
}
extra = yyget_extra (scanner);
/* file in current directory has precedence */
f = fopen (filename, "r");
if (!f)
{
strcpy( db_file, db_path );
strcat( db_file, "/" );
strcat( db_file, "bsdl" );
strcat( db_file, "/" );
strcat( db_file, filename );
f = fopen( db_file, "r" );
if (!f)
urj_bsdl_msg( extra->proc_mode,
BSDL_MSG_FATAL, _("Cannot open file %s or %s.\n"), filename, db_file );
free( db_file );
if (!f)
return;
const char *db_path = urj_get_data_dir ();
char *db_file;
if ((db_file = malloc (strlen (db_path) + 1 + /* "/" */
4 + /* "bsdl" */
1 + /* "/" */
strlen (filename) + 1)))
{
strcpy (db_file, db_path);
strcat (db_file, "/");
strcat (db_file, "bsdl");
strcat (db_file, "/");
strcat (db_file, filename);
f = fopen (db_file, "r");
if (!f)
urj_bsdl_msg (extra->proc_mode,
BSDL_MSG_FATAL,
_("Cannot open file %s or %s.\n"), filename,
db_file);
free (db_file);
if (!f)
return;
}
}
}
yypush_buffer_state( yy_create_buffer( f, YY_BUF_SIZE, scanner ), scanner );
yyset_lineno( 1, scanner );
yypush_buffer_state (yy_create_buffer (f, YY_BUF_SIZE, scanner), scanner);
yyset_lineno (1, scanner);
}
@ -539,10 +549,11 @@ void urj_vhdl_flex_switch_file( yyscan_t scanner, char *filename )
* Returns
* number of compile errors
****************************************************************************/
int urj_vhdl_flex_get_compile_errors( yyscan_t scanner )
int
urj_vhdl_flex_get_compile_errors (yyscan_t scanner)
{
urj_bsdl_scan_extra_t *extra = yyget_extra( scanner );
return extra->Compile_Errors;
urj_bsdl_scan_extra_t *extra = yyget_extra (scanner);
return extra->Compile_Errors;
}
@ -558,10 +569,11 @@ int urj_vhdl_flex_get_compile_errors( yyscan_t scanner )
* Returns
* void
****************************************************************************/
static void urj_vhdl_flex_set_compile_errors( int n, yyscan_t scanner )
static void
urj_vhdl_flex_set_compile_errors (int n, yyscan_t scanner)
{
urj_bsdl_scan_extra_t *extra = yyget_extra( scanner );
extra->Compile_Errors = n;
urj_bsdl_scan_extra_t *extra = yyget_extra (scanner);
extra->Compile_Errors = n;
}
@ -576,12 +588,13 @@ static void urj_vhdl_flex_set_compile_errors( int n, yyscan_t scanner )
* Returns
* number of compile errors before increment
****************************************************************************/
int urj_vhdl_flex_postinc_compile_errors( yyscan_t scanner )
int
urj_vhdl_flex_postinc_compile_errors (yyscan_t scanner)
{
int errors = urj_vhdl_flex_get_compile_errors( scanner );
int errors = urj_vhdl_flex_get_compile_errors (scanner);
urj_vhdl_flex_set_compile_errors( errors+1, scanner );
return errors;
urj_vhdl_flex_set_compile_errors (errors + 1, scanner);
return errors;
}
@ -596,9 +609,10 @@ int urj_vhdl_flex_postinc_compile_errors( yyscan_t scanner )
* Returns
* current line number
****************************************************************************/
int urj_vhdl_flex_get_lineno( yyscan_t scanner )
int
urj_vhdl_flex_get_lineno (yyscan_t scanner)
{
return yyget_lineno( scanner );
return yyget_lineno (scanner);
}

@ -1123,7 +1123,7 @@ urj_svf_txr (enum URJ_SVF_generic_irdr_coding ir_dr,
* 0 : error occurred
* ***************************************************************************/
void
urj_svf_run (urj_chain_t *chain, FILE * SVF_FILE, int stop_on_mismatch,
urj_svf_run (urj_chain_t *chain, FILE *SVF_FILE, int stop_on_mismatch,
int print_progress, uint32_t ref_freq)
{
const urj_svf_sxr_t sxr_default = { {0.0, NULL, NULL, NULL, NULL},

@ -405,60 +405,64 @@ direction
| INOUT
;
%%
void
yyerror(YYLTYPE *locp, urj_svf_parser_priv_t *priv_data, urj_chain_t *chain, const char *error_string)
%% void
yyerror (YYLTYPE *locp, urj_svf_parser_priv_t *priv_data, urj_chain_t *chain,
const char *error_string)
{
printf("Error occurred for SVF command %s.\n", error_string);
printf ("Error occurred for SVF command %s.\n", error_string);
}
static void
urj_svf_free_ths_params(struct ths_params *params)
urj_svf_free_ths_params (struct ths_params *params)
{
params->number = 0.0;
if (params->tdi) {
free(params->tdi);
params->tdi = NULL;
}
if (params->tdo) {
free(params->tdo);
params->tdo = NULL;
}
if (params->mask) {
free(params->mask);
params->mask = NULL;
}
if (params->smask) {
free(params->smask);
params->smask = NULL;
}
params->number = 0.0;
if (params->tdi)
{
free (params->tdi);
params->tdi = NULL;
}
if (params->tdo)
{
free (params->tdo);
params->tdo = NULL;
}
if (params->mask)
{
free (params->mask);
params->mask = NULL;
}
if (params->smask)
{
free (params->smask);
params->smask = NULL;
}
}
int
urj_svf_bison_init(urj_svf_parser_priv_t *priv_data, FILE *f, int num_lines, int print_progress)
urj_svf_bison_init (urj_svf_parser_priv_t *priv_data, FILE *f, int num_lines,
int print_progress)
{
const struct svf_parser_params params = {
{0.0, NULL, NULL, NULL, NULL},
{{}, 0},
{0, 0.0, 0, 0, 0, 0}
};
priv_data->parser_params = params;
if ((priv_data->scanner = urj_svf_flex_init(f, num_lines, print_progress)) == NULL)
return 0;
else
return 1;
const struct svf_parser_params params = {
{0.0, NULL, NULL, NULL, NULL},
{{}, 0},
{0, 0.0, 0, 0, 0, 0}
};
priv_data->parser_params = params;
if ((priv_data->scanner =
urj_svf_flex_init (f, num_lines, print_progress)) == NULL)
return 0;
else
return 1;
}
void
urj_svf_bison_deinit(urj_svf_parser_priv_t *priv_data)
urj_svf_bison_deinit (urj_svf_parser_priv_t *priv_data)
{
urj_svf_flex_deinit(priv_data->scanner);
urj_svf_flex_deinit (priv_data->scanner);
}

@ -217,185 +217,198 @@ COMMENT (!.*)|("//".*)[^\n]
*===========================================================================*/
static struct rwtable
{
char *rw_name;
int rw_yylex;
} rwtable[] = {
{"ABSENT", ABSENT},
{"D", D},
{"DRCAPTURE", DRCAPTURE},
{"DREXIT1", DREXIT1},
{"DREXIT2", DREXIT2},
{"DRPAUSE", DRPAUSE},
{"DRSELECT", DRSELECT},
{"DRSHIFT", DRSHIFT},
{"DRUPDATE", DRUPDATE},
{"EMPTY", EMPTY},
{"ENDDR", ENDDR},
{"ENDIR", ENDIR},
{"ENDSTATE", ENDSTATE},
{"FREQUENCY", FREQUENCY},
{"H", H},
{"HDR", HDR},
{"HIR", HIR},
{"HZ", HZ},
{"URJ_JIM_IDLE", URJ_JIM_IDLE},
{"IN", IN},
{"INOUT", INOUT},
{"IRCAPTURE", IRCAPTURE},
{"IREXIT1", IREXIT1},
{"IREXIT2", IREXIT2},
{"IRPAUSE", IRPAUSE},
{"IRSELECT", IRSELECT},
{"IRSHIFT", IRSHIFT},
{"IRUPDATE", IRUPDATE},
{"L", L},
{"MASK", MASK},
{"MAXIMUM", MAXIMUM},
{"OFF", OFF},
{"ON", ON},
{"OUT", OUT},
{"PIO", PIO},
{"PIOMAP", PIOMAP},
{"URJ_JIM_RESET", URJ_JIM_RESET},
{"RUNTEST", RUNTEST},
{"SCK", SCK},
{"SDR", SDR},
{"SEC", SEC},
{"SIR", SIR},
{"SMASK", SMASK},
{"STATE", STATE},
{"TCK", TCK},
{"TDI", TDI},
{"TDO", TDO},
{"TDR", TDR},
{"TIR", TIR},
{"TRST", TRST},
{"U", U},
{"X", X},
{"Z", Z}
};//end of rwtable struct
#define END(v) (sizeof(v) / sizeof(v[0]) - 1)
char *rw_name;
int rw_yylex;
} rwtable[] =
{
{ "ABSENT", ABSENT },
{ "D", D },
{ "DRCAPTURE", DRCAPTURE },
{ "DREXIT1", DREXIT1 },
{ "DREXIT2", DREXIT2 },
{ "DRPAUSE", DRPAUSE },
{ "DRSELECT", DRSELECT },
{ "DRSHIFT", DRSHIFT },
{ "DRUPDATE", DRUPDATE },
{ "EMPTY", EMPTY },
{ "ENDDR", ENDDR },
{ "ENDIR", ENDIR },
{ "ENDSTATE", ENDSTATE },
{ "FREQUENCY", FREQUENCY },
{ "H", H },
{ "HDR", HDR },
{ "HIR", HIR },
{ "HZ", HZ },
{ "URJ_JIM_IDLE", URJ_JIM_IDLE },
{ "IN", IN },
{ "INOUT", INOUT },
{ "IRCAPTURE", IRCAPTURE },
{ "IREXIT1", IREXIT1 },
{ "IREXIT2", IREXIT2 },
{ "IRPAUSE", IRPAUSE },
{ "IRSELECT", IRSELECT },
{ "IRSHIFT", IRSHIFT },
{ "IRUPDATE", IRUPDATE },
{ "L", L },
{ "MASK", MASK },
{ "MAXIMUM", MAXIMUM },
{ "OFF", OFF },
{ "ON", ON },
{ "OUT", OUT },
{ "PIO", PIO },
{ "PIOMAP", PIOMAP },
{ "URJ_JIM_RESET", URJ_JIM_RESET },
{ "RUNTEST", RUNTEST },
{ "SCK", SCK },
{ "SDR", SDR },
{ "SEC", SEC },
{ "SIR", SIR },
{ "SMASK", SMASK },
{ "STATE", STATE },
{ "TCK", TCK },
{ "TDI", TDI },
{ "TDO", TDO },
{ "TDR", TDR },
{ "TIR", TIR },
{ "TRST", TRST },
{ "U", U },
{ "X", X },
{ "Z", Z }
}; //end of rwtable struct
#define END(v) (sizeof(v) / sizeof((v)[0]) - 1)
static int
map_keyw_ident(YYSTYPE * mylval, char *str)
map_keyw_ident (YYSTYPE *mylval, char *str)
{
int idx;
int rw = IDENTIFIER;
mylval->cvalue = str;
for (idx = 0; idx <= END(rwtable); idx++) {
if (strcasecmp(rwtable[idx].rw_name, str) == 0) {
/* always return terminal value as semantic value */
rw = rwtable[idx].rw_yylex;
mylval->token = rw;
int idx;
int rw = IDENTIFIER;
mylval->cvalue = str;
for (idx = 0; idx <= END (rwtable); idx++)
{
if (strcasecmp (rwtable[idx].rw_name, str) == 0)
{
/* always return terminal value as semantic value */
rw = rwtable[idx].rw_yylex;
mylval->token = rw;
}
}
}
return(rw);
return (rw);
}
static void
align_string(char *str)
align_string (char *str)
{
int src, dst, len;
int src, dst, len;
dst = 0;
len = strlen(str);
dst = 0;
len = strlen (str);
for (src = 0; src < len; src++) {
if (isxdigit(str[src]))
str[dst++] = str[src];
}
str[dst] = '\0';
for (src = 0; src < len; src++)
{
if (isxdigit (str[src]))
str[dst++] = str[src];
}
str[dst] = '\0';
}
static void
fix_yylloc(YYLTYPE * mylloc, char *str)
fix_yylloc (YYLTYPE *mylloc, char *str)
{
mylloc->first_line = mylloc->last_line;
mylloc->first_column = mylloc->last_column;
mylloc->last_column += strlen(str);
mylloc->first_line = mylloc->last_line;
mylloc->first_column = mylloc->last_column;
mylloc->last_column += strlen (str);
}
static void
fix_yylloc_nl(YYLTYPE * mylloc, char *str, YY_EXTRA_TYPE extra)
fix_yylloc_nl (YYLTYPE *mylloc, char *str, YY_EXTRA_TYPE extra)
{
char *p;
mylloc->first_line = mylloc->last_line;
mylloc->first_column = mylloc->last_column;
for (p = str; *p; ++p) {
if (*p == '\n') {
mylloc->last_column = 0;
++mylloc->last_line;
progress_nl(mylloc, extra);
} else {
++mylloc->last_column;
char *p;
mylloc->first_line = mylloc->last_line;
mylloc->first_column = mylloc->last_column;
for (p = str; *p; ++p)
{
if (*p == '\n')
{
mylloc->last_column = 0;
++mylloc->last_line;
progress_nl (mylloc, extra);
}
else
{
++mylloc->last_column;
}
}
}
}
static void
progress_nl(YYLTYPE * mylloc, YY_EXTRA_TYPE extra)
progress_nl (YYLTYPE *mylloc, YY_EXTRA_TYPE extra)
{
int percent;
if ((extra->print_progress) && (mylloc->last_line % 10==0)) {
percent = ((mylloc->last_line * 100) + 1) / extra->num_lines;
if (percent <= 1) return; // dont bother printing < 1 %
printf( "\r" );
printf( _("Parsing %6d/%d (%3.0d%%)"),
mylloc->last_line, extra->num_lines, percent);
}
int percent;
if ((extra->print_progress) && (mylloc->last_line % 10 == 0))
{
percent = ((mylloc->last_line * 100) + 1) / extra->num_lines;
if (percent <= 1)
return; // dont bother printing < 1 %
printf ("\r");
printf (_("Parsing %6d/%d (%3.0d%%)"),
mylloc->last_line, extra->num_lines, percent);
}
}
void *urj_svf_flex_init(FILE *f, int num_lines, int print_progress)
void *
urj_svf_flex_init (FILE *f, int num_lines, int print_progress)
{
YY_EXTRA_TYPE extra;
yyscan_t scanner;
YY_EXTRA_TYPE extra;
yyscan_t scanner;
/* get our scanner structure */
if (yylex_init(&scanner) != 0)
return NULL;
/* get our scanner structure */
if (yylex_init (&scanner) != 0)
return NULL;
yyset_in(f, scanner);
yyset_in (f, scanner);
if (!(extra = malloc(sizeof(urj_svf_scanner_extra_t)))) {
printf( _("Out of memory, %s line %i\n"), __FILE__, __LINE__ );
yylex_destroy(scanner);
return NULL;
}
if (!(extra = malloc (sizeof (urj_svf_scanner_extra_t))))
{
printf (_("Out of memory, %s line %i\n"), __FILE__, __LINE__);
yylex_destroy (scanner);
return NULL;
}
extra->num_lines = num_lines;
extra->print_progress = print_progress;
extra->num_lines = num_lines;
extra->print_progress = print_progress;
#ifdef ENABLE_NLS
{
struct lconv *lc = localeconv();
extra->decimal_point = lc->decimal_point[0];
}
{
struct lconv *lc = localeconv ();
extra->decimal_point = lc->decimal_point[0];
}
#else
extra->decimal_point = '.';
extra->decimal_point = '.';
#endif
yyset_extra(extra, scanner);
yyset_extra (extra, scanner);
return scanner;
return scanner;
}
void urj_svf_flex_deinit(void *scanner)
void
urj_svf_flex_deinit (void *scanner)
{
YY_EXTRA_TYPE extra = yyget_extra(scanner);
if (extra->print_progress)
printf("\n");
free(extra);
yylex_destroy(scanner);
YY_EXTRA_TYPE extra = yyget_extra (scanner);
if (extra->print_progress)
printf ("\n");
free (extra);
yylex_destroy (scanner);
}

Loading…
Cancel
Save