home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
TELECOM
/
palias10.lzh
/
BNU
/
PALIAS
/
y.tab.c
< prev
next >
Wrap
Text File
|
1993-11-06
|
32KB
|
1,268 lines
/* A Bison parser, made from parse.y */
#define SITE 258
#define HOST 259
#define STRING 260
#define COST 261
#define NET 262
#define YEOL 263
#define PRIVATE 264
#define DEAD 265
#define DELETE 266
#define FILETOK 267
#define ADJUST 268
#line 1 "parse.y"
/* pathalias -- by steve bellovin, as told to peter honeyman */
#ifndef lint
static char *sccsid = "@(#)parse.y 9.11 91/06/01";
#endif /* lint */
#include "def.h"
/* scanner states (yylex, parse) */
#define OTHER 0
#define COSTING 1
#define NEWLINE 2
#define FILENAME 3
/* exports */
long Tcount;
extern void yyerror();
/* imports */
extern node *addnode(), *addprivate();
extern void fixprivate(), alias(), deadlink(), deletelink();
extern link *addlink();
extern int strcmp();
extern char *strsave();
extern int optind;
extern char *Cfile, *Netchars, **Argv;
extern int Lineno, Argc;
extern node *Home;
/* privates */
STATIC void fixnet(), adjust();
STATIC int yylex(), yywrap(), getword();
static int Scanstate = NEWLINE; /* scanner (yylex) state */
/* flags for ys_flags */
#define TERMINAL 1
#line 39 "parse.y"
typedef union {
node *y_node;
Cost y_cost;
char y_net;
char *y_name;
struct {
node *ys_node;
Cost ys_cost;
short ys_flag;
char ys_net;
char ys_dir;
} y_s;
} YYSTYPE;
#ifndef YYLTYPE
typedef
struct yyltype
{
int timestamp;
int first_line;
int first_column;
int last_line;
int last_column;
char *text;
}
yyltype;
#define YYLTYPE yyltype
#endif
#include <stdio.h>
#ifndef __STDC__
#define const
#endif
#define YYFINAL 122
#define YYFLAG -32768
#define YYNTBASE 26
#define YYTRANSLATE(x) ((unsigned)(x) <= 268 ? yytranslate[x] : 54)
static const char yytranslate[] = { 0,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 24,
25, 16, 14, 18, 15, 2, 17, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 19,
21, 20, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 22, 2, 23, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 1, 2, 3, 4, 5,
6, 7, 8, 9, 10, 11, 12, 13
};
static const short yyrline[] = { 0,
67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
77, 80, 89, 98, 101, 102, 103, 104, 105, 106,
109, 114, 119, 126, 130, 137, 138, 139, 142, 143,
144, 147, 148, 151, 152, 161, 164, 165, 168, 169,
170, 173, 175, 176, 177, 180, 181, 184, 186, 188,
189, 190, 193, 203, 206, 206, 206, 211, 213, 214,
215, 218, 220, 221, 221, 222, 225, 226, 227, 228,
229, 230, 231
};
static const char * const yytname[] = { 0,
"error","$illegal.","SITE","HOST","STRING","COST","NET","YEOL","PRIVATE","DEAD",
"DELETE","FILETOK","ADJUST","'+'","'-'","'*'","'/'","','","'<'","'>'",
"'='","'{'","'}'","'('","')'","map"
};
static const short yyr1[] = { 0,
26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
26, 27, 27, 27, 28, 28, 28, 28, 28, 28,
29, 29, 29, 30, 30, 31, 31, 31, 32, 32,
32, 33, 33, 34, 34, 34, 35, 35, 36, 36,
36, 37, 38, 38, 38, 39, 39, 40, 41, 42,
42, 42, 43, 43, 45, 46, 44, 47, 48, 48,
48, 49, 50, 51, 52, 50, 53, 53, 53, 53,
53, 53, 53
};
static const short yyr2[] = { 0,
0, 2, 3, 3, 3, 3, 3, 3, 3, 3,
2, 3, 4, 2, 1, 1, 1, 1, 1, 1,
1, 2, 2, 1, 3, 3, 3, 2, 5, 6,
6, 1, 2, 1, 3, 2, 4, 3, 1, 3,
2, 4, 1, 3, 2, 1, 3, 1, 4, 1,
3, 2, 1, 3, 0, 0, 6, 4, 1, 3,
2, 2, 0, 0, 0, 5, 1, 2, 3, 3,
3, 3, 3
};
static const short yydefact[] = { 0,
0, 0, 11, 15, 2, 16, 17, 18, 19, 20,
32, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 55, 0, 3, 14, 24, 0,
0, 33, 63, 21, 4, 28, 5, 0, 0, 6,
7, 8, 9, 10, 39, 38, 0, 46, 0, 43,
0, 53, 0, 0, 50, 0, 48, 63, 0, 59,
63, 22, 0, 26, 64, 12, 23, 27, 0, 34,
0, 41, 37, 45, 42, 0, 0, 52, 49, 56,
62, 61, 58, 13, 25, 0, 0, 36, 63, 40,
44, 47, 54, 51, 0, 60, 67, 0, 0, 65,
63, 35, 63, 29, 57, 68, 0, 0, 0, 0,
0, 0, 30, 31, 69, 70, 71, 72, 73, 66,
0, 0
};
static const short yydefgoto[] = { 2,
12, 13, 33, 34, 14, 15, 16, 71, 17, 47,
18, 49, 50, 51, 19, 54, 55, 20, 56, 95,
21, 59, 60, 66, 86, 112, 100
};
static const short yypact[] = { 5,
12, 27,-32768,-32768,-32768, -14, 2, 11, 29, 40,
-32768, 3, 22, 56, 14, 35, 65, 83, 84, 85,
86, 0, 92, 93,-32768, 94,-32768, 42,-32768, 31,
95, 96, 39, 68,-32768, 97,-32768, 79, 99,-32768,
-32768,-32768,-32768,-32768,-32768,-32768, -11, 98, 58,-32768,
100, 98, 101, 59,-32768, 104,-32768, 39, 60,-32768,
39,-32768, 90,-32768,-32768,-32768,-32768,-32768, 99,-32768,
61, 103,-32768, 92,-32768, 94, 94, 93,-32768,-32768,
-32768, 94,-32768,-32768,-32768, 4, 67, 108, 23,-32768,
-32768,-32768,-32768,-32768, 80,-32768,-32768, 4, 4, 72,
39,-32768, 39,-32768,-32768, 43, 55, 4, 4, 4,
4, 87,-32768,-32768,-32768, 43, 43,-32768,-32768,-32768,
113,-32768
};
static const short yypgoto[] = {-32768,
-32768,-32768, 76, 88,-32768,-32768,-32768, 45,-32768,-32768,
-32768,-32768, 41, -24,-32768,-32768, 38,-32768,-32768,-32768,
-32768,-32768, 37, -57,-32768,-32768, -43
};
#define YYLAST 119
static const short yytable[] = { 53,
81, 58, 45, 84, -1, 1, 72, 22, -1, 97,
27, 73, -1, -1, -1, -1, -1, -1, 98, 3,
28, 37, 46, 23, 29, -1, 121, 99, 30, 103,
4, 104, 24, 29, 5, 6, 7, 8, 9, 10,
31, 38, 32, 113, 29, 114, 65, 11, 30, 31,
25, 92, 93, 53, 106, 107, 39, 58, 110, 111,
31, 26, 65, 35, 116, 117, 118, 119, 108, 109,
110, 111, 40, 36, 67, 74, 78, 82, 88, 115,
75, 79, 83, 89, 88, 108, 109, 110, 111, 101,
41, 42, 43, 44, 48, 52, 57, 63, 64, 68,
69, 70, 105, 61, -48, 90, 76, 77, 80, 85,
102, 120, 122, 87, 91, 94, 0, 62, 96
};
static const short yycheck[] = { 24,
58, 26, 3, 61, 0, 1, 18, 22, 4, 6,
8, 23, 8, 9, 10, 11, 12, 13, 15, 8,
18, 8, 23, 22, 3, 21, 0, 24, 7, 7,
4, 89, 22, 3, 8, 9, 10, 11, 12, 13,
19, 7, 21, 101, 3, 103, 24, 21, 7, 19,
22, 76, 77, 78, 98, 99, 22, 82, 16, 17,
19, 22, 24, 8, 108, 109, 110, 111, 14, 15,
16, 17, 8, 18, 7, 18, 18, 18, 18, 25,
23, 23, 23, 23, 18, 14, 15, 16, 17, 23,
8, 8, 8, 8, 3, 3, 3, 3, 3, 3,
22, 3, 23, 28, 7, 3, 7, 7, 5, 20,
3, 25, 0, 69, 74, 78, -1, 30, 82
};
#define YYPURE 1
/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
#line 3 "bison.simple"
/* Skeleton output parser for bison,
Copyright (C) 1984 Bob Corbett and Richard Stallman
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__)
#include <alloca.h>
#endif
/* This is the parser code that is written into each bison parser
when the %semantic_parser declaration is not specified in the grammar.
It was written by Richard Stallman by simplifying the hairy parser
used when %semantic_parser is specified. */
/* Note: there must be only one dollar sign in this file.
It is replaced by the list of actions, each action
as one case of the switch. */
#define yyerrok (yyerrstatus = 0)
#define yyclearin (yychar = YYEMPTY)
#define YYEMPTY -2
#define YYEOF 0
#define YYFAIL goto yyerrlab;
#define YYACCEPT return(0)
#define YYABORT return(1)
#define YYERROR goto yyerrlab
#define YYTERROR 1
#ifndef YYIMPURE
#define YYLEX yylex()
#endif
#ifndef YYPURE
#define YYLEX yylex(&yylval, &yylloc)
#endif
/* If nonreentrant, generate the variables here */
#ifndef YYIMPURE
int yychar; /* the lookahead symbol */
YYSTYPE yylval; /* the semantic value of the */
/* lookahead symbol */
YYLTYPE yylloc; /* location data for the lookahead */
/* symbol */
int yynerrs; /* number of parse errors so far */
#endif /* YYIMPURE */
#if YYDEBUG != 0
int yydebug; /* nonzero means print parse trace */
/* Since this is uninitialized, it does not stop multiple parsers
from coexisting. */
#endif
/* YYMAXDEPTH indicates the initial size of the parser's stacks */
#ifndef YYMAXDEPTH
#define YYMAXDEPTH 200
#endif
/* YYMAXLIMIT is the maximum size the stacks can grow to
(effective only if the built-in stack extension method is used). */
#ifndef YYMAXLIMIT
#define YYMAXLIMIT 10000
#endif
#line 175 "bison.simple"
int
yyparse()
{
register int yystate;
register int yyn;
register short *yyssp;
register YYSTYPE *yyvsp;
YYLTYPE *yylsp;
int yyerrstatus; /* number of tokens to shift before error messages enabled */
int yychar1; /* lookahead token as an internal (translated) token number */
short yyssa[YYMAXDEPTH]; /* the state stack */
YYSTYPE yyvsa[YYMAXDEPTH]; /* the semantic value stack */
YYLTYPE yylsa[YYMAXDEPTH]; /* the location stack */
short *yyss = yyssa; /* refer to the stacks thru separate pointers */
YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
YYLTYPE *yyls = yylsa;
int yymaxdepth = YYMAXDEPTH;
#ifndef YYPURE
int yychar;
YYSTYPE yylval;
YYLTYPE yylloc;
int yynerrs;
#endif
YYSTYPE yyval; /* the variable used to return */
/* semantic values from the action */
/* routines */
int yylen;
#if YYDEBUG != 0
if (yydebug)
fprintf(stderr, "Starting parse\n");
#endif
yystate = 0;
yyerrstatus = 0;
yynerrs = 0;
yychar = YYEMPTY; /* Cause a token to be read. */
/* Initialize stack pointers.
Waste one element of value and location stack
so that they stay on the same level as the state stack. */
yyssp = yyss - 1;
yyvsp = yyvs;
yylsp = yyls;
/* Push a new state, which is found in yystate . */
/* In all cases, when you get here, the value and location stacks
have just been pushed. so pushing a state here evens the stacks. */
yynewstate:
*++yyssp = yystate;
if (yyssp >= yyss + yymaxdepth - 1)
{
/* Give user a chance to reallocate the stack */
/* Use copies of these so that the &'s don't force the real ones into memory. */
YYSTYPE *yyvs1 = yyvs;
YYLTYPE *yyls1 = yyls;
short *yyss1 = yyss;
/* Get the current used size of the three stacks, in elements. */
int size = yyssp - yyss + 1;
#ifdef yyoverflow
/* Each stack pointer address is followed by the size of
the data in use in that stack, in bytes. */
yyoverflow("parser stack overflow",
&yyss1, size * sizeof (*yyssp),
&yyvs1, size * sizeof (*yyvsp),
&yyls1, size * sizeof (*yylsp),
&yymaxdepth);
yyss = yyss1; yyvs = yyvs1; yyls = yyls1;
#else /* no yyoverflow */
/* Extend the stack our own way. */
if (yymaxdepth >= YYMAXLIMIT)
yyerror("parser stack overflow");
yymaxdepth *= 2;
if (yymaxdepth > YYMAXLIMIT)
yymaxdepth = YYMAXLIMIT;
yyss = (short *) alloca (yymaxdepth * sizeof (*yyssp));
bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
yyvs = (YYSTYPE *) alloca (yymaxdepth * sizeof (*yyvsp));
bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
#ifdef YYLSP_NEEDED
yyls = (YYLTYPE *) alloca (yymaxdepth * sizeof (*yylsp));
bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
#endif
#endif /* no yyoverflow */
yyssp = yyss + size - 1;
yyvsp = yyvs + size - 1;
#ifdef YYLSP_NEEDED
yylsp = yyls + size - 1;
#endif
#if YYDEBUG != 0
if (yydebug)
fprintf(stderr, "Stack size increased to %d\n", yymaxdepth);
#endif
if (yyssp >= yyss + yymaxdepth - 1)
YYABORT;
}
#if YYDEBUG != 0
if (yydebug)
fprintf(stderr, "Entering state %d\n", yystate);
#endif
/* Do appropriate processing given the current state. */
/* Read a lookahead token if we need one and don't already have one. */
yyresume:
/* First try to decide what to do without reference to lookahead token. */
yyn = yypact[yystate];
if (yyn == YYFLAG)
goto yydefault;
/* Not known => get a lookahead token if don't already have one. */
/* yychar is either YYEMPTY or YYEOF
or a valid token in external form. */
if (yychar == YYEMPTY)
{
#if YYDEBUG != 0
if (yydebug)
fprintf(stderr, "Reading a token: ");
#endif
yychar = YYLEX;
}
/* Convert token to internal form (in yychar1) for indexing tables with */
if (yychar <= 0) /* This means end of input. */
{
yychar1 = 0;
yychar = YYEOF; /* Don't call YYLEX any more */
#if YYDEBUG != 0
if (yydebug)
fprintf(stderr, "Now at end of input.\n");
#endif
}
else
{
yychar1 = YYTRANSLATE(yychar);
#if YYDEBUG != 0
if (yydebug)
fprintf(stderr, "Next token is %d (%s)\n", yychar, yytname[yychar1]);
#endif
}
yyn += yychar1;
if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
goto yydefault;
yyn = yytable[yyn];
/* yyn is what to do for this token type in this state.
Negative => reduce, -yyn is rule number.
Positive => shift, yyn is new state.
New state is final state => don't bother to shift,
just return success.
0, or most negative number => error. */
if (yyn < 0)
{
if (yyn == YYFLAG)
goto yyerrlab;
yyn = -yyn;
goto yyreduce;
}
else if (yyn == 0)
goto yyerrlab;
if (yyn == YYFINAL)
YYACCEPT;
/* Shift the lookahead token. */
#if YYDEBUG != 0
if (yydebug)
fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
#endif
/* Discard the token being shifted unless it is eof. */
if (yychar != YYEOF)
yychar = YYEMPTY;
*++yyvsp = yylval;
#ifdef YYLSP_NEEDED
*++yylsp = yylloc;
#endif
/* count tokens shifted since error; after three, turn off error status. */
if (yyerrstatus) yyerrstatus--;
yystate = yyn;
goto yynewstate;
/* Do the default action for the current state. */
yydefault:
yyn = yydefact[yystate];
if (yyn == 0)
goto yyerrlab;
/* Do a reduction. yyn is the number of a rule to reduce with. */
yyreduce:
yylen = yyr2[yyn];
yyval = yyvsp[1-yylen]; /* implement default value of the action */
#if YYDEBUG != 0
if (yydebug)
{
if (yylen == 1)
fprintf (stderr, "Reducing 1 value via line %d, ",
yyrline[yyn]);
else
fprintf (stderr, "Reducing %d values via line %d, ",
yylen, yyrline[yyn]);
}
#endif
switch (yyn) {
case 12:
#line 80 "parse.y"
{
struct link *l;
l = addlink(yyvsp[-2].y_node, yyvsp[-1].y_s.ys_node, yyvsp[0].y_cost, yyvsp[-1].y_s.ys_net, yyvsp[-1].y_s.ys_dir);
if (GATEWAYED(yyvsp[-1].y_s.ys_node))
l->l_flag |= LGATEWAY;
if (yyvsp[-1].y_s.ys_flag & TERMINAL)
l->l_flag |= LTERMINAL;
;
break;}
case 13:
#line 89 "parse.y"
{
struct link *l;
l = addlink(yyvsp[-3].y_node, yyvsp[-1].y_s.ys_node, yyvsp[0].y_cost, yyvsp[-1].y_s.ys_net, yyvsp[-1].y_s.ys_dir);
if (GATEWAYED(yyvsp[-1].y_s.ys_node))
l->l_flag |= LGATEWAY;
if (yyvsp[-1].y_s.ys_flag & TERMINAL)
l->l_flag |= LTERMINAL;
;
break;}
case 15:
#line 101 "parse.y"
{yyval.y_node = addnode(yyvsp[0].y_name);;
break;}
case 16:
#line 102 "parse.y"
{yyval.y_node = addnode("private");;
break;}
case 17:
#line 103 "parse.y"
{yyval.y_node = addnode("dead");;
break;}
case 18:
#line 104 "parse.y"
{yyval.y_node = addnode("delete");;
break;}
case 19:
#line 105 "parse.y"
{yyval.y_node = addnode("file");;
break;}
case 20:
#line 106 "parse.y"
{yyval.y_node = addnode("adjust");;
break;}
case 21:
#line 109 "parse.y"
{
yyval.y_s = yyvsp[0].y_s;
yyval.y_s.ys_net = DEFNET;
yyval.y_s.ys_dir = DEFDIR;
;
break;}
case 22:
#line 114 "parse.y"
{
yyval.y_s = yyvsp[0].y_s;
yyval.y_s.ys_net = yyvsp[-1].y_net;
yyval.y_s.ys_dir = LRIGHT;
;
break;}
case 23:
#line 119 "parse.y"
{
yyval.y_s = yyvsp[-1].y_s;
yyval.y_s.ys_net = yyvsp[0].y_net;
yyval.y_s.ys_dir = LLEFT;
;
break;}
case 24:
#line 126 "parse.y"
{
yyval.y_s.ys_node = addnode(yyvsp[0].y_name);
yyval.y_s.ys_flag = 0;
;
break;}
case 25:
#line 130 "parse.y"
{
Tcount++;
yyval.y_s.ys_node = addnode(yyvsp[-1].y_name);
yyval.y_s.ys_flag = TERMINAL;
;
break;}
case 26:
#line 137 "parse.y"
{alias(yyvsp[-2].y_node, addnode(yyvsp[0].y_name));;
break;}
case 27:
#line 138 "parse.y"
{alias(yyvsp[-2].y_node, addnode(yyvsp[0].y_name));;
break;}
case 29:
#line 142 "parse.y"
{fixnet(yyvsp[-4].y_node, yyvsp[-2].y_node, yyvsp[0].y_cost, DEFNET, DEFDIR);;
break;}
case 30:
#line 143 "parse.y"
{fixnet(yyvsp[-5].y_node, yyvsp[-2].y_node, yyvsp[0].y_cost, yyvsp[-4].y_net, LRIGHT);;
break;}
case 31:
#line 144 "parse.y"
{fixnet(yyvsp[-5].y_node, yyvsp[-3].y_node, yyvsp[0].y_cost, yyvsp[-1].y_net, LLEFT);;
break;}
case 32:
#line 147 "parse.y"
{yyval.y_node = 0; /* anonymous net */;
break;}
case 33:
#line 148 "parse.y"
{yyval.y_node = yyvsp[-1].y_node; /* named net */;
break;}
case 34:
#line 151 "parse.y"
{yyval.y_node = addnode(yyvsp[0].y_name);;
break;}
case 35:
#line 152 "parse.y"
{
node *n;
n = addnode(yyvsp[0].y_name);
if (n->n_net == 0) {
n->n_net = yyvsp[-2].y_node;
yyval.y_node = n;
}
;
break;}
case 38:
#line 165 "parse.y"
{fixprivate();;
break;}
case 39:
#line 168 "parse.y"
{addprivate(yyvsp[0].y_name)->n_flag |= ISPRIVATE;;
break;}
case 40:
#line 169 "parse.y"
{addprivate(yyvsp[0].y_name)->n_flag |= ISPRIVATE;;
break;}
case 46:
#line 180 "parse.y"
{deadlink(addnode(yyvsp[0].y_name), (node *) 0);;
break;}
case 47:
#line 181 "parse.y"
{deadlink(yyvsp[-2].y_node, yyvsp[0].y_node);;
break;}
case 48:
#line 184 "parse.y"
{yyval.y_node = addnode(yyvsp[0].y_name);;
break;}
case 53:
#line 193 "parse.y"
{
node *n;
n = addnode(yyvsp[0].y_name);
deletelink(n, (node *) 0);
n->n_flag |= ISPRIVATE;
/* reset Home if it's deleted */
if (n == Home)
Home = addnode(Home->n_name);
;
break;}
case 54:
#line 203 "parse.y"
{deletelink(yyvsp[-2].y_node, yyvsp[0].y_node);;
break;}
case 55:
#line 206 "parse.y"
{Scanstate = FILENAME;;
break;}
case 56:
#line 206 "parse.y"
{Scanstate = OTHER;;
break;}
case 57:
#line 206 "parse.y"
{
Lineno = 0;
Cfile = strsave(yyvsp[-2].y_name);
;
break;}
case 62:
#line 218 "parse.y"
{adjust(yyvsp[-1].y_node, yyvsp[0].y_cost);;
break;}
case 63:
#line 220 "parse.y"
{yyval.y_cost = DEFCOST; /* empty -- cost is always optional */;
break;}
case 64:
#line 221 "parse.y"
{Scanstate = COSTING;;
break;}
case 65:
#line 221 "parse.y"
{Scanstate = OTHER;;
break;}
case 66:
#line 222 "parse.y"
{yyval.y_cost = yyvsp[-2].y_cost;;
break;}
case 68:
#line 226 "parse.y"
{yyval.y_cost = -yyvsp[0].y_cost;;
break;}
case 69:
#line 227 "parse.y"
{yyval.y_cost = yyvsp[-1].y_cost;;
break;}
case 70:
#line 228 "parse.y"
{yyval.y_cost = yyvsp[-2].y_cost + yyvsp[0].y_cost;;
break;}
case 71:
#line 229 "parse.y"
{yyval.y_cost = yyvsp[-2].y_cost - yyvsp[0].y_cost;;
break;}
case 72:
#line 230 "parse.y"
{yyval.y_cost = yyvsp[-2].y_cost * yyvsp[0].y_cost;;
break;}
case 73:
#line 231 "parse.y"
{
if (yyvsp[0].y_cost == 0)
yyerror("zero divisor\n");
else
yyval.y_cost = yyvsp[-2].y_cost / yyvsp[0].y_cost;
;
break;}
}
/* the action file gets copied in in place of this dollarsign */
#line 412 "bison.simple"
yyvsp -= yylen;
yyssp -= yylen;
#ifdef YYLSP_NEEDED
yylsp -= yylen;
#endif
#if YYDEBUG != 0
if (yydebug)
{
short *ssp1 = yyss - 1;
fprintf (stderr, "state stack now");
while (ssp1 != yyssp)
fprintf (stderr, " %d", *++ssp1);
fprintf (stderr, "\n");
}
#endif
*++yyvsp = yyval;
#ifdef YYLSP_NEEDED
yylsp++;
if (yylen == 0)
{
yylsp->first_line = yylloc.first_line;
yylsp->first_column = yylloc.first_column;
yylsp->last_line = (yylsp-1)->last_line;
yylsp->last_column = (yylsp-1)->last_column;
yylsp->text = 0;
}
else
{
yylsp->last_line = (yylsp+yylen-1)->last_line;
yylsp->last_column = (yylsp+yylen-1)->last_column;
}
#endif
/* Now "shift" the result of the reduction.
Determine what state that goes to,
based on the state we popped back to
and the rule number reduced by. */
yyn = yyr1[yyn];
yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
yystate = yytable[yystate];
else
yystate = yydefgoto[yyn - YYNTBASE];
goto yynewstate;
yyerrlab: /* here on detecting error */
if (! yyerrstatus)
/* If not already recovering from an error, report this error. */
{
++yynerrs;
yyerror("parse error");
}
if (yyerrstatus == 3)
{
/* if just tried and failed to reuse lookahead token after an error, discard it. */
/* return failure if at end of input */
if (yychar == YYEOF)
YYABORT;
#if YYDEBUG != 0
if (yydebug)
fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
#endif
yychar = YYEMPTY;
}
/* Else will try to reuse lookahead token
after shifting the error token. */
yyerrstatus = 3; /* Each real token shifted decrements this */
goto yyerrhandle;
yyerrdefault: /* current state does not do anything special for the error token. */
#if 0
/* This is wrong; only states that explicitly want error tokens
should shift them. */
yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
if (yyn) goto yydefault;
#endif
yyerrpop: /* pop the current state because it cannot handle the error token */
if (yyssp == yyss) YYABORT;
yyvsp--;
yystate = *--yyssp;
#ifdef YYLSP_NEEDED
yylsp--;
#endif
#if YYDEBUG != 0
if (yydebug)
{
short *ssp1 = yyss - 1;
fprintf (stderr, "Error: state stack now");
while (ssp1 != yyssp)
fprintf (stderr, " %d", *++ssp1);
fprintf (stderr, "\n");
}
#endif
yyerrhandle:
yyn = yypact[yystate];
if (yyn == YYFLAG)
goto yyerrdefault;
yyn += YYTERROR;
if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
goto yyerrdefault;
yyn = yytable[yyn];
if (yyn < 0)
{
if (yyn == YYFLAG)
goto yyerrpop;
yyn = -yyn;
goto yyreduce;
}
else if (yyn == 0)
goto yyerrpop;
if (yyn == YYFINAL)
YYACCEPT;
#if YYDEBUG != 0
if (yydebug)
fprintf(stderr, "Shifting error token, ");
#endif
*++yyvsp = yylval;
#ifdef YYLSP_NEEDED
*++yylsp = yylloc;
#endif
yystate = yyn;
goto yynewstate;
}
#line 238 "parse.y"
void
#ifdef YYDEBUG
/*VARARGS1*/
yyerror(fmt, arg)
char *fmt, *arg;
#else
yyerror(s)
char *s;
#endif
{
/* a concession to bsd error(1) */
fprintf(stderr, "\"%s\", ", Cfile);
#ifdef YYDEBUG
fprintf(stderr, "line %d: ", Lineno);
fprintf(stderr, fmt, arg);
putc('\n', stderr);
#else
fprintf(stderr, "line %d: %s\n", Lineno, s);
#endif
}
/*
* patch in the costs of getting on/off the network.
*
* for each network member on netlist, add links:
* network -> member cost = 0;
* member -> network cost = parameter.
*
* if network and member both require gateways, assume network
* is a gateway to member (but not v.v., to avoid such travesties
* as topaz!seismo.css.gov.edu.rutgers).
*
* note that members can have varying costs to a network, by suitable
* multiple declarations. this is a feechur, albeit a useless one.
*/
STATIC void
fixnet(network, nlist, cost, netchar, netdir)
register node *network;
node *nlist;
Cost cost;
char netchar, netdir;
{ register node *member, *nextnet;
link *l;
static int netanon = 0;
char anon[25];
if (network == 0) {
sprintf(anon, "[unnamed net %d]", netanon++);
network = addnode(anon);
}
network->n_flag |= NNET;
/* insert the links */
for (member = nlist ; member; member = nextnet) {
/* network -> member, cost is 0 */
l = addlink(network, member, (Cost) 0, netchar, netdir);
if (GATEWAYED(network) && GATEWAYED(member))
l->l_flag |= LGATEWAY;
/* member -> network, cost is parameter */
/* never ever ever crawl up from a domain*/
if (!ISADOMAIN(network))
(void) addlink(member, network, cost, netchar, netdir);
nextnet = member->n_net;
member->n_net = 0; /* clear for later use */
}
}
/* scanner */
#define QUOTE '"'
#define STR_EQ(s1, s2) (s1[2] == s2[2] && strcmp(s1, s2) == 0)
#define NLRETURN() {Scanstate = NEWLINE; return YEOL;}
static struct ctable {
char *cname;
Cost cval;
} ctable[] = {
/* ordered by frequency of appearance in a "typical" dataset */
{"DIRECT", 200},
{"DEMAND", 300},
{"DAILY", 5000},
{"HOURLY", 500},
{"DEDICATED", 100},
{"EVENING", 2000},
{"LOCAL", 25},
{"LOW", 5}, /* baud rate, quality penalty */
{"DEAD", MILLION},
{"POLLED", 5000},
{"WEEKLY", 30000},
{"HIGH", -5}, /* baud rate, quality bonus */
{"FAST", -80}, /* high speed (>= 9.6 kbps) modem */
/* deprecated */
{"ARPA", 100},
{"DIALED", 300},
{0, 0}
};
STATIC int
yylex()
{ static char retbuf[128]; /* for return to yacc part */
register int c;
register char *buf = retbuf;
register struct ctable *ct;
register Cost cost;
char errbuf[128];
if (feof(stdin) && yywrap())
return EOF;
/* count lines, skip over space and comments */
if ((c = getchar()) == EOF)
NLRETURN();
continuation:
while (c == ' ' || c == '\t')
if ((c = getchar()) == EOF)
NLRETURN();
if (c == '#')
while ((c = getchar()) != '\n')
if (c == EOF)
NLRETURN();
/* scan token */
if (c == '\n') {
Lineno++;
if ((c = getchar()) != EOF) {
if (c == ' ' || c == '\t')
goto continuation;
ungetc(c, stdin);
}
NLRETURN();
}
switch(Scanstate) {
case COSTING:
if (isdigit(c)) {
cost = c - '0';
for (c = getchar(); isdigit(c); c = getchar())
cost = (cost * 10) + c - '0';
ungetc(c, stdin);
yylval.y_cost = cost;
return COST;
}
if (getword(buf, c) == 0) {
for (ct = ctable; ct->cname; ct++)
if (STR_EQ(buf, ct->cname)) {
yylval.y_cost = ct->cval;
return COST;
}
sprintf(errbuf, "unknown cost (%s), using default", buf);
yyerror(errbuf);
yylval.y_cost = DEFCOST;
return COST;
}
return c; /* pass the buck */
case NEWLINE:
Scanstate = OTHER;
if (getword(buf, c) != 0)
return c;
/*
* special purpose tokens.
*
* the "switch" serves the dual-purpose of recognizing
* unquoted tokens only.
*/
switch(c) {
case 'p':
if (STR_EQ(buf, "private"))
return PRIVATE;
break;
case 'd':
if (STR_EQ(buf, "dead"))
return DEAD;
if (STR_EQ(buf, "delete"))
return DELETE;
break;
case 'f':
if (STR_EQ(buf, "file"))
return FILETOK;
break;
case 'a':
if (STR_EQ(buf, "adjust"))
return ADJUST;
break;
}
yylval.y_name = buf;
return HOST;
case FILENAME:
while (c != EOF && isprint(c)) {
if (c == ' ' || c == '\t' || c == '\n' || c == '}')
break;
*buf++ = c;
c = getchar();
}
if (c != EOF)
ungetc(c, stdin);
*buf = 0;
yylval.y_name = retbuf;
return STRING;
}
if (getword(buf, c) == 0) {
yylval.y_name = buf;
return SITE;
}
if (index(Netchars, c)) {
yylval.y_net = c;
return NET;
}
return c;
}
/*
* fill str with the next word in [0-9A-Za-z][-._0-9A-Za-z]+ or a quoted
* string that contains no newline. return -1 on failure or EOF, 0 o.w.
*/
STATIC int
getword(str, c)
register char *str;
register int c;
{
if (c == QUOTE) {
while ((c = getchar()) != QUOTE) {
if (c == '\n') {
yyerror("newline in quoted string\n");
ungetc(c, stdin);
return -1;
}
if (c == EOF) {
yyerror("EOF in quoted string\n");
return -1;
}
*str++ = c;
}
*str = 0;
return 0;
}
/* host name must start with alphanumeric or `.' */
if (!isalnum(c) && c != '.')
return -1;
yymore:
do {
*str++ = c;
c = getchar();
} while (isalnum(c) || c == '.' || c == '_');
if (c == '-' && Scanstate != COSTING)
goto yymore;
ungetc(c, stdin);
*str = 0;
return 0;
}
STATIC int
yywrap()
{ char errbuf[100];
fixprivate(); /* munge private host definitions */
Lineno = 1;
while (optind < Argc) {
if (freopen((Cfile = Argv[optind++]), "r", stdin) != 0)
return 0;
sprintf(errbuf, "%s: %s", Argv[0], Cfile);
perror(errbuf);
}
freopen(DEVNULL, "r", stdin);
return -1;
}
STATIC void
adjust(n, cost)
node *n;
Cost cost;
{ link *l;
n->n_cost += cost; /* cumulative */
/* hit existing links */
for (l = n->n_link; l; l = l->l_next) {
if ((l->l_cost += cost) < 0) {
char buf[100];
l->l_flag |= LDEAD;
sprintf(buf, "link to %s deleted with negative cost",
l->l_to->n_name);
yyerror(buf);
}
}
}