-/* $NetBSD: grammar.y,v 1.4 1997/10/10 02:07:08 lukem Exp $ */
+/* $NetBSD: grammar.y,v 1.12 2015/06/19 06:02:31 dholland Exp $ */
/*-
* Copyright (c) 1990, 1993
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
}
%{
-#include "include.h"
-
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)grammar.y 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: grammar.y,v 1.4 1997/10/10 02:07:08 lukem Exp $");
+__RCSID("$NetBSD: grammar.y,v 1.12 2015/06/19 06:02:31 dholland Exp $");
#endif
#endif /* not lint */
-int errors = 0;
-int line = 1;
+#include <stdio.h>
+
+#include "def.h"
+#include "struct.h"
+#include "extern.h"
+#include "tunable.h"
+
+int line = 1;
+
+static int errors = 0;
+
+static int yyerror(const char *);
%}
%%
wdef:
WidthOp '=' ConstOp ';'
{
- if (sp->height != 0)
+ if (sp->width != 0)
return (yyerror("Redefinition of 'width'."));
else if ($3 < 3)
return (yyerror("'width' is too small."));
{
if (sp->num_beacons % REALLOC == 0) {
if (sp->beacon == NULL)
- sp->beacon = (BEACON *) malloc((sp->num_beacons
+ sp->beacon = malloc((sp->num_beacons
+ REALLOC) * sizeof (BEACON));
else
- sp->beacon = (BEACON *) realloc(sp->beacon,
+ sp->beacon = realloc(sp->beacon,
(sp->num_beacons + REALLOC) *
sizeof (BEACON));
if (sp->beacon == NULL)
if (sp->num_exits % REALLOC == 0) {
if (sp->exit == NULL)
- sp->exit = (EXIT *) malloc((sp->num_exits +
+ sp->exit = malloc((sp->num_exits +
REALLOC) * sizeof (EXIT));
else
- sp->exit = (EXIT *) realloc(sp->exit,
+ sp->exit = realloc(sp->exit,
(sp->num_exits + REALLOC) *
sizeof (EXIT));
if (sp->exit == NULL)
if (sp->num_airports % REALLOC == 0) {
if (sp->airport == NULL)
- sp->airport=(AIRPORT *)malloc((sp->num_airports
+ sp->airport = malloc((sp->num_airports
+ REALLOC) * sizeof(AIRPORT));
else
- sp->airport = (AIRPORT *) realloc(sp->airport,
+ sp->airport = realloc(sp->airport,
(sp->num_airports + REALLOC) *
sizeof(AIRPORT));
if (sp->airport == NULL)
sp->airport[sp->num_airports].y = $3;
sp->airport[sp->num_airports].dir = dir;
check_point($2, $3);
- check_adir($2, $3, dir);
sp->num_airports++;
}
;
{
if (sp->num_lines % REALLOC == 0) {
if (sp->line == NULL)
- sp->line = (LINE *) malloc((sp->num_lines +
+ sp->line = malloc((sp->num_lines +
REALLOC) * sizeof (LINE));
else
- sp->line = (LINE *) realloc(sp->line,
+ sp->line = realloc(sp->line,
(sp->num_lines + REALLOC) *
sizeof (LINE));
if (sp->line == NULL)
;
%%
-void
-check_edge(x, y)
- int x, y;
+static void
+check_edge(int x, int y)
{
if (!(x == 0) && !(x == sp->width - 1) &&
!(y == 0) && !(y == sp->height - 1))
yyerror("edge value not on edge.");
}
-void
-check_point(x, y)
- int x, y;
+static void
+check_point(int x, int y)
{
if (x < 1 || x >= sp->width - 1)
yyerror("X value out of range.");
yyerror("Y value out of range.");
}
-void
-check_linepoint(x, y)
- int x, y;
+static void
+check_linepoint(int x, int y)
{
if (x < 0 || x >= sp->width)
yyerror("X value out of range.");
yyerror("Y value out of range.");
}
-void
-check_line(x1, y1, x2, y2)
- int x1, y1, x2, y2;
+static void
+check_line(int px1, int py1, int px2, int py2)
{
int d1, d2;
- check_linepoint(x1, y1);
- check_linepoint(x2, y2);
+ check_linepoint(px1, py1);
+ check_linepoint(px2, py2);
- d1 = ABS(x2 - x1);
- d2 = ABS(y2 - y1);
+ d1 = ABS(px2 - px1);
+ d2 = ABS(py2 - py1);
if (!(d1 == d2) && !(d1 == 0) && !(d2 == 0))
yyerror("Bad line endpoints.");
}
-int
-yyerror(s)
- const char *s;
+static int
+yyerror(const char *s)
{
- fprintf(stderr, "\"%s\": line %d: %s\n", file, line, s);
+ fprintf(stderr, "\"%s\": line %d: %s\n", filename, line, s);
errors++;
return (errors);
}
-void
-check_edir(x, y, dir)
- int x, y, dir;
+static void
+check_edir(int x, int y, int dir)
{
int bad = 0;
yyerror("Bad direction for entrance at exit.");
}
-void
-check_adir(x, y, dir)
- int x, y, dir;
-{
-}
-
-int
-checkdefs()
+static int
+checkdefs(void)
{
- int err = 0;
+ int error = 0;
if (sp->width == 0) {
yyerror("'width' undefined.");
- err++;
+ error++;
}
if (sp->height == 0) {
yyerror("'height' undefined.");
- err++;
+ error++;
}
if (sp->update_secs == 0) {
yyerror("'update' undefined.");
- err++;
+ error++;
}
if (sp->newplane_time == 0) {
yyerror("'newplane' undefined.");
- err++;
+ error++;
}
- if (err)
+ if (error)
return (-1);
else
return (0);