2
* $Id: config_parser.y,v 1.2 2002/11/17 00:29:20 troth Exp $
4
****************************************************************************
6
* simulavr-vcd - A vcd file writer as display process for simulavr.
7
* Copyright (C) 2002 Carsten Beth
9
* This program is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation; either version 2 of the License, or
12
* (at your option) any later version.
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
19
* You should have received a copy of the GNU General Public License
20
* along with this program; if not, write to the Free Software
21
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
****************************************************************************
33
extern void config_scanner_init( FILE *infile );
34
extern int config_lex( void );
36
void config_error( char *s );
37
int parse_config( FILE *infile );
39
extern char *config_text;
61
%right '[' ']' ':' '=' '\n'
76
%type <string> filename
77
%type <integer> number
84
frequency_def vcd_file_def trace_defs;
88
CP_FREQUENCY '=' number '\n'
90
vcd_set_frequency( $3 );
94
CP_VCD_FILE '=' name '\n'
96
vcd_set_file_name( $3 );
98
| CP_VCD_FILE '=' filename '\n'
100
vcd_set_file_name( $3 );
106
| trace_defs CP_TRACE trace_def '\n'
107
| error '\n' { yyerrok; };
113
for( i = $2.from; i <= $2.to; i++ )
121
for( i = $2.from; i <= $2.to; i++ )
131
for( i = $2.from; i <= $2.to; i++ )
132
vcd_trace_io_reg( NULL, i );
136
vcd_trace_io_reg( $2, -1 );
154
| '[' number ':' number ']'
163
$$ = (char *)malloc( strlen( config_text ) + 1 );
164
strcpy( $$, config_text );
170
$$ = (char *)malloc( strlen( config_text ) + 1 );
171
strcpy( $$, config_text );
177
$$ = atoi( config_text );
184
extern int config_get_line (void);
186
/*************************************************************************
187
* Funktion : mapping_error() gibt den als Parameter �bergebenen String
188
* auf dem Standard-Fehlerkanal aus. Diese Funktion wird von
189
* mapping_parse() aufgerufen, wenn ein ihr ein Fehler gefunden
191
* Parameter : s - Auszugebender Fehlertext
195
*************************************************************************/
196
void config_error( char *s )
199
fprintf( stderr, "line %i: %s\n", config_get_line(), s );
202
/*************************************************************************
208
*************************************************************************/
209
int parse_config( FILE *infile )
215
/* Scanner iniitialization. */
216
config_scanner_init( infile );
218
/* Parse the data. */
220
if ( errorFound || (rv != 0) )