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, 675 Mass Ave, Cambridge, MA 02139, USA. */
31 /* Chain of all defs built by the parser. */
35 static struct node *makenode ();
36 static struct variation *makevar ();
37 static struct def *makedef ();
47 struct variation *variation;
51 %token <string> DEFOP STRING
52 %type <string> opt_string
54 %type <variation> variations variation
55 %type <node> list items item
67 { $2->next = $1; $$ = $2; }
71 DEFOP '(' STRING ',' opt_string ',' '(' variations ')' ')'
72 { $$ = makedef ($3, $5, $8); }
77 | variations ',' variation
78 { $3->next = $1; $$ = $3; }
83 { $$ = makevar ($2, (struct node *) NULL, (struct node *) NULL, (struct node *) NULL); }
84 | '(' opt_string ',' list ')'
85 { $$ = makevar ($2, $4, (struct node *) NULL, (struct node *) NULL); }
86 | '(' opt_string ',' list ',' list ')'
87 { $$ = makevar ($2, $4, $6, (struct node *) NULL); }
88 | '(' opt_string ',' list ',' list ',' list ')'
89 { $$ = makevar ($2, $4, $6, $8); }
93 /* empty */ { $$ = ""; }
106 /* Note right recursion. */
108 { $1->next = $3; $$ = $1; }
113 { $$ = makenode ($1); }
124 n = (struct node *) malloc (sizeof (struct node));
130 static struct variation *
131 makevar (name, inputs, outputs, literals)
133 struct node *inputs, *outputs, *literals;
137 v = (struct variation *) malloc (sizeof (struct variation));
141 v->outputs = outputs;
142 v->literals = literals;
148 makedef (name, template, vars)
149 char *name, *template;
150 struct variation *vars;
154 d = (struct def *) malloc (sizeof (struct def));
156 d->template = template;
157 d->variations = vars;
166 fprintf (stderr, "syntax error in input\n");
167 exit (FATAL_EXIT_CODE);