1 /*
2 
3     This file is part of the Maude 2 interpreter.
4 
5     Copyright 1997-2003 SRI International, Menlo Park, CA 94025, USA.
6 
7     This program is free software; you can redistribute it and/or modify
8     it under the terms of the GNU General Public License as published by
9     the Free Software Foundation; either version 2 of the License, or
10     (at your option) any later version.
11 
12     This program is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15     GNU General Public License for more details.
16 
17     You should have received a copy of the GNU General Public License
18     along with this program; if not, write to the Free Software
19     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
20 
21 */
22 
23 /************************************************
24  ** SCP Parsing Algorithm                      **
25  **  	Maude Implementation                   **
26  **		Jose F. Quesada                **
27  **		CSL - SRI Int.  1998           **
28  ************************************************/
29 
30 /*******
31  ******* scp_memory.cc
32  *******/
33 
34 #include "scp_parser.hh"
35 
ScpParser()36 ScpParser::ScpParser()
37 {
38   compiled  = 0;
39 
40   lenprodtn = MEMPRODTN;
41   memprodtn = new ScpProdtn[lenprodtn];
42   curprodtn = 0;
43   ldgrprodtn = 0;
44 
45   lenrhs    = MEMRHS;
46   memrhs    = new int[lenrhs];
47   currhs    = 0;
48 
49   lenbasent = MEMBASENT;
50   membasent = new ScpBaseNT[lenbasent];
51   memset(membasent,-1,lenbasent*sizeof(ScpBaseNT));
52   maxbasent = 0;
53 
54   lenabslnt = MEMABSLNT;
55   memabslnt = new ScpAbslNT[lenabslnt];
56   memset(memabslnt,0,lenabslnt*sizeof(ScpAbslNT));
57   maxabslnt = 0;
58 
59   lenbubble = MEMBUBBLE;
60   membubble = new ScpBubble[lenbubble];
61   curbubble = 0;
62 
63   lenexcept = MEMEXCEPT;
64   memexcept = new int[lenexcept];
65   curexcept = 0;
66 
67   maxtermn  = -1;
68 
69   addrtermn = 0;
70 
71   covtbl = 0;
72   adjtb = 0;
73   bubexcept = 0;
74 
75   memcov = 0;
76   bubcov = 0;
77 
78   maxlenterm = MEMLENTERM;
79   nodeterm  = new int[maxlenterm*5];
80   eventterm = nodeterm+maxlenterm;
81   inputterm = eventterm+maxlenterm;
82   errorlist = inputterm+maxlenterm;
83   errorlevel = errorlist+maxlenterm;
84 
85   lenevent  = MEMEVENT;
86   memevent  = new ScpEvent[lenevent];
87 
88   lennode   = MEMNODE;
89   memnode   = new ScpNode[lennode];
90   memambnode = new int[lennode];
91   prevambnode = 1; /* because memambnode hasn't been initialized */
92 
93   lenanal   = MEMANAL;
94   memanal   = new ScpAnal[lenanal];
95 
96   lendetect = MEMDETECT;
97   memdetect = new int[lendetect];
98   typedetect = new int[lendetect];
99 
100   memalter  = 0;
101   lenalter  = 0;
102 
103   memprodruntoken = 0;  // includes memprodrunnode
104 }
105 
~ScpParser()106 ScpParser::~ScpParser()
107 {
108   delete [] memprodtn;
109   delete [] ldgrprodtn;
110   delete [] memrhs;
111   delete [] membasent;
112   delete [] memabslnt;
113   delete [] membubble;
114   delete [] memexcept;
115   delete [] addrtermn;
116   delete [] covtbl;
117   delete [] adjtb;
118   delete [] bubexcept;
119   delete [] memcov;
120   delete [] bubcov;
121   delete [] nodeterm;
122   delete [] memevent;
123   delete [] memnode;
124   delete [] memambnode;
125   delete [] memanal;
126   delete [] memprodruntoken;
127   delete [] memdetect;
128   delete [] typedetect;
129   delete [] memalter;
130 }
131