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