My Project
Data Structures | Enumerations | Functions | Variables
fevoices.h File Reference
#include "reporter/reporter.h"
#include "resources/feResource.h"
#include "kernel/structs.h"

Go to the source code of this file.

Data Structures

class  Voice
 

Enumerations

enum  feBufferTypes {
  BT_none = 0 , BT_break = 1 , BT_proc , BT_example ,
  BT_file , BT_execute , BT_if , BT_else
}
 
enum  feBufferInputs { BI_stdin = 1 , BI_buffer , BI_file }
 
enum  noeof_t {
  noeof_brace = 1 , noeof_asstring , noeof_block , noeof_bracket ,
  noeof_comment , noeof_procname , noeof_string
}
 

Functions

VoicefeInitStdin (Voice *pp)
 
const char * VoiceName ()
 
int VoiceLine ()
 
void VoiceBackTrack ()
 
BOOLEAN contBuffer (feBufferTypes typ)
 
BOOLEAN exitBuffer (feBufferTypes typ)
 
BOOLEAN exitVoice ()
 
void monitor (void *F, int mode)
 
BOOLEAN newFile (char *fname)
 
void newBuffer (char *s, feBufferTypes t, procinfo *pname=NULL, int start_lineno=0)
 
void * myynewbuffer ()
 
void myyoldbuffer (void *oldb)
 

Variables

EXTERN_VAR int yylineno
 
EXTERN_VAR char my_yylinebuf [80]
 
const char sNoName_fe []
 
EXTERN_VAR VoicecurrentVoice
 

Enumeration Type Documentation

◆ feBufferInputs

Enumerator
BI_stdin 
BI_buffer 
BI_file 

Definition at line 28 of file fevoices.h.

29{
30 BI_stdin = 1,
33};
@ BI_file
Definition: fevoices.h:32
@ BI_buffer
Definition: fevoices.h:31
@ BI_stdin
Definition: fevoices.h:30

◆ feBufferTypes

Enumerator
BT_none 
BT_break 
BT_proc 
BT_example 
BT_file 
BT_execute 
BT_if 
BT_else 

Definition at line 16 of file fevoices.h.

17{
18 BT_none = 0, // entry level
19 BT_break = 1, // while, for
20 BT_proc, // proc
21 BT_example, // example
22 BT_file, // <"file"
23 BT_execute, // execute
24 BT_if, // if
25 BT_else // else
26};
@ BT_none
Definition: fevoices.h:18
@ BT_else
Definition: fevoices.h:25
@ BT_if
Definition: fevoices.h:24
@ BT_break
Definition: fevoices.h:19
@ BT_example
Definition: fevoices.h:21
@ BT_execute
Definition: fevoices.h:23
@ BT_proc
Definition: fevoices.h:20
@ BT_file
Definition: fevoices.h:22

◆ noeof_t

enum noeof_t
Enumerator
noeof_brace 
noeof_asstring 
noeof_block 
noeof_bracket 
noeof_comment 
noeof_procname 
noeof_string 

Definition at line 34 of file fevoices.h.

35{
36 noeof_brace = 1,
43}; /* for scanner.l */
@ noeof_string
Definition: fevoices.h:42
@ noeof_brace
Definition: fevoices.h:36
@ noeof_comment
Definition: fevoices.h:40
@ noeof_asstring
Definition: fevoices.h:37
@ noeof_block
Definition: fevoices.h:38
@ noeof_procname
Definition: fevoices.h:41
@ noeof_bracket
Definition: fevoices.h:39

Function Documentation

◆ contBuffer()

BOOLEAN contBuffer ( feBufferTypes  typ)

Definition at line 302 of file fevoices.cc.

303{
304 //printf("contBuffer: %d(%s),(%x)\n",
305 // typ,BT_name[typ], currentVoice);
306 if (typ == BT_break) // valid inside for, while. may skip if, else
307 {
308 // first check for valid buffer type
310 loop
311 {
312 if ((p->typ != BT_if)
313 &&(p->typ != BT_else))
314 {
315 if (p->typ == BT_break /*typ*/)
316 {
317 while (p != currentVoice)
318 {
319 exitVoice();
320 }
323 return FALSE;
324 }
325 else return TRUE;
326 }
327 if (p->prev==NULL) break;
328 p=p->prev;
329 }
330 }
331 return TRUE;
332}
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
int p
Definition: cfModGcd.cc:4078
Definition: fevoices.h:59
int start_lineno
Definition: fevoices.h:75
long fptr
Definition: fevoices.h:70
VAR int yylineno
Definition: febase.cc:40
VAR Voice * currentVoice
Definition: fevoices.cc:47
BOOLEAN exitVoice()
Definition: fevoices.cc:339
#define NULL
Definition: omList.c:12
#define loop
Definition: structs.h:75

◆ exitBuffer()

BOOLEAN exitBuffer ( feBufferTypes  typ)

Definition at line 234 of file fevoices.cc.

235{
236 //printf("exitBuffer: %d(%s),(%x)\n",
237 // typ,BT_name[typ], currentVoice);
238 //Voice *p=currentVoice;
239 //PrintS("-----------------\ncurr:");
240 //do
241 //{
242 //Print("voice fn:%s\n",p->filename);
243 //p=p->prev;
244 //}
245 //while (p!=NULL);
246 //PrintS("----------------\n");
247 if (typ == BT_break) // valid inside for, while. may skip if, else
248 {
249 /*4 first check for valid buffer type, skip if/else*/
251 loop
252 {
253 if ((p->typ != BT_if)
254 &&(p->typ != BT_else))
255 {
256 if (p->typ == BT_break /*typ*/)
257 {
258 while (p != currentVoice)
259 {
260 exitVoice();
261 }
262 exitVoice();
263 return FALSE;
264 }
265 else return TRUE;
266 }
267 if (p->prev==NULL) break;
268 p=p->prev;
269 }
270 /*4 break not inside a for/while: return an error*/
271 if (/*typ*/ BT_break != currentVoice->typ) return 1;
272 return exitVoice();
273 }
274
275 if ((typ == BT_proc)
276 || (typ == BT_example))
277 {
279 loop
280 {
281 if ((p->typ == BT_proc)
282 || (p->typ == BT_example))
283 {
284 while (p != currentVoice)
285 {
286 exitVoice();
287 }
288 exitVoice();
289 return FALSE;
290 }
291 if (p->prev==NULL) break;
292 p=p->prev;
293 }
294 }
295 /*4 return not inside a proc: return an error*/
296 return TRUE;
297}
feBufferTypes typ
Definition: fevoices.h:85

◆ exitVoice()

BOOLEAN exitVoice ( )

Definition at line 339 of file fevoices.cc.

340{
341 //printf("exitVoice: %d(%s),(%x)\n",
342 // currentVoice->typ,BT_name[currentVoice->typ], currentVoice);
343 //{
344 //Voice *p=currentVoice;
345 //PrintS("-----------------\ncurr:");
346 //do
347 //{
348 //Print("voice fn:%s\n",p->filename);
349 //p=p->prev;
350 //}
351 //while (p!=NULL);
352 //PrintS("----------------\n");
353 //}
354 if (currentVoice!=NULL)
355 {
356 if (currentVoice->oldb!=NULL)
357 {
360 }
362 {
365 }
367 {
370 }
371 if ((currentVoice->prev==NULL)
373 &&(currentVoice->files!=stdin))
374 {
376 }
377 if (currentVoice->prev!=NULL)
378 {
379 //printf("exitVoice typ %d(%s)\n",
380 // currentVoice->typ,BT_name[currentVoice->typ]);
381 if (currentVoice->typ==BT_if)
382 {
384 }
385 else
386 {
388 }
389 if ((currentVoice->sw == BI_file)
390 && (currentVoice->files!=NULL))
391 {
392 fclose(currentVoice->files);
393 }
396 }
398 delete currentVoice;
400 }
401 return currentVoice==NULL;
402}
void * ADDRESS
Definition: auxiliary.h:119
int curr_lineno
Definition: fevoices.h:76
Voice * next
Definition: fevoices.h:61
FILE * files
Definition: fevoices.h:67
char * buffer
Definition: fevoices.h:69
char ifsw
Definition: fevoices.h:80
char * filename
Definition: fevoices.h:63
feBufferInputs sw
Definition: fevoices.h:77
void * oldb
Definition: fevoices.h:65
Voice * prev
Definition: fevoices.h:62
Voice * feInitStdin(Voice *pp)
Definition: fevoices.cc:670
void myyoldbuffer(void *oldb)
Definition: scanner.cc:2304
#define omFree(addr)
Definition: omAllocDecl.h:261

◆ feInitStdin()

Voice * feInitStdin ( Voice pp)

Definition at line 670 of file fevoices.cc.

671{
672 Voice *p = new Voice;
673 p->files = stdin;
674 p->sw = (isatty(STDIN_FILENO)) ? BI_stdin : BI_file;
675 if ((pp!=NULL) && (pp->sw==BI_stdin) && (pp->files==stdin))
676 {
677 p->files=freopen("/dev/tty","r",stdin);
678 //stdin=p->files;
679 if (p->files==NULL)
680 {
681 p->files = stdin;
682 p->sw = BI_file;
683 }
684 else
685 p->sw = BI_stdin;
686 }
687 p->filename = omStrDup("STDIN");
688 p->start_lineno = 1;
690 omMarkAsStaticAddr(p->filename);
691 return p;
692}
CanonicalForm FACTORY_PUBLIC pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition: cf_gcd.cc:676
#define STDIN_FILENO
Definition: fevoices.cc:668
#define omStrDup(s)
Definition: omAllocDecl.h:263
void omMarkAsStaticAddr(void *addr)

◆ monitor()

void monitor ( void *  F,
int  mode 
)

Definition at line 68 of file febase.cc.

69{
70 if (feProt)
71 {
72 fclose(feProtFile);
73 feProt = 0;
74 }
75 if (F!=NULL)
76 {
77 feProtFile = (FILE *)F;
78 feProt = mode;
79 }
80}
VAR int feProt
Definition: reporter.cc:56
VAR FILE * feProtFile
Definition: reporter.cc:57

◆ myynewbuffer()

void * myynewbuffer ( )

Definition at line 2297 of file scanner.cc.

2298{
2299 void * oldb = YY_CURRENT_BUFFER;
2301 return oldb;
2302}
void yy_switch_to_buffer(YY_BUFFER_STATE new_buffer)
Definition: scanner.cc:1879
YY_BUFFER_STATE yy_create_buffer(FILE *file, int size)
Definition: scanner.cc:1922
#define YY_CURRENT_BUFFER
Definition: scanner.cc:208
#define YY_BUF_SIZE
Definition: scanner.cc:98

◆ myyoldbuffer()

void myyoldbuffer ( void *  oldb)

Definition at line 2304 of file scanner.cc.

2305{
2307 yy_switch_to_buffer((YY_BUFFER_STATE)oldb);
2308 //yy_flush_buffer((YY_BUFFER_STATE)oldb);
2309}
void yy_delete_buffer(YY_BUFFER_STATE b)
Definition: scanner.cc:1953

◆ newBuffer()

void newBuffer ( char *  s,
feBufferTypes  t,
procinfo pname = NULL,
int  start_lineno = 0 
)

Definition at line 164 of file fevoices.cc.

165{
167 //Print(":Buffer%d(%s):%s(%x)\n",
168 // t,BT_name[t],pname,currentVoice);
169 if (pi!=NULL)
170 {
171 long l=strlen(pi->procname);
172 if (pi->libname!=NULL) l+=strlen(pi->libname);
173 currentVoice->filename = (char *)omAlloc(l+3);
174 *currentVoice->filename='\0';
175 if (pi->libname!=NULL) strcat(currentVoice->filename,pi->libname);
176 strcat(currentVoice->filename,"::");
177 strcat(currentVoice->filename,pi->procname);
178 currentVoice->pi = pi;
179 }
180 else
181 {
183 {
186 }
187 else
188 {
190 currentVoice->pi = pi;
191 }
192 }
195 currentVoice->typ = t;
196 switch (t)
197 {
198 case BT_execute:
199 yylineno-=2;
200 break;
201 case BT_proc:
202 case BT_example:
204 yylineno = lineno+1;
205 break;
206 case BT_if:
207 case BT_else:
208 case BT_break:
210 break;
211 //case BT_file:
212 default:
213 yylineno = 1;
214 break;
215 }
216 //Print("start body (%s) at line %d\n",BT_name[t],yylineno);
218 //printf("start buffer typ %d\n",t);
219 //Voice *p=currentVoice;
220 //PrintS("-----------------\ncurr:");
221 //do
222 //{
223 //Print("voice fn:%s\n",p->filename);
224 //p=p->prev;
225 //}
226 //while (p!=NULL);
227 //PrintS("----------------\n");
228}
int l
Definition: cfEzgcd.cc:100
void Next()
Definition: fevoices.cc:92
procinfo * pi
Definition: fevoices.h:64
const CanonicalForm int s
Definition: facAbsFact.cc:51
VAR int yy_blocklineno
Definition: fevoices.cc:46
void * myynewbuffer()
Definition: scanner.cc:2297
#define pi
Definition: libparse.cc:1145
#define omAlloc(size)
Definition: omAllocDecl.h:210

◆ newFile()

BOOLEAN newFile ( char *  fname)

Definition at line 127 of file fevoices.cc.

128{
130 //Print(":File%d(%s):%s(%x)\n",
131 // currentVoice->typ,BT_name[currentVoice->typ],fname,currentVoice);
134 if (strcmp(fname,"STDIN") == 0)
135 {
136 currentVoice->files = stdin;
139 }
140 else
141 {
142 currentVoice->sw = BI_file; /* needed by exitVoice below */
143 currentVoice->files = feFopen(fname,"r",NULL,TRUE);
144 if (currentVoice->files==NULL)
145 {
146 exitVoice();
147 return TRUE;
148 }
150 }
152 //Voice *p=currentVoice;
153 //PrintS("-----------------\ncurr:");
154 //do
155 //{
156 //Print("voice fn:%s\n",p->filename);
157 //p=p->prev;
158 //}
159 //while (p!=NULL);
160 //PrintS("----------------\n");
161 return FALSE;
162}
FILE * feFopen(const char *path, const char *mode, char *where, short useWerror, short path_only)
Definition: feFopen.cc:47

◆ VoiceBackTrack()

void VoiceBackTrack ( )

Definition at line 75 of file fevoices.cc.

76{
78 while (p->prev!=NULL)
79 {
80 p=p->prev;
81 char *s=p->filename;
82 if (s==NULL)
83 PrintS("-- called from ? --\n");
84 else
85 Print("-- called from %s --\n",s);
86 }
87}
#define Print
Definition: emacs.cc:80
void PrintS(const char *s)
Definition: reporter.cc:284

◆ VoiceLine()

int VoiceLine ( )

Definition at line 64 of file fevoices.cc.

65{
66 if ((currentVoice!=NULL)
69 return -1;
70}

◆ VoiceName()

const char * VoiceName ( )

Definition at line 56 of file fevoices.cc.

57{
58 if ((currentVoice!=NULL)
60 return currentVoice->filename;
61 return sNoName_fe;
62}
const char sNoName_fe[]
Definition: fevoices.cc:55

Variable Documentation

◆ currentVoice

EXTERN_VAR Voice* currentVoice

Definition at line 92 of file fevoices.h.

◆ my_yylinebuf

EXTERN_VAR char my_yylinebuf[80]

Definition at line 46 of file fevoices.h.

◆ sNoName_fe

const char sNoName_fe[]
extern

Definition at line 55 of file fevoices.cc.

◆ yylineno

EXTERN_VAR int yylineno

Definition at line 45 of file fevoices.h.