Skip to content
Browse files

First Git commit

Crappy, crappy, damn crappy code.
To be branched: graph design versus graph generation.
  • Loading branch information...
0 parents commit 73d1d7ba1028b3f9fcae4d370ad2c619347c231d @CiccioIdoine CiccioIdoine committed May 22, 2011
Showing with 4,937 additions and 0 deletions.
  1. +104 −0 AdjMatrix.cpp
  2. +30 −0 AdjMatrix.h
  3. +17 −0 CallStack.cpp
  4. +22 −0 CallStack.h
  5. +53 −0 Edge.cpp
  6. +40 −0 Edge.h
  7. +110 −0 Edgeset.cpp
  8. +36 −0 Edgeset.h
  9. +19 −0 Environment.cpp
  10. +39 −0 Environment.h
  11. +390 −0 Frame.cpp
  12. +45 −0 Frame.h
  13. +17 −0 Function.cpp
  14. +23 −0 Function.h
  15. +239 −0 Graph.cpp
  16. +51 −0 Graph.h
  17. +119 −0 Linkable.cpp
  18. +67 −0 Linkable.h
  19. +47 −0 NameSpace.cpp
  20. +42 −0 NameSpace.h
  21. +101 −0 Node.cpp
  22. +113 −0 Node.h
  23. +149 −0 Nodeset.cpp
  24. +56 −0 Nodeset.h
  25. +19 −0 SymbolTable.cpp
  26. +39 −0 SymbolTable.h
  27. +49 −0 dapsl.ll
  28. +2,045 −0 dapsl.tab.cc
  29. +63 −0 dapsl.tab.hh
  30. +162 −0 dapsl.yy
  31. +49 −0 globals.h
  32. +54 −0 main.cc
  33. +24 −0 main.h
  34. +435 −0 nodes.cc
  35. +69 −0 nodes.h
104 AdjMatrix.cpp
@@ -0,0 +1,104 @@
+/*
+ * AdjMatrix.cpp
+ *
+ * Created on: 17/apr/2010
+ * Author: ciccio
+ */
+
+#include "AdjMatrix.h"
+#include <stdio.h>
+#include <vector>
+#include "globals.h"
+
+using namespace std;
+
+AdjMatrix::AdjMatrix() {
+ // TODO Auto-generated constructor stub
+
+
+}
+
+AdjMatrix::~AdjMatrix() {
+
+ for(int i=0;i<_n;i++)
+ delete (*_mat)[i];
+
+ delete *_mat;
+ delete _mat;
+}
+
+AdjMatrix::AdjMatrix(int n, int m) {
+ _n=n;
+ _m=m;
+ _mat= new int **;
+ (*_mat)= new int *[n];
+
+ for(int i=0;i<n;i++) {
+ (*_mat)[i]=new int [m];
+ for(int j=0;j<m;j++)
+ (*_mat)[i][j]=0;
+ }
+}
+
+void AdjMatrix::toDot(Nodeset &Ns) {
+ FILE *fid;
+ Nodeset::iterator i;
+ Nodeset::iterator j;
+ int ii=0, ij=0;
+ fid=fopen((string(protname) + ".dot").c_str(), "w");
+ string attr_string="";
+ std::map<std::string, std::string>::iterator mapit;
+ std::map<std::string, std::string> attribs;
+
+ fprintf(fid, "digraph G {\n");
+ fprintf(fid, "node [shape=box, style=rounded];\n");
+ fprintf(fid, "rankdir=LR;\n");
+
+
+
+ for(i=Ns.begin(); i!=Ns.end(); ++i){
+ attr_string = "[ label = ";
+ attr_string += i->getName();
+
+ attribs = i->GetAttributes();
+ for(mapit = attribs.begin(); mapit!=attribs.end(); mapit++){
+ attr_string += ", ";
+ attr_string += (mapit -> first).c_str();
+ attr_string += " = ";
+ attr_string += (mapit -> second).c_str();
+ }
+ attr_string += "] ";
+
+ fprintf(fid, "%d %s;\n", i->getId(), attr_string.c_str());
+ //fprintf(fid, "%d [ label = \"%s\", color = \"%s\" ];\n", i->getId(), i->getName().c_str(), i->GetAttribute("color").c_str());
+
+
+ }
+
+
+ for (ii=0;ii<_n;++ii){ // process ARCs
+ for (ij=0; ij<_m; ++ij) {
+ if((*_mat)[ii][ij])
+ fprintf(fid, "%d->%d;\n", ii, ij);
+ }
+ }
+ fprintf(fid, "}");
+ fclose(fid);
+
+
+}
+
+void AdjMatrix::Set(unsigned i, unsigned j)
+{
+ (*_mat)[i][j]=1;
+}
+
+ostream& AdjMatrix::operator>>(std::ostream &){
+ int j,i;
+
+ for(i=0; i<_n; i++){
+ for(j=0; j<_m-1; j++)
+ cout << (*_mat)[i][j] << ",";
+ cout <<(*_mat)[i][j] << endl;
+ }
+}
30 AdjMatrix.h
@@ -0,0 +1,30 @@
+/*
+ * AdjMatrix.h
+ *
+ * Created on: 17/apr/2010
+ * Author: ciccio
+ */
+
+#ifndef ADJMATRIX_H_
+#define ADJMATRIX_H_
+
+#include <string>
+#include "Nodeset.h"
+
+class AdjMatrix {
+public:
+ AdjMatrix();
+ virtual ~AdjMatrix();
+ AdjMatrix(int n, int m);
+ int *&operator[](unsigned i) {return *_mat[i];}
+ void toDot(Nodeset &ns);
+ void Set(unsigned, unsigned);
+ ostream& operator>>(std::ostream &);
+
+private:
+ int ***_mat;
+ int _n;
+ int _m;
+};
+
+#endif /* ADJMATRIX_H_ */
17 CallStack.cpp
@@ -0,0 +1,17 @@
+/*
+ * CallStack.cpp
+ *
+ * Created on: 23/mag/2010
+ * Author: ciccio
+ */
+
+#include "CallStack.h"
+
+CallStack::CallStack() {
+ // TODO Auto-generated constructor stub
+
+}
+
+CallStack::~CallStack() {
+ // TODO Auto-generated destructor stub
+}
22 CallStack.h
@@ -0,0 +1,22 @@
+/*
+ * CallStack.h
+ *
+ * Created on: 23/mag/2010
+ * Author: ciccio
+ */
+
+#ifndef CALLSTACK_H_
+#define CALLSTACK_H_
+
+#include "Frame.h"
+#include <stack>
+#include "Linkable.h"
+
+class CallStack : public std::stack<Frame>{
+public:
+ CallStack();
+ virtual ~CallStack();
+ Linkable &Run(void) {Linkable &g = top().Run(); pop(); return g;}
+};
+
+#endif /* CALLSTACK_H_ */
53 Edge.cpp
@@ -0,0 +1,53 @@
+/*
+ * Edge.cpp
+ *
+ * Created on: 08/apr/2010
+ * Author: ciccio
+ */
+
+#include "Edge.h"
+#include "Graph.h"
+
+Edge::Edge() {
+ // TODO Auto-generated constructor stub
+
+}
+
+/*Edge::Edge(Node & n1, Node & n2)
+{
+ _srcnodeid=n1.getId();
+ _dstnodeid=n2.getId();
+ n2._issource = false;
+ n1._issink = false;
+}*/
+
+Edge::Edge(unsigned id1, unsigned id2)
+{
+ _srcnodeid=id1;
+ _dstnodeid=id2;
+ //n2._issource = false;
+ //n1._issink = false;
+}
+
+
+Edge::~Edge() {
+ // TODO Auto-generated destructor stub
+}
+ostream & Edge::operator>>(std::ostream &str){
+ str << "E[";
+
+ str << _srcnodeid;
+ str << ", ";
+ str << _dstnodeid;
+ str << "]";
+ return str;
+}
+
+
+ /*Node & Edge::getSrcNode(void)
+{return _mygraph->findNode(_srcnodeid);}
+*/
+
+/*Node & Edge::getDstNode(void)
+{return _mygraph->findNode(_dstnodeid);}
+*/
40 Edge.h
@@ -0,0 +1,40 @@
+/*
+ * Edge.h
+ *
+ * Created on: 08/apr/2010
+ * Author: ciccio
+ */
+
+#ifndef EDGE_H_
+#define EDGE_H_
+
+#include "Node.h"
+
+
+class Edge {
+ friend class Edgeset;
+
+public:
+ Edge();
+ //Edge(Node &, Node &);
+ Edge(unsigned, unsigned);
+ virtual ~Edge();
+ std::ostream & operator>>(std::ostream &);
+ //Node & getSrcNode(void);
+ //Node & getDstNode(void);
+
+ unsigned int getSrcNodeId(void){return _srcnodeid;}
+ unsigned int getDstNodeId(void){return _dstnodeid;}
+ void setSrcNodeId(unsigned id){_srcnodeid=id;}
+ void setDstNodeId(unsigned id){_dstnodeid=id;}
+
+private:
+ unsigned int _srcnodeid;
+ unsigned int _dstnodeid;
+ bool _directed;
+
+};
+
+
+
+#endif /* EDGE_H_ */
110 Edgeset.cpp
@@ -0,0 +1,110 @@
+/*
+ * Edgeset.cpp
+ *
+ * Created on: 08/apr/2010
+ * Author: ciccio
+ */
+
+#include "Edgeset.h"
+#include "Nodeset.h"
+#include <fstream> //debug
+
+Edgeset::Edgeset() {
+ // TODO Auto-generated constructor stub
+
+}
+
+Edgeset::Edgeset(Nodeset & ns1, Nodeset & ns2)
+{
+ Nodeset::iterator i;
+ Nodeset::iterator j;
+
+
+ for(i=ns1.begin();
+ i!=ns1.end(); i++)
+ for(j=ns2.begin();
+ j!=ns2.end(); j++)
+ AddEdge(i->getId(), j->getId());
+}
+
+Edgeset::~Edgeset() {
+ // TODO Auto-generated destructor stub
+}
+
+/*Edge &Edgeset::AddEdge(Node & n1, Node & n2)
+{
+ Edge *e = new Edge(n1, n2);
+ push_back(*e);
+ return *e;
+}*/
+
+Edge &Edgeset::AddEdge(unsigned int id1, unsigned int id2)
+{
+ Edge *e = new Edge(id1, id2);
+ if(!has(id1, id2) )
+ push_back(*e);
+ return *e;
+}
+
+void Edgeset::AddEdges(Edgeset & es)
+{
+ Edgeset::iterator i;
+ for(i=es.begin(); i!=es.end(); i++)
+ AddEdge(i->getSrcNodeId(), i->getDstNodeId());
+}
+
+/*Nodeset & Edgeset::GetOutNodes(Node & node)
+{
+Nodeset *innodes = new Nodeset;
+
+ Edgeset::iterator i;
+ for(i=begin(); i !=end(); i++)
+ if(i->getSrcNode().getId() == node.getId())
+ innodes->AddNode(i->getDstNode());
+
+ return *innodes;
+}*/
+
+/*Nodeset & Edgeset::GetInNodes(Node & node)
+{
+Nodeset *innodes = new Nodeset;
+
+ Edgeset::iterator i;
+ for(i=begin(); i !=end(); i++)
+ if(i->getDstNode().getName() == node.getName())
+ innodes->AddNode(i->getSrcNode());
+
+ return *innodes;
+}*/
+
+
+ostream & Edgeset::operator>>(std::ostream &str){
+ Edgeset::iterator i;
+ str << " ES {" << endl;
+ if(empty()) {
+ str << " <empty>" << endl << " }"<<endl;
+ return str;
+ }
+ for(i=begin(); i!=end()-1; i++) {
+ cout << " ";
+ *i >> str << endl;
+ }
+ cout << " ";
+ *i >> str << endl << " }" << endl;
+ return str;
+
+}
+
+
+
+bool Edgeset::has(unsigned iid, unsigned jid){
+ Edgeset::iterator i;
+ for(i=begin(); i!=end(); i++)
+ if( (i->getSrcNodeId() == iid) &&
+ (i->getDstNodeId() == jid))
+ return true;
+ return false;
+}
+
+
+
36 Edgeset.h
@@ -0,0 +1,36 @@
+/*
+ * Edgeset.h
+ *
+ * Created on: 08/apr/2010
+ * Author: ciccio
+ */
+
+#ifndef EDGESET_H_
+#define EDGESET_H_
+
+#include <vector>
+#include "Edge.h"
+//#include <iostream>
+
+class Nodeset;
+class Edge;
+class Edgeset : public vector<Edge>{
+ friend class Graph;
+public:
+ Edgeset();
+ Edgeset(Nodeset &, Nodeset &);
+ virtual ~Edgeset();
+ void AddEdge(Edge &);
+// Edge & AddEdge(Node &, Node &);
+ Edge & AddEdge(unsigned int id1, unsigned int id2);
+ void AddEdges(Edgeset &);
+ //Nodeset &GetInNodes(Node &);
+ //Nodeset &GetOutNodes(Node &);
+ std::ostream & operator>>(std::ostream &str);
+ bool has(unsigned iid, unsigned jid);
+
+private:
+
+};
+
+#endif /* EDGESET_H_ */
19 Environment.cpp
@@ -0,0 +1,19 @@
+/*
+ * SymbolTable.cpp
+ *
+ * Created on: 06/mag/2010
+ * Author: ciccio
+ */
+
+#include "Environment.h"
+#include "NameSpace.h"
+
+Environment::Environment() {
+ NameSpace *global = new NameSpace;
+ this->addNameSpace("global", *global);
+
+}
+
+Environment::~Environment() {
+ // TODO Auto-generated destructor stub
+}
39 Environment.h
@@ -0,0 +1,39 @@
+/*
+ * SymbolTable.h
+ *
+ * Created on: 06/mag/2010
+ * Author: ciccio
+ */
+
+#ifndef SYMBOLTABLE_H_
+#define SYMBOLTABLE_H_
+
+#include "NameSpace.h"
+#include "Linkable.h"
+#include <vector>
+#include <string>
+
+class Environment {
+public:
+ Environment();
+ virtual ~Environment();
+ void addNameSpace(std::string name, NameSpace &n)
+ {_namespaces[name]=&n;}
+ void addSymbol(std::string space, std::string symbol, Linkable *l)
+ {_namespaces.find(space)->second->AddSymbol(symbol, l);}
+
+ Linkable *getSymbol(std::string symbol)
+ {return _namespaces.find("global")->second->GetObject(symbol);}
+ Linkable *getSymbol(std::string space, std::string symbol)
+ {Linkable *l =_namespaces.find(space)->second->GetObject(symbol);
+ if(l)
+ return l;
+ else return _namespaces.find("global")->second->GetObject(symbol);}
+
+
+private:
+ std::map<std::string, NameSpace *> _namespaces;
+
+};
+
+#endif /* SYMBOLTABLE_H_ */
390 Frame.cpp
@@ -0,0 +1,390 @@
+/*
+ * Frame.cpp
+ *
+ * Created on: 22/mag/2010
+ * Author: ciccio
+ */
+
+#include "globals.h"
+#include "Frame.h"
+#include "Linkable.h"
+#include <stdio.h>
+#include <stdlib.h> //itoa
+#include <string>
+#include <sstream>
+#include "Graph.h"
+#include "Nodeset.h"
+#include "Environment.h"
+#include <typeinfo>
+
+using namespace std;
+
+bool FRAME_DEBUG = 0;
+
+Frame::Frame() {
+ g=new Graph();
+ // TODO Auto-generated constructor stub
+
+}
+
+Frame::~Frame() {
+ // TODO Auto-generated destructor stub
+}
+
+
+
+Linkable* Frame::doAction(ACTION_TYPE type, Linkable * p1, Linkable * p2, Linkable * p3, Linkable * p4)
+{
+ Node *n;
+ stringstream ss;
+ Nodeset *ns;
+ static string name="global";
+ Linkable *l;
+ static Graph *gtemp = new Graph;
+ static Nodeset *realins ;
+ static Nodeset *realouts;
+ Graph *arrowgraph;
+ static string connector = "";
+ static vector<string> inconnectors;
+ static vector<string> outconnectors;
+ bool isold = false;
+ static vector< pair <string, string> > attribs;
+ static bool suspend_actions = false;
+ static unsigned int groupid=0;
+
+
+ if(suspend_actions) {
+ if((int)p1 == 0 && type == ACT_FUNCTDEF) {
+ suspend_actions = false;
+ if(FRAME_DEBUG) cout << "Re-enabling actions" << endl;
+ }
+ else return 0;
+ }
+
+ switch(type)
+ {
+ case ACT_ATTRIBUTE:
+ pair<string, string> *attr;
+ attr = new pair<string, string>((const char *)p1, (const char *)p2);
+ attribs.push_back(*attr);
+ return (Linkable *) attr;
+
+ case ACT_FUNCTDEF:
+ if((int)p1 == 1) {
+ suspend_actions = true;
+ if(FRAME_DEBUG) cout << "Suspending actions" << endl;
+ }
+ return p1;
+
+
+ case ACT_CHAINASFORKSON:
+ if(FRAME_DEBUG) cout << "Performing action CHAINASFORKSON" << endl;
+ p1->SetInputs(p1->GetSources());
+ if(FRAME_DEBUG) *p1>>cout << endl;
+ return p1;
+
+ case ACT_REFERENCE:
+ if(FRAME_DEBUG) cout << "Performing action REFERENCE" << endl;
+ l = symboltable.getSymbol(name, (const char *)p1);
+ // *namesp >> cout;
+ if(l) {
+ if(FRAME_DEBUG) *l>>cout << endl;
+ return l;
+ }
+ else cerr << "Reference not found: " <<(const char *)p1;
+ exit(1);
+
+ case ACT_GRAPHNAME:
+ name = (const char *)p1;
+ symboltable.addNameSpace(name, *new NameSpace);
+ if((int) p2)
+ attribs.push_back(pair<string, string>(((pair<string, string>*)p2)->first, ((pair<string, string>*)p2)->second));
+
+ return p1;
+
+ case ACT_GROUP:
+ { //necessary
+ Nodeset &nodes = p1->GetNodes();
+ Nodeset::iterator ni;
+
+ for(ni = nodes.begin(); ni!=nodes.end(); ni++) {
+ std::stringstream out;
+ out << groupid;
+ gtemp->SetAttribute(ni->getId(), "group", out.str());
+ }
+
+ groupid++;
+ return p1;
+
+ }
+
+
+ case ACT_PARENTHESIS:
+ /*quadopenpar+=(int)p2;
+ roundopenpar+=(int)p1;*/
+
+ return p3;
+
+
+ case ACT_CONNECTOR:
+ if(FRAME_DEBUG) cout << "Performing action CONNECTOR" << endl;
+ if(FRAME_DEBUG) cout << (const char *)p1 << endl;
+ return (Linkable *) p1;
+
+ case ACT_NODE:
+ if(FRAME_DEBUG) cout << "Performing action NODE" << endl;
+ ss << (char *)p1;
+
+
+ l = symboltable.getSymbol(name, (const char *)p1);
+ if(l) {
+ isold=true;
+ if(FRAME_DEBUG) {cout << "Found existing symbol:" << endl;
+ *l >> cout << endl;}
+ Linkable &l2=l->Clone();
+ l2.UpdateIds();
+ symboltable.addSymbol(name, ss.str(), &l2);
+ gtemp->AddNodes(l2.GetNodes());
+ gtemp->AddEdges(l2.GetEdges());
+ if(FRAME_DEBUG) cout << "Result:" << endl;
+ if(FRAME_DEBUG) l2 >> cout << endl;
+ l=&l2;
+ }
+
+ else {
+ l = new Node(ss.str());
+ }
+
+ if(attribs.size()!=0) {
+ vector< pair <string, string> >::iterator i;
+ for(i=attribs.begin(); i!=attribs.end(); ++i)
+ l->SetAttribute((*i).first, (*i).second);
+ attribs.clear();
+ }
+
+ if((int) p4 == 1){
+ if(!realins)
+ realins = new Nodeset;
+ realins->AddNode(*(Node *)l);
+ inconnectors.push_back((const char *) p2);
+ }
+ if((int) p4 == 2){
+ if(!realouts)
+ realouts = new Nodeset;
+ realouts->AddNode(*(Node *)l);
+ outconnectors.push_back((const char *) p2);
+ }
+ if(!isold){
+ symboltable.addSymbol(name, ss.str(), (Node *)l);
+ gtemp->AddNode(*(Node *)l);
+ }
+
+
+ if(FRAME_DEBUG) {cout << "Result:" << endl;
+ *(Node *)l >> cout << endl;}
+
+ return l;
+
+ case ACT_COMMA:
+ if(FRAME_DEBUG) {
+ cout << "Performing action COMMA" << endl;
+ cout << "p1" << endl;
+ *p1 >> cout << endl;
+ cout << "p2" << endl;
+ *p2 >> cout << endl;
+ }
+
+ ns = &leaf::merge(*p1, *p2);
+
+ if(FRAME_DEBUG) {cout << "Result:"<<endl;
+ *ns >> cout;}
+ return ns;
+
+
+ case ACT_ARROW:
+ if(FRAME_DEBUG) {
+ cout << "Performing action ARROW" << endl;
+ cout << "p1" << endl;
+ *p1 >> cout << endl;
+ cout << "p2" << endl;
+ *p2 >> cout << endl;
+ }
+
+ arrowgraph=new Graph;
+
+ arrowgraph->AddNodes(p1->GetNodes());
+ arrowgraph->AddNodes(p2->GetNodes());
+ arrowgraph->AddEdges(p1->GetEdges());
+ arrowgraph->AddEdges(p2->GetEdges());
+
+ arrowgraph->AddEdges(leaf::link(*p1, *p2));
+
+ if(!p4) {
+ arrowgraph->SetOutputs(p2->GetOutputs());
+ arrowgraph->SetInputs(p1->GetInputs());
+ }
+
+ else {
+ arrowgraph->SetInputs(p2->GetOutputs());
+ arrowgraph->SetOutputs(p1->GetInputs());
+ }
+ gtemp->AddNodes(arrowgraph->GetNodes());
+ gtemp->AddEdges(arrowgraph->GetEdges());
+
+ if ((int) p3 == 2){ // hashing
+ Nodeset &temp = p2->GetOutputs();
+ Nodeset::iterator it;
+
+ for(it = temp.begin(); it!=temp.end(); it++){
+ gtemp->SetAttribute(it->getId(), "hash", "true");
+ p2->SetAttribute(it->getId(), "hash", "true");
+ }
+ }
+
+
+ if(FRAME_DEBUG)
+ { cout << "result" << endl;
+ *arrowgraph >> cout;}
+
+ return arrowgraph;
+
+
+ case ACT_MERGE:
+ if(FRAME_DEBUG) {
+ cout << "Performing action MERGE" << endl;
+ cout << "p1" << endl;
+ *p1 >> cout << endl;
+ cout << "p2" << endl;
+ *p2 >> cout << endl;
+ cout << "p3" << endl;
+ *p3 >> cout << endl;
+ }
+
+ gtemp->AddNodes(p1->GetNodes());
+ gtemp->AddNodes(p3->GetNodes());
+ gtemp->AddNodes(p3->GetNodes());
+ gtemp->AddEdges(p1->GetEdges());
+ gtemp->AddEdges(p2->GetEdges());
+ gtemp->AddEdges(p3->GetEdges());
+ gtemp->AddEdges(leaf::link(*p1, *p2));
+ gtemp->AddEdges(leaf::link(*p3, *p2));
+ gtemp->SetOutputs(p2->GetOutputs());
+ gtemp->SetInputs(p2->GetInputs());
+
+ if ((int) p4 == ACT_FLAG_HASH){
+ Nodeset &temp = p2->GetInputs();
+ Nodeset::iterator it;
+
+ for(it = temp.begin(); it!=temp.end(); it++){
+ gtemp->SetAttribute(it->getId(), "hash", "true");
+ p2->SetAttribute(it->getId(), "hash", "true");
+ }
+ }
+
+
+ if(FRAME_DEBUG) cout << "result" << endl;
+ if(FRAME_DEBUG) *gtemp >> cout;
+
+ return p2;
+
+
+ case ACT_FORK:
+ if(FRAME_DEBUG) {
+ cout << "Performing action FORK" << endl;
+ cout << "p1" << endl;
+ *p1 >> cout << endl;
+ cout << "p2" << endl;
+ *p2 >> cout << endl;
+ cout << "p3" << endl;
+ *p3 >> cout << endl;
+ }
+
+ gtemp->AddNodes(p1->GetNodes());
+ gtemp->AddNodes(p2->GetNodes());
+ gtemp->AddNodes(p3->GetNodes());
+ gtemp->AddEdges(p1->GetEdges());
+ gtemp->AddEdges(p2->GetEdges());
+ gtemp->AddEdges(p3->GetEdges());
+ gtemp->AddEdges(leaf::link(*p2, *p1));
+ gtemp->AddEdges(leaf::link(*p2, *p3));
+ gtemp->SetOutputs(p2->GetOutputs());
+ gtemp->SetInputs(p2->GetInputs());
+
+ if ((int) p4 == ACT_FLAG_HASH){
+
+ Nodeset &temp = p2->GetOutputs();
+ Nodeset::iterator it;
+
+ for(it = temp.begin(); it!=temp.end(); it++){
+ gtemp->SetAttribute(it->getId(), "hash", "true");
+ p2->SetAttribute(it->getId(), "hash", "true");
+ }
+ }
+
+
+
+
+ if(FRAME_DEBUG) {cout << "result" << endl;
+ *gtemp >> cout;}
+ return p2;
+
+
+ case ACT_DIAGRAM:
+ if(FRAME_DEBUG) cout << "Performing action DIAGRAM" << endl;
+
+ if(!name.empty()){
+ gtemp->setName(name);
+ symboltable.addSymbol("global", name, gtemp);
+ name="global";
+ }
+
+ if(realins) {
+ Nodeset::iterator i;
+ for(i=realins->begin(); i!=realins->end();i++)
+ i->setInConnector(inconnectors[i-realins->begin()]);
+ gtemp->SetInputs(*realins);
+ if(FRAME_DEBUG) {cout << "*****************" << endl;
+ *realins >> cout;}
+ delete realins;
+ inconnectors.clear();
+ realins=0;
+ }
+ else gtemp->SetInputs(gtemp->GetSources());
+
+ if(realouts) {
+ Nodeset::iterator i;
+ for(i=realouts->begin(); i!=realouts->end();i++)
+ i->setOutConnector(outconnectors[i-realouts->begin()]);
+ gtemp->SetOutputs(*realouts);
+ delete realouts;
+ outconnectors.clear();
+ realouts=0;
+ }
+ else gtemp->SetOutputs(gtemp->GetSinks());
+
+ if(attribs.size()!=0){
+ gtemp->SetAttribute(attribs[0].first, attribs[0].second);
+ attribs[0].first="";
+ }
+
+ if(FRAME_DEBUG) *gtemp >> cout;
+
+ g->AddNodes(gtemp->GetNodes());
+ g->AddEdges(gtemp->GetEdges());
+
+ gtemp = new Graph;
+ return gtemp;
+
+ }
+
+return 0;
+}
+
+Linkable &Frame::Run(void)
+{
+ yyin = _fid;
+ int res = yyparse();
+ if(res)
+ throw(1);
+ return *g;
+}
45 Frame.h
@@ -0,0 +1,45 @@
+/*
+ * Frame.h
+ *
+ * Created on: 22/mag/2010
+ * Author: ciccio
+ */
+
+#ifndef FRAME_H_
+#define FRAME_H_
+
+#include "Environment.h"
+#include "Linkable.h"
+#include "globals.h"
+#include <stdio.h>
+
+extern FILE *yyin;
+class Linkable;
+
+class Frame {
+public:
+ Frame();
+ virtual ~Frame();
+ Environment const& getEnv() const
+ {
+ return _env;
+ }
+
+ void setEnv(Environment _env)
+ {
+ this->_env = _env;
+ }
+
+ Linkable* doAction(ACTION_TYPE type, Linkable *, Linkable *, Linkable *, Linkable *);
+
+ Linkable &Run(void);
+
+ void setStream(FILE *fid) {_fid = fid;}
+
+private:
+ Environment _env;
+ FILE *_fid;
+ Graph *g;
+};
+
+#endif /* FRAME_H_ */
17 Function.cpp
@@ -0,0 +1,17 @@
+/*
+ * Function.cpp
+ *
+ * Created on: 23/mag/2010
+ * Author: ciccio
+ */
+
+#include "Function.h"
+
+Function::Function() {
+ // TODO Auto-generated constructor stub
+
+}
+
+Function::~Function() {
+ // TODO Auto-generated destructor stub
+}
23 Function.h
@@ -0,0 +1,23 @@
+/*
+ * Function.h
+ *
+ * Created on: 23/mag/2010
+ * Author: ciccio
+ */
+
+#ifndef FUNCTION_H_
+#define FUNCTION_H_
+#include <string>
+
+class Function {
+public:
+ Function();
+ virtual ~Function();
+
+private:
+ long _srcoffset;
+ std::string _name;
+ unsigned char _numpar;
+};
+
+#endif /* FUNCTION_H_ */
239 Graph.cpp
@@ -0,0 +1,239 @@
+/*
+ * Graph.cpp
+ *
+ * Created on: 08/apr/2010
+ * Author: ciccio
+ */
+
+#include "Graph.h"
+#include "AdjMatrix.h"
+
+
+Graph::Graph() {
+ // TODO Auto-generated constructor stub
+
+}
+
+Graph::~Graph() {
+ // TODO Auto-generated destructor stub
+}
+
+Graph::Graph(Nodeset &n, Edgeset&e){
+_E.AddEdges(e);
+_V.AddNodes(n);
+}
+
+void Graph::MergeWith(Graph & graph)
+{
+}
+
+
+void Graph::FindNode(string string)
+{
+}
+
+
+
+void Graph::Destroy(void)
+{
+}
+
+
+void Graph::Visit(void)
+{
+Node i;
+Nodeset::iterator j;
+Nodeset stack;
+
+Nodeset *ns;
+
+unsigned maxid=0;
+Nodeset::iterator ni;
+for(ni=_V.begin();ni!=_V.end();ni++)
+ if(ni->getId() > maxid)
+ maxid=ni->getId();
+
+AdjMatrix &adjmat = *new AdjMatrix(maxid+1, maxid+1);
+
+stack.AddNodes(GetSources());
+//cout <<endl << "Visiting " << getName() << endl;
+unsigned ij=0;
+
+while(!stack.empty()){
+ i=stack.back();
+ //i >> cout << endl;
+ stack.pop_back();
+
+ _V.findNode(i.getId()).Visit();
+ ns=&GetOutNodes(i);
+ //i >> cout;
+ //cout << " ha figli:" << endl;
+ //*ns >> cout;
+
+ for(j=ns->begin(); j!=ns->end(); j++, ij++) {
+ if(!j->isVisited()) {
+ stack.AddNode(*j);
+ }
+ adjmat.Set(i.getId(), j->getId());
+ //cout << "Added (" << i.getId() << ", " << j->getId() << ")"<<endl;
+ }
+
+}
+//adjmat >> cout;
+adjmat.toDot(GetNodes());
+//cout << "dot made... all done!" << endl;
+
+}
+
+ostream& Graph::operator>>(std::ostream &str){
+ str << "Graph(" << _name << ")" << endl << "{" << endl;
+ _V >> (str);
+ _E >> (str);
+ str << "}"<< endl;
+ return str;
+}
+
+
+void Graph::SetInputs(Nodeset &in)
+{
+ Nodeset::iterator i;
+
+ for (i=_V.begin(); i!=_V.end(); ++i)
+ if(in.has(i->getId())){
+ i->setIsinput(true);
+ i->setInConnector(in.findNode(i->getId()).getInConnector());
+ }
+ else i->setIsinput(false);
+}
+
+
+void Graph::SetOutputs(Nodeset &o)
+{
+ Nodeset::iterator i;
+
+ for (i=_V.begin(); i!=_V.end(); ++i)
+ if(o.has(i->getId())) {
+ i->setIsoutput(true);
+ i->setOutConnector(o.findNode(i->getId()).getOutConnector());
+ }
+ else i->setIsoutput(false);
+}
+
+
+Nodeset& Graph::GetInputs(void)
+{
+ Nodeset *ns = new Nodeset;
+ Nodeset::iterator i;
+
+ for (i=_V.begin(); i!=_V.end(); ++i){
+ if(i->getIsinput())
+ ns->AddNode(*i);
+ }
+
+ return *ns;
+}
+
+Nodeset& Graph::GetOutputs(void)
+{
+ Nodeset *ns = new Nodeset;
+ Nodeset::iterator i;
+
+ for (i=_V.begin(); i!=_V.end(); ++i){
+ if(i->getIsoutput())
+ ns->AddNode(*i);
+ }
+
+ return *ns;
+}
+
+Nodeset& Graph::GetSinks(void)
+{
+ Nodeset &ns = (*new Nodeset());
+ Nodeset::iterator i;
+
+ for (i=_V.begin(); i!=_V.end(); ++i){
+ if(i->isSink())
+ ns.push_back(*i);
+ }
+ return ns;
+}
+
+
+
+
+Nodeset &Graph::GetOutNodes(Node &n){
+ Nodeset &ns = *new Nodeset;
+ Edgeset::iterator i;
+
+ for(i=_E.begin(); i!=_E.end(); i++)
+ if(i->getSrcNodeId()==n.getId())
+ ns.push_back(_V.findNode(i->getDstNodeId()));
+ return ns;
+}
+
+
+
+Nodeset& Graph::GetSources(void)
+{
+ Nodeset &ns = (*new Nodeset());
+ Nodeset::iterator i;
+
+ for (i=_V.begin(); i!=_V.end(); ++i){
+ if(i->isSource())
+ ns.push_back(*i);
+ }
+ return ns;
+}
+
+Graph::operator Nodeset(){
+
+cerr << "unimplemented";
+}
+
+void Graph::AddNode(Node &n){
+ _V.AddNode(n);
+}
+
+
+void Graph::AddEdges(Edgeset &e)
+{
+ Node *n1, *n2;
+ Edgeset::iterator i;
+ Edge *ne;
+
+ for(i = e.begin(); i<e.end(); i++) {
+ n1 = &_V.findNode(i->getSrcNodeId());
+ n2 = &_V.findNode(i->getDstNodeId());
+ ne=&_E.AddEdge(n1->getId(), n2->getId());
+ n1->_issink=false;
+ n2->_issource=false;
+ }
+}
+
+
+void Graph::UpdateIds()
+{
+Nodeset::iterator i;
+Edgeset::iterator e;
+unsigned id;
+
+for(i=_V.begin(); i!=_V.end(); i++){
+ id = Node::newId();
+
+ for(e=_E.begin(); e!=_E.end(); e++){
+ if(e->getSrcNodeId() == i->getId())
+ e->setSrcNodeId(id);
+ if(e->getDstNodeId() == i->getId())
+ e->setDstNodeId(id);
+ }
+i->setId(id);
+}
+}
+
+void Graph::SetAttribute(std::string s1, std::string s2)
+{
+ Linkable::SetAttribute(s1,s2);
+ Nodeset::iterator i;
+ for(i=_V.begin(); i!=_V.end(); i++)
+ i->SetAttribute(s1, s2);
+}
51 Graph.h
@@ -0,0 +1,51 @@
+/*
+ * Graph.h
+ *
+ * Created on: 08/apr/2010
+ * Author: ciccio
+ */
+
+#ifndef GRAPH_H_
+#define GRAPH_H_
+
+#include "Nodeset.h"
+#include "Edgeset.h"
+
+class Graph : public Linkable {
+
+public:
+ Graph();
+ Graph(Nodeset &, Edgeset&);
+ virtual ~Graph();
+ void MergeWith(Graph &);
+ void FindNode(string);
+ void Destroy(void);
+ Nodeset& GetOutputs(void);
+ Nodeset& GetInputs(void);
+ void Visit(void);
+ ostream& operator>>(std::ostream &);
+ Edgeset& GetEdges(void) {return _E;}
+ void AddEdges(Edgeset &e);
+ void AddNodes(Nodeset &e) {_V.AddNodes(e);}
+ Nodeset& GetNodes(void) {return _V;}
+ void SetInputs(Nodeset &);
+ void SetOutputs(Nodeset &);
+ Nodeset& GetSources(void);
+ Nodeset& GetSinks(void);
+ virtual operator Nodeset();
+ void AddNode(Node &);
+ Node &findNode(unsigned id){return _V.findNode(id);}
+ Nodeset &GetOutNodes(Node &);
+ virtual Linkable &Clone(){Graph &g=*new Graph; g = *this; return g;}
+ void UpdateIds();
+ void SetAttribute(std::string s1, std::string s2);
+ void SetAttribute(unsigned n, std::string s1, std::string s2){_V.SetAttribute(n,s1,s2);}
+
+private:
+ Edgeset _E;
+ Nodeset _V;
+};
+
+
+
+#endif /* GRAPH_H_ */
119 Linkable.cpp
@@ -0,0 +1,119 @@
+/*è
+ * Linkable.cpp
+ *
+ * Created on: 10/apr/2010
+ * Author: ciccio
+ */
+
+#include "Linkable.h"
+#include "Edgeset.h"
+#include "Nodeset.h"
+#include <map>
+//#include <assert>
+
+vector <Linkable *> Linkable::_linkables;
+
+Linkable::Linkable() {
+ // TODO Auto-generated constructor stub
+}
+
+
+Linkable::~Linkable() {
+ // TODO Auto-generated destructor stub
+}
+
+
+void Linkable::setName(std::string _name)
+{
+ this->_name = _name;
+ _linkables.push_back(this);
+}
+
+
+Linkable *Linkable::_has(std::string s) {
+ std::vector<Linkable *>::iterator i=_linkables.begin();
+
+ for(;i!=_linkables.end(); i++)
+ if((*i)->getName()==s)
+ return *i;
+
+ return 0;
+}
+
+
+namespace leaf {
+Edgeset & link(Linkable & l1, Linkable & l2)
+{
+ Nodeset &l1o = l1.GetNodes();
+ Nodeset &l2i = l2.GetNodes();
+ map<std::string, Nodeset > dbi;
+ map<std::string, Nodeset > dbo;
+ Nodeset::iterator i;
+ map<std::string, Nodeset >::iterator dbiter;
+ map<std::string, Nodeset >::iterator found;
+ Edgeset *E = new Edgeset;
+ bool foundin = false;
+ bool foundout = false;
+ std::string s;
+
+ //cout << "Linking" << endl;
+
+
+ for(i=l1o.begin(); i!=l1o.end(); i++){
+ s = i->getOutConnector();
+ if(i->getOutConnector()!="") {
+ //cout << "Found out-connector:" << s << endl;
+ foundout = true;
+ dbo[i->getOutConnector()].AddNode(*i);
+ }
+ }
+
+ for(i=l2i.begin(); i!=l2i.end(); i++){
+ s = i->getInConnector();
+ if(i->getInConnector()!=""){
+ //cout << "Found in-connector:" << s << endl;
+ foundin = true;
+ dbi[i->getInConnector()].AddNode(*i);
+ }
+ }
+
+
+ if(foundin || foundout){
+ for(dbiter = dbo.begin(); dbiter != dbo.end(); dbiter++){
+ found = dbi.find(dbiter->first);
+ if(found!=dbi.end())
+ E->AddEdges(*new Edgeset(dbiter->second, found->second));
+ }
+ }
+
+
+ else E->AddEdges(*new Edgeset(l1.GetOutputs(), l2.GetInputs()));
+
+ return *E;
+}
+
+
+
+Edgeset& ulink(Linkable & l1, Linkable & l2)
+{
+Edgeset& e1 = (*new Edgeset(l1.GetOutputs(), l2.GetInputs()));
+Edgeset& e2 = (*new Edgeset(l2.GetOutputs(), l1.GetInputs()));
+
+e1.AddEdges(e2);
+e2.~Edgeset();
+
+return e1;
+}
+
+Nodeset& merge(Linkable& l1, Linkable& l2)
+{
+Nodeset& n1 = (*new Nodeset(l1.GetNodes()));
+
+n1.AddNodes(l2.GetNodes());
+return n1;
+}
+
+}
+
+
+
67 Linkable.h
@@ -0,0 +1,67 @@
+/*
+ * Linkable.h
+ *
+ * Created on: 10/apr/2010
+ * Author: ciccio
+ */
+
+#ifndef LINKABLE_H_
+#define LINKABLE_H_
+
+#include <iostream> //for debug
+#include <fstream>
+#include <string>
+#include <vector>
+#include <map>
+
+enum LINK_TYPE {
+ LINK_DIRECTED,
+ LINK_UNDIRECTED
+};
+
+class Node;
+class Nodeset;
+class Edgeset;
+
+
+class Linkable {
+ friend class Byname;
+
+public:
+ Linkable ();
+ virtual ~Linkable ();
+ virtual Nodeset& GetOutputs (void)=0;
+ virtual Nodeset& GetInputs (void)=0;
+ virtual Nodeset& GetNodes (void)=0;
+ virtual void SetInputs (Nodeset &)=0;
+ virtual void SetOutputs (Nodeset &)=0;
+ virtual Nodeset& GetSources (void)=0;
+ virtual Nodeset& GetSinks (void)=0;
+ virtual std::ostream & operator>> (std::ostream &)=0;
+ virtual Edgeset & GetEdges (void)=0;
+ virtual Linkable & Clone ()=0;
+ virtual void UpdateIds ()=0;
+ virtual void SetAttribute (std::string s1, std::string s2) {_attributes[s1]=s2;}
+ virtual void SetAttribute (unsigned, std::string s1, std::string s2)=0;
+ std::string getName () const {return _name;}
+ void setName (std::string _name);
+ std::string GetAttribute (std::string s) {return _attributes[s];}
+ std::map<std::string, std::string> GetAttributes() {return _attributes;}
+
+protected:
+ std::string _name;
+ std::map<std::string, std::string> _attributes;
+
+private:
+ static std::vector<Linkable *> _linkables;
+ Linkable *_has(std::string s);
+};
+
+namespace leaf {
+ Edgeset& link(Linkable&, Linkable&);
+ Edgeset& ulink(Linkable&, Linkable&);
+ Nodeset& merge(Linkable&, Linkable&);
+}
+
+
+#endif /* LINKABLE_H_ */
47 NameSpace.cpp
@@ -0,0 +1,47 @@
+/*
+ * Symbols.cpp
+ *
+ * Created on: 26/apr/2010
+ * Author: ciccio
+ */
+
+#include "NameSpace.h"
+#include "Linkable.h"
+
+
+NameSpace::NameSpace() {
+ // TODO Auto-generated constructor stub
+
+}
+
+NameSpace::~NameSpace() {
+ // TODO Auto-generated destructor stub
+}
+
+Linkable *NameSpace::GetObject(std::string s)
+{
+ std::map<std::string, Linkable *>::iterator i;
+ i=_symvalues.find(s);
+ if (i == _symvalues.end())
+ return 0;
+ return i->second;
+}
+
+std::ostream& NameSpace::operator>>(std::ostream &str){
+ std::map<std::string, Linkable *>::iterator i;
+ str << "Symbol table {" << std::endl;
+ int j=0;
+
+ if(_symvalues.empty()) {
+ str << "<empty>" << std::endl << "}"<<std::endl;
+ return str;
+ }
+ for(i=_symvalues.begin(); i!=_symvalues.end(); i++, j++) {
+ str << i->first << ":\t";
+ *(i->second) >> str;
+ str << std::endl;
+ }
+ /*str << *i << std::endl << "}" << std::endl;*/
+ return str;
+
+}
42 NameSpace.h
@@ -0,0 +1,42 @@
+/*
+ * Symbols.h
+ *
+ * Created on: 26/apr/2010
+ * Author: ciccio
+ */
+
+#ifndef SYMBOLS_H_
+#define SYMBOLS_H_
+
+#include <vector>
+#include <map>
+#include <string>
+#include <algorithm>
+#include <ostream>
+#include "Linkable.h"
+#include "Function.h"
+
+
+class NameSpace {
+public:
+ NameSpace();
+ virtual ~NameSpace();
+ void AddSymbol(std::string s, Linkable *l)
+ {_symvalues.insert(std::pair<std::string, Linkable*>(s,l));}
+ bool HasSymbol(std::string s)
+ {return !(_symvalues.find(s)==_symvalues.end());}
+ Linkable *GetObject(std::string s);
+ std::ostream& operator>>(std::ostream &);
+ std::string getName() const
+ {return _name;}
+
+ void setName(std::string _name)
+ {this->_name = _name;}
+
+private:
+ std::map<std::string, Linkable *> _symvalues;
+ std::map<std::string, Function *> __functions;
+ std::string _name;
+};
+
+#endif /* SYMBOLS_H_ */
101 Node.cpp
@@ -0,0 +1,101 @@
+/*
+ * Node.cpp
+ *
+ * Created on: 01/apr/2010
+ * Author: ciccio
+ */
+
+#include "Node.h"
+#include <iostream> // JUST FOR DEBUG
+#include "Nodeset.h"
+
+unsigned Node::_lastid=0;
+
+Node::Node() {
+_id=Node::_lastid++;
+_issink = true;
+_issource = true;
+_isinput = true;
+_isoutput = true;
+_outconnector="";
+_inconnector="";
+_visited=false;
+SetAttribute("color", "black");
+}
+
+Node::Node(string name)
+{
+ _id=Node::_lastid++;
+ _issink = true;
+ _issource = true;
+ _isinput = true;
+ _isoutput = true;
+ _outconnector="";
+ _inconnector="";
+ _visited=false;
+ setName(name);
+ SetAttribute("color","black");
+}
+
+Node::~Node() {
+ // TODO Auto-generated destructor stub
+}
+
+void Node::SetInputs(Nodeset &n){*this = n[0];}
+void Node::SetOutputs(Nodeset &n){*this = n[0];}
+
+Nodeset& Node::GetSources(void)
+{return *(new Nodeset(*this));}
+
+Nodeset& Node::GetSinks(void)
+{return *(new Nodeset(*this));}
+
+inline Nodeset& Node::GetInputs(void)
+{return *(new Nodeset(*this));}
+
+inline Nodeset& Node::GetOutputs(void)
+{return *(new Nodeset(*this));}
+
+
+void Node::Visit(void)
+{
+ //* this >> cout;
+ _visited=true;
+}
+
+inline Nodeset& Node::GetNodes(void)
+{
+ return (*new Nodeset(*this));
+}
+
+ostream& Node::operator>>(std::ostream &str)
+{
+ std::map<std::string, std::string>::iterator mapit;
+ std::map<std::string, std::string> attribs;
+ string attr_string;
+
+ attribs = GetAttributes();
+ for(mapit = attribs.begin(); mapit!=attribs.end(); mapit++){
+ attr_string += ", ";
+ attr_string += (mapit -> first).c_str();
+ attr_string += " = ";
+ attr_string += (mapit -> second).c_str();
+ }
+
+ str << "N(" << _id << ", ";
+ str << "\"" << getName() << "\"" ;
+ str << ", " << _inconnector;
+ str << ", " << _outconnector;
+ str << (_issink ? ", Snk" : "");
+ str << (_issource ? ", Src" : "");
+ str << (_isinput ? ", In" : "");
+ str << (_isoutput ? ", Out" : "");
+ //str << ", " << _attributes["color"];
+ str << ", " << attr_string;
+ str << ")";
+
+ return str;
+}
+
+
+Edgeset &Node::GetEdges(void){return *new Edgeset();}
113 Node.h
@@ -0,0 +1,113 @@
+/*
+ * Node.h
+ *
+ * Created on: 01/apr/2010
+ * Author: ciccio
+ */
+
+#ifndef NODE_H_
+#define NODE_H_
+
+#include <vector>
+#include <string>
+#include "Linkable.h"
+
+using namespace std;
+
+class Node : public Linkable {
+ friend class Edge;
+ friend class Graph;
+public:
+ Node();
+ Node(string name);
+ virtual ~Node();
+
+
+ bool isVisited(void) {return _visited;}
+
+ void Visit(void);
+ bool isSink() const
+ {
+ return _issink;
+ }
+
+ bool isSource() const
+ {
+ return _issource;
+ }
+
+
+ unsigned getId() {return _id;}
+
+ ostream& operator>>(std::ostream &);
+ Edgeset &GetEdges(void);
+ string getInConnector() const
+ {
+ return _inconnector;
+ }
+
+ string getOutConnector() const
+ {
+ return _outconnector;
+ }
+
+ void setInConnector(string _inconn)
+ {
+ _inconnector = _inconn;
+ }
+
+ void setOutConnector(string _outconn)
+ {
+ _outconnector = _outconn;
+ }
+
+ bool getIsinput() const
+ {
+ return _isinput;
+ }
+
+ bool getIsoutput() const
+ {
+ return _isoutput;
+ }
+
+ void setIsinput(bool _isinput)
+ {
+ this->_isinput = _isinput;
+ }
+
+ void setIsoutput(bool _isoutput)
+ {
+ this->_isoutput = _isoutput;
+ }
+ virtual Linkable &Clone(){Node &n=*new Node; n=*this; return n;}
+
+ unsigned static newId(){return _lastid++;}
+
+ void setId(unsigned i){_id =i;}
+ void UpdateIds(){setId(newId());}
+ void SetAttribute(std::string s1, std::string s2) {_attributes[s1]=s2;}
+
+private:
+ void SetAttribute(unsigned, std::string s1, std::string s2){_attributes[s1]=s2;};
+ inline Nodeset& GetOutputs(void);
+ inline Nodeset& GetInputs(void);
+ inline Nodeset& GetNodes(void);
+ inline void SetInputs(Nodeset &);
+ inline void SetOutputs(Nodeset &);
+ inline Nodeset& GetSources(void);
+ inline Nodeset& GetSinks(void);
+
+ bool _visited;
+ unsigned _id;
+ static unsigned _lastid;
+ bool _issink;
+ bool _issource;
+ bool _isinput;
+ bool _isoutput;
+ std::string _inconnector;
+ std::string _outconnector;
+
+};
+
+#endif /* NODE_H_ */
149 Nodeset.cpp
@@ -0,0 +1,149 @@
+/*
+ * Nodeset.cpp
+ *
+ * Created on: 01/apr/2010
+ * Author: ciccio
+ */
+
+#include "Nodeset.h"
+#include "Node.h"
+
+Nodeset::Nodeset() {
+}
+
+
+Nodeset::~Nodeset() {
+// TODO Auto-generated destructor stub
+}
+
+void Nodeset::AddNodes(Nodeset & ns)
+{
+ Nodeset::iterator i;
+ for(i=ns.begin(); i!=ns.end(); i++)
+ if(!has(i->getId()))
+ push_back(*i);
+}
+
+
+void Nodeset::AddNode(Node &n)
+{
+ push_back(n);
+}
+
+Nodeset::Nodeset(Node & node)
+{
+ AddNode(node);
+}
+
+Nodeset::Nodeset(const Nodeset & ns)
+{
+ AddNodes(const_cast<Nodeset &>(ns).GetNodes());
+}
+
+void Nodeset::AddNewNode(string label)
+{
+}
+
+Edgeset &Nodeset::link(Nodeset &nodeset)
+{
+Edgeset *n;
+n = new Edgeset(*this, nodeset);
+return *n;
+}
+
+
+
+
+std::ostream& Nodeset::operator>>(std::ostream &str){
+Nodeset::iterator i;
+str << " NS {" << endl;
+if(empty()) {
+ str << " <empty>" << endl << " }"<<endl;
+ return str;
+}
+ for(i=begin(); i!=end()-1; i++) {
+ cout << " ";
+ *i >> str << endl;
+ }
+ cout << " ";
+ *i >> str << endl << " }" << endl;
+ return str;
+}
+
+bool Nodeset::has(string name){
+ Nodeset::iterator i;
+ for(i=begin(); i!=end(); i++)
+ if(i->getName() == name)
+ return true;
+ return false;
+}
+
+
+bool Nodeset::has(unsigned id){
+ Nodeset::iterator i;
+ for(i=begin(); i!=end(); i++)
+ if(i->getId() == id)
+ return true;
+ return false;
+}
+
+Node &Nodeset::findNode(unsigned id)
+{
+ Nodeset::iterator i;
+ for(i=begin(); i!=end(); i++)
+ if(i->getId() == id)
+ return *i;
+ cout << "****** Internal ERROR" <<endl;
+
+
+}
+
+#include "Graph.h"
+/*Nodeset::operator Graph()
+{
+ Graph *g = new Graph;
+ g->_V = *this;
+ g->SetInputs(*this);
+ g->SetOutputs(*this);
+ g->setName(this->_name);
+}
+*/
+
+
+void Nodeset::SetInputs(Nodeset &in)
+{
+ Nodeset::iterator i;
+
+ for (i=begin(); i!=end(); ++i){
+ if(in.has(i->getId()))
+ i->setIsinput(true);
+ else i->setIsinput(false);
+ }
+
+}
+
+void Nodeset::SetOutputs(Nodeset &o)
+{
+ Nodeset::iterator i;
+
+ for (i=begin(); i!=end(); ++i){
+ if(o.has(i->getId()))
+ i->setIsoutput(true);
+ else i->setIsoutput(false);
+ }
+
+}
+
+
+void Nodeset::SetAttribute(unsigned id, std::string s1, std::string s2)
+{
+ Nodeset::iterator i;
+
+ for (i=begin(); i!=end(); ++i){
+ if(i->getId()==id)
+ i->SetAttribute(s1,s2);
+ }
+
+ Linkable::SetAttribute(s1,s2);
+}
+
56 Nodeset.h
@@ -0,0 +1,56 @@
+/*
+ * Nodeset.h
+ *
+ * Created on: 01/apr/2010
+ * Author: ciccio
+ */
+
+#ifndef NODESET_H_
+#define NODESET_H_
+
+
+#include "Node.h"
+#include <vector>
+#include "Edgeset.h"
+
+using namespace std;
+
+class Nodeset : public Linkable, public std::vector<Node> {
+friend class Edgeset;
+friend class Graph;
+friend class AdjMatrix;
+friend Edgeset & leaf::link(Linkable & l1, Linkable & l2);
+
+public:
+ Nodeset();
+ Nodeset(Node &);
+ Nodeset(const Nodeset &);
+ virtual ~Nodeset();
+ void AddNode(Node &);
+ void AddNodes(Nodeset &);
+ void AddNewNode(string label);
+ Edgeset& link(Nodeset &);
+ std::ostream & operator>>(std::ostream &);
+ virtual Edgeset &GetEdges(void) {return *new Edgeset();}
+ bool has(string name);
+ bool has(unsigned id);
+ Node &findNode(unsigned id);
+ //operator class Graph();
+ virtual Linkable &Clone(){Nodeset &ns=*new Nodeset; ns=*this; return ns;}
+ //vector<Node> _nodes;
+ void UpdateIds(){Nodeset::iterator i; for(i=begin();i!=end();i++)i->UpdateIds();}
+ void SetAttribute(unsigned, std::string s1, std::string s2);
+
+private:
+ Nodeset& GetOutputs(void) {return *this;}
+ Nodeset& GetInputs(void) {return *this;}
+ Nodeset& GetNodes(void) {return *this;}
+ void SetInputs(Nodeset &);
+ void SetOutputs(Nodeset &);
+ Nodeset& GetSources(void) {return *this;}
+ Nodeset& GetSinks(void) {return *this;}
+};
+
+
+
+#endif /* NODESET_H_ */
19 SymbolTable.cpp
@@ -0,0 +1,19 @@
+/*
+ * SymbolTable.cpp
+ *
+ * Created on: 06/mag/2010
+ * Author: ciccio
+ */
+
+#include "SymbolTable.h"
+#include "NameSpace.h"
+
+SymbolTable::SymbolTable() {
+ NameSpace *global = new NameSpace;
+ this->addNameSpace("global", *global);
+
+}
+
+SymbolTable::~SymbolTable() {
+ // TODO Auto-generated destructor stub
+}
39 SymbolTable.h
@@ -0,0 +1,39 @@
+/*
+ * SymbolTable.h
+ *
+ * Created on: 06/mag/2010
+ * Author: ciccio
+ */
+
+#ifndef SYMBOLTABLE_H_
+#define SYMBOLTABLE_H_
+
+#include "NameSpace.h"
+#include "Linkable.h"
+#include <vector>
+#include <string>
+
+class SymbolTable {
+public:
+ SymbolTable();
+ virtual ~SymbolTable();
+ void addNameSpace(std::string name, NameSpace &n)
+ {_namespaces[name]=&n;}
+ void addSymbol(std::string space, std::string symbol, Linkable *l)
+ {_namespaces.find(space)->second->AddSymbol(symbol, l);}
+
+ Linkable *getSymbol(std::string symbol)
+ {return _namespaces.find("global")->second->GetObject(symbol);}
+ Linkable *getSymbol(std::string space, std::string symbol)
+ {Linkable *l =_namespaces.find(space)->second->GetObject(symbol);
+ if(l)
+ return l;
+ else return _namespaces.find("global")->second->GetObject(symbol);}
+
+
+private:
+ std::map<std::string, NameSpace *> _namespaces;
+
+};
+
+#endif /* SYMBOLTABLE_H_ */
49 dapsl.ll
@@ -0,0 +1,49 @@
+%{
+#include "dapsl.tab.hh" /* Generated by bison. */
+#define YY_NO_INPUT
+extern FILE *fid;
+%}
+%s IN_COMMENT
+
+DIGIT [0-9]
+ALPHA [a-zA-Z_]
+TOKEN [0-9a-zA-Z_]
+
+%%
+<INITIAL>{
+ "/*" BEGIN(IN_COMMENT);
+ }
+ <IN_COMMENT>{
+ "*/" BEGIN(INITIAL);
+ [^*\n]+ // eat comment in chunks
+ "*" // eat the lone star
+ \n yylineno++;
+ }
+
+
+
+"->" return TOK_RARROW;
+
+"<-" return TOK_LARROW;
+
+"-{" return TOK_RARROW_HASH;
+
+
+{TOKEN}+ { yylval = (YYSTYPE) strdup(yytext);
+ return TOK_ID; }
+
+
+
+
+[ \t\n|]+ /* eat up whitespace */
+
+. return *yytext;
+
+
+%%
+int yywrap()
+{
+return(1);
+}
+
+
2,045 dapsl.tab.cc
@@ -0,0 +1,2045 @@
+
+/* A Bison parser, made by GNU Bison 2.4.1. */
+
+/* Skeleton implementation for Bison's Yacc-like parsers in C
+
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+ Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* As a special exception, you may create a larger work that contains
+ part or all of the Bison parser skeleton and distribute that work
+ under terms of your choice, so long as that work isn't itself a
+ parser generator using the skeleton or a modified version thereof
+ as a parser skeleton. Alternatively, if you modify or redistribute
+ the parser skeleton itself, you may (at your option) remove this
+ special exception, which will cause the skeleton and the resulting
+ Bison output files to be licensed under the GNU General Public
+ License without this special exception.
+
+ This special exception was added by the Free Software Foundation in
+ version 2.2 of Bison. */
+
+/* C LALR(1) parser skeleton written by Richard Stallman, by
+ simplifying the original so-called "semantic" parser. */
+
+/* All symbols defined below should begin with yy or YY, to avoid
+ infringing on user name space. This should be done even for local
+ variables, as they might otherwise be expanded by user macros.
+ There are some unavoidable exceptions within include files to
+ define necessary library symbols; they are noted "INFRINGES ON
+ USER NAME SPACE" below. */
+
+/* Identify Bison output. */
+#define YYBISON 1
+
+/* Bison version. */
+#define YYBISON_VERSION "2.4.1"
+
+/* Skeleton name. */
+#define YYSKELETON_NAME "yacc.c"
+
+/* Pure parsers. */
+#define YYPURE 0
+
+/* Push parsers. */
+#define YYPUSH 0
+
+/* Pull parsers. */
+#define YYPULL 1
+
+/* Using locations. */
+#define YYLSP_NEEDED 0
+
+
+
+/* Copy the first part of user declarations. */
+
+/* Line 189 of yacc.c */
+#line 1 "dapsl.yy"
+
+#include <stdio.h>
+#include "globals.h"
+#include "nodes.h"
+#include "Linkable.h"
+#include "Frame.h"
+#define YYDEBUG 1
+#define YYSTYPE Linkable*
+//#define YYPARSE_PARAM scanner
+//#define YYLEX_PARAM scanner
+
+ inline int yyerror(const char *s) {/*fprintf (stderr, "%s\n", s);*/ return 1;}
+ void say(const char *s);
+ int yylex(void);
+
+
+
+/* Line 189 of yacc.c */
+#line 91 "dapsl.tab.cc"
+
+/* Enabling traces. */
+#ifndef YYDEBUG
+# define YYDEBUG 0
+#endif
+
+/* Enabling verbose error messages. */
+#ifdef YYERROR_VERBOSE
+# undef YYERROR_VERBOSE
+# define YYERROR_VERBOSE 1
+#else
+# define YYERROR_VERBOSE 0
+#endif
+
+/* Enabling the token table. */
+#ifndef YYTOKEN_TABLE
+# define YYTOKEN_TABLE 0
+#endif
+
+
+/* Tokens. */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
+ know about them. */
+ enum yytokentype {
+ TOK_ID = 258,
+ TOK_LARROW = 259,
+ TOK_LARROW_HASH = 260,
+ TOK_RARROW = 261,
+ TOK_RARROW_HASH = 262,
+ NUM = 263,
+ BOGUS = 264
+ };
+#endif
+
+
+
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
+typedef int YYSTYPE;
+# define YYSTYPE_IS_TRIVIAL 1
+# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+
+/* Copy the second part of user declarations. */
+
+
+/* Line 264 of yacc.c */
+#line 142 "dapsl.tab.cc"
+
+#ifdef short
+# undef short
+#endif
+
+#ifdef YYTYPE_UINT8
+typedef YYTYPE_UINT8 yytype_uint8;
+#else
+typedef unsigned char yytype_uint8;
+#endif
+
+#ifdef YYTYPE_INT8
+typedef YYTYPE_INT8 yytype_int8;
+#elif (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+typedef signed char yytype_int8;
+#else
+typedef short int yytype_int8;
+#endif
+
+#ifdef YYTYPE_UINT16
+typedef YYTYPE_UINT16 yytype_uint16;
+#else
+typedef unsigned short int yytype_uint16;
+#endif
+
+#ifdef YYTYPE_INT16
+typedef YYTYPE_INT16 yytype_int16;
+#else
+typedef short int yytype_int16;
+#endif
+
+#ifndef YYSIZE_T
+# ifdef __SIZE_TYPE__
+# define YYSIZE_T __SIZE_TYPE__
+# elif defined size_t
+# define YYSIZE_T size_t
+# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
+# define YYSIZE_T size_t
+# else
+# define YYSIZE_T unsigned int
+# endif
+#endif
+
+#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
+
+#ifndef YY_
+# if YYENABLE_NLS
+# if ENABLE_NLS
+# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
+# define YY_(msgid) dgettext ("bison-runtime", msgid)
+# endif
+# endif
+# ifndef YY_
+# define YY_(msgid) msgid
+# endif
+#endif
+
+/* Suppress unused-variable warnings by "using" E. */
+#if ! defined lint || defined __GNUC__
+# define YYUSE(e) ((void) (e))
+#else
+# define YYUSE(e) /* empty */
+#endif
+
+/* Identity function, used to suppress warnings about constant conditions. */
+#ifndef lint
+# define YYID(n) (n)
+#else
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static int
+YYID (int yyi)
+#else
+static int
+YYID (yyi)
+ int yyi;
+#endif
+{
+ return yyi;
+}
+#endif
+
+#if ! defined yyoverflow || YYERROR_VERBOSE
+
+/* The parser invokes alloca or malloc; define the necessary symbols. */
+
+# ifdef YYSTACK_USE_ALLOCA
+# if YYSTACK_USE_ALLOCA
+# ifdef __GNUC__
+# define YYSTACK_ALLOC __builtin_alloca
+# elif defined __BUILTIN_VA_ARG_INCR
+# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
+# elif defined _AIX
+# define YYSTACK_ALLOC __alloca
+# elif defined _MSC_VER
+# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
+# define alloca _alloca
+# else
+# define YYSTACK_ALLOC alloca
+# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+# ifndef _STDLIB_H
+# define _STDLIB_H 1
+# endif
+# endif
+# endif
+# endif
+# endif
+
+# ifdef YYSTACK_ALLOC
+ /* Pacify GCC's `empty if-body' warning. */
+# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
+# ifndef YYSTACK_ALLOC_MAXIMUM
+ /* The OS might guarantee only one guard page at the bottom of the stack,
+ and a page size can be as small as 4096 bytes. So we cannot safely
+ invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
+ to allow for a few compiler-allocated temporary stack slots. */
+# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
+# endif
+# else
+# define YYSTACK_ALLOC YYMALLOC
+# define YYSTACK_FREE YYFREE
+# ifndef YYSTACK_ALLOC_MAXIMUM
+# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
+# endif
+# if (defined __cplusplus && ! defined _STDLIB_H \
+ && ! ((defined YYMALLOC || defined malloc) \
+ && (defined YYFREE || defined free)))
+# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+# ifndef _STDLIB_H
+# define _STDLIB_H 1
+# endif
+# endif
+# ifndef YYMALLOC
+# define YYMALLOC malloc
+# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
+# endif
+# endif
+# ifndef YYFREE
+# define YYFREE free
+# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+void free (void *); /* INFRINGES ON USER NAME SPACE */
+# endif
+# endif
+# endif
+#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
+
+
+#if (! defined yyoverflow \
+ && (! defined __cplusplus \
+ || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
+
+/* A type that is properly aligned for any stack member. */
+union yyalloc
+{
+ yytype_int16 yyss_alloc;
+ YYSTYPE yyvs_alloc;
+};
+
+/* The size of the maximum gap between one aligned stack and the next. */
+# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
+
+/* The size of an array large to enough to hold all stacks, each with
+ N elements. */
+# define YYSTACK_BYTES(N) \
+ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
+ + YYSTACK_GAP_MAXIMUM)
+
+/* Copy COUNT objects from FROM to TO. The source and destination do
+ not overlap. */
+# ifndef YYCOPY
+# if defined __GNUC__ && 1 < __GNUC__
+# define YYCOPY(To, From, Count) \
+ __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
+# else
+# define YYCOPY(To, From, Count) \
+ do \
+ { \
+ YYSIZE_T yyi; \
+ for (yyi = 0; yyi < (Count); yyi++) \
+ (To)[yyi] = (From)[yyi]; \
+ } \
+ while (YYID (0))
+# endif
+# endif
+
+/* Relocate STACK from its old location to the new one. The
+ local variables YYSIZE and YYSTACKSIZE give the old and new number of
+ elements in the stack, and YYPTR gives the new location of the
+ stack. Advance YYPTR to a properly aligned location for the next
+ stack. */
+# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
+ do \
+ { \
+ YYSIZE_T yynewbytes; \
+ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
+ Stack = &yyptr->Stack_alloc; \
+ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
+ yyptr += yynewbytes / sizeof (*yyptr); \
+ } \
+ while (YYID (0))
+
+#endif
+
+/* YYFINAL -- State number of the termination state. */
+#define YYFINAL 2
+/* YYLAST -- Last index in YYTABLE. */
+#define YYLAST 236
+
+/* YYNTOKENS -- Number of terminals. */
+#define YYNTOKENS 31
+/* YYNNTS -- Number of nonterminals. */
+#define YYNNTS 28
+/* YYNRULES -- Number of rules. */
+#define YYNRULES 65
+/* YYNRULES -- Number of states. */
+#define YYNSTATES 135
+
+/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
+#define YYUNDEFTOK 2
+#define YYMAXUTOK 266
+
+#define YYTRANSLATE(YYX) \
+ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
+
+/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
+static const yytype_uint8 yytranslate[] =
+{
+ 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 13, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 18, 19, 2, 2, 27, 24, 2, 10, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 30, 12,
+ 14, 15, 11, 2, 28, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 22, 16, 23, 29, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 20, 17, 21, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
+ 5, 6, 7, 8, 9, 25, 26
+};
+
+#if YYDEBUG
+/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
+ YYRHS. */
+static const yytype_uint8 yyprhs[] =
+{
+ 0, 0, 3, 4, 7, 11, 14, 18, 21, 25,
+ 28, 30, 31, 40, 42, 44, 47, 50, 53, 56,
+ 59, 61, 64, 67, 71, 75, 79, 83, 87, 91,
+ 95, 100, 105, 109, 111, 116, 121, 125, 127, 131,
+ 135, 140, 145, 147, 151, 156, 161, 163, 165, 169,
+ 173, 177, 181, 185, 188, 191, 194, 197, 201, 204,
+ 207, 212, 217, 219, 223, 227
+};
+
+/* YYRHS -- A `-1'-separated list of the rules' RHS. */
+static const yytype_int8 yyrhs[] =
+{
+ 32, 0, -1, -1, 32, 33, -1, 54, 47, 12,
+ -1, 47, 12, -1, 54, 48, 12, -1, 48, 12, <