16 IncFile(char *s, int st)
26 IncFile *findTrueLine(int ln, int *trueline)
38 if (pom->start > ln) {
43 while ((pom != NULL) && (ln > pom->start)) {
44 if (ln < pom->start + pom->len) {
45 *trueline = ln-pom->start;
55 while (pom1 != NULL) {
64 while (pom1 != NULL) {
74 int main(int argc,char **argv)
80 QString poms, poms1, poms2;
83 int i, j, line, tline;
86 poms.sprintf("%s", argv[1]);
87 i = poms.findRev('/', poms.length() - 1, FALSE);
89 //******* get home directory
91 poms1 = poms.left(i + 1);
92 strcpy(homedir, poms1.data());
97 poms.sprintf("%s", argv[0]);
98 i = poms.findRev('/', poms.length() - 1, FALSE);
105 strcpy(mydir,poms1.data());
107 poms.sprintf("%s", argv[1]);
108 i = poms.findRev(".log", poms.length()-1, FALSE);
109 poms1 = poms.left(i);
110 strcpy(fname, poms1.data());
112 // ********************
114 poms.sprintf("%s/.cmp00", mydir);
115 poms1.sprintf("%s/cmp01.log", mydir);
117 unlink(poms1.data());
119 QFile compfile(poms1.data());
120 QFile srcfile(argv[1]);
122 if (!compfile.open(IO_WriteOnly)) {
123 fprintf(stdout,"Cannot open temp file to write %s\n",
128 if (!srcfile.open(IO_ReadOnly)) {
129 fprintf(stdout, "Cannot open file\n");
133 QTextStream comps(&compfile);
134 QTextStream src(&srcfile);
137 poms = src.readLine();
138 i = poms.find("#include");
140 /* get include file */
143 j=poms.find('"',i+1);
145 if ((i != -1) && (j != -1)) {
147 poms1 = poms.mid(i + 1, j - i - 1);
148 p = new IncFile((char*)poms1.ascii(),
150 poms2.sprintf("%s%s", homedir, poms1.data());
151 QFile pomf(poms2.data());
152 if (!pomf.open(IO_ReadOnly)) {
153 fprintf(stdout, "Cannot open include "
154 "file: %s\n", poms2.data());
157 QTextStream pomstream(&pomf);
158 while (!pomstream.eof()) {
159 poms1 = pomstream.readLine();
160 comps << poms1.data();
169 comps << poms.data();
178 poms.sprintf("%s/cmp01.lcd", mydir);
181 sprintf(ss, "%s/loglan %s/cmp01 > %s/.cmp00", mydir, mydir, mydir);
182 if (system(ss) == -1) {
183 fprintf(stdout, "Cannot execute compiler\n");
187 poms1.sprintf("%s.lcd", fname);
189 if (QFile::exists(poms.data())) {
190 rename(poms.data(), poms1.data());
192 fprintf(stdout, "Compile ok\n");
193 sprintf(ss,"%s/gen %s", mydir, fname);
194 if (system(ss)==-1) {
195 fprintf(stdout, "Cannot execute generator\n");
198 poms.sprintf("%s.ccd", fname);
199 if (QFile::exists(poms.data())) {
200 unlink(poms1.data());
203 fprintf(stdout, "Errors\n");
204 poms.sprintf("%s/.cmp00", mydir);
205 QFile err(poms.data());
207 if (!err.open(IO_ReadOnly)) {
208 fprintf(stdout,"Cannot open error file\n");
211 QTextStream errstream(&err);
214 poms = errstream.readLine();
215 i = poms.find("LOGLAN-82");
216 while ((!errstream.eof()) && (i == -1)) {
217 poms = errstream.readLine();
218 i = poms.find("LOGLAN-82");
221 while (!errstream.eof()) {
222 poms = errstream.readLine();
223 i = poms.find("ERROR");
226 j = poms.findRev(' ', i);
227 poms1 = poms.mid(j + 1, i - j);
228 line = poms1.toInt();
229 fl = findTrueLine(line, &tline);
230 poms2 = poms.right(poms.length() - i - 1);
232 fprintf(stdout, "%s: ", fl->filename);
233 fprintf(stdout, "%d %s\n",
234 tline, poms2.data());
240 poms.sprintf("%s/cmp01.log",mydir);
242 poms.sprintf("%s/.cmp00",mydir);