Go to most recent revision | Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 2 | mjames | 1 | %{ |
| 2 | /* |
||
| 3 | * $Id: acf_lex.l,v 1.2 2004/06/22 21:44:10 mjames Exp $ * |
||
| 4 | * |
||
| 5 | * $Log: acf_lex.l,v $ |
||
| 6 | * Revision 1.2 2004/06/22 21:44:10 mjames |
||
| 7 | * Firrst build most files |
||
| 8 | * |
||
| 9 | * Revision 1.30 2002/10/02 18:46:34 MJAMES |
||
| 10 | * attribute is recognised in acfp syntax as well as vhdl |
||
| 11 | * |
||
| 12 | * Revision 1.29 2002/09/27 22:24:14 MJAMES |
||
| 13 | * Separated out a quote as a token |
||
| 14 | * Added VHDL_CONN token |
||
| 15 | * |
||
| 16 | * Revision 1.28 2002/09/16 11:03:50 mjames |
||
| 17 | * Added some of the generic string types to the input parser. |
||
| 18 | * |
||
| 19 | * Revision 1.27 2002/09/09 10:14:58 mjames |
||
| 20 | * Modified expression parser to match CC as previous one was |
||
| 21 | * broken |
||
| 22 | * |
||
| 23 | * Revision 1.26 2002/08/23 14:21:55 mjames |
||
| 24 | * Added the <VHDL> string keyword. |
||
| 25 | * |
||
| 26 | * Revision 1.25 2002/08/19 14:31:27 mjames |
||
| 27 | * Removed an incompatibility with env_string generics where the output |
||
| 28 | * of Vertical caused an error under some circumstances. |
||
| 29 | * |
||
| 30 | * Revision 1.24 2002/08/14 11:58:43 mjames |
||
| 31 | * Corrected end-of-file behaviour that resulted in an infinite loop |
||
| 32 | * |
||
| 33 | * Revision 1.23 2002/08/06 12:56:21 mjames |
||
| 34 | * Merge in from latest version |
||
| 35 | * |
||
| 36 | * |
||
| 37 | * Revision 1.25 2002/08/06 09:25:23 mjames |
||
| 38 | * Changed file include handler for an improved one. |
||
| 39 | * Improvements created as a part of a microcode assembler |
||
| 40 | * |
||
| 41 | * Revision 1.24 2002/03/22 16:16:28 mjames |
||
| 42 | * Modifications to undo over-zealous checking of |
||
| 43 | * current chip even in incorrect scenarios. |
||
| 44 | * |
||
| 45 | * Revision 1.23 2002/03/21 17:11:32 mjames |
||
| 46 | * Allowed '[' and ']' in acfp file syntax for pin identifiers in Quartus |
||
| 47 | * |
||
| 48 | * Revision 1.22 2002/01/21 09:28:49 mjames |
||
| 49 | * coredump when opening non-existent Verilog include file due to |
||
| 50 | * use of NULL file pointer. Avoided by not using file pointer until certain |
||
| 51 | * that file was opened properly. |
||
| 52 | * |
||
| 53 | * Revision 1.21 2002/01/16 10:04:35 mjames |
||
| 54 | * Added package definitions to VHDL syntax |
||
| 55 | * According to report by John Marquis |
||
| 56 | * |
||
| 57 | * Revision 1.20 2001/12/13 22:12:16 mjames |
||
| 58 | * Vertical now supports nested include database files |
||
| 59 | * This allows wrappers around 'pure' VHDL or Verilog files |
||
| 60 | * |
||
| 61 | * Revision 1.19 2001/12/11 21:29:56 mjames |
||
| 62 | * Verilog syntax now read in by Vertical allows pin templates |
||
| 63 | * defined by Certify to be used. |
||
| 64 | * |
||
| 65 | * Revision 1.18 2001/11/30 22:21:19 mjames |
||
| 66 | * Modifying Verilog reading syntax to accept valid code. |
||
| 67 | * |
||
| 68 | * Revision 1.17 2001/11/19 10:41:54 mjames |
||
| 69 | * Merged back DTC release |
||
| 70 | * |
||
| 71 | * Revision 1.16.2.1 2001/11/16 15:10:59 mjames |
||
| 72 | * Removed an unecessary local variable |
||
| 73 | * |
||
| 74 | * Revision 1.16 2001/10/31 22:19:56 mjames |
||
| 75 | * Tidying up problematical comments caused by CVS |
||
| 76 | * 'intelligent' comment guessing |
||
| 77 | * |
||
| 78 | * Revision 1.15 2001/09/28 14:34:13 mjames |
||
| 79 | * FIxed yydebug variable to exist when YYDEBUG macro |
||
| 80 | * is not defined. Otherwise linker error will be reported. |
||
| 81 | * |
||
| 82 | * Revision 1.14 2001/09/16 20:01:06 mjames |
||
| 83 | * tidying |
||
| 84 | * |
||
| 85 | * Revision 1.13 2001/07/09 09:36:30 mjames |
||
| 86 | * Amending the syntax and end of file behaviour to allow Quartus pin fit files |
||
| 87 | * to be read . |
||
| 88 | * They are harder to read because they are not block structured. The end of file is used as a marker. Vertical has been persuaded to handle end of file events properly. |
||
| 89 | * |
||
| 90 | * Revision 1.12 2001/07/06 12:50:36 mjames |
||
| 91 | * Added the ability to read in Quartus pinfit files |
||
| 92 | * |
||
| 93 | * Revision 1.11 2001/07/05 15:12:36 MJAMES |
||
| 94 | * Amended to read Quartus pin files. not fully working |
||
| 95 | * |
||
| 96 | * Revision 1.10 2001/06/06 12:10:27 mjames |
||
| 97 | * Move from HPUX |
||
| 98 | * |
||
| 99 | * Revision 1.9 2001/04/30 10:01:08 Administrator |
||
| 100 | * Have finally got the Verilog/VHDL comment pragma parser working. |
||
| 101 | * |
||
| 102 | * Revision 1.8 2001/04/30 07:55:53 mjames |
||
| 103 | * Improving parsing of Verilog, still a few loose ends |
||
| 104 | * |
||
| 105 | * Revision 1.7 2001/04/27 22:30:10 mjames |
||
| 106 | * Starting to get comment and pragma handling OK. |
||
| 107 | * Added correct header file includes to lx_support.c |
||
| 108 | * |
||
| 109 | * Revision 1.6 2001/03/29 08:27:06 mjames |
||
| 110 | * Converted frbread for use with the newer files from the drawing office |
||
| 111 | * |
||
| 112 | * Revision 1.5 2001/02/21 16:37:33 mjames |
||
| 113 | * Provided a new method of defining port maps with VHDL which allows for short |
||
| 114 | * cut definitions. |
||
| 115 | * |
||
| 116 | * Cleaned up TCL/Tk interfacing issues |
||
| 117 | * |
||
| 118 | * Revision 1.4 2001/01/02 07:53:51 mjames |
||
| 119 | * Made changes to allow for interface with TCL/Tk |
||
| 120 | * |
||
| 121 | * Revision 1.3 2000/12/04 12:55:48 mjames |
||
| 122 | * Copied files back from HPUX to create definitive CygWin version |
||
| 123 | * |
||
| 124 | * Then amended the syntax of ACFP files so that a/2 was no longer |
||
| 125 | * seen as "a/2" but instead as "a" divided_by 2. This was a throwback |
||
| 126 | * to some of the earlier efforts at variant syntax for VHDL and ACFP |
||
| 127 | * parsing. |
||
| 128 | * |
||
| 129 | * Revision 1.2 2000/10/19 22:19:49 mjames |
||
| 130 | * removed header lines |
||
| 131 | * |
||
| 132 | * Revision 1.1.1.1 2000/10/19 21:58:34 mjames |
||
| 133 | * Mike put it here |
||
| 134 | * |
||
| 135 | * |
||
| 136 | */ |
||
| 137 | |||
| 138 | |||
| 139 | #include <stdio.h> |
||
| 140 | #include <stdlib.h> |
||
| 141 | #include <ctype.h> |
||
| 142 | #include <string.h> |
||
| 143 | |||
| 144 | /* see makefile for how this appears */ |
||
| 145 | |||
| 146 | #include "vertcl_main.h" |
||
| 147 | #include "expression.h" |
||
| 148 | #include "generic.h" |
||
| 149 | #include "database.h" |
||
| 150 | #include "acf_yacc.h" |
||
| 151 | #include "lx_support.h" |
||
| 152 | #include "cmdparse.h" |
||
| 153 | #include "cmdlog.h" |
||
| 154 | #include "cmdutil.h" |
||
| 155 | #include "yywrap.h" |
||
| 156 | |||
| 157 | |||
| 158 | |||
| 159 | |||
| 160 | #define YYLMAX MAXIDLEN |
||
| 161 | |||
| 162 | #if !defined YY_START |
||
| 163 | #define YY_START (yybgin -1 -yysvec) |
||
| 164 | #endif |
||
| 165 | |||
| 166 | /* YY_INPUT redefinition |
||
| 167 | keep the original definition, replace with a function which will |
||
| 168 | check a flag and either use the original file reading version or read from |
||
| 169 | a string */ |
||
| 170 | |||
| 171 | |||
| 172 | |||
| 173 | |||
| 174 | |||
| 175 | |||
| 176 | |||
| 177 | |||
| 178 | |||
| 179 | |||
| 180 | |||
| 181 | #define MAX_INCLUDE_DEPTH 10 |
||
| 182 | |||
| 183 | |||
| 184 | |||
| 185 | |||
| 186 | #ident "@(#)$Header: C:/cvsroot/Vert03/acf_src/acf_lex.l,v 1.2 2004/06/22 21:44:10 mjames Exp $" |
||
| 187 | |||
| 188 | /* state stores for include files */ |
||
| 189 | YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH]; |
||
| 190 | struct str * incl_first = NULL, * incl_last = NULL; |
||
| 191 | char * filename[MAX_INCLUDE_DEPTH]; |
||
| 192 | int old_linenumber[MAX_INCLUDE_DEPTH]; |
||
| 193 | FILE * handles[MAX_INCLUDE_DEPTH]; |
||
| 194 | |||
| 195 | |||
| 196 | int include_stack_ptr = 0; |
||
| 197 | |||
| 198 | |||
| 199 | char lex_from_string = 0; |
||
| 200 | |||
| 201 | extern int errorseen; |
||
| 202 | extern int yyval; |
||
| 203 | extern int yydebug; |
||
| 204 | extern int lineno; |
||
| 205 | |||
| 206 | |||
| 207 | extern int inside_block; /* flag to help 'generic' context dependence */ |
||
| 208 | |||
| 209 | generic_info_t info; |
||
| 210 | |||
| 211 | int prev_begin = -1; |
||
| 212 | int prev_begin_include = -1; |
||
| 213 | int read_state = 1; /* start off by reading */ |
||
| 214 | |||
| 215 | int comment_type = 0; |
||
| 216 | |||
| 217 | void lex_exec_line(void); |
||
| 218 | |||
| 219 | void skip_to_eol(void); |
||
| 220 | void skip_c_comment(void); |
||
| 221 | void exit_lex_block(void); |
||
| 222 | |||
| 223 | |||
| 224 | int my_yyinput(char * buf , int max_size); |
||
| 225 | |||
| 226 | |||
| 227 | static char * yyerr_start_names[] = { |
||
| 228 | "INITIAL", |
||
| 229 | "vhdl", |
||
| 230 | "Verilog", |
||
| 231 | "ACFplus", |
||
| 232 | "skipping", |
||
| 233 | "C (Verilog) comment", |
||
| 234 | "VHDL comment", |
||
| 235 | "Command line expression", |
||
| 236 | "Include file area" |
||
| 237 | }; |
||
| 238 | |||
| 239 | /* token forced into LEX by method described in |
||
| 240 | Lex & Yacc , O'Reilly page 206 */ |
||
| 241 | int start_grammar; |
||
| 242 | |||
| 243 | |||
| 244 | %} |
||
| 245 | |||
| 246 | |||
| 247 | /* removed '.' '-' ':' '/' ',' from here as it is now a unique token */ |
||
| 248 | /* Permit '$' as this could become a variable to be expanded in make_string */ |
||
| 249 | L [A-Za-z0-9_\~\$] |
||
| 250 | L2 [A-Za-z0-9_\~\|\$] |
||
| 251 | /* do not permit square brackets in ACFP syntax inside strings (to be handled properly) */ |
||
| 252 | L2A [A-Za-z0-9_\~\|/\$] |
||
| 253 | L2D [A-Za-z0-9_\\$\.] |
||
| 254 | /* no / in this set, as its a valid arithmetic operator */ |
||
| 255 | L2V [A-Za-z0-9_\~\|\$] |
||
| 256 | |||
| 257 | S [^\"] |
||
| 258 | Q [\"] |
||
| 259 | |||
| 260 | |||
| 261 | Ct [ -\~] |
||
| 262 | |||
| 263 | Cm [^\n] |
||
| 264 | |||
| 265 | |||
| 266 | |||
| 267 | D [0-9] |
||
| 268 | Spc [ \t] |
||
| 269 | |||
| 270 | /* lex directive */ |
||
| 271 | %p 4000 |
||
| 272 | %a 2500 |
||
| 273 | %e 1500 |
||
| 274 | %k 2000 |
||
| 275 | %n 1000 |
||
| 276 | |||
| 277 | /* can have VHDL Verilog and ACFP keywords defined exclusively */ |
||
| 278 | /* s inclusive set */ |
||
| 279 | %x vhdl |
||
| 280 | %x vlog |
||
| 281 | %x acfp |
||
| 282 | %x pragma |
||
| 283 | %x vert_c_comment |
||
| 284 | %x vert_vhdl_comment |
||
| 285 | /* expression tokens are used on the command line */ |
||
| 286 | %x expr |
||
| 287 | /* copied almost verbatim from the examples given */ |
||
| 288 | %x incl |
||
| 289 | |||
| 290 | |||
| 291 | |||
| 292 | %% |
||
| 293 | %{ |
||
| 294 | |||
| 295 | /* Page 206, Lex & Yacc , O'Reilly */ |
||
| 296 | /* solution to multiple lexers */ |
||
| 297 | |||
| 298 | if(start_grammar) |
||
| 299 | { |
||
| 300 | int tmp = start_grammar; |
||
| 301 | start_grammar = 0; |
||
| 302 | return tmp; |
||
| 303 | } |
||
| 304 | %} |
||
| 305 | |||
| 306 | |||
| 307 | <INITIAL,acfp,vhdl>include { prev_begin_include = YY_START; BEGIN(incl); } |
||
| 308 | |||
| 309 | <vlog>'include { prev_begin_include = YY_START; BEGIN(incl); } |
||
| 310 | |||
| 311 | |||
| 312 | <incl>[ \t]* /* eat the whitespace */ |
||
| 313 | <incl>[^ \t\n]+ { /* got the include file name */ |
||
| 314 | if ( include_stack_ptr >= MAX_INCLUDE_DEPTH ) |
||
| 315 | { |
||
| 316 | Log(LOG_ERROR, "-- Includes nested too deeply\n" ); |
||
| 317 | exit( 1 ); |
||
| 318 | } |
||
| 319 | if(errorseen) |
||
| 320 | { |
||
| 321 | Log(LOG_ERROR, "-- skipping include: previous error\n" ); |
||
| 322 | exit( 1 ); |
||
| 323 | } |
||
| 324 | |||
| 325 | /* printf("++ Using Begin=%s\n",yyerr_start_names[YY_START]); */ |
||
| 326 | |||
| 327 | |||
| 328 | include_stack[include_stack_ptr] = |
||
| 329 | YY_CURRENT_BUFFER; |
||
| 330 | /* expand arguments in string */ |
||
| 331 | |||
| 332 | old_linenumber[include_stack_ptr]= lineno; |
||
| 333 | |||
| 334 | handles[include_stack_ptr] = yyin; |
||
| 335 | |||
| 336 | include_stack_ptr++; |
||
| 337 | |||
| 338 | |||
| 339 | filename[include_stack_ptr] = strdup(yytext); |
||
| 340 | |||
| 341 | yyin = fopen( filename[include_stack_ptr], "r" ); |
||
| 342 | |||
| 343 | if ( ! yyin ) |
||
| 344 | { |
||
| 345 | Log(LOG_ERROR, "-- cannot open include file '%s'\n",filename[include_stack_ptr]); |
||
| 346 | include_stack_ptr -= 1; |
||
| 347 | lineno = old_linenumber[include_stack_ptr]; |
||
| 348 | /* yy_switch_to_buffer( |
||
| 349 | include_stack[include_stack_ptr] ); |
||
| 350 | */ |
||
| 351 | yyin = handles[include_stack_ptr]; |
||
| 352 | |||
| 353 | } |
||
| 354 | else |
||
| 355 | { |
||
| 356 | lineno = 1; |
||
| 357 | |||
| 358 | yy_switch_to_buffer( |
||
| 359 | |||
| 360 | yy_create_buffer( yyin, YY_BUF_SIZE ) ); |
||
| 361 | } |
||
| 362 | BEGIN(prev_begin_include); |
||
| 363 | } |
||
| 364 | |||
| 365 | <<EOF>> { |
||
| 366 | /* rewind(yyin); */ |
||
| 367 | /* printf("-- +++ At level %d\n",include_stack_ptr); */ |
||
| 368 | if ( include_stack_ptr == 0 ) |
||
| 369 | { |
||
| 370 | /* printf("lex: termination\n"); */ |
||
| 371 | /* YY_FLUSH_BUFFER; |
||
| 372 | yy_delete_buffer( YY_CURRENT_BUFFER ); |
||
| 373 | */ |
||
| 374 | exit_lex_block(); |
||
| 375 | yyterminate(); |
||
| 376 | } |
||
| 377 | |||
| 378 | else |
||
| 379 | { |
||
| 380 | /* printf("lex: backup level in file buffer\n"); */ |
||
| 381 | /* YY_FLUSH_BUFFER; */ |
||
| 382 | include_stack_ptr --; |
||
| 383 | yy_delete_buffer( YY_CURRENT_BUFFER ); |
||
| 384 | lineno = old_linenumber[include_stack_ptr]; |
||
| 385 | yyin = handles[include_stack_ptr]; |
||
| 386 | yy_switch_to_buffer( |
||
| 387 | include_stack[include_stack_ptr] ); |
||
| 388 | } |
||
| 389 | /* printf("handle ending"); */ |
||
| 390 | break; |
||
| 391 | } |
||
| 392 | |||
| 393 | |||
| 394 | |||
| 395 | <INITIAL,acfp,vlog,vhdl>"\"" { char t; |
||
| 396 | char * p; |
||
| 397 | char buff[MAXIDLEN]; |
||
| 398 | |||
| 399 | int c; /* quoted string using either type of quotes, |
||
| 400 | * including escaped quotes */ |
||
| 401 | |||
| 402 | t = *yytext; /* determine terminator */ |
||
| 403 | |||
| 404 | p = buff; /* setup destination */ |
||
| 405 | |||
| 406 | for(;;) { |
||
| 407 | |||
| 408 | c = input(); |
||
| 409 | if (c == t) |
||
| 410 | break; |
||
| 411 | |||
| 412 | if(c=='\n') { |
||
| 413 | lineno++; |
||
| 414 | Log(LOG_GENERAL,"Carriage Return in string (line %d)\n",lineno); |
||
| 415 | continue; |
||
| 416 | } |
||
| 417 | |||
| 418 | if (c=='\\') { |
||
| 419 | *p++ = c; |
||
| 420 | c = input(); |
||
| 421 | } |
||
| 422 | if(c==EOF) { |
||
| 423 | Log(LOG_GENERAL,"End of file in string\n"); |
||
| 424 | break; |
||
| 425 | } |
||
| 426 | if(c<' ') { |
||
| 427 | Log(LOG_GENERAL,"Ctl char 0x%02X in string\n",c); |
||
| 428 | break; |
||
| 429 | } |
||
| 430 | |||
| 431 | *p++ = c; |
||
| 432 | if((p - buff) >= MAXIDLEN-100) { |
||
| 433 | Log(LOG_GENERAL,"No closing quote after %d chars in string\n",MAXIDLEN-100); |
||
| 434 | break; |
||
| 435 | } |
||
| 436 | |||
| 437 | } |
||
| 438 | *p = 0; |
||
| 439 | yylval.string = make_string(buff,&lx_first,&lx_last) ; |
||
| 440 | /* printf("quoted (yytext:'%s')\n",yylval.string); */ |
||
| 441 | if(yydebug) fprintf(stderr,"String (quo) ='%s'\n",yylval.string); |
||
| 442 | return(QUOTED_STRING); |
||
| 443 | }; |
||
| 444 | |||
| 445 | <vlog>"\\" { char * p; |
||
| 446 | char buff[MAXIDLEN]; |
||
| 447 | |||
| 448 | int c; |
||
| 449 | p = buff; /* setup destination */ |
||
| 450 | while(1) { |
||
| 451 | c = input(); |
||
| 452 | if (!isalnum(c) && c!='[' && c!=']') /* any non-space char */ |
||
| 453 | break; |
||
| 454 | *p++ = c; |
||
| 455 | } |
||
| 456 | |||
| 457 | *p = 0; |
||
| 458 | yylval.string = make_string(buff,&lx_first,&lx_last) ; |
||
| 459 | if(yydebug) fprintf(stderr,"String (escaped) ='%s'\n",yylval.string); |
||
| 460 | return(QUOTED_STRING); |
||
| 461 | }; |
||
| 462 | |||
| 463 | |||
| 464 | |||
| 465 | |||
| 466 | |||
| 467 | |||
| 468 | <INITIAL,acfp,vhdl,pragma>"--" { |
||
| 469 | /* |
||
| 470 | printf("-- vhdl comment"); |
||
| 471 | */ |
||
| 472 | one_line_comment: |
||
| 473 | if(YY_START!=pragma) |
||
| 474 | prev_begin=YY_START; |
||
| 475 | comment_type= vert_vhdl_comment; |
||
| 476 | BEGIN(vert_vhdl_comment); |
||
| 477 | break; }; |
||
| 478 | <INITIAL,vlog>"//" { |
||
| 479 | /* |
||
| 480 | printf("-- vhdl comment"); |
||
| 481 | */ |
||
| 482 | goto one_line_comment; |
||
| 483 | }; |
||
| 484 | |||
| 485 | |||
| 486 | <INITIAL,acfp,vlog,pragma>"/*" { |
||
| 487 | /* |
||
| 488 | printf("-- C comment"); |
||
| 489 | */ |
||
| 490 | if(YY_START!=pragma) |
||
| 491 | prev_begin=YY_START; |
||
| 492 | comment_type= vert_c_comment; |
||
| 493 | BEGIN(vert_c_comment); |
||
| 494 | break; |
||
| 495 | }; |
||
| 496 | |||
| 497 | |||
| 498 | <acfp>[rR][eE][aA][dD]_[oO][fF][fF] { |
||
| 499 | /* |
||
| 500 | printf(" Read Off"); |
||
| 501 | */ |
||
| 502 | if (comment_type == vert_c_comment) |
||
| 503 | skip_c_comment(); |
||
| 504 | if (comment_type == vert_vhdl_comment) |
||
| 505 | skip_to_eol(); |
||
| 506 | /* |
||
| 507 | printf(" Skipped comment\n"); |
||
| 508 | */ |
||
| 509 | read_state = 0; |
||
| 510 | BEGIN(pragma); |
||
| 511 | break; |
||
| 512 | }; |
||
| 513 | |||
| 514 | <acfp>[rR][eE][aA][dD]_[oO][nN] { |
||
| 515 | /* |
||
| 516 | printf(" Read On"); |
||
| 517 | */ |
||
| 518 | if (comment_type == vert_c_comment) |
||
| 519 | skip_c_comment(); |
||
| 520 | if (comment_type == vert_vhdl_comment) |
||
| 521 | skip_to_eol(); |
||
| 522 | /* |
||
| 523 | printf(" Skipped comment\n"); |
||
| 524 | */ |
||
| 525 | read_state = 1; |
||
| 526 | if(prev_begin>= 0) |
||
| 527 | BEGIN(prev_begin); |
||
| 528 | break; |
||
| 529 | }; |
||
| 530 | |||
| 531 | |||
| 532 | <pragma,vert_vhdl_comment,vert_c_comment>[Vv][Ee][Rr][Tt][Ii][Cc][Aa][Ll]{Spc}* { |
||
| 533 | /* |
||
| 534 | printf(" Vertical"); |
||
| 535 | */ |
||
| 536 | /* the line is acfp syntax */ |
||
| 537 | BEGIN (acfp); break; }; |
||
| 538 | |||
| 539 | |||
| 540 | |||
| 541 | <vert_vhdl_comment,acfp>"\n" { |
||
| 542 | lineno++; |
||
| 543 | if (comment_type == vert_vhdl_comment ) |
||
| 544 | { |
||
| 545 | /* |
||
| 546 | printf(" endline\n"); |
||
| 547 | */ |
||
| 548 | comment_type = -1; |
||
| 549 | lineno++; |
||
| 550 | if(read_state==0) /* parser was not reading, so go back into pragma context */ |
||
| 551 | BEGIN(pragma); |
||
| 552 | else /* parser was reading, so go back into pre-comment context */ |
||
| 553 | BEGIN(prev_begin); |
||
| 554 | break; |
||
| 555 | } |
||
| 556 | }; |
||
| 557 | |||
| 558 | <vert_c_comment,acfp,vlog,INITIAL>"*/" { |
||
| 559 | /* pickup only inside a pragma enclosed in a C comment */ |
||
| 560 | /* |
||
| 561 | printf(" end C comment\n"); |
||
| 562 | */ |
||
| 563 | if (comment_type != vert_c_comment ) |
||
| 564 | Log(LOG_ERROR,"-- close comment unexpected\n"); |
||
| 565 | comment_type = -1; |
||
| 566 | if(read_state==0) /* parser was not reading, so go back into pragma context */ |
||
| 567 | BEGIN(pragma); |
||
| 568 | else /* parser was reading, so go back into pre-comment context */ |
||
| 569 | BEGIN(prev_begin); |
||
| 570 | break; |
||
| 571 | }; |
||
| 572 | |||
| 573 | |||
| 574 | |||
| 575 | |||
| 576 | <vert_c_comment>"\n" { lineno++; break; }; |
||
| 577 | |||
| 578 | <pragma>"\n" { lineno++; break; }; |
||
| 579 | <vert_c_comment,pragma>"\r" { break; }; |
||
| 580 | |||
| 581 | <vert_vhdl_comment,vert_c_comment>{Spc} { break; }; |
||
| 582 | |||
| 583 | <vert_vhdl_comment>. {skip_to_eol(); |
||
| 584 | goto ignored_comment; |
||
| 585 | }; |
||
| 586 | |||
| 587 | <vert_c_comment>. { skip_c_comment(); |
||
| 588 | ignored_comment: |
||
| 589 | comment_type = -1; |
||
| 590 | if(read_state==0) /* parser was not reading, so go back into pragma context */ |
||
| 591 | BEGIN(pragma); |
||
| 592 | else /* parser was reading, so go back into pre-comment context */ |
||
| 593 | BEGIN(prev_begin); |
||
| 594 | break; }; |
||
| 595 | <pragma>. { break; }; |
||
| 596 | |||
| 597 | |||
| 598 | <INITIAL,vlog,expr,vhdl>"\'" { return QUOTE; }; |
||
| 599 | <INITIAL,acfp,vhdl>"=>" { return CONNECTED; }; |
||
| 600 | <INITIAL,acfp,vlog,vhdl,expr>":=" { return ASSIGN; }; |
||
| 601 | <INITIAL,acfp,vhdl>"<=" { return SIG_ASSIGN; }; |
||
| 602 | <INITIAL,acfp,vlog,vhdl,expr>":" { return (':'); }; |
||
| 603 | <INITIAL,acfp,vlog,vhdl,expr>";" { return (';'); }; |
||
| 604 | <INITIAL,acfp,vlog,expr>"=" { return ('='); }; |
||
| 605 | <INITIAL,acfp,vlog,vhdl,expr>"(" { return ('('); }; |
||
| 606 | <INITIAL,acfp,vlog,vhdl,expr>")" { return (')'); }; |
||
| 607 | <INITIAL,acfp,vlog,vhdl>"." { return ('.'); }; |
||
| 608 | <INITIAL,acfp,vlog,vhdl>"!" { return ('!'); }; |
||
| 609 | <INITIAL,acfp,vlog,vhdl,expr>"+" { return ('+'); }; |
||
| 610 | <INITIAL,acfp,vlog,vhdl,expr>"-" { return ('-'); }; |
||
| 611 | <vhdl>"/=" { return (N_EQ); }; |
||
| 612 | <INITIAL,acfp,vlog,vhdl,expr>"/" { return ('/'); }; |
||
| 613 | <INITIAL,acfp,vlog,expr>"%" { return ('%'); }; |
||
| 614 | <INITIAL,acfp,vlog,expr>"?" { return ('?'); }; |
||
| 615 | <INITIAL,acfp,vlog,expr>"<<" { return (SHL); }; |
||
| 616 | <INITIAL,acfp,vlog,expr>">>" { return (SHR); }; |
||
| 617 | <INITIAL,acfp,vlog,expr>"<" { return ('<'); }; |
||
| 618 | <INITIAL,acfp,vlog,expr>">" { return ('>'); }; |
||
| 619 | <INITIAL,acfp,vlog,expr>"^" { return ('^'); }; |
||
| 620 | <INITIAL,acfp,vlog,expr>"~" { return ('~'); }; |
||
| 621 | <INITIAL,acfp,vlog,expr>"&&" { return (LOG_AND); }; |
||
| 622 | <INITIAL,acfp,vlog,expr>"&" { return ('&'); }; |
||
| 623 | <INITIAL,acfp,vlog,expr>"||" { return (LOG_OR); }; |
||
| 624 | <INITIAL,acfp,vlog,expr>"|" { return ('|'); }; |
||
| 625 | |||
| 626 | |||
| 627 | <INITIAL,acfp,vlog,expr>"==" { return (EQ_EQ); }; |
||
| 628 | <vhdl>"=" { return (EQ_EQ); }; |
||
| 629 | <INITIAL,acfp,vlog,expr>"!=" { return (N_EQ); }; |
||
| 630 | <INITIAL,acfp,vhdl,expr>"**" { return (TO_POW); }; |
||
| 631 | <INITIAL,acfp,vlog,vhdl,expr>"*" { return ('*'); }; |
||
| 632 | <INITIAL,acfp,vlog,vhdl>"," { return (','); }; |
||
| 633 | <vlog,acfp>"[" { return ('['); }; |
||
| 634 | <vlog,acfp>"]" { return (']'); }; |
||
| 635 | |||
| 636 | |||
| 637 | <INITIAL,acfp,vlog,vhdl,expr>{Spc} { break; }; |
||
| 638 | |||
| 639 | <INITIAL,acfp,vlog,vhdl>"\n" { lineno++; if(yydebug) printf("line %d\n",lineno); break; }; |
||
| 640 | <INITIAL,acfp,vlog,vhdl>"\r" { break; }; |
||
| 641 | |||
| 642 | |||
| 643 | |||
| 644 | |||
| 645 | <acfp>[eE][xX][eE][cC] { lex_exec_line();goto ignored_comment; /* commands to vertical */ }; |
||
| 646 | |||
| 647 | |||
| 648 | <INITIAL>[aA][hH][dD][lL] { BEGIN(acfp);prev_begin=acfp; |
||
| 649 | Log(LOG_GENERAL,"Entering ACFP block\n"); |
||
| 650 | inside_block=1; |
||
| 651 | return (AHDL); } |
||
| 652 | <INITIAL>[cC][hH][iI][pP] { BEGIN(acfp);prev_begin=acfp; |
||
| 653 | inside_block=1; |
||
| 654 | return (CHIP); } |
||
| 655 | <INITIAL>[jJ][oO][iI][nN][eE][dD]_[nN][eE][tT][sS] { BEGIN(acfp);prev_begin=acfp; |
||
| 656 | inside_block=1; |
||
| 657 | return (JOINED_NETS); } ; |
||
| 658 | <INITIAL>[cC][oO][mM][pP][oO][nN][eE][nN][tT][sS] { BEGIN(acfp);prev_begin=acfp; |
||
| 659 | inside_block=1; |
||
| 660 | return (COMPONENTS); }; |
||
| 661 | <INITIAL>[rR][eE][nN][aA][mM][eE]_[pP][iI][nN][sS] { BEGIN(acfp);prev_begin=acfp; |
||
| 662 | inside_block=1; |
||
| 663 | return (RENAME_PINS); } ; |
||
| 664 | <INITIAL>[tT][eE][mM][pP][lL][aA][tT][eE] { BEGIN(acfp);prev_begin=acfp; |
||
| 665 | inside_block=1; |
||
| 666 | return (TEMPLATE); } ; |
||
| 667 | <INITIAL,acfp,vlog,vhdl>[vV][hH][dD][lL] { BEGIN(vhdl); |
||
| 668 | Log(LOG_GENERAL,"Entering VHDL block\n"); |
||
| 669 | inside_block=1; |
||
| 670 | prev_begin=vhdl; |
||
| 671 | return (VHDL); } ; |
||
| 672 | |||
| 673 | <INITIAL,acfp,vlog,vhdl>[vV][eE][rR][iI][lL][oO][gG] { BEGIN(vlog); |
||
| 674 | Log(LOG_GENERAL,"Entering Verilog block\n"); |
||
| 675 | prev_begin=vlog; |
||
| 676 | inside_block=1; |
||
| 677 | return (VERILOG); } ; |
||
| 678 | |||
| 679 | <INITIAL,acfp,vlog,vhdl>[wW][iI][rR][eE][dD]_[nN][eE][tT][sS] { BEGIN(acfp);prev_begin=acfp; |
||
| 680 | inside_block=1; |
||
| 681 | return (WIRED_NETS); }; |
||
| 682 | <INITIAL,acfp,vlog,vhdl>[gG][eE][nN][eE][rR][iI][cC] { if (!inside_block) /* special */ |
||
| 683 | { inside_block=1; |
||
| 684 | BEGIN(vhdl);prev_begin=vhdl; }; |
||
| 685 | return (GENERIC);}; |
||
| 686 | <vhdl>[aA][lL][lL] { return (ALL); } |
||
| 687 | <vhdl>[aA][rR][cC][hH][iI][tT][eE][cC][tT][uU][rR][eE] { return (ARCHITECTURE); } |
||
| 688 | <acfp,vhdl>[aA][tT][tT][rR][iI][bB][uU][tT][eE] { return (ATTRIBUTE); } |
||
| 689 | <acfp>[aA][sS][sS][iI][gG][nN][eE][dD] { return (ASSIGNED); } |
||
| 690 | <acfp,vhdl>[aA][lL][iI][aA][sS] { return (ALIAS); } |
||
| 691 | <acfp>[aA][nN] { return (AN); } |
||
| 692 | <acfp,vlog,vhdl>[bB][eE][gG][iI][nN] { return (BEGIN_TOK); } |
||
| 693 | <acfp>[bB][iI][dD][iI][rR]_[pP][iI][nN] { yylval.integer = BIDIR; return(PINDIR); } |
||
| 694 | <acfp>[bB][iI][dD][iI][rR] { yylval.integer = BIDIR; return(PINDIR); } |
||
| 695 | <vhdl>[bB][oO][oO][lL][eE][aA][nN] { return(BOOLEAN); } |
||
| 696 | <vhdl>[iI][nN][oO][uU][tT] { yylval.integer = BIDIR; return(PINDIR); } |
||
| 697 | <vlog>[oO][uU][tT] { yylval.integer = BIDIR; return(PINDIR); } |
||
| 698 | <acfp>[bB][uU][fF][fF][eE][rR]_[pP][iI][nN] { yylval.integer = BUFFER; return(PINDIR); } |
||
| 699 | <vhdl>[bB][uU][fF][fF][eE][rR] { yylval.integer = BUFFER; return(PINDIR); } |
||
| 700 | <acfp>[cC][oO][nN][fF][iI][gG]_[pP][iI][nN] { yylval.integer = CONFIG; return(PINDIR); }; |
||
| 701 | <vhdl>[cC][oO][mM][pP][oO][nN][eE][nN][tT] { return (COMPONENT); }; |
||
| 702 | <vhdl>[cC][oO][nN][sS][tT][aA][nN][tT] { return (CONSTANT); }; |
||
| 703 | <acfp>[cC][oO][nN][nN][eE][cC][tT][iI][oO][nN] { return (CONN); }; |
||
| 704 | <acfp>[vV][hH][dD][lL]_[cC][oO][nN][nN] { return (VHDL_CONN); }; |
||
| 705 | <acfp>[dD][eE][cC][lL][aA][rR][aA][tT][iI][oO][nN] { return (DECLARATION); }; |
||
| 706 | <acfp>[dD][eE][vV][iI][cC][eE] { return (DEVICE); }; |
||
| 707 | <vhdl,acfp,expr>[dD][oO][wW][nN][tT][oO] { return (DOWNTO); }; |
||
| 708 | <acfp,vlog,vhdl>[eE][nN][dD] { return (END); /* do not free_strings here as it is too early !! */}; |
||
| 709 | <acfp>[eE][nN][dD]_[cC][oO][nN][nN] { return (END_CONN); } ; |
||
| 710 | <vlog>endmodule { return (ENDMODULE); }; |
||
| 711 | <acfp,vhdl>[eE][nN][tT][iI][tT][yY] { return (ENTITY); }; |
||
| 712 | <acfp>[eE][qQ][uU][iI][vV][aA][lL][eE][nN][tT] { return (EQUIVALENT); }; |
||
| 713 | <vhdl>[eE][nN][vV]_[sS][tT][rR][iI][nN][gG] { return (ENV_STRING); }; |
||
| 714 | <vhdl,expr>[fF][aA][lL][sS][eE] { return (FALSE); }; |
||
| 715 | <acfp>[fF][iI][xX]_[lL][oO][cC][aA][tT][iI][oO][nN] { return (FIX_LOCATION); }; |
||
| 716 | <vhdl>[fF][oO][rR] { return (FOR); }; |
||
| 717 | <acfp>[gG][nN][dD]\* { return (GND_RES_IO); }; |
||
| 718 | <acfp>[gG][nN][dD]\+ { return (GND_RES_IN); }; |
||
| 719 | <acfp>[gG][nN][dD]{L2}* { yylval.string = make_string(yytext,&lx_first,&lx_last); |
||
| 720 | if(yydebug) fprintf(stderr,"String (GND) ='%s'\n",yytext); |
||
| 721 | return (GND); }; |
||
| 722 | <acfp>[iI][nN][pP][uU][tT]_[pP][iI][nN] { yylval.integer = INPUT; return(PINDIR); }; |
||
| 723 | <vhdl>[iI][nN] { yylval.integer = INPUT; return(PINDIR); }; |
||
| 724 | <vlog,acfp>[iI][nN][pP][uU][tT] { yylval.integer = INPUT; return(PINDIR); }; |
||
| 725 | <vlog>[iI][nN][oO][uU][tT] { yylval.integer = BIDIR; return(PINDIR); } |
||
| 726 | <acfp>[iI][nN][sS][tT][aA][nN][cC][eE] { return (INSTANCE); }; |
||
| 727 | <acfp,vhdl>[iI][nN][tT][eE][gG][eE][rR] { return (INTEGER); }; |
||
| 728 | <acfp,vhdl>[iI][sS] { return (IS); }; |
||
| 729 | <acfp>[jJ][uU][mM][pP][eE][rR] { return (JUMPER); } ; |
||
| 730 | <vhdl>[lL][iI][bB][rR][aA][rR][yY] { return (LIBRARY); } ; |
||
| 731 | <acfp>[lL][oO][cC][aA][tT][iI][oO][nN] { return (LOCATION); } ; |
||
| 732 | <vhdl>[mM][aA][pP] { return (MAP); }; |
||
| 733 | <vlog>module { return (MODULE); }; |
||
| 734 | <acfp>[nN][oO][nN][eE] { yylval.integer = NONE; return(PINDIR); }; |
||
| 735 | <acfp>[nN][aA][mM][eE][dD] { return (NAMED); } ; |
||
| 736 | <vhdl>[oO][fF] { return (OF); }; |
||
| 737 | <acfp>[oO][uU][tT][pP][uU][tT]_[pP][iI][nN] { yylval.integer = OUTPUT; return(PINDIR); }; |
||
| 738 | <vlog,acfp>[oO][uU][tT][pP][uU][tT] { yylval.integer = OUTPUT; return(PINDIR); }; |
||
| 739 | <vhdl>[oO][uU][tT] { yylval.integer = OUTPUT; return(PINDIR); }; |
||
| 740 | <vhdl>[oO][pP][eE][nN] { return (OPEN); }; |
||
| 741 | <vhdl>[pP][aA][cC][kK][aA][gG][eE] { return (PACKAGE); }; |
||
| 742 | <vhdl>[pP][oO][rR][tT] { return (PORT); }; |
||
| 743 | <acfp>[pP][oO][wW][eE][rR]_[pP][iI][nN] { yylval.integer = POWER; return(PINDIR); }; |
||
| 744 | <acfp,vlog,vhdl>[rR][aA][nN][gG][eE] { return (RANGE); }; |
||
| 745 | <acfp>[rR][oO][uU][tT][eE]_[fF][lL][aA][gG][sS] { return (ROUTE_FLAGS); }; |
||
| 746 | <acfp>[rR][oO][uU][tT][eE][dD] { return (ROUTED); } ; |
||
| 747 | <vhdl>[sS][hH][lL] { return (SHL); }; |
||
| 748 | <vhdl>[sS][hH][rR] { return (SHR); }; |
||
| 749 | <vhdl>[sS][iI][gG][nN][aA][lL] { return (ASIGNAL); }; |
||
| 750 | <vhdl>[sS][tT][rR][iI][nN][gG] { return (STRING); }; |
||
| 751 | <vlog>[sS][uU][bB][dD][eE][sS][iI][gG][nN] { return (SUBDESIGN); }; |
||
| 752 | <acfp,vhdl,expr>[tT][oO] { return (TO); }; |
||
| 753 | <vhdl,expr>[tT][rR][uU][eE] { return (TRUE); }; |
||
| 754 | <acfp>[uU][nN][rR][oO][uU][tT][eE][dD] { return (UNROUTED); } ; |
||
| 755 | <acfp>[vV][cC][cC]{L2}* { yylval.string = make_string(yytext,&lx_first,&lx_last); |
||
| 756 | if(yydebug) fprintf(stderr,"String (VCC) ='%s'\n",yytext); |
||
| 757 | return (VCC); }; |
||
| 758 | <vhdl>[uU][sS][eE] { return (USE); }; |
||
| 759 | <vlog>wire { return (WIRE); }; |
||
| 760 | |||
| 761 | <INITIAL,acfp,expr>{D}{L2D}* { yylval.string = make_string(yytext,&lx_first,&lx_last); /* do it anyway */ |
||
| 762 | if(yydebug) fprintf(stderr,"String (num) ='%s'\n",yytext); |
||
| 763 | return(NUM_STRING); }; |
||
| 764 | |||
| 765 | <vlog,vhdl,expr>{D}{L2V}* { yylval.string = make_string(yytext,&lx_first,&lx_last); /* do it anyway */ |
||
| 766 | if(yydebug) fprintf(stderr,"String (num) ='%s'\n",yytext); |
||
| 767 | return(NUM_STRING); }; |
||
| 768 | |||
| 769 | <INITIAL,acfp,expr>{L}{L2A}* { yylval.string = make_string(yytext,&lx_first,&lx_last); /* do it anyway */ |
||
| 770 | if(yydebug) fprintf(stderr,"String (num) ='%s'\n",yytext); |
||
| 771 | return(TXT_STRING); }; |
||
| 772 | |||
| 773 | <vlog,vhdl,expr>{L}{L2V}* { yylval.string = make_string(yytext,&lx_first,&lx_last); /* do it anyway */ |
||
| 774 | if(yydebug) fprintf(stderr,"String (txt) ='%s'\n",yytext); |
||
| 775 | return(isdigit(yylval.string[0])?NUM_STRING : TXT_STRING); }; |
||
| 776 | |||
| 777 | <vlog>"/"{L2D}+ { yylval.string = make_string(yytext,&lx_first,&lx_last); /* do it anyway */ |
||
| 778 | if(yydebug) fprintf(stderr,"String (num) ='%s'\n",yytext); |
||
| 779 | return(TXT_STRING); }; |
||
| 780 | |||
| 781 | |||
| 782 | <INITIAL,acfp,vlog,vhdl>. { printf("-- error in %s syntax: found character code 0x%02X (%c) at line %d\n",yyerr_start_names[YY_START],yytext[0],yytext[0]>32?yytext[0]:'.',lineno); break; }; |
||
| 783 | |||
| 784 | |||
| 785 | %% |
||
| 786 | |||
| 787 | |||
| 788 | /* terminate an ACFP and VHDL comment */ |
||
| 789 | void skip_to_eol(void) { |
||
| 790 | int c; |
||
| 791 | for(;;) { |
||
| 792 | c=input(); |
||
| 793 | if (c=='\n' || c==EOF) { |
||
| 794 | lineno++; |
||
| 795 | return; |
||
| 796 | } |
||
| 797 | }/* VHDL comment */ |
||
| 798 | } |
||
| 799 | |||
| 800 | |||
| 801 | |||
| 802 | |||
| 803 | /* execute a command line command */ |
||
| 804 | char stringbuff[MAXIDLEN]; |
||
| 805 | void lex_exec_line(void) { |
||
| 806 | int c,i; |
||
| 807 | for(i=0;i<MAXIDLEN-2;) { |
||
| 808 | c=input(); |
||
| 809 | stringbuff[i++] = c; |
||
| 810 | if (c=='\n' || c==EOF) { |
||
| 811 | lineno++; |
||
| 812 | stringbuff[i]=0; |
||
| 813 | ExecuteString (stringbuff ,yy_nArgs, yy_Args); |
||
| 814 | return; |
||
| 815 | } |
||
| 816 | } |
||
| 817 | stringbuff[i] = 0; |
||
| 818 | ExecuteString (stringbuff ,yy_nArgs,yy_Args); |
||
| 819 | } |
||
| 820 | |||
| 821 | |||
| 822 | |||
| 823 | |||
| 824 | /* supporting functions need to be in sane file so LEX macros work */ |
||
| 825 | void skip_c_comment(void) { |
||
| 826 | int c; |
||
| 827 | for(;;) { |
||
| 828 | while(((c = input()) !=EOF) && (c != '*')) { |
||
| 829 | if(c=='\n') |
||
| 830 | lineno++; |
||
| 831 | } |
||
| 832 | if (c=='*') { |
||
| 833 | while((c = input()) == '*') putchar(c); |
||
| 834 | if(c=='\n') |
||
| 835 | lineno++; |
||
| 836 | if (c=='/') |
||
| 837 | break; |
||
| 838 | } |
||
| 839 | if(c==EOF) { |
||
| 840 | Log(LOG_GENERAL,"End of file in comment\n"); |
||
| 841 | break; |
||
| 842 | } |
||
| 843 | } |
||
| 844 | } |
||
| 845 | |||
| 846 | void exit_lex_block(void) { |
||
| 847 | inside_block = 0; |
||
| 848 | prev_begin=INITIAL; |
||
| 849 | BEGIN(INITIAL); |
||
| 850 | } |
||
| 851 | |||
| 852 | void tidy_lex(void) |
||
| 853 | { |
||
| 854 | errorseen = 0; |
||
| 855 | include_stack_ptr = 0; |
||
| 856 | exit_lex_block(); |
||
| 857 | start_grammar = FILEMODE; |
||
| 858 | } |
||
| 859 | |||
| 860 | |||
| 861 | |||
| 862 | |||
| 863 | int yyerror(char * x) |
||
| 864 | { |
||
| 865 | |||
| 866 | if (!errorseen) { |
||
| 867 | if(include_stack_ptr==0) |
||
| 868 | { |
||
| 869 | Log(LOG_ERROR,"-- Error in %s syntax\n-- -->%s near string (%s) at line %d\n", |
||
| 870 | yyerr_start_names[YY_START],x,yytext,lineno); |
||
| 871 | } |
||
| 872 | else |
||
| 873 | { |
||
| 874 | Log(LOG_ERROR,"-- File %s: Error in %s syntax\n-- -->%s near string (%s) at line %d\n", |
||
| 875 | filename[include_stack_ptr],yyerr_start_names[YY_START],x,yytext,lineno); |
||
| 876 | } |
||
| 877 | } |
||
| 878 | errorseen = 1; |
||
| 879 | include_stack_ptr = 0; |
||
| 880 | exit_lex_block(); |
||
| 881 | YY_FLUSH_BUFFER; |
||
| 882 | yyterminate(); |
||
| 883 | return 1; |
||
| 884 | } |
||
| 885 | |||
| 886 | |||
| 887 | |||
| 888 | /********************************************************/ |
||
| 889 | /* Reading generic expressions from a string */ |
||
| 890 | /********************************************************/ |
||
| 891 | |||
| 892 | static char * myinputptr; |
||
| 893 | static char * myinputlim; |
||
| 894 | /* this is exported */ |
||
| 895 | expression_t * cmd_expression; |
||
| 896 | |||
| 897 | |||
| 898 | int my_yyinput(char * buf, int max_size) |
||
| 899 | { |
||
| 900 | int n; |
||
| 901 | n =(max_size < (myinputlim-myinputptr))? max_size :myinputlim-myinputptr; |
||
| 902 | if(n>0) |
||
| 903 | { |
||
| 904 | memcpy(buf,myinputptr,n); |
||
| 905 | myinputptr+=n; |
||
| 906 | } |
||
| 907 | return n; |
||
| 908 | } |
||
| 909 | |||
| 910 | |||
| 911 | /* this function requires a large number of declarations from |
||
| 912 | lex. */ |
||
| 913 | |||
| 914 | |||
| 915 | |||
| 916 | expression_t * compile_expression_from_string(char * s) |
||
| 917 | { |
||
| 918 | int prev_expr_begin; |
||
| 919 | myinputptr = s; |
||
| 920 | myinputlim = s+strlen(s); |
||
| 921 | prev_expr_begin = YY_START; |
||
| 922 | |||
| 923 | BEGIN(expr); |
||
| 924 | |||
| 925 | start_grammar = CMDMODE; |
||
| 926 | lex_from_string = 1; |
||
| 927 | |||
| 928 | yy_scan_buffer (s, strlen(s)); // new code no macro mangle |
||
| 929 | |||
| 930 | |||
| 931 | lex_from_string = 0; |
||
| 932 | BEGIN(prev_expr_begin); |
||
| 933 | |||
| 934 | return cmd_expression; |
||
| 935 | } |