1 /* FILE: grph.h 2 * DATE MODIFIED: 31-Aug-07 3 * DESCRIPTION: Part of the SREC graph compiler project source files. 4 * 5 * Copyright 2007, 2008 Nuance Communciations, Inc. * 6 * * 7 * Licensed under the Apache License, Version 2.0 (the 'License'); * 8 * you may not use this file except in compliance with the License. * 9 * * 10 * You may obtain a copy of the License at * 11 * http://www.apache.org/licenses/LICENSE-2.0 * 12 * * 13 * Unless required by applicable law or agreed to in writing, software * 14 * distributed under the License is distributed on an 'AS IS' BASIS, * 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 16 * See the License for the specific language governing permissions and * 17 * limitations under the License. * 18 * * 19 *---------------------------------------------------------------------------*/ 20 21 #include "sub_grph.h" 22 23 class Graph 24 { 25 public: Graph(const char * name)26 Graph (const char *name) 27 { 28 int count= strlen(name); 29 title= new char [count+1]; 30 strcpy (title, name); 31 numSubGraph= 0; 32 subGraph= 0; 33 subIndex= 0; 34 }; 35 ~Graph()36 ~Graph() 37 { 38 delete [] subGraph; 39 delete [] subIndex; 40 delete [] title; 41 } 42 43 int addSubGraph (SubGraph *subGraph); 44 int getSubGraphIndex (SubGraph *subGraph); 45 46 void BeginRule (SubGraph *subg); 47 void EndRule (SubGraph *subg); 48 void BeginItem (SubGraph *subg); 49 void BeginItemRepeat (SubGraph *subg, int min_count, int max_count); 50 void AddRuleRef (SubGraph *subg, int ruleNo); 51 void AddLabel (SubGraph *subg, int labNo); 52 void AddTag (SubGraph *subg, int tagNo); 53 void EndItem (SubGraph *subg); 54 void BeginOneOf (SubGraph *subg); 55 void EndOneOf (SubGraph *subg); 56 void BeginCount (SubGraph *subg, int minCount, int maxCount); 57 void EndCount (SubGraph *subg); 58 void BeginOptional (SubGraph *subg); 59 60 void ExpandRules (SubGraph *subg); 61 62 private: 63 64 int numSubGraph; 65 SubGraph **subGraph; 66 int *subIndex; 67 68 int getSubGraphIndex (int subId); 69 70 char *title; 71 72 }; 73 74 75