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

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

◆ 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 };
Definition: fevoices.h:24

◆ 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.

Function Documentation

◆ contBuffer()

BOOLEAN contBuffer ( feBufferTypes  typ)

Definition at line 294 of file fevoices.cc.

295 {
296  //printf("contBuffer: %d(%s),(%x)\n",
297  // typ,BT_name[typ], currentVoice);
298  if (typ == BT_break) // valid inside for, while. may skip if, else
299  {
300  // first check for valid buffer type
302  loop
303  {
304  if ((p->typ != BT_if)
305  &&(p->typ != BT_else))
306  {
307  if (p->typ == BT_break /*typ*/)
308  {
309  while (p != currentVoice)
310  {
311  exitVoice();
312  }
314  currentVoice->fptr=0;
315  return FALSE;
316  }
317  else return TRUE;
318  }
319  if (p->prev==NULL) break;
320  p=p->prev;
321  }
322  }
323  return TRUE;
324 }
long fptr
Definition: fevoices.h:70
#define FALSE
Definition: auxiliary.h:96
#define TRUE
Definition: auxiliary.h:100
Definition: fevoices.h:58
#define loop
Definition: structs.h:80
int start_lineno
Definition: fevoices.h:74
Definition: fevoices.h:24
BOOLEAN exitVoice()
Definition: fevoices.cc:331
VAR int yylineno
Definition: febase.cc:40
feBufferTypes typ
Definition: fevoices.h:84
Voice * prev
Definition: fevoices.h:62
VAR Voice * currentVoice
Definition: fevoices.cc:47
#define NULL
Definition: omList.c:12
int p
Definition: cfModGcd.cc:4019

◆ exitBuffer()

BOOLEAN exitBuffer ( feBufferTypes  typ)

Definition at line 226 of file fevoices.cc.

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

◆ exitVoice()

BOOLEAN exitVoice ( )

Definition at line 331 of file fevoices.cc.

332 {
333  //printf("exitVoice: %d(%s),(%x)\n",
334  // currentVoice->typ,BT_name[currentVoice->typ], currentVoice);
335  //{
336  //Voice *p=currentVoice;
337  //PrintS("-----------------\ncurr:");
338  //do
339  //{
340  //Print("voice fn:%s\n",p->filename);
341  //p=p->prev;
342  //}
343  //while (p!=NULL);
344  //PrintS("----------------\n");
345  //}
346  if (currentVoice!=NULL)
347  {
348  if (currentVoice->oldb!=NULL)
349  {
352  }
353  if (currentVoice->filename!=NULL)
354  {
357  }
358  if (currentVoice->buffer!=NULL)
359  {
362  }
363  if ((currentVoice->prev==NULL)
364  &&(currentVoice->sw==BI_file)
365  &&(currentVoice->files!=stdin))
366  {
368  }
369  if (currentVoice->prev!=NULL)
370  {
371  //printf("exitVoice typ %d(%s)\n",
372  // currentVoice->typ,BT_name[currentVoice->typ]);
373  if (currentVoice->typ==BT_if)
374  {
375  currentVoice->prev->ifsw=2;
376  }
377  else
378  {
379  currentVoice->prev->ifsw=0;
380  }
381  if ((currentVoice->sw == BI_file)
382  && (currentVoice->files!=NULL))
383  {
384  fclose(currentVoice->files);
385  }
388  }
390  delete currentVoice;
391  currentVoice=p;
392  }
393  return currentVoice==NULL;
394 }
char * buffer
Definition: fevoices.h:69
char * filename
Definition: fevoices.h:63
void * ADDRESS
Definition: auxiliary.h:135
Definition: fevoices.h:58
Voice * next
Definition: fevoices.h:61
int curr_lineno
Definition: fevoices.h:75
char ifsw
Definition: fevoices.h:79
Definition: fevoices.h:24
Voice * feInitStdin(Voice *pp)
Definition: fevoices.cc:655
#define omFree(addr)
Definition: omAllocDecl.h:261
VAR int yylineno
Definition: febase.cc:40
feBufferTypes typ
Definition: fevoices.h:84
Voice * prev
Definition: fevoices.h:62
void * oldb
Definition: fevoices.h:65
void myyoldbuffer(void *oldb)
Definition: scanner.cc:2324
VAR Voice * currentVoice
Definition: fevoices.cc:47
#define NULL
Definition: omList.c:12
FILE * files
Definition: fevoices.h:67
int p
Definition: cfModGcd.cc:4019
feBufferInputs sw
Definition: fevoices.h:76

◆ feInitStdin()

Voice* feInitStdin ( Voice pp)

Definition at line 655 of file fevoices.cc.

656 {
657  Voice *p = new Voice;
658  p->files = stdin;
659  p->sw = (isatty(STDIN_FILENO)) ? BI_stdin : BI_file;
660  if ((pp!=NULL) && (pp->sw==BI_stdin) && (pp->files==stdin))
661  {
662  p->files=freopen("/dev/tty","r",stdin);
663  //stdin=p->files;
664  if (p->files==NULL)
665  {
666  p->files = stdin;
667  p->sw = BI_file;
668  }
669  else
670  p->sw = BI_stdin;
671  }
672  p->filename = omStrDup("STDIN");
673  p->start_lineno = 1;
676  return p;
677 }
char * filename
Definition: fevoices.h:63
Definition: fevoices.h:58
int start_lineno
Definition: fevoices.h:74
#define STDIN_FILENO
Definition: fevoices.cc:653
#define NULL
Definition: omList.c:12
FILE * files
Definition: fevoices.h:67
void omMarkAsStaticAddr(void *addr)
int p
Definition: cfModGcd.cc:4019
feBufferInputs sw
Definition: fevoices.h:76
#define omStrDup(s)
Definition: omAllocDecl.h:263

◆ 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 }
VAR FILE * feProtFile
Definition: reporter.cc:57
#define NULL
Definition: omList.c:12
VAR int feProt
Definition: reporter.cc:56

◆ myynewbuffer()

void* myynewbuffer ( )

Definition at line 2317 of file scanner.cc.

2318 {
2319  void * oldb = YY_CURRENT_BUFFER;
2321  return oldb;
2322 }
YY_BUFFER_STATE yy_create_buffer(FILE *file, int size)
Definition: scanner.cc:1942
void yy_switch_to_buffer(YY_BUFFER_STATE new_buffer)
Definition: scanner.cc:1899
#define YY_CURRENT_BUFFER
Definition: scanner.cc:208
#define YY_BUF_SIZE
Definition: scanner.cc:98
#define NULL
Definition: omList.c:12

◆ myyoldbuffer()

void myyoldbuffer ( void *  oldb)

Definition at line 2324 of file scanner.cc.

2325 {
2327  yy_switch_to_buffer((YY_BUFFER_STATE)oldb);
2328  //yy_flush_buffer((YY_BUFFER_STATE)oldb);
2329 }
void yy_switch_to_buffer(YY_BUFFER_STATE new_buffer)
Definition: scanner.cc:1899
#define YY_CURRENT_BUFFER
Definition: scanner.cc:208
void yy_delete_buffer(YY_BUFFER_STATE b)
Definition: scanner.cc:1973

◆ newBuffer()

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

Definition at line 156 of file fevoices.cc.

157 {
158  currentVoice->Next();
159  //Print(":Buffer%d(%s):%s(%x)\n",
160  // t,BT_name[t],pname,currentVoice);
161  if (pi!=NULL)
162  {
163  long l=strlen(pi->procname);
164  if (pi->libname!=NULL) l+=strlen(pi->libname);
165  currentVoice->filename = (char *)omAlloc(l+3);
166  *currentVoice->filename='\0';
167  if (pi->libname!=NULL) strcat(currentVoice->filename,pi->libname);
168  strcat(currentVoice->filename,"::");
169  strcat(currentVoice->filename,pi->procname);
170  currentVoice->pi = pi;
171  }
172  else
173  {
174  if(currentVoice->prev!=NULL)
175  {
178  }
179  else
180  {
182  currentVoice->pi = pi;
183  }
184  }
185  currentVoice->buffer = s;
187  currentVoice->typ = t;
188  switch (t)
189  {
190  case BT_execute:
191  yylineno-=2;
192  break;
193  case BT_proc:
194  case BT_example:
196  yylineno = lineno+1;
197  break;
198  case BT_if:
199  case BT_else:
200  case BT_break:
202  break;
203  //case BT_file:
204  default:
205  yylineno = 1;
206  break;
207  }
208  //Print("start body (%s) at line %d\n",BT_name[t],yylineno);
210  //printf("start buffer typ %d\n",t);
211  //Voice *p=currentVoice;
212  //PrintS("-----------------\ncurr:");
213  //do
214  //{
215  //Print("voice fn:%s\n",p->filename);
216  //p=p->prev;
217  //}
218  //while (p!=NULL);
219  //PrintS("----------------\n");
220 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
char * buffer
Definition: fevoices.h:69
void Next()
Definition: fevoices.cc:84
char * filename
Definition: fevoices.h:63
void * myynewbuffer()
Definition: scanner.cc:2317
#define omAlloc(size)
Definition: omAllocDecl.h:210
int start_lineno
Definition: fevoices.h:74
Definition: fevoices.h:24
procinfo * pi
Definition: fevoices.h:64
VAR int yylineno
Definition: febase.cc:40
VAR int yy_blocklineno
Definition: fevoices.cc:46
feBufferTypes typ
Definition: fevoices.h:84
Voice * prev
Definition: fevoices.h:62
#define pi
Definition: libparse.cc:1145
void * oldb
Definition: fevoices.h:65
VAR Voice * currentVoice
Definition: fevoices.cc:47
#define NULL
Definition: omList.c:12
feBufferInputs sw
Definition: fevoices.h:76
int l
Definition: cfEzgcd.cc:93
#define omStrDup(s)
Definition: omAllocDecl.h:263

◆ newFile()

BOOLEAN newFile ( char *  fname)

Definition at line 119 of file fevoices.cc.

120 {
121  currentVoice->Next();
122  //Print(":File%d(%s):%s(%x)\n",
123  // currentVoice->typ,BT_name[currentVoice->typ],fname,currentVoice);
124  currentVoice->filename = omStrDup(fname);
126  if (strcmp(fname,"STDIN") == 0)
127  {
128  currentVoice->files = stdin;
131  }
132  else
133  {
134  currentVoice->sw = BI_file; /* needed by exitVoice below */
135  currentVoice->files = feFopen(fname,"r",NULL,TRUE);
136  if (currentVoice->files==NULL)
137  {
138  exitVoice();
139  return TRUE;
140  }
142  }
144  //Voice *p=currentVoice;
145  //PrintS("-----------------\ncurr:");
146  //do
147  //{
148  //Print("voice fn:%s\n",p->filename);
149  //p=p->prev;
150  //}
151  //while (p!=NULL);
152  //PrintS("----------------\n");
153  return FALSE;
154 }
void Next()
Definition: fevoices.cc:84
#define FALSE
Definition: auxiliary.h:96
char * filename
Definition: fevoices.h:63
#define TRUE
Definition: auxiliary.h:100
int start_lineno
Definition: fevoices.h:74
BOOLEAN exitVoice()
Definition: fevoices.cc:331
VAR int yylineno
Definition: febase.cc:40
FILE * feFopen(const char *path, const char *mode, char *where, short useWerror, short path_only)
Definition: feFopen.cc:47
VAR Voice * currentVoice
Definition: fevoices.cc:47
#define NULL
Definition: omList.c:12
FILE * files
Definition: fevoices.h:67
void omMarkAsStaticAddr(void *addr)
feBufferInputs sw
Definition: fevoices.h:76
#define omStrDup(s)
Definition: omAllocDecl.h:263

◆ VoiceBackTrack()

void VoiceBackTrack ( )

Definition at line 67 of file fevoices.cc.

68 {
70  while (p->prev!=NULL)
71  {
72  p=p->prev;
73  char *s=p->filename;
74  if (s==NULL)
75  PrintS("-- called from ? --\n");
76  else
77  Print("-- called from %s --\n",s);
78  }
79 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define Print
Definition: emacs.cc:80
char * filename
Definition: fevoices.h:63
Definition: fevoices.h:58
void PrintS(const char *s)
Definition: reporter.cc:284
Voice * prev
Definition: fevoices.h:62
VAR Voice * currentVoice
Definition: fevoices.cc:47
#define NULL
Definition: omList.c:12
int p
Definition: cfModGcd.cc:4019

◆ VoiceName()

const char* VoiceName ( )

Definition at line 56 of file fevoices.cc.

57 {
58  if ((currentVoice!=NULL)
59  && (currentVoice->filename!=NULL))
60  return currentVoice->filename;
61  return sNoName_fe;
62 }
const char sNoName_fe[]
Definition: fevoices.cc:55
char * filename
Definition: fevoices.h:63
VAR Voice * currentVoice
Definition: fevoices.cc:47
#define NULL
Definition: omList.c:12

Variable Documentation

◆ currentVoice

EXTERN_VAR Voice* currentVoice

Definition at line 91 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[]

Definition at line 55 of file fevoices.cc.

◆ yylineno

EXTERN_VAR int yylineno

Definition at line 45 of file fevoices.h.