1 /*
2 This file is part of adms - http://sourceforge.net/projects/mot-adms.
3
4 adms is a code generator for the Verilog-AMS language.
5
6 Copyright (C) 2002-2012 Laurent Lemaitre <r29173@users.sourceforge.net>
7 2014 Francesco Lannutti <nicolati@fastwebnet.it>
8 2014 Guilherme Brondani Torri <guitorri@gmail.com>
9 2013 Ryan Fox <ryan@rcfox.ca>
10
11 This program is free software: you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 */
24
25 %name-prefix "preprocessor"
26 %defines
27
28 %{
29
30 #include "admsPreprocessor.h"
31
32 #define YYDEBUG 1
33 #define KS(s) adms_k2strconcat(&message,s);
34 #define KI(i) adms_k2strconcat(&message,adms_integertostring(i));
35 #define K0 KS("[") KS(pproot()->cr_scanner->filename) KS(":") \
36 KI(adms_preprocessor_get_line_position(pproot()->cr_scanner,0)) KS("]: ")
37 #define DONT_SKIPP (pproot()->skipp_text->data==INT2ADMS(0))
38
39 p_slist continuatorList=NULL;
40 p_slist condistrue=NULL;
41
42 %}
43
44 %union{
45 p_slist slist;
46 char* mystr;
47 }
48
49 %token <mystr> TK_PRAGMA_NAME
50 %token <mystr> TK_IDENT
51 %token <mystr> TK_STRING
52 %token <mystr> TK_NOT_IDENT
53 %token <mystr> TK_ARG
54 %token <mystr> TK_ARG_NULL
55 %token <mystr> TK_SUBSTITUTOR_NOARG
56 %token <mystr> TK_SUBSTITUTOR_NULLARG
57 %token <mystr> TK_SUBSTITUTOR_NULLARG_ALONE
58 %token <mystr> TK_SUBSTITUTOR_WITHARG
59 %token <mystr> TK_SUBSTITUTOR_WITHARG_ALONE
60 %token <mystr> TK_CONTINUATOR
61 %token <mystr> TK_NOPRAGMA_CONTINUATOR
62 %token <mystr> TK_EOL
63 %token <mystr> TK_EOF
64 %token <mystr> TK_COMMENT
65 %token <mystr> TK_INCLUDE
66 %token <mystr> TK_SPACE
67
68 %token <mystr> TK_ERROR_PRAGMA_DEFINITION
69 %token <mystr> TK_ERROR_PRAGMA_NOT_FOUND
70 %token <mystr> TK_ERROR_UNEXPECTED_CHAR
71 %token <mystr> TK_ERROR_FILE_OPEN
72
73 %token TK_DEFINE
74 %token TK_DEFINE_END
75 %token TK_UNDEF
76 %token <mystr> TK_IFDEF
77 %token <mystr> TK_IFNDEF
78 %token <mystr> TK_ELSE
79 %token <mystr> TK_ENDIF
80
81 %type <slist> R_description
82 %type <slist> R_list_of_conditional
83 %type <slist> R_conditional
84 %type <slist> R_alternative
85 %type <slist> R_define_alternative
86
87 %type <slist> R_define_list_of_arg
88 %type <slist> R_pragma
89
90 %type <slist> R_define_text
91
92 %type <slist> R_define_notpragma
93 %type <slist> R_notpragma
94 %type <slist> R_arg_null
95 %type <slist> R_substitutor
96 %type <slist> R_substitutor_list_of_arg
97 %type <slist> R_list_of_arg
98 %type <slist> R_list_of_arg_with_comma
99 %type <slist> R_arg
100 %type <slist> R_other
101
102 %type <slist> R_include
103
104 %type <slist> R_if
105 %type <slist> R_ifn
106 %type <slist> R_else
107 %type <slist> R_endif
108
109 %type <mystr> R_substitutor_nullarg
110 %type <mystr> R_substitutor_witharg
111
112 %type <mystr> R_ifdef
113 %type <mystr> R_ifndef
114 %type <mystr> R_undef
115 %type <mystr> R_define
116
117 %start R_description
118
119 %%
120
121 R_description
122 : R_list_of_conditional
123 {
124 pproot()->Text=$1;
125 }
126 ;
127
128 R_list_of_conditional
129 : R_conditional
130 {
131 $$=$1;
132 }
133 | R_list_of_conditional R_conditional
134 {
135 $$=$2;
136 adms_slist_concat(&($$),$1);
137 }
138 ;
139
140 R_conditional
141 : R_if R_ifdef R_list_of_conditional R_else R_list_of_conditional R_endif
142 {
143 if(condistrue->data==INT2ADMS(1))
144 {
145 $$=$6;
146 adms_slist_concat(&($$),$3);
147 }
148 else if(condistrue->data==INT2ADMS(0))
149 {
150 $$=$5;
151 adms_slist_concat(&($$),$4);
152 }
153 adms_slist_pull(&pproot()->skipp_text);
154 adms_slist_pull(&condistrue);
155 }
156 | R_if R_ifdef R_list_of_conditional R_endif
157 {
158 if(condistrue->data==INT2ADMS(1))
159 {
160 $$=$3;
161 adms_slist_concat(&($$),$1);
162 }
163 else if(condistrue->data==INT2ADMS(0))
164 $$=$4;
165 adms_slist_pull(&pproot()->skipp_text);
166 adms_slist_pull(&condistrue);
167 }
168 | R_ifn R_ifndef R_list_of_conditional R_else R_list_of_conditional R_endif
169 {
170 if(condistrue->data==INT2ADMS(1))
171 {
172 $$=$6;
173 adms_slist_concat(&($$),$3);
174 }
175 else if(condistrue->data==INT2ADMS(0))
176 {
177 $$=$5;
178 adms_slist_concat(&($$),$4);
179 }
180 adms_slist_pull(&pproot()->skipp_text);
181 adms_slist_pull(&condistrue);
182 }
183 | R_ifn R_ifndef R_list_of_conditional R_endif
184 {
185 if(condistrue->data==INT2ADMS(1))
186 {
187 $$=$3;
188 adms_slist_concat(&($$),$1);
189 }
190 else if(condistrue->data==INT2ADMS(0))
191 $$=$4;
192 adms_slist_pull(&pproot()->skipp_text);
193 adms_slist_pull(&condistrue);
194 }
195 | R_alternative
196 {
197 $$=$1;
198 }
199 ;
200
201 R_if
202 : TK_IFDEF
203 {
204 p_preprocessor_text newtext=adms_preprocessor_new_text_as_string($1);
205 $$=adms_slist_new((p_adms)newtext);
206 }
207 ;
208 R_ifn
209 : TK_IFNDEF
210 {
211 p_preprocessor_text newtext=adms_preprocessor_new_text_as_string($1);
212 $$=adms_slist_new((p_adms)newtext);
213 }
214 ;
215 R_ifdef
216 : TK_PRAGMA_NAME
217 {
218 $$=$1;
219 if(!DONT_SKIPP)
220 {
221 adms_slist_push(&pproot()->skipp_text,INT2ADMS(1));
222 adms_slist_push(&condistrue,INT2ADMS(-1));
223 }
224 else if(adms_preprocessor_identifier_is_def($1))
225 {
226 adms_slist_push(&condistrue,INT2ADMS(1));
227 adms_slist_push(&pproot()->skipp_text,INT2ADMS(0));
228 }
229 else
230 {
231 adms_slist_push(&condistrue,INT2ADMS(0));
232 adms_slist_push(&pproot()->skipp_text,INT2ADMS(1));
233 }
234 }
235 ;
236 R_ifndef
237 : TK_PRAGMA_NAME
238 {
239 $$=$1;
240 if(!DONT_SKIPP)
241 {
242 adms_slist_push(&pproot()->skipp_text,INT2ADMS(1));
243 adms_slist_push(&condistrue,INT2ADMS(-1));
244 }
245 else if(adms_preprocessor_identifier_is_ndef($1))
246 {
247 adms_slist_push(&condistrue,INT2ADMS(1));
248 adms_slist_push(&pproot()->skipp_text,INT2ADMS(0));
249 }
250 else
251 {
252 adms_slist_push(&condistrue,INT2ADMS(0));
253 adms_slist_push(&pproot()->skipp_text,INT2ADMS(1));
254 }
255 }
256 ;
257
258 R_else
259 : TK_ELSE
260 {
261 p_preprocessor_text newtext=adms_preprocessor_new_text_as_string($1);
262 $$=adms_slist_new((p_adms)newtext);
263 if(condistrue->data==INT2ADMS(0))
264 pproot()->skipp_text->data=INT2ADMS(0);
265 else if(condistrue->data==INT2ADMS(1))
266 pproot()->skipp_text->data=INT2ADMS(1);
267 else
268 pproot()->skipp_text->data=INT2ADMS(1);
269 }
270 ;
271
272 R_endif
273 : TK_ENDIF
274 {
275 p_preprocessor_text newtext=adms_preprocessor_new_text_as_string($1);
276 $$=adms_slist_new((p_adms)newtext);
277 }
278 ;
279
280 R_include
281 : TK_INCLUDE
282 {
283 p_preprocessor_text newtext;
284 newtext=adms_preprocessor_new_text_as_string($1);
285 $$=adms_slist_new((p_adms)newtext);
286 }
287 ;
288
289 R_undef
290 : TK_UNDEF TK_PRAGMA_NAME
291 {
292 $$=$2;
293 }
294 ;
295
296 R_alternative
297 : R_pragma
298 {
299 $$=$1;
300 }
301 | R_notpragma
302 {
303 $$=$1;
304 }
305 ;
306
307 R_pragma
308 : R_include
309 {
310 $$=$1;
311 }
312 | R_define_alternative
313 {
314 $$=$1;
315 }
316 | R_undef
317 {
318 $$=NULL;
319 if(DONT_SKIPP) adms_preprocessor_identifer_set_undef($1);
320 }
321 | TK_ERROR_UNEXPECTED_CHAR
322 {
323 $$=NULL;
324 }
325 | TK_ERROR_FILE_OPEN
326 {
327 char*message=NULL;
328 $$=NULL;
329 K0 KS(pproot()->cr_scanner->cur_message) KS("\n")
330 adms_preprocessor_add_message(message);
331 free(pproot()->cr_scanner->cur_message);
332 pproot()->cr_scanner->cur_message=NULL;
333 }
334 | TK_ERROR_PRAGMA_DEFINITION
335 {
336 char*message=NULL;
337 $$=NULL;
338 K0 KS("macro ") KS(pproot()->cr_scanner->cur_message) KS(" badly formed\n")
339 adms_preprocessor_add_message(message);
340 pproot()->error += 1;
341 free(pproot()->cr_scanner->cur_message);
342 pproot()->cr_scanner->cur_message=NULL;
343 }
344 ;
345
346 R_notpragma
347 : R_substitutor
348 {
349 $$=$1;
350 }
351 | TK_NOPRAGMA_CONTINUATOR
352 {
353 p_preprocessor_text newtext=adms_preprocessor_new_text_as_string("\n");
354 adms_slist_push(&continuatorList,(p_adms)newtext);
355 $$=NULL;
356 }
357 | TK_EOL
358 {
359 p_preprocessor_text newtext=adms_preprocessor_new_text_as_string("\n");
360 $$=adms_slist_new((p_adms)newtext);
361 adms_slist_concat(&($$),continuatorList);
362 continuatorList=NULL;
363 ++pproot()->cr_scanner->cur_line_position;
364 pproot()->cr_scanner->cur_char_position=1;
365 pproot()->cr_scanner->cur_continuator_position=NULL;
366 }
367 | R_other
368 {
369 $$=$1;
370 }
371 | TK_ERROR_PRAGMA_NOT_FOUND
372 {
373 char*message=NULL;
374 $$=NULL;
375 K0 KS("macro ") KS(pproot()->cr_scanner->cur_message) KS(" is undefined\n")
376 adms_preprocessor_add_message(message);
377 pproot()->error += 1;
378 free(pproot()->cr_scanner->cur_message);
379 pproot()->cr_scanner->cur_message=NULL;
380 }
381 ;
382
383 R_define_notpragma
384 : R_substitutor
385 {
386 $$=$1;
387 }
388 | TK_CONTINUATOR
389 {
390 p_preprocessor_text newtext1=adms_preprocessor_new_text_as_string("\n");
391 p_preprocessor_text newtext2=adms_preprocessor_new_text_as_string("");
392 adms_slist_push(&continuatorList,(p_adms)newtext1);
393 $$=adms_slist_new((p_adms)newtext2);
394 }
395 | TK_EOL
396 {
397 p_preprocessor_text newtext=adms_preprocessor_new_text_as_string($1);
398 $$=adms_slist_new((p_adms)newtext);
399 adms_slist_concat(&($$),continuatorList);
400 continuatorList=NULL;
401 ++pproot()->cr_scanner->cur_line_position;
402 pproot()->cr_scanner->cur_char_position=1;
403 pproot()->cr_scanner->cur_continuator_position=NULL;
404 }
405 | R_other
406 {
407 $$=$1;
408 }
409 | TK_ERROR_PRAGMA_NOT_FOUND
410 {
411 char*message=NULL;
412 $$=NULL;
413 K0 KS("macro ") KS(pproot()->cr_scanner->cur_message) KS(" is undefined\n")
414 adms_preprocessor_add_message(message);
415 pproot()->error += 1;
416 free(pproot()->cr_scanner->cur_message);
417 pproot()->cr_scanner->cur_message=NULL;
418 }
419 ;
420
421 R_substitutor
422 : TK_SUBSTITUTOR_NOARG
423 {
424 p_preprocessor_pragma_define Define=adms_preprocessor_pragma_define_exists($1);
425 $$=adms_preprocessor_new_text_as_substitutor(Define,NULL);
426 }
427 | TK_SUBSTITUTOR_NULLARG_ALONE
428 {
429 p_preprocessor_pragma_define Define=adms_preprocessor_pragma_define_exists($1);
430 $$=adms_preprocessor_new_text_as_substitutor(Define,NULL);
431 }
432 | R_substitutor_nullarg R_arg_null
433 {
434 p_preprocessor_pragma_define Define=adms_preprocessor_pragma_define_exists($1);
435 $$=adms_preprocessor_new_text_as_substitutor(Define,NULL);
436 }
437 | R_substitutor_nullarg '(' R_substitutor_list_of_arg ')'
438 {
439 char*message=NULL;
440 p_preprocessor_pragma_define Define=adms_preprocessor_pragma_define_exists($1);
441 $$=adms_preprocessor_new_text_as_substitutor(Define, $3);
442 K0 KS("arguments given to macro `") KS( Define->name) KS("\n")
443 adms_preprocessor_add_message(message);
444 pproot()->error += 1;
445 }
446 | TK_SUBSTITUTOR_WITHARG_ALONE
447 {
448 char*message=NULL;
449 p_preprocessor_pragma_define Define=adms_preprocessor_pragma_define_exists($1);
450 $$=adms_preprocessor_new_text_as_substitutor(Define,NULL);
451 K0 KS("macro `") KS(Define->name) KS(" has no argument [") KI(adms_slist_length(Define->arg)) KS(" expected]\n")
452 adms_preprocessor_add_message(message);
453 pproot()->error += 1;
454 adms_slist_push(&($$),(p_adms)$1);
455 }
456 | R_substitutor_witharg R_arg_null
457 {
458 char*message=NULL;
459 p_preprocessor_pragma_define Define=adms_preprocessor_pragma_define_exists($1);
460 $$=adms_preprocessor_new_text_as_substitutor(Define,NULL);
461 K0 KS("macro `") KS(Define->name) KS(" has no argument [") KI(adms_slist_length(Define->arg)) KS(" expected]\n")
462 adms_preprocessor_add_message(message);
463 pproot()->error += 1;
464 }
465 | R_substitutor_witharg '(' R_substitutor_list_of_arg ')'
466 {
467 p_preprocessor_pragma_define Define=adms_preprocessor_pragma_define_exists($1);
468 {
469 if(adms_slist_length($3) == adms_slist_length(Define->arg))
470 {
471 }
472 else if(adms_slist_length($3) > adms_slist_length(Define->arg))
473 {
474 if(adms_slist_length($3) == 1)
475 {
476 char*message=NULL;
477 K0 KS("macro `") KS(Define->name) KS(" has one argument [") KI(adms_slist_length(Define->arg)) KS(" expected]\n")
478 adms_preprocessor_add_message(message);
479 }
480 else
481 {
482 char*message=NULL;
483 K0 KS("macro `") KS(Define->name) KS(" has too many (") KI(adms_slist_length($3)) KS(") arguments\n")
484 adms_preprocessor_add_message(message);
485 }
486 pproot()->error += 1;
487 }
488 else
489 {
490 if(adms_slist_length($3) == 1)
491 {
492 char*message=NULL;
493 K0 KS("macro `") KS(Define->name) KS(" has one argument [") KI(adms_slist_length(Define->arg)) KS(" expected]\n")
494 adms_preprocessor_add_message(message);
495 }
496 else
497 {
498 char*message=NULL;
499 K0 KS("macro `") KS(Define->name) KS(" has too few (") KI(adms_slist_length($3)) KS(") arguments\n")
500 adms_preprocessor_add_message(message);
501 }
502 pproot()->error += 1;
503 }
504 }
505 $$=adms_preprocessor_new_text_as_substitutor(Define, $3);
506 }
507 ;
508
509 R_substitutor_nullarg
510 : TK_SUBSTITUTOR_NULLARG TK_SPACE
511 {
512 $$=$1;
513 }
514 | TK_SUBSTITUTOR_NULLARG
515 {
516 $$=$1;
517 }
518 ;
519
520 R_substitutor_witharg
521 : TK_SUBSTITUTOR_WITHARG TK_SPACE
522 {
523 $$=$1;
524 }
525 | TK_SUBSTITUTOR_WITHARG
526 {
527 $$=$1;
528 }
529 ;
530
531 R_arg_null
532 : '(' ')'
533 {
534 }
535 ;
536
537 R_substitutor_list_of_arg
538 : R_list_of_arg
539 {
540 $$=adms_slist_new((p_adms)$1);
541 }
542 | R_substitutor_list_of_arg ',' R_list_of_arg
543 {
544 adms_slist_push(&($1),(p_adms)$3);
545 $$=$1;
546 }
547 ;
548
549 R_list_of_arg
550 : R_arg
551 {
552 $$=$1;
553 }
554 | R_list_of_arg R_arg
555 {
556 $$=$2;
557 adms_slist_concat(&($$),$1);
558 }
559 ;
560
561 R_list_of_arg_with_comma
562 : R_list_of_arg
563 {
564 $$=$1;
565 }
566 | R_list_of_arg_with_comma ',' R_list_of_arg
567 {
568 p_preprocessor_text comma=adms_preprocessor_new_text_as_string(",");
569 adms_slist_push(&($1),(p_adms)comma);
570 $$=$3;
571 adms_slist_concat(&($$),$1);
572 }
573 ;
574 R_arg
575 : TK_SPACE
576 {
577 p_preprocessor_text newtext=adms_preprocessor_new_text_as_string($1);
578 $$=adms_slist_new((p_adms)newtext);
579 }
580 | TK_CONTINUATOR
581 {
582 /* SRW - fix bsim6.va parse problem, string macro arg broken by
583 * continuator caused 'unexpected end of line' error.
584 */
585 $$=0;
586 }
587 | TK_COMMENT
588 {
589 p_preprocessor_text newtext=adms_preprocessor_new_text_as_string($1);
590 $$=adms_slist_new((p_adms)newtext);
591 }
592 | TK_EOL
593 {
594 p_preprocessor_text newtext=adms_preprocessor_new_text_as_string("\n");
595 ++pproot()->cr_scanner->cur_line_position;
596 pproot()->cr_scanner->cur_char_position=1;
597 pproot()->cr_scanner->cur_continuator_position=NULL;
598 $$=adms_slist_new((p_adms)newtext);
599 }
600 | '(' R_list_of_arg_with_comma ')'
601 {
602 p_preprocessor_text lparen=adms_preprocessor_new_text_as_string("(");
603 p_preprocessor_text rparen=adms_preprocessor_new_text_as_string(")");
604 $$=$2;
605 adms_slist_concat(&($$),adms_slist_new((p_adms)lparen));
606 adms_slist_push(&($$),(p_adms)rparen);
607 }
608 | '(' ')'
609 {
610 p_preprocessor_text lparen=adms_preprocessor_new_text_as_string("(");
611 p_preprocessor_text rparen=adms_preprocessor_new_text_as_string(")");
612 $$=adms_slist_new((p_adms)lparen);
613 adms_slist_push(&($$),(p_adms)rparen);
614 }
615 | TK_IDENT
616 {
617 p_preprocessor_text newtext=adms_preprocessor_new_text_as_string($1);
618 $$=adms_slist_new((p_adms)newtext);
619 }
620 | TK_STRING
621 {
622 p_preprocessor_text newtext=adms_preprocessor_new_text_as_string($1);
623 $$=adms_slist_new((p_adms)newtext);
624 }
625 | TK_NOT_IDENT
626 {
627 p_preprocessor_text newtext=adms_preprocessor_new_text_as_string($1);
628 $$=adms_slist_new((p_adms)newtext);
629 }
630 | R_substitutor
631 {
632 $$=$1;
633 }
634 ;
635
636 R_other
637 : '('
638 {
639 p_preprocessor_text newtext=adms_preprocessor_new_text_as_string("(");
640 $$=adms_slist_new((p_adms)newtext);
641 }
642 | ')'
643 {
644 p_preprocessor_text newtext=adms_preprocessor_new_text_as_string(")");
645 $$=adms_slist_new((p_adms)newtext);
646 }
647 | ','
648 {
649 p_preprocessor_text newtext=adms_preprocessor_new_text_as_string(",");
650 $$=adms_slist_new((p_adms)newtext);
651 }
652 | TK_IDENT
653 {
654 p_preprocessor_text newtext=adms_preprocessor_new_text_as_string($1);
655 $$=adms_slist_new((p_adms)newtext);
656 }
657 | TK_NOT_IDENT
658 {
659 p_preprocessor_text newtext=adms_preprocessor_new_text_as_string($1);
660 $$=adms_slist_new((p_adms)newtext);
661 }
662 | TK_STRING
663 {
664 p_preprocessor_text newtext=adms_preprocessor_new_text_as_string($1);
665 $$=adms_slist_new((p_adms)newtext);
666 }
667 | TK_SPACE
668 {
669 p_preprocessor_text newtext=adms_preprocessor_new_text_as_string($1);
670 $$=adms_slist_new((p_adms)newtext);
671 }
672 | TK_COMMENT
673 {
674 p_preprocessor_text newtext=adms_preprocessor_new_text_as_string($1);
675 $$=adms_slist_new((p_adms)newtext);
676 }
677 | TK_EOF
678 {
679 p_preprocessor_text newtext=adms_preprocessor_new_text_as_string($1);
680 $$=adms_slist_new((p_adms)newtext);
681 }
682 ;
683
684 R_define_alternative
685 : R_define TK_DEFINE_END
686 {
687 p_preprocessor_pragma_define Define;
688 if(DONT_SKIPP) Define=adms_preprocessor_define_add($1);
689 $$=NULL;
690 }
691 | R_define R_define_text TK_DEFINE_END
692 {
693 p_preprocessor_pragma_define Define;
694 if(DONT_SKIPP) Define=adms_preprocessor_define_add_with_text($1, $2);
695 $$=NULL;
696 }
697 | R_define TK_ARG_NULL TK_DEFINE_END
698 {
699 p_preprocessor_pragma_define Define;
700 if(DONT_SKIPP) Define=adms_preprocessor_define_add_with_arg($1, NULL);
701 $$=NULL;
702 }
703 | R_define TK_ARG_NULL R_define_text TK_DEFINE_END
704 {
705 p_preprocessor_pragma_define Define;
706 if(DONT_SKIPP) Define=adms_preprocessor_define_add_with_arg_and_text($1, NULL, $3);
707 $$=NULL;
708 }
709 | R_define R_define_list_of_arg TK_DEFINE_END
710 {
711 p_preprocessor_pragma_define Define;
712 if(DONT_SKIPP) Define=adms_preprocessor_define_add_with_arg($1, $2);
713 $$=NULL;
714 }
715 | R_define R_define_list_of_arg R_define_text TK_DEFINE_END
716 {
717 p_preprocessor_pragma_define Define;
718 if(DONT_SKIPP) Define=adms_preprocessor_define_add_with_arg_and_text($1, $2, $3);
719 $$=NULL;
720 }
721 ;
722
723 R_define
724 : TK_DEFINE TK_PRAGMA_NAME
725 {
726 $$=$2;
727 }
728 ;
729
730 R_define_list_of_arg
731 : TK_ARG
732 {
733 $$=adms_slist_new((p_adms)$1);
734 }
735 | R_define_list_of_arg TK_ARG
736 {
737 adms_slist_push(&($1),(p_adms)$2);
738 $$=$1;
739 }
740 ;
741
742 R_define_text
743 : R_define_notpragma
744 {
745 $$=$1;
746 }
747 | R_define_text R_define_notpragma
748 {
749 $$=$2;
750 adms_slist_concat(&($$),$1);
751 }
752 ;
753
754 %%
755
756 int adms_preprocessor_getint_yydebug(void)
757 {
758 return yydebug;
759 }
adms_preprocessor_setint_yydebug(const int val)760 void adms_preprocessor_setint_yydebug(const int val)
761 {
762 yydebug=val;
763 }
764