#define YYBISON 1
# define T_graph 257
# define T_digraph 258
# define T_strict 259
# define T_node 260
# define T_edge 261
# define T_edgeop 262
# define T_symbol 263
# define T_qsymbol 264
# define T_subgraph 265
#line 1 "/home/ellson/graphviz/graph/parser.y"
#pragma prototyped
#include "libgraph.h"
#ifdef DMALLOC
#include "dmalloc.h"
#endif
static char Port[SMALLBUF],*Symbol;
static char In_decl,In_edge_stmt;
static int Current_class,Agraph_type;
static Agraph_t *G;
static Agnode_t *N;
static Agedge_t *E;
static objstack_t *SP;
static Agraph_t *Gstack[32];
static int GSP;
static int override;
void agoverride(int ov)
{
override = (ov > 0 ? ov : 0);
}
static void push_subg(Agraph_t *g)
{
G = Gstack[GSP++] = g;
}
static Agraph_t *pop_subg(void)
{
Agraph_t *g;
if (GSP == 0) {
agerr (AGERR, "Gstack underflow in graph parser\n"); exit(1);
}
g = Gstack[--GSP];
if (GSP > 0) G = Gstack[GSP - 1];
else G = 0;
return g;
}
static objport_t pop_gobj(void)
{
objport_t rv;
rv.obj = pop_subg();
rv.port = NULL;
return rv;
}
static void anonname(char* buf)
{
static int anon_id = 0;
sprintf(buf,"_anonymous_%d",anon_id++);
}
static void begin_graph(char *name)
{
Agraph_t *g;
char buf[SMALLBUF];
if (!name) {
anonname(buf);
name = buf;
}
g = AG.parsed_g = agopen(name,Agraph_type);
Current_class = TAG_GRAPH;
push_subg(g);
In_decl = TRUE;
}
static void end_graph(void)
{
pop_subg();
}
static Agnode_t *bind_node(char *name)
{
Agnode_t *n = agnode(G,name);
In_decl = FALSE;
return n;
}
static void anonsubg(void)
{
char buf[SMALLBUF];
Agraph_t *subg;
In_decl = FALSE;
anonname(buf);
subg = agsubg(G,buf);
push_subg(subg);
}
#if 0
static int isanonsubg(Agraph_t *g)
{
return (strncmp("_anonymous_",g->name,11) == 0);
}
#endif
static void begin_edgestmt(objport_t objp)
{
struct objstack_t *new_sp;
new_sp = NEW(objstack_t);
new_sp->link = SP;
SP = new_sp;
SP->list = SP->last = NEW(objlist_t);
SP->list->data = objp;
SP->list->link = NULL;
SP->in_edge_stmt = In_edge_stmt;
SP->subg = G;
agpushproto(G);
In_edge_stmt = TRUE;
}
static void mid_edgestmt(objport_t objp)
{
SP->last->link = NEW(objlist_t);
SP->last = SP->last->link;
SP->last->data = objp;
SP->last->link = NULL;
}
static void end_edgestmt(void)
{
objstack_t *old_SP;
objlist_t *tailptr,*headptr,*freeptr;
Agraph_t *t_graph,*h_graph;
Agnode_t *t_node,*h_node,*t_first,*h_first;
Agedge_t *e;
char *tport,*hport;
for (tailptr = SP->list; tailptr->link; tailptr = tailptr->link) {
headptr = tailptr->link;
tport = tailptr->data.port;
hport = headptr->data.port;
if (TAG_OF(tailptr->data.obj) == TAG_NODE) {
t_graph = NULL;
t_first = (Agnode_t*)(tailptr->data.obj);
}
else {
t_graph = (Agraph_t*)(tailptr->data.obj);
t_first = agfstnode(t_graph);
}
if (TAG_OF(headptr->data.obj) == TAG_NODE) {
h_graph = NULL;
h_first = (Agnode_t*)(headptr->data.obj);
}
else {
h_graph = (Agraph_t*)(headptr->data.obj);
h_first = agfstnode(h_graph);
}
for (t_node = t_first; t_node; t_node = t_graph ?
agnxtnode(t_graph,t_node) : NULL) {
for (h_node = h_first; h_node; h_node = h_graph ?
agnxtnode(h_graph,h_node) : NULL ) {
e = agedge(G,t_node,h_node);
if (e) {
char *tp = tport;
char *hp = hport;
if ((e->tail != e->head) && (e->head == t_node)) {
char *temp;
temp = tp; tp = hp; hp = temp;
}
if (tp && tp[0]) agxset(e,TAILX,tp);
if (hp && hp[0]) agxset(e,HEADX,hp);
}
}
}
}
tailptr = SP->list;
while (tailptr) {
freeptr = tailptr;
tailptr = tailptr->link;
if (TAG_OF(freeptr->data.obj) == TAG_NODE)
free(freeptr->data.port);
free(freeptr);
}
if (G != SP->subg) abort();
agpopproto(G);
In_edge_stmt = SP->in_edge_stmt;
old_SP = SP;
SP = SP->link;
In_decl = FALSE;
free(old_SP);
Current_class = TAG_GRAPH;
}
#if 0
static Agraph_t *parent_of(Agraph_t *g)
{
Agraph_t *rv;
rv = agusergraph(agfstin(g->meta_node->graph,g->meta_node)->tail);
return rv;
}
#endif
static void attr_set(char *name, char *value)
{
Agsym_t *ap = NULL;
char *defval = "";
if (In_decl && (G->root == G)) defval = value;
switch (Current_class) {
case TAG_NODE:
ap = agfindattr(G->proto->n,name);
if (ap == NULL)
ap = agnodeattr(AG.parsed_g,name,defval);
else if (override && In_decl)
return;
agxset(N,ap->index,value);
break;
case TAG_EDGE:
ap = agfindattr(G->proto->e,name);
if (ap == NULL)
ap = agedgeattr(AG.parsed_g,name,defval);
else if (override && In_decl)
return;
agxset(E,ap->index,value);
break;
case 0:
case TAG_GRAPH:
ap = agfindattr(G,name);
if (ap == NULL)
ap = agraphattr(AG.parsed_g,name,defval);
else if (override && In_decl)
return;
agxset(G,ap->index,value);
break;
}
}
static char*
concat (char* s1, char* s2)
{
char* s;
char buf[BUFSIZ];
char* sym;
int len = strlen(s1) + strlen(s2) + 1;
if (len <= BUFSIZ) sym = buf;
else sym = (char*)malloc(len);
strcpy(sym,s1);
strcat(sym,s2);
s = agstrdup (sym);
if (sym != buf) free (sym);
return s;
}
#line 272 "/home/ellson/graphviz/graph/parser.y"
#ifndef YYSTYPE
typedef union {
int i;
char *str;
struct objport_t obj;
struct Agnode_t *n;
} agstype;
# define YYSTYPE agstype
# define YYSTYPE_IS_TRIVIAL 1
#endif
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#define YYFINAL 100
#define YYFLAG -32768
#define YYNTBASE 24
#define YYTRANSLATE(x) ((unsigned)(x) <= 265 ? agtranslate[x] : 63)
static const char agtranslate[] =
{
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,
20, 21, 2, 23, 14, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 19, 18,
2, 17, 2, 2, 22, 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, 15, 2, 16, 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, 12, 2, 13, 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, 3, 4, 5,
6, 7, 8, 9, 10, 11
};
#if YYDEBUG
static const short agprhs[] =
{
0, 0, 1, 8, 10, 11, 13, 14, 16, 19,
21, 24, 26, 28, 30, 34, 35, 36, 38, 42,
45, 46, 48, 52, 54, 56, 58, 59, 61, 64,
66, 69, 71, 73, 75, 77, 79, 82, 84, 87,
89, 90, 92, 94, 97, 100, 103, 104, 112, 115,
116, 120, 121, 122, 128, 129, 130, 136, 139, 140,
145, 148, 149, 154, 159, 160, 166, 167, 172, 174,
177, 179, 181, 183
};
static const short agrhs[] =
{
-1, 27, 26, 25, 12, 36, 13, 0, 1, 0,
0, 61, 0, 0, 3, 0, 5, 3, 0, 4,
0, 5, 4, 0, 3, 0, 6, 0, 7, 0,
35, 30, 29, 0, 0, 0, 14, 0, 15, 29,
16, 0, 32, 31, 0, 0, 32, 0, 61, 17,
61, 0, 34, 0, 61, 0, 37, 0, 0, 38,
0, 37, 38, 0, 39, 0, 39, 18, 0, 1,
0, 47, 0, 49, 0, 40, 0, 57, 0, 28,
31, 0, 34, 0, 42, 43, 0, 61, 0, 0,
44, 0, 46, 0, 46, 44, 0, 44, 46, 0,
19, 61, 0, 0, 19, 20, 61, 45, 14, 61,
21, 0, 22, 61, 0, 0, 41, 48, 33, 0,
0, 0, 41, 50, 54, 51, 33, 0, 0, 0,
57, 52, 54, 53, 33, 0, 8, 41, 0, 0,
8, 41, 55, 54, 0, 8, 57, 0, 0, 8,
57, 56, 54, 0, 60, 12, 36, 13, 0, 0,
11, 12, 58, 36, 13, 0, 0, 12, 59, 36,
13, 0, 60, 0, 11, 61, 0, 9, 0, 62,
0, 10, 0, 62, 23, 10, 0
};
#endif
#if YYDEBUG
static const short agrline[] =
{
0, 289, 289, 293, 300, 303, 303, 306, 308, 310,
312, 316, 318, 320, 324, 325, 328, 329, 332, 335,
336, 339, 342, 346, 347, 351, 352, 355, 356, 359,
360, 361, 364, 365, 366, 367, 370, 372, 376, 386,
389, 390, 391, 392, 393, 396, 397, 397, 404, 411,
411, 417, 417, 417, 424, 424, 424, 433, 434, 434,
437, 439, 439, 445, 446, 446, 447, 447, 448, 451,
461, 462, 465, 466
};
#endif
#if (YYDEBUG) || defined YYERROR_VERBOSE
static const char *const agtname[] =
{
"$", "error", "$undefined.", "T_graph", "T_digraph", "T_strict", "T_node",
"T_edge", "T_edgeop", "T_symbol", "T_qsymbol", "T_subgraph", "'{'",
"'}'", "','", "'['", "']'", "'='", "';'", "':'", "'('", "')'", "'@'",
"'+'", "file", "@1", "optgraphname", "graph_type", "attr_class",
"inside_attr_list", "optcomma", "attr_list", "rec_attr_list",
"opt_attr_list", "attr_set", "iattr_set", "stmt_list", "stmt_list1",
"stmt", "stmt1", "attr_stmt", "node_id", "node_name", "node_port",
"port_location", "@2", "port_angle", "node_stmt", "@3", "edge_stmt",
"@4", "@5", "@6", "@7", "edgeRHS", "@8", "@9", "subg_stmt", "@10",
"@11", "subg_hdr", "symbol", "qsymbol", 0
};
#endif
static const short agr1[] =
{
0, 25, 24, 24, 24, 26, 26, 27, 27, 27,
27, 28, 28, 28, 29, 29, 30, 30, 31, 32,
32, 33, 34, 35, 35, 36, 36, 37, 37, 38,
38, 38, 39, 39, 39, 39, 40, 40, 41, 42,
43, 43, 43, 43, 43, 44, 45, 44, 46, 48,
47, 50, 51, 49, 52, 53, 49, 54, 55, 54,
54, 56, 54, 57, 58, 57, 59, 57, 57, 60,
61, 61, 62, 62
};
static const short agr2[] =
{
0, 0, 6, 1, 0, 1, 0, 1, 2, 1,
2, 1, 1, 1, 3, 0, 0, 1, 3, 2,
0, 1, 3, 1, 1, 1, 0, 1, 2, 1,
2, 1, 1, 1, 1, 1, 2, 1, 2, 1,
0, 1, 1, 2, 2, 2, 0, 7, 2, 0,
3, 0, 0, 5, 0, 0, 5, 2, 0, 4,
2, 0, 4, 4, 0, 5, 0, 4, 1, 2,
1, 1, 1, 3
};
static const short agdefact[] =
{
0, 3, 7, 9, 0, 6, 8, 10, 70, 72,
1, 5, 71, 0, 0, 0, 73, 31, 11, 12,
13, 0, 66, 0, 37, 0, 0, 27, 29, 34,
49, 40, 32, 33, 35, 68, 39, 64, 69, 0,
15, 36, 2, 28, 30, 20, 0, 0, 0, 38,
41, 42, 0, 0, 0, 0, 0, 0, 23, 16,
24, 21, 50, 0, 52, 0, 45, 48, 44, 43,
55, 0, 22, 0, 67, 18, 17, 15, 19, 57,
60, 39, 20, 46, 20, 63, 65, 14, 0, 0,
53, 0, 56, 59, 62, 0, 0, 47, 0, 0,
0
};
static const short agdefgoto[] =
{
98, 13, 10, 5, 23, 57, 77, 41, 61, 62,
24, 59, 25, 26, 27, 28, 29, 30, 31, 49,
50, 91, 51, 32, 45, 33, 46, 82, 52, 84,
64, 88, 89, 34, 55, 39, 35, 36, 12
};
static const short agpact[] =
{
4,-32768,-32768,-32768, 37, 53,-32768,-32768,-32768,-32768,
-32768,-32768, -17, 10, 15, 17,-32768,-32768,-32768,-32768,
-32768, 22,-32768, 29,-32768, 33, 44,-32768, 30,-32768,
56, 14,-32768,-32768, 57, 40, 49,-32768,-32768, 17,
53,-32768,-32768,-32768,-32768,-32768, 59, 1, 53,-32768,
46, 50, 59, 17, 53, 17, 58, 54,-32768, 60,
49, 29,-32768, 3,-32768, 53,-32768,-32768,-32768,-32768,
-32768, 62,-32768, 63,-32768,-32768,-32768, 53,-32768, 65,
69,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 59, 59,
-32768, 64,-32768,-32768,-32768, 53, 61,-32768, 79, 80,
-32768
};
static const short agpgoto[] =
{
-32768,-32768,-32768,-32768,-32768, 6,-32768, 20,-32768, -23,
-38,-32768, -36,-32768, 66,-32768,-32768, 21,-32768,-32768,
34,-32768, 36,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
-51,-32768,-32768, 24,-32768,-32768,-32768, -5,-32768
};
#define YYLAST 92
static const short agtable[] =
{
11, 70, 58, 56, -4, 1, 14, 2, 3, 4,
8, 9, 8, 9, 21, 22, 38, 71, 17, 73,
18, 65, 15, 19, 20, 16, 8, 9, 21, 22,
-26, 8, 9, 47, 37, 60, 48, 93, 94, 58,
6, 7, 66, 67, 40, 17, 42, 18, 44, 72,
19, 20, 53, 8, 9, 21, 22, -25, 81, 90,
83, 92, 8, 9, -51, -54, 54, 63, 48, 47,
75, 74, 60, -58, 76, 85, 86, -61, 95, 99,
100, 78, 97, 87, 79, 69, 68, 80, 0, 0,
96, 0, 43
};
static const short agcheck[] =
{
5, 52, 40, 39, 0, 1, 23, 3, 4, 5,
9, 10, 9, 10, 11, 12, 21, 53, 1, 55,
3, 20, 12, 6, 7, 10, 9, 10, 11, 12,
13, 9, 10, 19, 12, 40, 22, 88, 89, 77,
3, 4, 47, 48, 15, 1, 13, 3, 18, 54,
6, 7, 12, 9, 10, 11, 12, 13, 63, 82,
65, 84, 9, 10, 8, 8, 17, 8, 22, 19,
16, 13, 77, 8, 14, 13, 13, 8, 14, 0,
0, 61, 21, 77, 63, 51, 50, 63, -1, -1,
95, -1, 26
};
#line 3 "/usr/share/bison/bison.simple"
#if ! defined (agoverflow) || defined (YYERROR_VERBOSE)
# if YYSTACK_USE_ALLOCA
# define YYSTACK_ALLOC alloca
# else
# ifndef YYSTACK_USE_ALLOCA
# if defined (alloca) || defined (_ALLOCA_H)
# define YYSTACK_ALLOC alloca
# else
# ifdef __GNUC__
# define YYSTACK_ALLOC __builtin_alloca
# endif
# endif
# endif
# endif
# ifdef YYSTACK_ALLOC
# define YYSTACK_FREE(Ptr) do { ; } while (0)
# else
# if defined (__STDC__) || defined (__cplusplus)
# include <stdlib.h>
# define YYSIZE_T size_t
# endif
# define YYSTACK_ALLOC malloc
# define YYSTACK_FREE free
# endif
#endif
#if (! defined (agoverflow) \
&& (! defined (__cplusplus) \
|| (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
union agalloc
{
short agss;
YYSTYPE agvs;
# if YYLSP_NEEDED
YYLTYPE agls;
# endif
};
# define YYSTACK_GAP_MAX (sizeof (union agalloc) - 1)
# if YYLSP_NEEDED
# define YYSTACK_BYTES(N) \
((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
+ 2 * YYSTACK_GAP_MAX)
# else
# define YYSTACK_BYTES(N) \
((N) * (sizeof (short) + sizeof (YYSTYPE)) \
+ YYSTACK_GAP_MAX)
# endif
# ifndef YYCOPY
# if 1 < __GNUC__
# define YYCOPY(To, From, Count) \
__builtin_memcpy (To, From, (Count) * sizeof (*(From)))
# else
# define YYCOPY(To, From, Count) \
do \
{ \
register YYSIZE_T agi; \
for (agi = 0; agi < (Count); agi++) \
(To)[agi] = (From)[agi]; \
} \
while (0)
# endif
# endif
# define YYSTACK_RELOCATE(Stack) \
do \
{ \
YYSIZE_T agnewbytes; \
YYCOPY (&agptr->Stack, Stack, agsize); \
Stack = &agptr->Stack; \
agnewbytes = agstacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \
agptr += agnewbytes / sizeof (*agptr); \
} \
while (0)
#endif
#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
# define YYSIZE_T __SIZE_TYPE__
#endif
#if ! defined (YYSIZE_T) && defined (size_t)
# define YYSIZE_T size_t
#endif
#if ! defined (YYSIZE_T)
# if defined (__STDC__) || defined (__cplusplus)
# include <stddef.h>
# define YYSIZE_T size_t
# endif
#endif
#if ! defined (YYSIZE_T)
# define YYSIZE_T unsigned int
#endif
#define agerrok (agerrstatus = 0)
#define agclearin (agchar = YYEMPTY)
#define YYEMPTY -2
#define YYEOF 0
#define YYACCEPT goto agacceptlab
#define YYABORT goto agabortlab
#define YYERROR goto agerrlab1
#define YYFAIL goto agerrlab
#define YYRECOVERING() (!!agerrstatus)
#define YYBACKUP(Token, Value) \
do \
if (agchar == YYEMPTY && aglen == 1) \
{ \
agchar = (Token); \
aglval = (Value); \
agchar1 = YYTRANSLATE (agchar); \
YYPOPSTACK; \
goto agbackup; \
} \
else \
{ \
agerror ("syntax error: cannot back up"); \
YYERROR; \
} \
while (0)
#define YYTERROR 1
#define YYERRCODE 256
#ifndef YYLLOC_DEFAULT
# define YYLLOC_DEFAULT(Current, Rhs, N) \
Current.last_line = Rhs[N].last_line; \
Current.last_column = Rhs[N].last_column;
#endif
#if YYPURE
# if YYLSP_NEEDED
# ifdef YYLEX_PARAM
# define YYLEX aglex (&aglval, &aglloc, YYLEX_PARAM)
# else
# define YYLEX aglex (&aglval, &aglloc)
# endif
# else
# ifdef YYLEX_PARAM
# define YYLEX aglex (&aglval, YYLEX_PARAM)
# else
# define YYLEX aglex (&aglval)
# endif
# endif
#else
# define YYLEX aglex ()
#endif
#if YYDEBUG
# ifndef YYFPRINTF
# include <stdio.h>
# define YYFPRINTF fprintf
# endif
# define YYDPRINTF(Args) \
do { \
if (agdebug) \
YYFPRINTF Args; \
} while (0)
int agdebug;
#else
# define YYDPRINTF(Args)
#endif
#ifndef YYINITDEPTH
# define YYINITDEPTH 200
#endif
#if YYMAXDEPTH == 0
# undef YYMAXDEPTH
#endif
#ifndef YYMAXDEPTH
# define YYMAXDEPTH 10000
#endif
#ifdef YYERROR_VERBOSE
# ifndef agstrlen
# if defined (__GLIBC__) && defined (_STRING_H)
# define agstrlen strlen
# else
static YYSIZE_T
# if defined (__STDC__) || defined (__cplusplus)
agstrlen (const char *agstr)
# else
agstrlen (agstr)
const char *agstr;
# endif
{
register const char *ags = agstr;
while (*ags++ != '\0')
continue;
return ags - agstr - 1;
}
# endif
# endif
# ifndef agstpcpy
# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
# define agstpcpy stpcpy
# else
static char *
# if defined (__STDC__) || defined (__cplusplus)
agstpcpy (char *agdest, const char *agsrc)
# else
agstpcpy (agdest, agsrc)
char *agdest;
const char *agsrc;
# endif
{
register char *agd = agdest;
register const char *ags = agsrc;
while ((*agd++ = *ags++) != '\0')
continue;
return agd - 1;
}
# endif
# endif
#endif
#line 315 "/usr/share/bison/bison.simple"
#ifdef YYPARSE_PARAM
# if defined (__STDC__) || defined (__cplusplus)
# define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
# define YYPARSE_PARAM_DECL
# else
# define YYPARSE_PARAM_ARG YYPARSE_PARAM
# define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
# endif
#else
# define YYPARSE_PARAM_ARG
# define YYPARSE_PARAM_DECL
#endif
#ifdef __GNUC__
# ifdef YYPARSE_PARAM
int agparse (void *);
# else
int agparse (void);
# endif
#endif
#define YY_DECL_NON_LSP_VARIABLES \
\
int agchar; \
\
\
YYSTYPE aglval; \
\
\
int agnerrs;
#if YYLSP_NEEDED
# define YY_DECL_VARIABLES \
YY_DECL_NON_LSP_VARIABLES \
\
\
YYLTYPE aglloc;
#else
# define YY_DECL_VARIABLES \
YY_DECL_NON_LSP_VARIABLES
#endif
#if !YYPURE
YY_DECL_VARIABLES
#endif
int
agparse (YYPARSE_PARAM_ARG)
YYPARSE_PARAM_DECL
{
#if YYPURE
YY_DECL_VARIABLES
#endif
register int agstate;
register int agn;
int agresult;
int agerrstatus;
int agchar1 = 0;
short agssa[YYINITDEPTH];
short *agss = agssa;
register short *agssp;
YYSTYPE agvsa[YYINITDEPTH];
YYSTYPE *agvs = agvsa;
register YYSTYPE *agvsp;
#if YYLSP_NEEDED
YYLTYPE aglsa[YYINITDEPTH];
YYLTYPE *agls = aglsa;
YYLTYPE *aglsp;
#endif
#if YYLSP_NEEDED
# define YYPOPSTACK (agvsp--, agssp--, aglsp--)
#else
# define YYPOPSTACK (agvsp--, agssp--)
#endif
YYSIZE_T agstacksize = YYINITDEPTH;
YYSTYPE agval;
#if YYLSP_NEEDED
YYLTYPE agloc;
#endif
int aglen;
YYDPRINTF ((stderr, "Starting parse\n"));
agstate = 0;
agerrstatus = 0;
agnerrs = 0;
agchar = YYEMPTY;
agssp = agss;
agvsp = agvs;
#if YYLSP_NEEDED
aglsp = agls;
#endif
goto agsetstate;
agnewstate:
agssp++;
agsetstate:
*agssp = agstate;
if (agssp >= agss + agstacksize - 1)
{
YYSIZE_T agsize = agssp - agss + 1;
#ifdef agoverflow
{
YYSTYPE *agvs1 = agvs;
short *agss1 = agss;
# if YYLSP_NEEDED
YYLTYPE *agls1 = agls;
agoverflow ("parser stack overflow",
&agss1, agsize * sizeof (*agssp),
&agvs1, agsize * sizeof (*agvsp),
&agls1, agsize * sizeof (*aglsp),
&agstacksize);
agls = agls1;
# else
agoverflow ("parser stack overflow",
&agss1, agsize * sizeof (*agssp),
&agvs1, agsize * sizeof (*agvsp),
&agstacksize);
# endif
agss = agss1;
agvs = agvs1;
}
#else
# ifndef YYSTACK_RELOCATE
goto agoverflowlab;
# else
if (agstacksize >= YYMAXDEPTH)
goto agoverflowlab;
agstacksize *= 2;
if (agstacksize > YYMAXDEPTH)
agstacksize = YYMAXDEPTH;
{
short *agss1 = agss;
union agalloc *agptr =
(union agalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (agstacksize));
if (! agptr)
goto agoverflowlab;
YYSTACK_RELOCATE (agss);
YYSTACK_RELOCATE (agvs);
# if YYLSP_NEEDED
YYSTACK_RELOCATE (agls);
# endif
# undef YYSTACK_RELOCATE
if (agss1 != agssa)
YYSTACK_FREE (agss1);
}
# endif
#endif
agssp = agss + agsize - 1;
agvsp = agvs + agsize - 1;
#if YYLSP_NEEDED
aglsp = agls + agsize - 1;
#endif
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
(unsigned long int) agstacksize));
if (agssp >= agss + agstacksize - 1)
YYABORT;
}
YYDPRINTF ((stderr, "Entering state %d\n", agstate));
goto agbackup;
agbackup:
agn = agpact[agstate];
if (agn == YYFLAG)
goto agdefault;
if (agchar == YYEMPTY)
{
YYDPRINTF ((stderr, "Reading a token: "));
agchar = YYLEX;
}
if (agchar <= 0)
{
agchar1 = 0;
agchar = YYEOF;
YYDPRINTF ((stderr, "Now at end of input.\n"));
}
else
{
agchar1 = YYTRANSLATE (agchar);
#if YYDEBUG
if (agdebug)
{
YYFPRINTF (stderr, "Next token is %d (%s",
agchar, agtname[agchar1]);
# ifdef YYPRINT
YYPRINT (stderr, agchar, aglval);
# endif
YYFPRINTF (stderr, ")\n");
}
#endif
}
agn += agchar1;
if (agn < 0 || agn > YYLAST || agcheck[agn] != agchar1)
goto agdefault;
agn = agtable[agn];
if (agn < 0)
{
if (agn == YYFLAG)
goto agerrlab;
agn = -agn;
goto agreduce;
}
else if (agn == 0)
goto agerrlab;
if (agn == YYFINAL)
YYACCEPT;
YYDPRINTF ((stderr, "Shifting token %d (%s), ",
agchar, agtname[agchar1]));
if (agchar != YYEOF)
agchar = YYEMPTY;
*++agvsp = aglval;
#if YYLSP_NEEDED
*++aglsp = aglloc;
#endif
if (agerrstatus)
agerrstatus--;
agstate = agn;
goto agnewstate;
agdefault:
agn = agdefact[agstate];
if (agn == 0)
goto agerrlab;
goto agreduce;
agreduce:
aglen = agr2[agn];
agval = agvsp[1-aglen];
#if YYLSP_NEEDED
agloc = aglsp[1-aglen];
YYLLOC_DEFAULT (agloc, (aglsp - aglen), aglen);
#endif
#if YYDEBUG
if (agdebug)
{
int agi;
YYFPRINTF (stderr, "Reducing via rule %d (line %d), ",
agn, agrline[agn]);
for (agi = agprhs[agn]; agrhs[agi] > 0; agi++)
YYFPRINTF (stderr, "%s ", agtname[agrhs[agi]]);
YYFPRINTF (stderr, " -> %s\n", agtname[agr1[agn]]);
}
#endif
switch (agn) {
case 1:
#line 290 "/home/ellson/graphviz/graph/parser.y"
{begin_graph(agvsp[0].str); agstrfree(agvsp[0].str);}
break;
case 2:
#line 292 "/home/ellson/graphviz/graph/parser.y"
{AG.accepting_state = TRUE; end_graph();}
break;
case 3:
#line 294 "/home/ellson/graphviz/graph/parser.y"
{
if (AG.parsed_g)
agclose(AG.parsed_g);
AG.parsed_g = NULL;
}
break;
case 4:
#line 300 "/home/ellson/graphviz/graph/parser.y"
{AG.parsed_g = NULL;}
break;
case 5:
#line 303 "/home/ellson/graphviz/graph/parser.y"
{agval.str=agvsp[0].str;}
break;
case 6:
#line 303 "/home/ellson/graphviz/graph/parser.y"
{agval.str=0;}
break;
case 7:
#line 307 "/home/ellson/graphviz/graph/parser.y"
{Agraph_type = AGRAPH; AG.edge_op = "--";}
break;
case 8:
#line 309 "/home/ellson/graphviz/graph/parser.y"
{Agraph_type = AGRAPHSTRICT; AG.edge_op = "--";}
break;
case 9:
#line 311 "/home/ellson/graphviz/graph/parser.y"
{Agraph_type = AGDIGRAPH; AG.edge_op = "->";}
break;
case 10:
#line 313 "/home/ellson/graphviz/graph/parser.y"
{Agraph_type = AGDIGRAPHSTRICT; AG.edge_op = "->";}
break;
case 11:
#line 317 "/home/ellson/graphviz/graph/parser.y"
{Current_class = TAG_GRAPH;}
break;
case 12:
#line 319 "/home/ellson/graphviz/graph/parser.y"
{Current_class = TAG_NODE; N = G->proto->n;}
break;
case 13:
#line 321 "/home/ellson/graphviz/graph/parser.y"
{Current_class = TAG_EDGE; E = G->proto->e;}
break;
case 22:
#line 343 "/home/ellson/graphviz/graph/parser.y"
{attr_set(agvsp[-2].str,agvsp[0].str); agstrfree(agvsp[-2].str); agstrfree(agvsp[0].str);}
break;
case 24:
#line 348 "/home/ellson/graphviz/graph/parser.y"
{attr_set(agvsp[0].str,"true"); agstrfree(agvsp[0].str); }
break;
case 31:
#line 361 "/home/ellson/graphviz/graph/parser.y"
{agerror("syntax error, statement skipped");}
break;
case 35:
#line 367 "/home/ellson/graphviz/graph/parser.y"
{}
break;
case 36:
#line 371 "/home/ellson/graphviz/graph/parser.y"
{Current_class = TAG_GRAPH; }
break;
case 37:
#line 373 "/home/ellson/graphviz/graph/parser.y"
{Current_class = TAG_GRAPH;}
break;
case 38:
#line 377 "/home/ellson/graphviz/graph/parser.y"
{
objport_t rv;
rv.obj = agvsp[-1].n;
rv.port = strdup(Port);
Port[0] = '\0';
agval.obj = rv;
}
break;
case 39:
#line 386 "/home/ellson/graphviz/graph/parser.y"
{agval.n = bind_node(agvsp[0].str); agstrfree(agvsp[0].str);}
break;
case 45:
#line 396 "/home/ellson/graphviz/graph/parser.y"
{strcat(Port,":"); strcat(Port,agvsp[0].str);}
break;
case 46:
#line 397 "/home/ellson/graphviz/graph/parser.y"
{Symbol = strdup(agvsp[0].str);}
break;
case 47:
#line 398 "/home/ellson/graphviz/graph/parser.y"
{ char buf[SMALLBUF];
sprintf(buf,":(%s,%s)",Symbol,agvsp[-1].str);
strcat(Port,buf); free(Symbol);
}
break;
case 48:
#line 405 "/home/ellson/graphviz/graph/parser.y"
{ char buf[SMALLBUF];
sprintf(buf,"@%s",agvsp[0].str);
strcat(Port,buf);
}
break;
case 49:
#line 412 "/home/ellson/graphviz/graph/parser.y"
{Current_class = TAG_NODE; N = (Agnode_t*)(agvsp[0].obj.obj);}
break;
case 50:
#line 414 "/home/ellson/graphviz/graph/parser.y"
{Current_class = TAG_GRAPH; }
break;
case 51:
#line 418 "/home/ellson/graphviz/graph/parser.y"
{begin_edgestmt(agvsp[0].obj);}
break;
case 52:
#line 420 "/home/ellson/graphviz/graph/parser.y"
{ E = SP->subg->proto->e;
Current_class = TAG_EDGE; }
break;
case 53:
#line 423 "/home/ellson/graphviz/graph/parser.y"
{end_edgestmt();}
break;
case 54:
#line 425 "/home/ellson/graphviz/graph/parser.y"
{begin_edgestmt(agvsp[0].obj);}
break;
case 55:
#line 427 "/home/ellson/graphviz/graph/parser.y"
{ E = SP->subg->proto->e;
Current_class = TAG_EDGE; }
break;
case 56:
#line 430 "/home/ellson/graphviz/graph/parser.y"
{end_edgestmt();}
break;
case 57:
#line 433 "/home/ellson/graphviz/graph/parser.y"
{mid_edgestmt(agvsp[0].obj);}
break;
case 58:
#line 435 "/home/ellson/graphviz/graph/parser.y"
{mid_edgestmt(agvsp[0].obj);}
break;
case 60:
#line 438 "/home/ellson/graphviz/graph/parser.y"
{mid_edgestmt(agvsp[0].obj);}
break;
case 61:
#line 440 "/home/ellson/graphviz/graph/parser.y"
{mid_edgestmt(agvsp[0].obj);}
break;
case 63:
#line 445 "/home/ellson/graphviz/graph/parser.y"
{agval.obj = pop_gobj();}
break;
case 64:
#line 446 "/home/ellson/graphviz/graph/parser.y"
{ anonsubg(); }
break;
case 65:
#line 446 "/home/ellson/graphviz/graph/parser.y"
{agval.obj = pop_gobj();}
break;
case 66:
#line 447 "/home/ellson/graphviz/graph/parser.y"
{ anonsubg(); }
break;
case 67:
#line 447 "/home/ellson/graphviz/graph/parser.y"
{agval.obj = pop_gobj();}
break;
case 68:
#line 448 "/home/ellson/graphviz/graph/parser.y"
{agval.obj = pop_gobj();}
break;
case 69:
#line 452 "/home/ellson/graphviz/graph/parser.y"
{ Agraph_t *subg;
if ((subg = agfindsubg(AG.parsed_g,agvsp[0].str))) aginsert(G,subg);
else subg = agsubg(G,agvsp[0].str);
push_subg(subg);
In_decl = FALSE;
agstrfree(agvsp[0].str);
}
break;
case 70:
#line 461 "/home/ellson/graphviz/graph/parser.y"
{agval.str = agvsp[0].str; }
break;
case 71:
#line 462 "/home/ellson/graphviz/graph/parser.y"
{agval.str = agvsp[0].str; }
break;
case 72:
#line 465 "/home/ellson/graphviz/graph/parser.y"
{agval.str = agvsp[0].str; }
break;
case 73:
#line 466 "/home/ellson/graphviz/graph/parser.y"
{agval.str = concat(agvsp[-2].str,agvsp[0].str); agstrfree(agvsp[-2].str); agstrfree(agvsp[0].str);}
break;
}
#line 705 "/usr/share/bison/bison.simple"
agvsp -= aglen;
agssp -= aglen;
#if YYLSP_NEEDED
aglsp -= aglen;
#endif
#if YYDEBUG
if (agdebug)
{
short *agssp1 = agss - 1;
YYFPRINTF (stderr, "state stack now");
while (agssp1 != agssp)
YYFPRINTF (stderr, " %d", *++agssp1);
YYFPRINTF (stderr, "\n");
}
#endif
*++agvsp = agval;
#if YYLSP_NEEDED
*++aglsp = agloc;
#endif
agn = agr1[agn];
agstate = agpgoto[agn - YYNTBASE] + *agssp;
if (agstate >= 0 && agstate <= YYLAST && agcheck[agstate] == *agssp)
agstate = agtable[agstate];
else
agstate = agdefgoto[agn - YYNTBASE];
goto agnewstate;
agerrlab:
if (!agerrstatus)
{
++agnerrs;
#ifdef YYERROR_VERBOSE
agn = agpact[agstate];
if (agn > YYFLAG && agn < YYLAST)
{
YYSIZE_T agsize = 0;
char *agmsg;
int agx, agcount;
agcount = 0;
for (agx = agn < 0 ? -agn : 0;
agx < (int) (sizeof (agtname) / sizeof (char *)); agx++)
if (agcheck[agx + agn] == agx)
agsize += agstrlen (agtname[agx]) + 15, agcount++;
agsize += agstrlen ("parse error, unexpected ") + 1;
agsize += agstrlen (agtname[YYTRANSLATE (agchar)]);
agmsg = (char *) YYSTACK_ALLOC (agsize);
if (agmsg != 0)
{
char *agp = agstpcpy (agmsg, "parse error, unexpected ");
agp = agstpcpy (agp, agtname[YYTRANSLATE (agchar)]);
if (agcount < 5)
{
agcount = 0;
for (agx = agn < 0 ? -agn : 0;
agx < (int) (sizeof (agtname) / sizeof (char *));
agx++)
if (agcheck[agx + agn] == agx)
{
const char *agq = ! agcount ? ", expecting " : " or ";
agp = agstpcpy (agp, agq);
agp = agstpcpy (agp, agtname[agx]);
agcount++;
}
}
agerror (agmsg);
YYSTACK_FREE (agmsg);
}
else
agerror ("parse error; also virtual memory exhausted");
}
else
#endif
agerror ("parse error");
}
goto agerrlab1;
agerrlab1:
if (agerrstatus == 3)
{
if (agchar == YYEOF)
YYABORT;
YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
agchar, agtname[agchar1]));
agchar = YYEMPTY;
}
agerrstatus = 3;
goto agerrhandle;
agerrdefault:
#if 0
agn = agdefact[agstate];
if (agn)
goto agdefault;
#endif
agerrpop:
if (agssp == agss)
YYABORT;
agvsp--;
agstate = *--agssp;
#if YYLSP_NEEDED
aglsp--;
#endif
#if YYDEBUG
if (agdebug)
{
short *agssp1 = agss - 1;
YYFPRINTF (stderr, "Error: state stack now");
while (agssp1 != agssp)
YYFPRINTF (stderr, " %d", *++agssp1);
YYFPRINTF (stderr, "\n");
}
#endif
agerrhandle:
agn = agpact[agstate];
if (agn == YYFLAG)
goto agerrdefault;
agn += YYTERROR;
if (agn < 0 || agn > YYLAST || agcheck[agn] != YYTERROR)
goto agerrdefault;
agn = agtable[agn];
if (agn < 0)
{
if (agn == YYFLAG)
goto agerrpop;
agn = -agn;
goto agreduce;
}
else if (agn == 0)
goto agerrpop;
if (agn == YYFINAL)
YYACCEPT;
YYDPRINTF ((stderr, "Shifting error token, "));
*++agvsp = aglval;
#if YYLSP_NEEDED
*++aglsp = aglloc;
#endif
agstate = agn;
goto agnewstate;
agacceptlab:
agresult = 0;
goto agreturn;
agabortlab:
agresult = 1;
goto agreturn;
agoverflowlab:
agerror ("parser stack overflow");
agresult = 2;
agreturn:
#ifndef agoverflow
if (agss != agssa)
YYSTACK_FREE (agss);
#endif
return agresult;
}
#line 468 "/home/ellson/graphviz/graph/parser.y"