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,
31  BI_buffer,
32  BI_file
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 304 of file fevoices.cc.

305 {
306  //printf("contBuffer: %d(%s),(%x)\n",
307  // typ,BT_name[typ], currentVoice);
308  if (typ == BT_break) // valid inside for, while. may skip if, else
309  {
310  // first check for valid buffer type
312  loop
313  {
314  if ((p->typ != BT_if)
315  &&(p->typ != BT_else))
316  {
317  if (p->typ == BT_break /*typ*/)
318  {
319  while (p != currentVoice)
320  {
321  exitVoice();
322  }
324  currentVoice->fptr=0;
325  return FALSE;
326  }
327  else return TRUE;
328  }
329  if (p->prev==NULL) break;
330  p=p->prev;
331  }
332  }
333  return TRUE;
334 }
#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:49
BOOLEAN exitVoice()
Definition: fevoices.cc:341
#define NULL
Definition: omList.c:12
#define loop
Definition: structs.h:75

◆ exitBuffer()

BOOLEAN exitBuffer ( feBufferTypes  typ)

Definition at line 236 of file fevoices.cc.

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

◆ exitVoice()

BOOLEAN exitVoice ( )

Definition at line 341 of file fevoices.cc.

342 {
343  //printf("exitVoice: %d(%s),(%x)\n",
344  // currentVoice->typ,BT_name[currentVoice->typ], currentVoice);
345  //{
346  //Voice *p=currentVoice;
347  //PrintS("-----------------\ncurr:");
348  //do
349  //{
350  //Print("voice fn:%s\n",p->filename);
351  //p=p->prev;
352  //}
353  //while (p!=NULL);
354  //PrintS("----------------\n");
355  //}
356  if (currentVoice!=NULL)
357  {
358  if (currentVoice->oldb!=NULL)
359  {
362  }
363  if (currentVoice->filename!=NULL)
364  {
367  }
368  if (currentVoice->buffer!=NULL)
369  {
372  }
373  if ((currentVoice->prev==NULL)
374  &&(currentVoice->sw==BI_file)
375  &&(currentVoice->files!=stdin))
376  {
378  }
379  if (currentVoice->prev!=NULL)
380  {
381  //printf("exitVoice typ %d(%s)\n",
382  // currentVoice->typ,BT_name[currentVoice->typ]);
383  if (currentVoice->typ==BT_if)
384  {
385  currentVoice->prev->ifsw=2;
386  }
387  else
388  {
389  currentVoice->prev->ifsw=0;
390  }
391  if ((currentVoice->sw == BI_file)
392  && (currentVoice->files!=NULL))
393  {
394  fclose(currentVoice->files);
395  }
398  }
400  delete currentVoice;
401  currentVoice=p;
402  }
403  return currentVoice==NULL;
404 }
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:677
void myyoldbuffer(void *oldb)
Definition: scanner.cc:2304
#define omFree(addr)
Definition: omAllocDecl.h:261

◆ feInitStdin()

Voice* feInitStdin ( Voice pp)

Definition at line 677 of file fevoices.cc.

678 {
679  Voice *p = new Voice;
680  p->files = stdin;
681  p->sw = (isatty(STDIN_FILENO)) ? BI_stdin : BI_file;
682  if ((pp!=NULL) && (pp->sw==BI_stdin) && (pp->files==stdin))
683  {
684  p->files=freopen("/dev/tty","r",stdin);
685  //stdin=p->files;
686  if (p->files==NULL)
687  {
688  p->files = stdin;
689  p->sw = BI_file;
690  }
691  else
692  p->sw = BI_stdin;
693  }
694  p->filename = omStrDup("STDIN");
695  p->start_lineno = 1;
697  omMarkAsStaticAddr(p->filename);
698  return p;
699 }
CanonicalForm FACTORY_PUBLIC pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition: cf_gcd.cc:676
#define STDIN_FILENO
Definition: fevoices.cc:675
#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 166 of file fevoices.cc.

167 {
168  currentVoice->Next();
169  //Print(":Buffer%d(%s):%s(%x)\n",
170  // t,BT_name[t],pname,currentVoice);
171  if (pi!=NULL)
172  {
173  long l=strlen(pi->procname);
174  if (pi->libname!=NULL) l+=strlen(pi->libname);
175  currentVoice->filename = (char *)omAlloc(l+3);
176  *currentVoice->filename='\0';
177  if (pi->libname!=NULL) strcat(currentVoice->filename,pi->libname);
178  strcat(currentVoice->filename,"::");
179  strcat(currentVoice->filename,pi->procname);
180  currentVoice->pi = pi;
181  }
182  else
183  {
184  if(currentVoice->prev!=NULL)
185  {
188  }
189  else
190  {
192  currentVoice->pi = pi;
193  }
194  }
195  currentVoice->buffer = s;
197  currentVoice->typ = t;
198  switch (t)
199  {
200  case BT_execute:
201  yylineno-=2;
202  break;
203  case BT_proc:
204  case BT_example:
206  yylineno = lineno+1;
207  break;
208  case BT_if:
209  case BT_else:
210  case BT_break:
212  break;
213  //case BT_file:
214  default:
215  yylineno = 1;
216  break;
217  }
218  //Print("start body (%s) at line %d\n",BT_name[t],yylineno);
220  //printf("start buffer typ %d\n",t);
221  //Voice *p=currentVoice;
222  //PrintS("-----------------\ncurr:");
223  //do
224  //{
225  //Print("voice fn:%s\n",p->filename);
226  //p=p->prev;
227  //}
228  //while (p!=NULL);
229  //PrintS("----------------\n");
230 }
int l
Definition: cfEzgcd.cc:100
void Next()
Definition: fevoices.cc:94
procinfo * pi
Definition: fevoices.h:64
const CanonicalForm int s
Definition: facAbsFact.cc:51
VAR int yy_blocklineno
Definition: fevoices.cc:48
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 129 of file fevoices.cc.

130 {
131  currentVoice->Next();
132  //Print(":File%d(%s):%s(%x)\n",
133  // currentVoice->typ,BT_name[currentVoice->typ],fname,currentVoice);
134  currentVoice->filename = omStrDup(fname);
136  if (strcmp(fname,"STDIN") == 0)
137  {
138  currentVoice->files = stdin;
141  }
142  else
143  {
144  currentVoice->sw = BI_file; /* needed by exitVoice below */
145  currentVoice->files = feFopen(fname,"r",NULL,TRUE);
146  if (currentVoice->files==NULL)
147  {
148  exitVoice();
149  return TRUE;
150  }
152  }
154  //Voice *p=currentVoice;
155  //PrintS("-----------------\ncurr:");
156  //do
157  //{
158  //Print("voice fn:%s\n",p->filename);
159  //p=p->prev;
160  //}
161  //while (p!=NULL);
162  //PrintS("----------------\n");
163  return FALSE;
164 }
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 77 of file fevoices.cc.

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

◆ VoiceLine()

int VoiceLine ( )

Definition at line 66 of file fevoices.cc.

67 {
68  if ((currentVoice!=NULL)
69  && (currentVoice->curr_lineno>=0))
70  return currentVoice->curr_lineno;
71  return -1;
72 }

◆ VoiceName()

const char* VoiceName ( )

Definition at line 58 of file fevoices.cc.

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

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 57 of file fevoices.cc.

◆ yylineno

EXTERN_VAR int yylineno

Definition at line 45 of file fevoices.h.