My Project  debian-1:4.1.1-p2+ds-4build3
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 ()
 
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

int yylineno
 
char my_yylinebuf [80]
 
const char sNoName_fe []
 
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,
31  BI_buffer,
32  BI_file
33 };

◆ 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 };

◆ 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 */

Function Documentation

◆ contBuffer()

BOOLEAN contBuffer ( feBufferTypes  typ)

Definition at line 295 of file fevoices.cc.

296 {
297  //printf("contBuffer: %d(%s),(%x)\n",
298  // typ,BT_name[typ], currentVoice);
299  if (typ == BT_break) // valid inside for, while. may skip if, else
300  {
301  // first check for valid buffer type
303  loop
304  {
305  if ((p->typ != BT_if)
306  &&(p->typ != BT_else))
307  {
308  if (p->typ == BT_break /*typ*/)
309  {
310  while (p != currentVoice)
311  {
312  exitVoice();
313  }
315  currentVoice->fptr=0;
316  return FALSE;
317  }
318  else return TRUE;
319  }
320  if (p->prev==NULL) break;
321  p=p->prev;
322  }
323  }
324  return TRUE;
325 }

◆ exitBuffer()

BOOLEAN exitBuffer ( feBufferTypes  typ)

Definition at line 227 of file fevoices.cc.

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

◆ exitVoice()

BOOLEAN exitVoice ( )

Definition at line 332 of file fevoices.cc.

333 {
334  //printf("exitVoice: %d(%s),(%x)\n",
335  // currentVoice->typ,BT_name[currentVoice->typ], currentVoice);
336  //{
337  //Voice *p=currentVoice;
338  //PrintS("-----------------\ncurr:");
339  //do
340  //{
341  //Print("voice fn:%s\n",p->filename);
342  //p=p->prev;
343  //}
344  //while (p!=NULL);
345  //PrintS("----------------\n");
346  //}
347  if (currentVoice!=NULL)
348  {
349  if (currentVoice->oldb!=NULL)
350  {
353  }
354  if (currentVoice->filename!=NULL)
355  {
358  }
359  if (currentVoice->buffer!=NULL)
360  {
363  }
364  if ((currentVoice->prev==NULL)
365  &&(currentVoice->sw==BI_file)
366  &&(currentVoice->files!=stdin))
367  {
369  }
370  if (currentVoice->prev!=NULL)
371  {
372  //printf("exitVoice typ %d(%s)\n",
373  // currentVoice->typ,BT_name[currentVoice->typ]);
374  if (currentVoice->typ==BT_if)
375  {
376  currentVoice->prev->ifsw=2;
377  }
378  else
379  {
380  currentVoice->prev->ifsw=0;
381  }
382  if ((currentVoice->sw == BI_file)
383  && (currentVoice->files!=NULL))
384  {
385  fclose(currentVoice->files);
386  }
389  }
391  delete currentVoice;
392  currentVoice=p;
393  }
394  return currentVoice==NULL;
395 }

◆ feInitStdin()

Voice* feInitStdin ( Voice pp)

Definition at line 656 of file fevoices.cc.

657 {
658  Voice *p = new Voice;
659  p->files = stdin;
660  p->sw = (isatty(STDIN_FILENO)) ? BI_stdin : BI_file;
661  if ((pp!=NULL) && (pp->sw==BI_stdin) && (pp->files==stdin))
662  {
663  p->files=freopen("/dev/tty","r",stdin);
664  //stdin=p->files;
665  if (p->files==NULL)
666  {
667  p->files = stdin;
668  p->sw = BI_file;
669  }
670  else
671  p->sw = BI_stdin;
672  }
673  p->filename = omStrDup("STDIN");
674  p->start_lineno = 1;
676  omMarkAsStaticAddr(p->filename);
677  return p;
678 }

◆ monitor()

void monitor ( void *  F,
int  mode 
)

Definition at line 67 of file febase.cc.

68 {
69  if (feProt)
70  {
71  fclose(feProtFile);
72  feProt = 0;
73  }
74  if (F!=NULL)
75  {
76  feProtFile = (FILE *)F;
77  feProt = mode;
78  }
79 }

◆ myynewbuffer()

void* myynewbuffer ( )

Definition at line 2316 of file scanner.cc.

2317 {
2318  void * oldb = YY_CURRENT_BUFFER;
2320  return oldb;
2321 }

◆ myyoldbuffer()

void myyoldbuffer ( void *  oldb)

Definition at line 2323 of file scanner.cc.

2324 {
2326  yy_switch_to_buffer((YY_BUFFER_STATE)oldb);
2327  //yy_flush_buffer((YY_BUFFER_STATE)oldb);
2328 }

◆ newBuffer()

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

Definition at line 157 of file fevoices.cc.

158 {
159  currentVoice->Next();
160  //Print(":Buffer%d(%s):%s(%x)\n",
161  // t,BT_name[t],pname,currentVoice);
162  if (pi!=NULL)
163  {
164  long l=strlen(pi->procname);
165  if (pi->libname!=NULL) l+=strlen(pi->libname);
166  currentVoice->filename = (char *)omAlloc(l+3);
167  *currentVoice->filename='\0';
168  if (pi->libname!=NULL) strcat(currentVoice->filename,pi->libname);
169  strcat(currentVoice->filename,"::");
170  strcat(currentVoice->filename,pi->procname);
171  currentVoice->pi = pi;
172  }
173  else
174  {
175  if(currentVoice->prev!=NULL)
176  {
179  }
180  else
181  {
183  currentVoice->pi = pi;
184  }
185  }
186  currentVoice->buffer = s;
188  currentVoice->typ = t;
189  switch (t)
190  {
191  case BT_execute:
192  yylineno-=2;
193  break;
194  case BT_proc:
195  case BT_example:
197  yylineno = lineno+1;
198  break;
199  case BT_if:
200  case BT_else:
201  case BT_break:
203  break;
204  //case BT_file:
205  default:
206  yylineno = 1;
207  break;
208  }
209  //Print("start body (%s) at line %d\n",BT_name[t],yylineno);
211  //printf("start buffer typ %d\n",t);
212  //Voice *p=currentVoice;
213  //PrintS("-----------------\ncurr:");
214  //do
215  //{
216  //Print("voice fn:%s\n",p->filename);
217  //p=p->prev;
218  //}
219  //while (p!=NULL);
220  //PrintS("----------------\n");
221 }

◆ newFile()

BOOLEAN newFile ( char *  fname)

Definition at line 120 of file fevoices.cc.

121 {
122  currentVoice->Next();
123  //Print(":File%d(%s):%s(%x)\n",
124  // currentVoice->typ,BT_name[currentVoice->typ],fname,currentVoice);
125  currentVoice->filename = omStrDup(fname);
127  if (strcmp(fname,"STDIN") == 0)
128  {
129  currentVoice->files = stdin;
132  }
133  else
134  {
135  currentVoice->sw = BI_file; /* needed by exitVoice below */
136  currentVoice->files = feFopen(fname,"r",NULL,TRUE);
137  if (currentVoice->files==NULL)
138  {
139  exitVoice();
140  return TRUE;
141  }
143  }
145  //Voice *p=currentVoice;
146  //PrintS("-----------------\ncurr:");
147  //do
148  //{
149  //Print("voice fn:%s\n",p->filename);
150  //p=p->prev;
151  //}
152  //while (p!=NULL);
153  //PrintS("----------------\n");
154  return FALSE;
155 }

◆ VoiceBackTrack()

void VoiceBackTrack ( )

Definition at line 68 of file fevoices.cc.

69 {
71  while (p->prev!=NULL)
72  {
73  p=p->prev;
74  char *s=p->filename;
75  if (s==NULL)
76  PrintS("-- called from ? --\n");
77  else
78  Print("-- called from %s --\n",s);
79  }
80 }

◆ VoiceName()

const char* VoiceName ( )

Definition at line 57 of file fevoices.cc.

58 {
59  if ((currentVoice!=NULL)
60  && (currentVoice->filename!=NULL))
61  return currentVoice->filename;
62  return sNoName_fe;
63 }

Variable Documentation

◆ currentVoice

Voice* currentVoice

Definition at line 48 of file fevoices.cc.

◆ my_yylinebuf

char my_yylinebuf[80]

Definition at line 43 of file febase.cc.

◆ sNoName_fe

const char sNoName_fe[]

Definition at line 56 of file fevoices.cc.

◆ yylineno

int yylineno

Definition at line 40 of file febase.cc.

feProtFile
FILE * feProtFile
Definition: reporter.cc:57
FALSE
#define FALSE
Definition: auxiliary.h:94
Voice::buffer
char * buffer
Definition: fevoices.h:69
noeof_asstring
@ noeof_asstring
Definition: fevoices.h:37
feFopen
FILE * feFopen(const char *path, const char *mode, char *where, short useWerror, short path_only)
Definition: feFopen.cc:47
omFree
#define omFree(addr)
Definition: omAllocDecl.h:261
BT_none
@ BT_none
Definition: fevoices.h:20
Voice::Next
void Next()
Definition: fevoices.cc:85
BT_execute
@ BT_execute
Definition: fevoices.h:25
ADDRESS
void * ADDRESS
Definition: auxiliary.h:133
noeof_procname
@ noeof_procname
Definition: fevoices.h:41
exitVoice
BOOLEAN exitVoice()
Definition: fevoices.cc:332
BT_proc
@ BT_proc
Definition: fevoices.h:22
Voice::curr_lineno
int curr_lineno
Definition: fevoices.h:75
BT_file
@ BT_file
Definition: fevoices.h:24
yylineno
int yylineno
Definition: febase.cc:40
omStrDup
#define omStrDup(s)
Definition: omAllocDecl.h:263
yy_delete_buffer
void yy_delete_buffer(YY_BUFFER_STATE b)
Definition: scanner.cc:1972
Voice::filename
char * filename
Definition: fevoices.h:63
yy_create_buffer
YY_BUFFER_STATE yy_create_buffer(FILE *file, int size)
Definition: scanner.cc:1941
Voice::ifsw
char ifsw
Definition: fevoices.h:79
noeof_bracket
@ noeof_bracket
Definition: fevoices.h:39
loop
#define loop
Definition: structs.h:78
BT_example
@ BT_example
Definition: fevoices.h:23
myynewbuffer
void * myynewbuffer()
Definition: scanner.cc:2316
pi
#define pi
Definition: libparse.cc:1143
STDIN_FILENO
#define STDIN_FILENO
Definition: fevoices.cc:654
TRUE
#define TRUE
Definition: auxiliary.h:98
BT_else
@ BT_else
Definition: fevoices.h:27
BI_buffer
@ BI_buffer
Definition: fevoices.h:31
PrintS
void PrintS(const char *s)
Definition: reporter.cc:284
Voice::pi
procinfo * pi
Definition: fevoices.h:64
sNoName_fe
const char sNoName_fe[]
Definition: fevoices.cc:56
YY_BUF_SIZE
#define YY_BUF_SIZE
Definition: scanner.cc:97
Voice::typ
feBufferTypes typ
Definition: fevoices.h:84
currentVoice
Voice * currentVoice
Definition: fevoices.cc:48
Voice::next
Voice * next
Definition: fevoices.h:61
Voice::prev
Voice * prev
Definition: fevoices.h:62
omAlloc
#define omAlloc(size)
Definition: omAllocDecl.h:210
BI_stdin
@ BI_stdin
Definition: fevoices.h:30
Voice::start_lineno
int start_lineno
Definition: fevoices.h:74
yy_blocklineno
int yy_blocklineno
Definition: fevoices.cc:47
BT_break
@ BT_break
Definition: fevoices.h:21
noeof_brace
@ noeof_brace
Definition: fevoices.h:36
pp
CanonicalForm pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition: cf_gcd.cc:253
noeof_block
@ noeof_block
Definition: fevoices.h:38
myyoldbuffer
void myyoldbuffer(void *oldb)
Definition: scanner.cc:2323
Voice::oldb
void * oldb
Definition: fevoices.h:65
feInitStdin
Voice * feInitStdin(Voice *pp)
Definition: fevoices.cc:656
Print
#define Print
Definition: emacs.cc:80
omMarkAsStaticAddr
void omMarkAsStaticAddr(void *addr)
Voice
Definition: fevoices.h:59
noeof_string
@ noeof_string
Definition: fevoices.h:42
Voice::files
FILE * files
Definition: fevoices.h:67
NULL
#define NULL
Definition: omList.c:10
l
int l
Definition: cfEzgcd.cc:93
BT_if
@ BT_if
Definition: fevoices.h:26
p
int p
Definition: cfModGcd.cc:4019
s
const CanonicalForm int s
Definition: facAbsFact.cc:55
feProt
int feProt
Definition: reporter.cc:56
yy_switch_to_buffer
void yy_switch_to_buffer(YY_BUFFER_STATE new_buffer)
Definition: scanner.cc:1898
YY_CURRENT_BUFFER
#define YY_CURRENT_BUFFER
Definition: scanner.cc:207
noeof_comment
@ noeof_comment
Definition: fevoices.h:40
BI_file
@ BI_file
Definition: fevoices.h:32
Voice::fptr
long fptr
Definition: fevoices.h:70
Voice::sw
feBufferInputs sw
Definition: fevoices.h:76