#include "xcddraw.h" #include #include #include #include #include void VertexStore::genCd(FILE *fp) { localvertices->genCd(fp); } void NameSensitiveVertexStore::genCd(FILE *fp) { if (vertices) vertices->genCd(fp); } void NameSensitiveVertexList::genCd(FILE *fp) { elm->genCd(fp); if (next) next->genCd(fp); } void printCDComments(FILE *fp, char *c) { if (strlen(c) ==0) return; fprintf(fp,"\n// "); while (*c) { fprintf(fp,"%c",*c); if (*c == '\n' && *(c+1) != '\0') fprintf(fp,"// "); c++; } if (*(c-1) != '\n') fprintf(fp,"\n"); } void printSyntax(FILE *fp, char *s) { if (strlen(s) ==0) return; while (*s) { fprintf(fp,"%c",*s); if (*s == '\n' && *(s+1) != '\n') fprintf(fp," "); s++; } if (*(s-1) != '\n') fprintf(fp,"\n"); } void NameSensitiveVertex::genCd(FILE *fp) { char pname[1024]; char *c; pname[0] = '\0'; primary->get_name()->get_parameterized_name(primary->get_parassignstore(),pname); if (primary->no_parameters()) pname[strlen(pname)-2] = '\0'; fprintf(fp,"\n"); if (comments->get_comments()) printCDComments(fp,comments->get_comments()); fprintf(fp,"%s ",pname); switch(primary->get_kind()) { case CONS_VERTEX: fprintf(fp,"= "); if (before) printSyntax(fp,before); outgoing_consedge_store->printCons(fp); if (after) printSyntax(fp,after); vertices->printInheritExt(fp); break; case ALT_VERTEX: { int hasAlt = 0; fprintf(fp,": \n"); if (before) printSyntax(fp,before); vertices->printAlt(fp,hasAlt); if (hasAlt==0) { sprintf(message, "Print: Alternation vertex %s has no alternative.\n",pname); xm_print_message(message); XBell(XtDisplay(draw_area),0); } fprintf(fp," *common*\n"); outgoing_consedge_store->printCons(fp); if (after) printSyntax(fp,after); vertices->printInheritExt(fp); break; } case REP_VERTEX: { int hasRep = 0; fprintf(fp,"~ "); if (before) printSyntax(fp,before); vertices->printRep(fp,hasRep); if (hasRep ==0) { sprintf(message, "Print: Repetition vertex %s has no outgoing repetition edge.\n",pname); xm_print_message(message); XBell(XtDisplay(draw_area),0); } if (after) printSyntax(fp,after); break; } } fprintf(fp," .\n"); } void ObjectStore::printInheritExt(FILE *fp) { if (objects) objects->printInheritExt(fp); } void GraphicsObjectList::printInheritExt(FILE *fp) { elm->printInheritExt(fp); if (next) next->printInheritExt(fp); } void GraphicsObject::printInheritExt(FILE *fp) { } void VertexObject::printInheritExt(FILE *fp) { this->get_outgoing_inhedge_store()->printEachInheritExt(fp); } void ObjectStore::printEachInheritExt(FILE *fp) { if (objects) objects->printEachInheritExt(fp); } void GraphicsObjectList::printEachInheritExt(FILE *fp) { elm->printEachInheritExt(fp); if (next) next->printEachInheritExt(fp); } void GraphicsObject::printEachInheritExt(FILE *fp) { } void InheritanceEdge::printEachInheritExt(FILE *fp) { this->get_to_vertex()->printEachInheritExt(fp); } void VertexObject::printEachInheritExt(FILE *fp) { } void ExternalVertex::printEachInheritExt(FILE *fp) { fprintf(fp," *inherit* %s \n",this->get_vertex_name()); } /* printCons(FILE *fp) */ void ObjectStore::printCons(FILE *fp) { if (objects) objects->printCons(fp); } void GraphicsObjectList::printCons(FILE *fp) { elm->printCons(fp); if (next) next->printCons(fp); } void GraphicsObject::printCons(FILE *fp) { } void ReqConstructionEdge::printCons(FILE *fp) { char pname[1024]; char *c; pname[0] = '\0'; if (this->get_to_vertex()->get_is_template()) { this->get_to_vertex()->get_name() ->get_parameterized_name(this->get_to_vertex()->get_parassignstore(),pname); if (this->get_to_vertex()->no_parameters()) pname[strlen(pname)-2] = '\0'; } else if (this->get_to_vertex()->get_template_name()) /* template instance */ this->get_to_vertex()->get_template_name() ->get_parameterized_name(this->get_to_vertex()->get_parassignstore(),pname); if (before) printSyntax(fp,before); char *pl = this->get_edge_label()->get_val(); fprintf(fp," "); fprintf(fp," < %s > %s\n",pl,pname); if (after) printSyntax(fp,after); if (this->get_comments()->get_comments()) printCDComments(fp,this->get_comments()->get_comments()); } void OptConstructionEdge::printCons(FILE *fp) { char pname[1024]; char *c; pname[0] = '\0'; if (this->get_to_vertex()->get_is_template()) { this->get_to_vertex()->get_name() ->get_parameterized_name(this->get_to_vertex()->get_parassignstore(),pname); if (this->get_to_vertex()->no_parameters()) pname[strlen(pname)-2] = '\0'; } else if (this->get_to_vertex()->get_template_name()) /* template instance */ this->get_to_vertex()->get_template_name() ->get_parameterized_name(this->get_to_vertex()->get_parassignstore(),pname); if (before) printSyntax(fp,before); if (before == NULL) fprintf(fp,"\n "); fprintf(fp," [ "); if (inbefore) printSyntax(fp,inbefore); char *pl = this->get_edge_label()->get_val(); if (inbefore == NULL) fprintf(fp,"\n "); fprintf(fp," < %s > %s ",pl,pname); if (inafter) printSyntax(fp,inafter); if (inafter) fprintf(fp," "); fprintf(fp," ]\n"); if (after) printSyntax(fp,after); if (this->get_comments()->get_comments()) printCDComments(fp,this->get_comments()->get_comments()); } void ObjectStore::printRep(FILE *fp,int &hasAlt) { if (objects) objects->printRep(fp,hasAlt); } void GraphicsObjectList::printRep(FILE *fp,int &hasAlt) { elm->printRep(fp,hasAlt); if (next) next->printRep(fp,hasAlt); } void GraphicsObject::printRep(FILE *fp,int &hasRep) { } void RepetitionVertex::printRep(FILE *fp,int &hasRep) { this->get_outgoing_repedge_store()->printRepEdge(fp,hasRep); } void ObjectStore::printRepEdge(FILE *fp,int &hasRep) { if (objects) objects->printRepEdge(fp,hasRep); } void GraphicsObjectList::printRepEdge(FILE *fp,int &hasRep) { elm->printRepEdge(fp,hasRep); if (next) next->printRepEdge(fp,hasRep); } void GraphicsObject::printRepEdge(FILE *fp,int &hasRep) { } void ReqRepetitionEdge::printRepEdge(FILE *fp,int &hasRep) { char pname[1024]; char *c; pname[0] = '\0'; hasRep = 1; if (this->get_to_vertex()->get_is_template()) { this->get_to_vertex()->get_name() ->get_parameterized_name(this->get_to_vertex()->get_parassignstore(),pname); if (this->get_to_vertex()->no_parameters()) pname[strlen(pname)-2] = '\0'; } else if (this->get_to_vertex()->get_template_name()) /* template instance */ this->get_to_vertex()->get_template_name() ->get_parameterized_name(this->get_to_vertex()->get_parassignstore(),pname); if (outbefore) printSyntax(fp,outbefore); if (outbefore && strlen(outbefore)) fprintf(fp," "); fprintf(fp," %s ",pname); fprintf(fp," { "); if (before) printSyntax(fp,before); if (before && strlen(before)) fprintf(fp," "); fprintf(fp," %s\n",pname); if (after) printSyntax(fp,after); if (after && strlen(after)) fprintf(fp," "); fprintf(fp," }\n"); if (this->get_comments()->get_comments()) printCDComments(fp,this->get_comments()->get_comments()); } void OptRepetitionEdge::printRepEdge(FILE *fp,int &hasRep) { char pname[1024]; char *c; pname[0] = '\0'; hasRep = 1; if (this->get_to_vertex()->get_is_template()) { this->get_to_vertex()->get_name() ->get_parameterized_name(this->get_to_vertex()->get_parassignstore(),pname); if (this->get_to_vertex()->no_parameters()) pname[strlen(pname)-2] = '\0'; } else if (this->get_to_vertex()->get_template_name()) /* template instance */ this->get_to_vertex()->get_template_name() ->get_parameterized_name(this->get_to_vertex()->get_parassignstore(),pname); fprintf(fp," { "); if (before) printSyntax(fp,before); if (before) fprintf(fp," "); fprintf(fp," %s\n",pname); if (after) printSyntax(fp,after); fprintf(fp," } "); if (this->get_comments()->get_comments()) printCDComments(fp,this->get_comments()->get_comments()); } void ObjectStore::printAlt(FILE *fp,int &hasAlt) { if (objects) objects->printAlt(fp,hasAlt); } void GraphicsObjectList::printAlt(FILE *fp,int &hasAlt) { elm->printAlt(fp,hasAlt); if (next) next->printAlt(fp,hasAlt); } void GraphicsObject::printAlt(FILE *fp,int &hasAlt) { } void AlternationVertex::printAlt(FILE *fp,int &hasAlt) { this->get_outgoing_altedge_store()->printAltEdge(fp,hasAlt); } void ObjectStore::printAltEdge(FILE *fp,int &hasAlt) { if (objects) objects->printAltEdge(fp,hasAlt); } void GraphicsObjectList::printAltEdge(FILE *fp,int &hasAlt) { elm->printAltEdge(fp,hasAlt); if (next) next->printAltEdge(fp,hasAlt); } void GraphicsObject::printAltEdge(FILE *fp,int &hasAlt) { } void AlternationEdge::printAltEdge(FILE *fp,int &hasAlt) { char pname[1024]; if (hasAlt) fprintf(fp," | "); else fprintf(fp," "); pname[0] = '\0'; hasAlt = 1; if (this->get_to_vertex()->get_is_template()) { this->get_to_vertex()->get_name() ->get_parameterized_name(this->get_to_vertex()->get_parassignstore(),pname); if (this->get_to_vertex()->no_parameters()) pname[strlen(pname)-2] = '\0'; } else if (this->get_to_vertex()->get_template_name()) /* template instance */ this->get_to_vertex()->get_template_name() ->get_parameterized_name(this->get_to_vertex()->get_parassignstore(),pname); fprintf(fp,"%s\n",pname); if (this->get_comments()->get_comments()) printCDComments(fp,this->get_comments()->get_comments()); }