1 /* Bytecode definition file parser.
2 Copyright (C) 1993 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
32 /* Chain of all defs built by the parser. */
36 static struct node *makenode ();
37 static struct variation *makevar ();
38 static struct def *makedef ();
48 struct variation *variation;
52 %token <string> DEFOP STRING
53 %type <string> opt_string
55 %type <variation> variations variation
56 %type <node> list items item
68 { $2->next = $1; $$ = $2; }
72 DEFOP '(' STRING ',' opt_string ',' '(' variations ')' ')'
73 { $$ = makedef ($3, $5, $8); }
78 | variations ',' variation
79 { $3->next = $1; $$ = $3; }
84 { $$ = makevar ($2, (struct node *) NULL, (struct node *) NULL, (struct node *) NULL); }
85 | '(' opt_string ',' list ')'
86 { $$ = makevar ($2, $4, (struct node *) NULL, (struct node *) NULL); }
87 | '(' opt_string ',' list ',' list ')'
88 { $$ = makevar ($2, $4, $6, (struct node *) NULL); }
89 | '(' opt_string ',' list ',' list ',' list ')'
90 { $$ = makevar ($2, $4, $6, $8); }
94 /* empty */ { $$ = ""; }
107 /* Note right recursion. */
109 { $1->next = $3; $$ = $1; }
114 { $$ = makenode ($1); }
125 n = (struct node *) malloc (sizeof (struct node));
131 static struct variation *
132 makevar (name, inputs, outputs, literals)
134 struct node *inputs, *outputs, *literals;
138 v = (struct variation *) malloc (sizeof (struct variation));
142 v->outputs = outputs;
143 v->literals = literals;
149 makedef (name, template, vars)
150 char *name, *template;
151 struct variation *vars;
155 d = (struct def *) malloc (sizeof (struct def));
157 d->template = template;
158 d->variations = vars;
167 fprintf (stderr, "syntax error in input\n");
168 exit (FATAL_EXIT_CODE);