Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/graph/src/graphviz_graph_parser.cpp @ 12

Last change on this file since 12 was 12, checked in by landauf, 18 years ago

added boost

File size: 42.0 KB
Line 
1#define GRAPHVIZ_DIRECTED 0
2
3/*  A Bison parser, made from graphviz_parser.yy
4    by GNU Bison version 1.28  */
5
6#define YYBISON 1  /* Identify Bison output.  */
7
8#define yyparse bgl_undir_parse
9#define yylex bgl_undir_lex
10#define yyerror bgl_undir_error
11#define yylval bgl_undir_lval
12#define yychar bgl_undir_char
13#define yydebug bgl_undir_debug
14#define yynerrs bgl_undir_nerrs
15#define GRAPH_T 257
16#define NODE_T  258
17#define EDGE_T  259
18#define DIGRAPH_T       260
19#define EDGEOP_T        261
20#define SUBGRAPH_T      262
21#define ID_T    263
22
23
24//=======================================================================
25// Copyright 2001 University of Notre Dame.
26// Author: Lie-Quan Lee
27//
28// Distributed under the Boost Software License, Version 1.0. (See
29// accompanying file LICENSE_1_0.txt or copy at
30// http://www.boost.org/LICENSE_1_0.txt)
31//=======================================================================
32
33#include <iostream>
34#include <fstream>
35#include <string>
36#include <map>
37#include <vector>
38
39#include <boost/config.hpp>
40#include <boost/graph/graphviz.hpp>
41
42#if defined BOOST_NO_STRINGSTREAM
43  //#include <strstream> //We cannot use it since there is a bug in strstream 
44#include <stdlib.h>
45#else
46#include <sstream>
47#endif
48
49using std::free;
50using std::malloc;
51
52#ifndef GRAPHVIZ_DIRECTED
53#error Need to define the GRAPHVIZ_DIRECTED macro to either 0 or 1
54#endif
55
56#if GRAPHVIZ_DIRECTED == 0
57#define GRAPHVIZ_GRAPH boost::GraphvizGraph
58#define yyrestart bgl_undir_restart
59#else
60#define GRAPHVIZ_GRAPH boost::GraphvizDigraph
61#define yyrestart bgl_dir_restart
62#endif
63
64#define YYPARSE_PARAM g
65
66#include "yystype.h"
67
68  extern void yyerror(char* str);
69  extern void yyrestart(FILE* str);
70  extern int yylex(YYSTYPE* lvalp);
71
72  enum AttrState {GRAPH_GRAPH_A, GRAPH_NODE_A, GRAPH_EDGE_A, NODE_A, EDGE_A};
73
74  using boost::GraphvizAttrList;
75
76  namespace graphviz {
77
78    typedef boost::graph_traits<GRAPHVIZ_GRAPH>::vertex_descriptor Vertex;
79    typedef boost::graph_traits<GRAPHVIZ_GRAPH>::edge_descriptor   Edge;
80    typedef GRAPHVIZ_GRAPH Subgraph;
81
82    static Vertex current_vertex;
83    static Edge   current_edge;
84    static Subgraph* current_graph = NULL;
85    static Subgraph* previous_graph = NULL;
86
87    static std::vector< std::pair<void*, bool>* > vlist;//store a list of rhs
88
89    static std::map<std::string,std::string> attributes;//store attributes temporarily
90    static AttrState attribute_state;
91
92    static std::map<std::string, Subgraph*> subgraphs;  //store the names of subgraphs
93    static std::map<std::string, Vertex> nodes;         //store the names of nodes
94
95    typedef std::map<std::string, Subgraph*>::iterator It; 
96    typedef std::map<std::string, Vertex>::iterator Iter; 
97
98    static const std::string& get_graph_name(const Subgraph& g) {
99      const boost::graph_property<Subgraph, boost::graph_name_t>::type&
100        name = boost::get_property(g, boost::graph_name);
101      return name; 
102    }
103
104    static std::pair<Iter, bool> lookup(const std::string& name) {
105      //lookup in the top level
106      Iter it = nodes.find(name);
107      bool found = (it != nodes.end() );
108      return std::make_pair(it, found);
109    }
110   
111    static Vertex add_name(const std::string& name, GRAPHVIZ_GRAPH& g) {
112      Vertex v = boost::add_vertex(*current_graph);
113      v = current_graph->local_to_global(v);
114
115      //set the label of vertex, it could be overwritten later.
116      boost::property_map<GRAPHVIZ_GRAPH, boost::vertex_attribute_t>::type
117        va = boost::get(boost::vertex_attribute, g); 
118      va[v]["label"] = name; 
119     
120      //add v into the map so next time we will find it.
121      nodes[name] = v; 
122      return v;
123    }
124
125    static std::pair<It, bool> lookup_subgraph(const std::string& name) {
126      It it = subgraphs.find(name);
127      bool found = (it != subgraphs.end() );
128      return std::make_pair(it, found);
129    }
130   
131    static Subgraph* create_subgraph(const std::string& name) { 
132
133      Subgraph* new_subgraph = &(current_graph->create_subgraph()); 
134
135      subgraphs[name]        = new_subgraph;
136      return new_subgraph;
137    }
138
139   
140    static void set_attribute(GraphvizAttrList& p,
141                              const GraphvizAttrList& attr) {
142      GraphvizAttrList::const_iterator i, end;
143      for ( i=attr.begin(), end=attr.end(); i!=end; ++i)
144        p[i->first]=i->second;
145    }
146 
147    static void set_attribute(Subgraph& g,
148                              AttrState s, bool clear_attribute = true) {
149      typedef Subgraph Graph;
150      switch ( s ) {
151      case GRAPH_GRAPH_A: 
152        {
153          boost::graph_property<Graph, boost::graph_graph_attribute_t>::type&
154            gga = boost::get_property(g, boost::graph_graph_attribute);
155          set_attribute(gga, attributes); 
156        }
157        break;
158      case GRAPH_NODE_A: 
159        {
160          boost::graph_property<Graph, boost::graph_vertex_attribute_t>::type&
161            gna = boost::get_property(g, boost::graph_vertex_attribute);
162          set_attribute(gna, attributes); 
163        }
164        break;
165      case GRAPH_EDGE_A: 
166        {
167          boost::graph_property<Graph, boost::graph_edge_attribute_t>::type&
168            gea = boost::get_property(g, boost::graph_edge_attribute);
169          set_attribute(gea, attributes); 
170        }
171        break;
172      case NODE_A:
173        {
174          boost::property_map<Graph, boost::vertex_attribute_t>::type
175            va = boost::get(boost::vertex_attribute, g);    //va[v]
176          set_attribute(va[current_vertex], attributes);
177        }
178        break;
179      case EDGE_A: 
180        {
181          boost::property_map<Graph, boost::edge_attribute_t>::type
182            ea = boost::get(boost::edge_attribute, g);      //ea[e]
183          set_attribute(ea[current_edge], attributes); 
184        }
185        break;
186      }
187      if ( clear_attribute )
188        attributes.clear();
189    }
190
191
192    static void add_edges(const Vertex& u,
193                          const Vertex& v, GRAPHVIZ_GRAPH& g) {
194      graphviz::current_edge = boost::add_edge(u, v, g).first; 
195      graphviz::set_attribute(g, EDGE_A, false);
196    }
197   
198    static void add_edges(Subgraph* G1, Subgraph* G2,
199                          GRAPHVIZ_GRAPH& g) {
200      boost::graph_traits<Subgraph>::vertex_iterator i, j, m, n;
201      for ( boost::tie(i, j) = boost::vertices(*G1); i != j; ++i) {
202        for ( boost::tie(m, n) = boost::vertices(*G2); m != n; ++m) {
203          graphviz::add_edges(G1->local_to_global(*i),
204                              G2->local_to_global(*m), g);
205        }
206      }
207    }
208
209    static void add_edges(Subgraph* G, const Vertex& v, GRAPHVIZ_GRAPH& g) {
210      boost::graph_traits<Subgraph>::vertex_iterator i, j;
211      for ( boost::tie(i, j) = boost::vertices(*G); i != j; ++i) {
212        graphviz::add_edges(G->local_to_global(*i), v, g);
213      }
214    }
215
216    static void add_edges(const Vertex& u, Subgraph* G, GRAPHVIZ_GRAPH& g) {
217      boost::graph_traits<Subgraph>::vertex_iterator i, j;
218      for ( boost::tie(i, j) = boost::vertices(*G); i != j; ++i) {
219        graphviz::add_edges(u, G->local_to_global(*i), g);
220      }
221    }
222
223    static std::string random_string() {
224      static int i=0;
225#if defined BOOST_NO_STRINGSTREAM
226      //std::strstream out;
227      char buf[256];
228      sprintf(buf, "default%i\0", i);
229      ++i;
230      return std::string(buf);
231#else
232      std::stringstream out;
233      out << "default" << i;
234      ++i;
235      return out.str();
236#endif
237    }
238
239
240    static void set_graph_name(const std::string& name) {
241      boost::graph_property<Subgraph, boost::graph_name_t>::type&
242        gea = boost::get_property(*current_graph, boost::graph_name);
243      gea = name;
244    }
245
246  } //namespace detail {
247
248#include <stdio.h>
249
250#ifndef __cplusplus
251#ifndef __STDC__
252#define const
253#endif
254#endif
255
256
257
258#define YYFINAL         67
259#define YYFLAG          -32768
260#define YYNTBASE        18
261
262#define YYTRANSLATE(x) ((unsigned)(x) <= 263 ? yytranslate[x] : 46)
263
264static const char yytranslate[] = {     0,
265     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
266     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
267     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
268     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
269     2,     2,     2,    16,     2,     2,     2,     2,     2,     2,
270     2,     2,     2,     2,     2,     2,     2,    17,    12,     2,
271    15,     2,     2,     2,     2,     2,     2,     2,     2,     2,
272     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
273     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
274    13,     2,    14,     2,     2,     2,     2,     2,     2,     2,
275     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
276     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
277     2,     2,    10,     2,    11,     2,     2,     2,     2,     2,
278     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
279     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
280     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
281     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
282     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
283     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
284     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
285     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
286     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
287     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
288     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
289     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
290     2,     2,     2,     2,     2,     1,     3,     4,     5,     6,
291     7,     8,     9
292};
293
294#if YYDEBUG != 0
295static const short yyprhs[] = {     0,
296     0,     3,     7,    10,    12,    14,    16,    17,    20,    22,
297    24,    25,    28,    31,    36,    38,    40,    42,    44,    45,
298    47,    51,    55,    57,    59,    60,    62,    64,    66,    68,
299    70,    73,    77,    78,    80,    82,    86,    90,    93,    95,
300    98,   100,   102,   105,   106,   109,   112,   114
301};
302
303static const short yyrhs[] = {    20,
304    19,     0,    10,    23,    11,     0,    21,    22,     0,     3,
305     0,     6,     0,     9,     0,     0,    23,    25,     0,    25,
306     0,    12,     0,     0,    26,    24,     0,    32,    24,     0,
307    27,    13,    28,    14,     0,     3,     0,     4,     0,     5,
308     0,    29,     0,     0,    30,     0,    29,    31,    30,     0,
309     9,    15,     9,     0,    12,     0,    16,     0,     0,    34,
310     0,    38,     0,    33,     0,    42,     0,    30,     0,    36,
311    35,     0,    13,    28,    14,     0,     0,     9,     0,    37,
312     0,     9,    17,     9,     0,    41,    40,    35,     0,     7,
313    41,     0,    39,     0,    40,    39,     0,    36,     0,    42,
314     0,    44,    45,     0,     0,    43,    19,     0,     8,     9,
315     0,    19,     0,     0
316};
317
318#endif
319
320#if YYDEBUG != 0
321static const short yyrline[] = { 0,
322   239,   242,   245,   259,   259,   262,   262,   265,   265,   268,
323   268,   271,   271,   275,   282,   283,   284,   287,   287,   290,
324   290,   293,   303,   303,   303,   306,   306,   306,   306,   309,
325   317,   328,   328,   331,   346,   349,   368,   413,   417,   417,
326   420,   429,   440,   447,   457,   462,   483,   483
327};
328#endif
329
330
331#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
332
333static const char * const yytname[] = {   "$","error","$undefined.","GRAPH_T",
334"NODE_T","EDGE_T","DIGRAPH_T","EDGEOP_T","SUBGRAPH_T","ID_T","'{'","'}'","';'",
335"'['","']'","'='","','","':'","graph","graph_body","graph_header","graph_type",
336"graph_name","stmt_list","semicolon","stmt","attr_stmt","attr_header","attr_list",
337"nonempty_attr_list","attr","attr_separator","compound_stmt","graph_attr","node_stmt",
338"opt_attr","node_id","node_port","edge_stmt","edge_rhs_one","edge_rhs","edge_endpoint",
339"subgraph","@1","subgraph_header","opt_graph_body", NULL
340};
341#endif
342
343static const short yyr1[] = {     0,
344    18,    19,    20,    21,    21,    22,    22,    23,    23,    24,
345    24,    25,    25,    26,    27,    27,    27,    28,    28,    29,
346    29,    30,    31,    31,    31,    32,    32,    32,    32,    33,
347    34,    35,    35,    36,    36,    37,    38,    39,    40,    40,
348    41,    41,    42,    43,    42,    44,    45,    45
349};
350
351static const short yyr2[] = {     0,
352     2,     3,     2,     1,     1,     1,     0,     2,     1,     1,
353     0,     2,     2,     4,     1,     1,     1,     1,     0,     1,
354     3,     3,     1,     1,     0,     1,     1,     1,     1,     1,
355     2,     3,     0,     1,     1,     3,     3,     2,     1,     2,
356     1,     1,     2,     0,     2,     2,     1,     0
357};
358
359static const short yydefact[] = {     0,
360     4,     5,     0,     7,    44,     1,     6,     3,    15,    16,
361    17,     0,    34,    44,     9,    11,     0,    30,    11,    28,
362    26,    33,    35,    27,     0,    29,     0,    48,    46,     0,
363     0,     2,     8,    10,    12,    19,    13,    19,    31,    44,
364    39,    33,    45,    47,    43,    22,    36,     0,     0,    18,
365    20,     0,    34,    41,    38,    42,    37,    40,    14,    23,
366    24,     0,    32,    21,     0,     0,     0
367};
368
369static const short yydefgoto[] = {    65,
370     6,     3,     4,     8,    14,    35,    15,    16,    17,    49,
371    50,    18,    62,    19,    20,    21,    39,    22,    23,    24,
372    41,    42,    25,    26,    27,    28,    45
373};
374
375static const short yypact[] = {    19,
376-32768,-32768,    -9,     9,    12,-32768,-32768,-32768,-32768,-32768,
377-32768,    18,    13,     0,-32768,    17,    20,-32768,    17,-32768,
378-32768,    -1,-32768,-32768,    27,    28,    -9,    -9,-32768,    29,
379    30,-32768,-32768,-32768,-32768,    31,-32768,    31,-32768,    15,
380-32768,     6,-32768,-32768,-32768,-32768,-32768,    21,    23,    -2,
381-32768,    32,    24,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
382-32768,    31,-32768,-32768,    42,    43,-32768
383};
384
385static const short yypgoto[] = {-32768,
386     4,-32768,-32768,-32768,-32768,    25,    33,-32768,-32768,     7,
387-32768,   -36,-32768,-32768,-32768,-32768,     8,    11,-32768,-32768,
388    10,-32768,    14,    16,-32768,-32768,-32768
389};
390
391
392#define YYLAST          56
393
394
395static const short yytable[] = {    51,
396     5,    51,     9,    10,    11,   -41,   -25,    12,    13,    60,
397    32,    38,    40,    61,     9,    10,    11,     7,    38,    12,
398    13,     1,    12,    53,     2,    64,    29,    30,    34,    31,
399    43,    44,    36,    40,   -42,    30,    59,    46,    47,    48,
400    31,    66,    67,    37,    52,    63,    33,     0,     0,    57,
401    54,    58,     0,    55,     0,    56
402};
403
404static const short yycheck[] = {    36,
405    10,    38,     3,     4,     5,     7,     9,     8,     9,    12,
406    11,    13,     7,    16,     3,     4,     5,     9,    13,     8,
407     9,     3,     8,     9,     6,    62,     9,    15,    12,    17,
408    27,    28,    13,     7,     7,    15,    14,     9,     9,     9,
409    17,     0,     0,    19,    38,    14,    14,    -1,    -1,    42,
410    40,    42,    -1,    40,    -1,    40
411};
412#define YYPURE 1
413
414/* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
415
416/* This file comes from bison-1.28.  */
417
418/* Skeleton output parser for bison,
419   Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
420
421   This program is free software; you can redistribute it and/or modify
422   it under the terms of the GNU General Public License as published by
423   the Free Software Foundation; either version 2, or (at your option)
424   any later version.
425
426   This program is distributed in the hope that it will be useful,
427   but WITHOUT ANY WARRANTY; without even the implied warranty of
428   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
429   GNU General Public License for more details.
430
431   You should have received a copy of the GNU General Public License
432   along with this program; if not, write to the Free Software
433   Foundation, Inc., 59 Temple Place - Suite 330,
434   Boston, MA 02111-1307, USA.  */
435
436/* As a special exception, when this file is copied by Bison into a
437   Bison output file, you may use that output file without restriction.
438   This special exception was added by the Free Software Foundation
439   in version 1.24 of Bison.  */
440
441/* This is the parser code that is written into each bison parser
442  when the %semantic_parser declaration is not specified in the grammar.
443  It was written by Richard Stallman by simplifying the hairy parser
444  used when %semantic_parser is specified.  */
445
446#ifndef YYSTACK_USE_ALLOCA
447#ifdef alloca
448#define YYSTACK_USE_ALLOCA
449#else /* alloca not defined */
450#ifdef __GNUC__
451#define YYSTACK_USE_ALLOCA
452#define alloca __builtin_alloca
453#else /* not GNU C.  */
454#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
455#define YYSTACK_USE_ALLOCA
456#include <alloca.h>
457#else /* not sparc */
458/* We think this test detects Watcom and Microsoft C.  */
459/* This used to test MSDOS, but that is a bad idea
460   since that symbol is in the user namespace.  */
461#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
462#if 0 /* No need for malloc.h, which pollutes the namespace;
463         instead, just don't use alloca.  */
464#include <malloc.h>
465#endif
466#else /* not MSDOS, or __TURBOC__ */
467#if defined(_AIX)
468/* I don't know what this was needed for, but it pollutes the namespace.
469   So I turned it off.   rms, 2 May 1997.  */
470/* #include <malloc.h>  */
471 #pragma alloca
472#define YYSTACK_USE_ALLOCA
473#else /* not MSDOS, or __TURBOC__, or _AIX */
474#if 0
475#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
476                 and on HPUX 10.  Eventually we can turn this on.  */
477#define YYSTACK_USE_ALLOCA
478#define alloca __builtin_alloca
479#endif /* __hpux */
480#endif
481#endif /* not _AIX */
482#endif /* not MSDOS, or __TURBOC__ */
483#endif /* not sparc */
484#endif /* not GNU C */
485#endif /* alloca not defined */
486#endif /* YYSTACK_USE_ALLOCA not defined */
487
488#ifdef YYSTACK_USE_ALLOCA
489#define YYSTACK_ALLOC alloca
490#else
491#define YYSTACK_ALLOC malloc
492#endif
493
494/* Note: there must be only one dollar sign in this file.
495   It is replaced by the list of actions, each action
496   as one case of the switch.  */
497
498#define yyerrok         (yyerrstatus = 0)
499#define yyclearin       (yychar = YYEMPTY)
500#define YYEMPTY         -2
501#define YYEOF           0
502#define YYACCEPT        goto yyacceptlab
503#define YYABORT         goto yyabortlab
504#define YYERROR         goto yyerrlab1
505/* Like YYERROR except do call yyerror.
506   This remains here temporarily to ease the
507   transition to the new meaning of YYERROR, for GCC.
508   Once GCC version 2 has supplanted version 1, this can go.  */
509#define YYFAIL          goto yyerrlab
510#define YYRECOVERING()  (!!yyerrstatus)
511#define YYBACKUP(token, value) \
512do                                                              \
513  if (yychar == YYEMPTY && yylen == 1)                          \
514    { yychar = (token), yylval = (value);                       \
515      yychar1 = YYTRANSLATE (yychar);                           \
516      YYPOPSTACK;                                               \
517      goto yybackup;                                            \
518    }                                                           \
519  else                                                          \
520    { yyerror ("syntax error: cannot back up"); YYERROR; }      \
521while (0)
522
523#define YYTERROR        1
524#define YYERRCODE       256
525
526#ifndef YYPURE
527#define YYLEX           yylex()
528#endif
529
530#ifdef YYPURE
531#ifdef YYLSP_NEEDED
532#ifdef YYLEX_PARAM
533#define YYLEX           yylex(&yylval, &yylloc, YYLEX_PARAM)
534#else
535#define YYLEX           yylex(&yylval, &yylloc)
536#endif
537#else /* not YYLSP_NEEDED */
538#ifdef YYLEX_PARAM
539#define YYLEX           yylex(&yylval, YYLEX_PARAM)
540#else
541#define YYLEX           yylex(&yylval)
542#endif
543#endif /* not YYLSP_NEEDED */
544#endif
545
546/* If nonreentrant, generate the variables here */
547
548#ifndef YYPURE
549
550int     yychar;                 /*  the lookahead symbol                */
551YYSTYPE yylval;                 /*  the semantic value of the           */
552                                /*  lookahead symbol                    */
553
554#ifdef YYLSP_NEEDED
555YYLTYPE yylloc;                 /*  location data for the lookahead     */
556                                /*  symbol                              */
557#endif
558
559int yynerrs;                    /*  number of parse errors so far       */
560#endif  /* not YYPURE */
561
562#if YYDEBUG != 0
563int yydebug;                    /*  nonzero means print parse trace     */
564/* Since this is uninitialized, it does not stop multiple parsers
565   from coexisting.  */
566#endif
567
568/*  YYINITDEPTH indicates the initial size of the parser's stacks       */
569
570#ifndef YYINITDEPTH
571#define YYINITDEPTH 200
572#endif
573
574/*  YYMAXDEPTH is the maximum size the stacks can grow to
575    (effective only if the built-in stack extension method is used).  */
576
577#if YYMAXDEPTH == 0
578#undef YYMAXDEPTH
579#endif
580
581#ifndef YYMAXDEPTH
582#define YYMAXDEPTH 10000
583#endif
584
585/* Define __yy_memcpy.  Note that the size argument
586   should be passed with type unsigned int, because that is what the non-GCC
587   definitions require.  With GCC, __builtin_memcpy takes an arg
588   of type size_t, but it can handle unsigned int.  */
589
590#if __GNUC__ > 1                /* GNU C and GNU C++ define this.  */
591#define __yy_memcpy(TO,FROM,COUNT)      __builtin_memcpy(TO,FROM,COUNT)
592#else                           /* not GNU C or C++ */
593#ifndef __cplusplus
594
595/* This is the most reliable way to avoid incompatibilities
596   in available built-in functions on various systems.  */
597static void
598__yy_memcpy (to, from, count)
599     char *to;
600     char *from;
601     unsigned int count;
602{
603  register char *f = from;
604  register char *t = to;
605  register int i = count;
606
607  while (i-- > 0)
608    *t++ = *f++;
609}
610
611#else /* __cplusplus */
612
613/* This is the most reliable way to avoid incompatibilities
614   in available built-in functions on various systems.  */
615static void
616__yy_memcpy (char *to, char *from, unsigned int count)
617{
618  register char *t = to;
619  register char *f = from;
620  register int i = count;
621
622  while (i-- > 0)
623    *t++ = *f++;
624}
625
626#endif
627#endif
628
629
630
631/* The user can define YYPARSE_PARAM as the name of an argument to be passed
632   into yyparse.  The argument should have type void *.
633   It should actually point to an object.
634   Grammar actions can access the variable by casting it
635   to the proper pointer type.  */
636
637#ifdef YYPARSE_PARAM
638#ifdef __cplusplus
639#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
640#define YYPARSE_PARAM_DECL
641#else /* not __cplusplus */
642#define YYPARSE_PARAM_ARG YYPARSE_PARAM
643#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
644#endif /* not __cplusplus */
645#else /* not YYPARSE_PARAM */
646#define YYPARSE_PARAM_ARG
647#define YYPARSE_PARAM_DECL
648#endif /* not YYPARSE_PARAM */
649
650/* Prevent warning if -Wstrict-prototypes.  */
651#ifdef __GNUC__
652#ifdef YYPARSE_PARAM
653int yyparse (void *);
654#else
655int yyparse (void);
656#endif
657#endif
658
659int
660yyparse(YYPARSE_PARAM_ARG)
661     YYPARSE_PARAM_DECL
662{
663  register int yystate;
664  register int yyn;
665  register short *yyssp;
666  register YYSTYPE *yyvsp;
667  int yyerrstatus;      /*  number of tokens to shift before error messages enabled */
668  int yychar1 = 0;              /*  lookahead token as an internal (translated) token number */
669
670  short yyssa[YYINITDEPTH];     /*  the state stack                     */
671  YYSTYPE yyvsa[YYINITDEPTH];   /*  the semantic value stack            */
672
673  short *yyss = yyssa;          /*  refer to the stacks thru separate pointers */
674  YYSTYPE *yyvs = yyvsa;        /*  to allow yyoverflow to reallocate them elsewhere */
675
676#ifdef YYLSP_NEEDED
677  YYLTYPE yylsa[YYINITDEPTH];   /*  the location stack                  */
678  YYLTYPE *yyls = yylsa;
679  YYLTYPE *yylsp;
680
681#define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
682#else
683#define YYPOPSTACK   (yyvsp--, yyssp--)
684#endif
685
686  int yystacksize = YYINITDEPTH;
687  int yyfree_stacks = 0;
688
689#ifdef YYPURE
690  int yychar;
691  YYSTYPE yylval;
692  int yynerrs;
693#ifdef YYLSP_NEEDED
694  YYLTYPE yylloc;
695#endif
696#endif
697
698  YYSTYPE yyval;                /*  the variable used to return         */
699                                /*  semantic values from the action     */
700                                /*  routines                            */
701
702  int yylen;
703
704#if YYDEBUG != 0
705  if (yydebug)
706    fprintf(stderr, "Starting parse\n");
707#endif
708
709  yystate = 0;
710  yyerrstatus = 0;
711  yynerrs = 0;
712  yychar = YYEMPTY;             /* Cause a token to be read.  */
713
714  /* Initialize stack pointers.
715     Waste one element of value and location stack
716     so that they stay on the same level as the state stack.
717     The wasted elements are never initialized.  */
718
719  yyssp = yyss - 1;
720  yyvsp = yyvs;
721#ifdef YYLSP_NEEDED
722  yylsp = yyls;
723#endif
724
725/* Push a new state, which is found in  yystate  .  */
726/* In all cases, when you get here, the value and location stacks
727   have just been pushed. so pushing a state here evens the stacks.  */
728yynewstate:
729
730  *++yyssp = yystate;
731
732  if (yyssp >= yyss + yystacksize - 1)
733    {
734      /* Give user a chance to reallocate the stack */
735      /* Use copies of these so that the &'s don't force the real ones into memory. */
736      YYSTYPE *yyvs1 = yyvs;
737      short *yyss1 = yyss;
738#ifdef YYLSP_NEEDED
739      YYLTYPE *yyls1 = yyls;
740#endif
741
742      /* Get the current used size of the three stacks, in elements.  */
743      int size = yyssp - yyss + 1;
744
745#ifdef yyoverflow
746      /* Each stack pointer address is followed by the size of
747         the data in use in that stack, in bytes.  */
748#ifdef YYLSP_NEEDED
749      /* This used to be a conditional around just the two extra args,
750         but that might be undefined if yyoverflow is a macro.  */
751      yyoverflow("parser stack overflow",
752                 &yyss1, size * sizeof (*yyssp),
753                 &yyvs1, size * sizeof (*yyvsp),
754                 &yyls1, size * sizeof (*yylsp),
755                 &yystacksize);
756#else
757      yyoverflow("parser stack overflow",
758                 &yyss1, size * sizeof (*yyssp),
759                 &yyvs1, size * sizeof (*yyvsp),
760                 &yystacksize);
761#endif
762
763      yyss = yyss1; yyvs = yyvs1;
764#ifdef YYLSP_NEEDED
765      yyls = yyls1;
766#endif
767#else /* no yyoverflow */
768      /* Extend the stack our own way.  */
769      if (yystacksize >= YYMAXDEPTH)
770        {
771          yyerror("parser stack overflow");
772          if (yyfree_stacks)
773            {
774              free (yyss);
775              free (yyvs);
776#ifdef YYLSP_NEEDED
777              free (yyls);
778#endif
779            }
780          return 2;
781        }
782      yystacksize *= 2;
783      if (yystacksize > YYMAXDEPTH)
784        yystacksize = YYMAXDEPTH;
785#ifndef YYSTACK_USE_ALLOCA
786      yyfree_stacks = 1;
787#endif
788      yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
789      __yy_memcpy ((char *)yyss, (char *)yyss1,
790                   size * (unsigned int) sizeof (*yyssp));
791      yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
792      __yy_memcpy ((char *)yyvs, (char *)yyvs1,
793                   size * (unsigned int) sizeof (*yyvsp));
794#ifdef YYLSP_NEEDED
795      yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
796      __yy_memcpy ((char *)yyls, (char *)yyls1,
797                   size * (unsigned int) sizeof (*yylsp));
798#endif
799#endif /* no yyoverflow */
800
801      yyssp = yyss + size - 1;
802      yyvsp = yyvs + size - 1;
803#ifdef YYLSP_NEEDED
804      yylsp = yyls + size - 1;
805#endif
806
807#if YYDEBUG != 0
808      if (yydebug)
809        fprintf(stderr, "Stack size increased to %d\n", yystacksize);
810#endif
811
812      if (yyssp >= yyss + yystacksize - 1)
813        YYABORT;
814    }
815
816#if YYDEBUG != 0
817  if (yydebug)
818    fprintf(stderr, "Entering state %d\n", yystate);
819#endif
820
821  goto yybackup;
822 yybackup:
823
824/* Do appropriate processing given the current state.  */
825/* Read a lookahead token if we need one and don't already have one.  */
826/* yyresume: */
827
828  /* First try to decide what to do without reference to lookahead token.  */
829
830  yyn = yypact[yystate];
831  if (yyn == YYFLAG)
832    goto yydefault;
833
834  /* Not known => get a lookahead token if don't already have one.  */
835
836  /* yychar is either YYEMPTY or YYEOF
837     or a valid token in external form.  */
838
839  if (yychar == YYEMPTY)
840    {
841#if YYDEBUG != 0
842      if (yydebug)
843        fprintf(stderr, "Reading a token: ");
844#endif
845      yychar = YYLEX;
846    }
847
848  /* Convert token to internal form (in yychar1) for indexing tables with */
849
850  if (yychar <= 0)              /* This means end of input. */
851    {
852      yychar1 = 0;
853      yychar = YYEOF;           /* Don't call YYLEX any more */
854
855#if YYDEBUG != 0
856      if (yydebug)
857        fprintf(stderr, "Now at end of input.\n");
858#endif
859    }
860  else
861    {
862      yychar1 = YYTRANSLATE(yychar);
863
864#if YYDEBUG != 0
865      if (yydebug)
866        {
867          fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
868          /* Give the individual parser a way to print the precise meaning
869             of a token, for further debugging info.  */
870#ifdef YYPRINT
871          YYPRINT (stderr, yychar, yylval);
872#endif
873          fprintf (stderr, ")\n");
874        }
875#endif
876    }
877
878  yyn += yychar1;
879  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
880    goto yydefault;
881
882  yyn = yytable[yyn];
883
884  /* yyn is what to do for this token type in this state.
885     Negative => reduce, -yyn is rule number.
886     Positive => shift, yyn is new state.
887       New state is final state => don't bother to shift,
888       just return success.
889     0, or most negative number => error.  */
890
891  if (yyn < 0)
892    {
893      if (yyn == YYFLAG)
894        goto yyerrlab;
895      yyn = -yyn;
896      goto yyreduce;
897    }
898  else if (yyn == 0)
899    goto yyerrlab;
900
901  if (yyn == YYFINAL)
902    YYACCEPT;
903
904  /* Shift the lookahead token.  */
905
906#if YYDEBUG != 0
907  if (yydebug)
908    fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
909#endif
910
911  /* Discard the token being shifted unless it is eof.  */
912  if (yychar != YYEOF)
913    yychar = YYEMPTY;
914
915  *++yyvsp = yylval;
916#ifdef YYLSP_NEEDED
917  *++yylsp = yylloc;
918#endif
919
920  /* count tokens shifted since error; after three, turn off error status.  */
921  if (yyerrstatus) yyerrstatus--;
922
923  yystate = yyn;
924  goto yynewstate;
925
926/* Do the default action for the current state.  */
927yydefault:
928
929  yyn = yydefact[yystate];
930  if (yyn == 0)
931    goto yyerrlab;
932
933/* Do a reduction.  yyn is the number of a rule to reduce with.  */
934yyreduce:
935  yylen = yyr2[yyn];
936  if (yylen > 0)
937    yyval = yyvsp[1-yylen]; /* implement default value of the action */
938
939#if YYDEBUG != 0
940  if (yydebug)
941    {
942      int i;
943
944      fprintf (stderr, "Reducing via rule %d (line %d), ",
945               yyn, yyrline[yyn]);
946
947      /* Print the symbols being reduced, and their result.  */
948      for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
949        fprintf (stderr, "%s ", yytname[yyrhs[i]]);
950      fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
951    }
952#endif
953
954
955  switch (yyn) {
956
957case 2:
958{yyval.i=0;;
959    break;}
960case 3:
961{
962    graphviz::vlist.clear();
963    graphviz::attributes.clear();
964    graphviz::subgraphs.clear();
965    graphviz::nodes.clear();
966    std::string* name = static_cast<std::string*>(yyvsp[0].ptr);
967    graphviz::previous_graph = static_cast<graphviz::Subgraph*>(g);
968    graphviz::current_graph = static_cast<graphviz::Subgraph*>(g);
969    graphviz::set_graph_name(*name);
970    delete name;
971  ;
972    break;}
973case 6:
974{yyval.ptr = yyvsp[0].ptr; ;
975    break;}
976case 7:
977{yyval.ptr=(void*)(new std::string("G")); ;
978    break;}
979case 14:
980{ 
981    graphviz::set_attribute(*graphviz::current_graph,
982                          graphviz::attribute_state); 
983  ;
984    break;}
985case 15:
986{ graphviz::attribute_state = GRAPH_GRAPH_A; ;
987    break;}
988case 16:
989{ graphviz::attribute_state = GRAPH_NODE_A; ;
990    break;}
991case 17:
992{ graphviz::attribute_state = GRAPH_EDGE_A; ;
993    break;}
994case 19:
995{;
996    break;}
997case 22:
998{ 
999    std::string* name  = static_cast<std::string*>(yyvsp[-2].ptr);
1000    std::string* value = static_cast<std::string*>(yyvsp[0].ptr);
1001    graphviz::attributes[*name] = *value; 
1002    delete name;
1003    delete value;
1004  ;
1005    break;}
1006case 29:
1007{ yyval.i = 0; ;
1008    break;}
1009case 30:
1010{ 
1011    graphviz::set_attribute(
1012         *static_cast<graphviz::Subgraph*>(graphviz::current_graph),
1013                            GRAPH_GRAPH_A);
1014  ;
1015    break;}
1016case 31:
1017{ 
1018    graphviz::Vertex* temp   = static_cast<graphviz::Vertex*>(yyvsp[-1].ptr); 
1019    graphviz::current_vertex = *temp;
1020    graphviz::set_attribute(*static_cast<GRAPHVIZ_GRAPH*>(YYPARSE_PARAM),
1021                            NODE_A); 
1022    delete temp;
1023    yyval.i = 0;
1024  ;
1025    break;}
1026case 32:
1027{ yyval.i=0; ;
1028    break;}
1029case 33:
1030{ yyval.i=0; ;
1031    break;}
1032case 34:
1033{
1034    std::string* name  = static_cast<std::string*>(yyvsp[0].ptr);
1035    std::pair<graphviz::Iter, bool> result = graphviz::lookup(*name); 
1036    if (result.second) {
1037      graphviz::current_vertex = result.first->second; 
1038      if (! graphviz::current_graph->is_root())
1039        boost::add_vertex(graphviz::current_vertex, *graphviz::current_graph);
1040    } else
1041      graphviz::current_vertex = graphviz::add_name(*name, *static_cast<GRAPHVIZ_GRAPH*>(YYPARSE_PARAM)) ; 
1042    graphviz::Vertex* temp = new graphviz::Vertex(graphviz::current_vertex);
1043    yyval.ptr = (void *)temp;
1044    graphviz::attribute_state = NODE_A; 
1045    delete name;
1046  ;
1047    break;}
1048case 35:
1049{ yyval.ptr=yyvsp[0].ptr; ;
1050    break;}
1051case 36:
1052{
1053    //consider port as a special properties ?? --need work here
1054    std::string* name = static_cast<std::string*>(yyvsp[-2].ptr);
1055    std::string* port = static_cast<std::string*>(yyvsp[0].ptr);
1056
1057    std::pair<graphviz::Iter, bool> result = graphviz::lookup(*name); 
1058    if (result.second) 
1059      graphviz::current_vertex = result.first->second; 
1060    else
1061      graphviz::current_vertex = graphviz::add_name(*name, *static_cast<GRAPHVIZ_GRAPH*>(YYPARSE_PARAM)) ; 
1062    graphviz::Vertex* temp = new graphviz::Vertex(graphviz::current_vertex);
1063    yyval.ptr = (void *)temp;
1064    graphviz::attribute_state = NODE_A; 
1065    delete name;
1066    delete port;
1067  ;
1068    break;}
1069case 37:
1070{
1071
1072    typedef std::pair<void*, bool>* Ptr;
1073    Ptr source = static_cast<Ptr>(yyvsp[-2].ptr);
1074
1075    for (std::vector<Ptr>::iterator it=graphviz::vlist.begin();
1076         it !=graphviz::vlist.end(); ++it) { 
1077      if ( source->second ) {
1078        if ( (*it)->second )
1079          graphviz::add_edges(static_cast<graphviz::Subgraph*>(source->first),
1080                            static_cast<graphviz::Subgraph*>((*it)->first),
1081                            *static_cast<GRAPHVIZ_GRAPH*>(YYPARSE_PARAM));
1082        else
1083          graphviz::add_edges(static_cast<graphviz::Subgraph*>(source->first),
1084                            *static_cast<graphviz::Vertex*>((*it)->first),
1085                            *static_cast<GRAPHVIZ_GRAPH*>(YYPARSE_PARAM));
1086      } else {
1087        graphviz::Vertex* temp = static_cast<graphviz::Vertex*>(source->first);
1088        if ( (*it)->second )
1089          graphviz::add_edges(*temp,
1090                            static_cast<graphviz::Subgraph*>((*it)->first),
1091                            *static_cast<GRAPHVIZ_GRAPH*>(YYPARSE_PARAM));
1092        else
1093          graphviz::add_edges(*temp,
1094                            *static_cast<graphviz::Vertex*>((*it)->first),
1095                            *static_cast<GRAPHVIZ_GRAPH*>(YYPARSE_PARAM));
1096        delete temp;
1097      }
1098
1099      delete source; 
1100      source = *it; 
1101    } 
1102   
1103    if ( ! source->second ) {
1104      graphviz::Vertex* temp = static_cast<graphviz::Vertex*>(source->first);
1105      delete temp;
1106    }
1107    delete source;
1108
1109    graphviz::attributes.clear();
1110    graphviz::vlist.clear(); 
1111  ;
1112    break;}
1113case 38:
1114{ graphviz::vlist.push_back(static_cast<std::pair<void*, bool>*>(yyvsp[0].ptr)); ;
1115    break;}
1116case 41:
1117{ 
1118    std::pair<void*, bool>* temp = new std::pair<void*, bool>;
1119    temp->first = yyvsp[0].ptr;
1120    temp->second = false;
1121    yyval.ptr = (void*)temp;
1122
1123    graphviz::attribute_state = EDGE_A; 
1124  ;
1125    break;}
1126case 42:
1127{ 
1128    std::pair<void*, bool>* temp = new std::pair<void*, bool>;
1129    temp->first = yyvsp[0].ptr;
1130    temp->second = true;
1131    yyval.ptr = (void*)temp;
1132
1133    graphviz::attribute_state = EDGE_A; 
1134  ;
1135    break;}
1136case 43:
1137{
1138    if ( yyvsp[0].i )
1139      graphviz::current_graph = &graphviz::current_graph->parent();
1140    else
1141      graphviz::current_graph = graphviz::previous_graph;
1142  ;
1143    break;}
1144case 44:
1145{
1146    graphviz::previous_graph = graphviz::current_graph;
1147    std::string name = graphviz::random_string();
1148    graphviz::Subgraph* temp = graphviz::create_subgraph(name);
1149    graphviz::current_graph = temp;
1150    graphviz::set_graph_name(name);
1151
1152    yyval.ptr = (void *) graphviz::current_graph;
1153  ;
1154    break;}
1155case 45:
1156{
1157    graphviz::current_graph = &graphviz::current_graph->parent();
1158  ;
1159    break;}
1160case 46:
1161{
1162    //lookup ID_T if it is already in the subgraph,
1163    //if it is not, add a new subgraph
1164    std::string* name  = static_cast<std::string*>(yyvsp[0].ptr);
1165
1166    std::pair<graphviz::It, bool> temp = graphviz::lookup_subgraph(*name);
1167
1168    graphviz::previous_graph = graphviz::current_graph;
1169    if ( temp.second )  {//found
1170      graphviz::current_graph = (temp.first)->second;
1171    } else {
1172      graphviz::current_graph = graphviz::create_subgraph(*name);
1173      graphviz::set_graph_name(*name);
1174    }
1175
1176    yyval.ptr = (void *) graphviz::current_graph;
1177    delete name;
1178  ;
1179    break;}
1180case 47:
1181{yyval.i = 1; ;
1182    break;}
1183case 48:
1184{ yyval.i = 0; ;
1185    break;}
1186}
1187   /* the action file gets copied in in place of this dollarsign */
1188
1189
1190  yyvsp -= yylen;
1191  yyssp -= yylen;
1192#ifdef YYLSP_NEEDED
1193  yylsp -= yylen;
1194#endif
1195
1196#if YYDEBUG != 0
1197  if (yydebug)
1198    {
1199      short *ssp1 = yyss - 1;
1200      fprintf (stderr, "state stack now");
1201      while (ssp1 != yyssp)
1202        fprintf (stderr, " %d", *++ssp1);
1203      fprintf (stderr, "\n");
1204    }
1205#endif
1206
1207  *++yyvsp = yyval;
1208
1209#ifdef YYLSP_NEEDED
1210  yylsp++;
1211  if (yylen == 0)
1212    {
1213      yylsp->first_line = yylloc.first_line;
1214      yylsp->first_column = yylloc.first_column;
1215      yylsp->last_line = (yylsp-1)->last_line;
1216      yylsp->last_column = (yylsp-1)->last_column;
1217      yylsp->text = 0;
1218    }
1219  else
1220    {
1221      yylsp->last_line = (yylsp+yylen-1)->last_line;
1222      yylsp->last_column = (yylsp+yylen-1)->last_column;
1223    }
1224#endif
1225
1226  /* Now "shift" the result of the reduction.
1227     Determine what state that goes to,
1228     based on the state we popped back to
1229     and the rule number reduced by.  */
1230
1231  yyn = yyr1[yyn];
1232
1233  yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1234  if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1235    yystate = yytable[yystate];
1236  else
1237    yystate = yydefgoto[yyn - YYNTBASE];
1238
1239  goto yynewstate;
1240
1241yyerrlab:   /* here on detecting error */
1242
1243  if (! yyerrstatus)
1244    /* If not already recovering from an error, report this error.  */
1245    {
1246      ++yynerrs;
1247
1248#ifdef YYERROR_VERBOSE
1249      yyn = yypact[yystate];
1250
1251      if (yyn > YYFLAG && yyn < YYLAST)
1252        {
1253          int size = 0;
1254          char *msg;
1255          int x, count;
1256
1257          count = 0;
1258          /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
1259          for (x = (yyn < 0 ? -yyn : 0);
1260               x < (sizeof(yytname) / sizeof(char *)); x++)
1261            if (yycheck[x + yyn] == x)
1262              size += strlen(yytname[x]) + 15, count++;
1263          msg = (char *) malloc(size + 15);
1264          if (msg != 0)
1265            {
1266              strcpy(msg, "parse error");
1267
1268              if (count < 5)
1269                {
1270                  count = 0;
1271                  for (x = (yyn < 0 ? -yyn : 0);
1272                       x < (sizeof(yytname) / sizeof(char *)); x++)
1273                    if (yycheck[x + yyn] == x)
1274                      {
1275                        strcat(msg, count == 0 ? ", expecting `" : " or `");
1276                        strcat(msg, yytname[x]);
1277                        strcat(msg, "'");
1278                        count++;
1279                      }
1280                }
1281              yyerror(msg);
1282              free(msg);
1283            }
1284          else
1285            yyerror ("parse error; also virtual memory exceeded");
1286        }
1287      else
1288#endif /* YYERROR_VERBOSE */
1289        yyerror("parse error");
1290    }
1291
1292  goto yyerrlab1;
1293yyerrlab1:   /* here on error raised explicitly by an action */
1294
1295  if (yyerrstatus == 3)
1296    {
1297      /* if just tried and failed to reuse lookahead token after an error, discard it.  */
1298
1299      /* return failure if at end of input */
1300      if (yychar == YYEOF)
1301        YYABORT;
1302
1303#if YYDEBUG != 0
1304      if (yydebug)
1305        fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1306#endif
1307
1308      yychar = YYEMPTY;
1309    }
1310
1311  /* Else will try to reuse lookahead token
1312     after shifting the error token.  */
1313
1314  yyerrstatus = 3;              /* Each real token shifted decrements this */
1315
1316  goto yyerrhandle;
1317
1318yyerrdefault:  /* current state does not do anything special for the error token. */
1319
1320#if 0
1321  /* This is wrong; only states that explicitly want error tokens
1322     should shift them.  */
1323  yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
1324  if (yyn) goto yydefault;
1325#endif
1326
1327yyerrpop:   /* pop the current state because it cannot handle the error token */
1328
1329  if (yyssp == yyss) YYABORT;
1330  yyvsp--;
1331  yystate = *--yyssp;
1332#ifdef YYLSP_NEEDED
1333  yylsp--;
1334#endif
1335
1336#if YYDEBUG != 0
1337  if (yydebug)
1338    {
1339      short *ssp1 = yyss - 1;
1340      fprintf (stderr, "Error: state stack now");
1341      while (ssp1 != yyssp)
1342        fprintf (stderr, " %d", *++ssp1);
1343      fprintf (stderr, "\n");
1344    }
1345#endif
1346
1347yyerrhandle:
1348
1349  yyn = yypact[yystate];
1350  if (yyn == YYFLAG)
1351    goto yyerrdefault;
1352
1353  yyn += YYTERROR;
1354  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1355    goto yyerrdefault;
1356
1357  yyn = yytable[yyn];
1358  if (yyn < 0)
1359    {
1360      if (yyn == YYFLAG)
1361        goto yyerrpop;
1362      yyn = -yyn;
1363      goto yyreduce;
1364    }
1365  else if (yyn == 0)
1366    goto yyerrpop;
1367
1368  if (yyn == YYFINAL)
1369    YYACCEPT;
1370
1371#if YYDEBUG != 0
1372  if (yydebug)
1373    fprintf(stderr, "Shifting error token, ");
1374#endif
1375
1376  *++yyvsp = yylval;
1377#ifdef YYLSP_NEEDED
1378  *++yylsp = yylloc;
1379#endif
1380
1381  yystate = yyn;
1382  goto yynewstate;
1383
1384 yyacceptlab:
1385  /* YYACCEPT comes here.  */
1386  if (yyfree_stacks)
1387    {
1388      free (yyss);
1389      free (yyvs);
1390#ifdef YYLSP_NEEDED
1391      free (yyls);
1392#endif
1393    }
1394  return 0;
1395
1396 yyabortlab:
1397  /* YYABORT comes here.  */
1398  if (yyfree_stacks)
1399    {
1400      free (yyss);
1401      free (yyvs);
1402#ifdef YYLSP_NEEDED
1403      free (yyls);
1404#endif
1405    }
1406  return 1;
1407}
1408
1409
1410namespace boost {
1411 
1412  void read_graphviz(const std::string& filename, GRAPHVIZ_GRAPH& g) {
1413    FILE* file = fopen(filename.c_str(), "r");
1414    yyrestart(file);
1415    void* in = static_cast<void*>(file);
1416    yyparse(static_cast<void*>(&g));
1417  }
1418
1419  void read_graphviz(FILE* file, GRAPHVIZ_GRAPH& g) {
1420    void* in = static_cast<void*>(file);
1421    yyrestart(file);
1422    yyparse(static_cast<void*>(&g));
1423  }
1424   
1425}
1426
Note: See TracBrowser for help on using the repository browser.