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, FILE *f=NULL)
 
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]
 
VoicecurrentVoice
 

Enumeration Type Documentation

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

BOOLEAN contBuffer ( feBufferTypes  typ)

Definition at line 299 of file fevoices.cc.

300 {
301  //printf("contBuffer: %d(%s),(%x)\n",
302  // typ,BT_name[typ], currentVoice);
303  if (typ == BT_break) // valid inside for, while. may skip if, else
304  {
305  // first check for valid buffer type
307  loop
308  {
309  if ((p->typ != BT_if)
310  &&(p->typ != BT_else))
311  {
312  if (p->typ == BT_break /*typ*/)
313  {
314  while (p != currentVoice)
315  {
316  exitVoice();
317  }
319  currentVoice->fptr=0;
320  return FALSE;
321  }
322  else return TRUE;
323  }
324  if (p->prev==NULL) break;
325  p=p->prev;
326  }
327  }
328  return TRUE;
329 }
long fptr
Definition: fevoices.h:69
int yylineno
Definition: febase.cc:45
loop
Definition: myNF.cc:98
#define FALSE
Definition: auxiliary.h:140
return P p
Definition: myNF.cc:203
#define TRUE
Definition: auxiliary.h:144
Definition: fevoices.h:57
int start_lineno
Definition: fevoices.h:71
Definition: fevoices.h:24
BOOLEAN exitVoice()
Definition: fevoices.cc:336
feBufferTypes typ
Definition: fevoices.h:81
Voice * prev
Definition: fevoices.h:61
#define NULL
Definition: omList.c:10
Voice * currentVoice
Definition: fevoices.cc:55
BOOLEAN exitBuffer ( feBufferTypes  typ)

Definition at line 231 of file fevoices.cc.

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

Definition at line 336 of file fevoices.cc.

337 {
338  //printf("exitVoice: %d(%s),(%x)\n",
339  // currentVoice->typ,BT_name[currentVoice->typ], currentVoice);
340  //{
341  //Voice *p=currentVoice;
342  //Print("-----------------\ncurr:");
343  //do
344  //{
345  //Print("voice fn:%s\n",p->filename);
346  //p=p->prev;
347  //}
348  //while (p!=NULL);
349  //Print("----------------\n");
350  //}
351  if (currentVoice!=NULL)
352  {
353  if (currentVoice->oldb!=NULL)
354  {
357  }
359  {
361  }
362  if (currentVoice->prev!=NULL)
363  {
364  //printf("exitVoice typ %d(%s)\n",
365  // currentVoice->typ,BT_name[currentVoice->typ]);
366  if (currentVoice->typ==BT_if)
367  {
368  currentVoice->prev->ifsw=2;
369  }
370  else
371  {
372  currentVoice->prev->ifsw=0;
373  }
374  if ((currentVoice->sw == BI_file)
375  && (currentVoice->files!=NULL))
376  {
377  fclose(currentVoice->files);
378  }
379  if (currentVoice->filename!=NULL)
380  {
383  }
384  if (currentVoice->buffer!=NULL)
385  {
388  }
391  }
393  delete currentVoice;
394  currentVoice=p;
395  }
396  return currentVoice==NULL;
397 }
int yylineno
Definition: febase.cc:45
char * buffer
Definition: fevoices.h:68
return P p
Definition: myNF.cc:203
char * filename
Definition: fevoices.h:62
void * ADDRESS
Definition: auxiliary.h:161
Definition: fevoices.h:57
Voice * next
Definition: fevoices.h:60
int curr_lineno
Definition: fevoices.h:72
char ifsw
Definition: fevoices.h:76
Definition: fevoices.h:24
Voice * feInitStdin(Voice *pp)
Definition: fevoices.cc:635
#define omFree(addr)
Definition: omAllocDecl.h:261
feBufferTypes typ
Definition: fevoices.h:81
Voice * prev
Definition: fevoices.h:61
void * oldb
Definition: fevoices.h:64
void myyoldbuffer(void *oldb)
Definition: scanner.cc:2326
#define NULL
Definition: omList.c:10
Voice * currentVoice
Definition: fevoices.cc:55
FILE * files
Definition: fevoices.h:66
feBufferInputs sw
Definition: fevoices.h:73
Voice* feInitStdin ( Voice pp)

Definition at line 635 of file fevoices.cc.

636 {
637  Voice *p = new Voice;
638  p->files = stdin;
639  p->sw = (isatty(STDIN_FILENO)) ? BI_stdin : BI_file;
640  if ((pp!=NULL) && (pp->files==stdin))
641  {
642  p->files=freopen("/dev/tty","r",stdin);
643  //stdin=p->files;
644  p->sw = BI_stdin;
645  }
646  p->filename = omStrDup("STDIN");
647  p->start_lineno = 1;
650  return p;
651 }
return P p
Definition: myNF.cc:203
char * filename
Definition: fevoices.h:62
Definition: fevoices.h:57
int start_lineno
Definition: fevoices.h:71
#define STDIN_FILENO
Definition: fevoices.cc:633
#define NULL
Definition: omList.c:10
FILE * files
Definition: fevoices.h:66
void omMarkAsStaticAddr(void *addr)
feBufferInputs sw
Definition: fevoices.h:73
#define omStrDup(s)
Definition: omAllocDecl.h:263
void monitor ( void *  F,
int  mode 
)

Definition at line 72 of file febase.cc.

73 {
74  if (feProt)
75  {
76  fclose(feProtFile);
77  feProt = 0;
78  }
79  if (F!=NULL)
80  {
81  feProtFile = (FILE *)F;
82  feProt = mode;
83  }
84 }
FILE * feProtFile
Definition: reporter.cc:57
int feProt
Definition: reporter.cc:56
#define NULL
Definition: omList.c:10
void* myynewbuffer ( )

Definition at line 2319 of file scanner.cc.

2320 {
2321  void * oldb = YY_CURRENT_BUFFER;
2323  return oldb;
2324 }
YY_BUFFER_STATE yy_create_buffer(FILE *file, int size)
Definition: scanner.cc:1944
void yy_switch_to_buffer(YY_BUFFER_STATE new_buffer)
Definition: scanner.cc:1901
#define YY_CURRENT_BUFFER
Definition: scanner.cc:207
#define YY_BUF_SIZE
Definition: scanner.cc:97
#define NULL
Definition: omList.c:10
void myyoldbuffer ( void *  oldb)

Definition at line 2326 of file scanner.cc.

2327 {
2329  yy_switch_to_buffer((YY_BUFFER_STATE)oldb);
2330  //yy_flush_buffer((YY_BUFFER_STATE)oldb);
2331 }
void yy_switch_to_buffer(YY_BUFFER_STATE new_buffer)
Definition: scanner.cc:1901
#define YY_CURRENT_BUFFER
Definition: scanner.cc:207
void yy_delete_buffer(YY_BUFFER_STATE b)
Definition: scanner.cc:1975
void newBuffer ( char *  s,
feBufferTypes  t,
procinfo pname = NULL,
int  start_lineno = 0 
)

Definition at line 169 of file fevoices.cc.

170 {
171  currentVoice->Next();
172  //Print(":Buffer%d(%s):%s(%x)\n",
173  // t,BT_name[t],pname,currentVoice);
174  if (pi!=NULL)
175  {
176  long l=strlen(pi->procname);
177  if (pi->libname!=NULL) l+=strlen(pi->libname);
178  currentVoice->filename = (char *)omAlloc(l+3);
179  *currentVoice->filename='\0';
180  if (pi->libname!=NULL) strcat(currentVoice->filename,pi->libname);
181  strcat(currentVoice->filename,"::");
182  strcat(currentVoice->filename,pi->procname);
183  currentVoice->pi = pi;
184  }
185  else
186  {
189  }
190  currentVoice->buffer = s;
192  currentVoice->typ = t;
193  switch (t)
194  {
195  case BT_execute:
196  yylineno-=2;
197  break;
198  case BT_proc:
199  case BT_example:
201  yylineno = lineno+1;
202  break;
203  case BT_if:
204  case BT_else:
205  case BT_break:
207  break;
208  //case BT_file:
209  default:
210  yylineno = 1;
211  break;
212  }
213  //Print("start body (%s) at line %d\n",BT_name[t],yylineno);
215  //printf("start buffer typ %d\n",t);
216  //Voice *p=currentVoice;
217  //Print("-----------------\ncurr:");
218  //do
219  //{
220  //Print("voice fn:%s\n",p->filename);
221  //p=p->prev;
222  //}
223  //while (p!=NULL);
224  //Print("----------------\n");
225 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
int yylineno
Definition: febase.cc:45
char * buffer
Definition: fevoices.h:68
void Next()
Definition: fevoices.cc:92
char * filename
Definition: fevoices.h:62
void * myynewbuffer()
Definition: scanner.cc:2319
#define omAlloc(size)
Definition: omAllocDecl.h:210
int start_lineno
Definition: fevoices.h:71
Definition: fevoices.h:24
procinfo * pi
Definition: fevoices.h:63
feBufferTypes typ
Definition: fevoices.h:81
Voice * prev
Definition: fevoices.h:61
#define pi
Definition: libparse.cc:1143
void * oldb
Definition: fevoices.h:64
int yy_blocklineno
Definition: fevoices.cc:54
#define NULL
Definition: omList.c:10
Voice * currentVoice
Definition: fevoices.cc:55
feBufferInputs sw
Definition: fevoices.h:73
int l
Definition: cfEzgcd.cc:94
#define omStrDup(s)
Definition: omAllocDecl.h:263
BOOLEAN newFile ( char *  fname,
FILE *  f = NULL 
)

Definition at line 127 of file fevoices.cc.

128 {
129  currentVoice->Next();
130  //Print(":File%d(%s):%s(%x)\n",
131  // currentVoice->typ,BT_name[currentVoice->typ],fname,currentVoice);
132  currentVoice->filename = omStrDup(fname);
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  if (f!=NULL)
144  currentVoice->files = f;
145  else
146  {
147  currentVoice->files = feFopen(fname,"r",NULL,TRUE);
148  if (currentVoice->files==NULL)
149  {
150  exitVoice();
151  return TRUE;
152  }
153  }
155  }
157  //Voice *p=currentVoice;
158  //Print("-----------------\ncurr:");
159  //do
160  //{
161  //Print("voice fn:%s\n",p->filename);
162  //p=p->prev;
163  //}
164  //while (p!=NULL);
165  //Print("----------------\n");
166  return FALSE;
167 }
int yylineno
Definition: febase.cc:45
void Next()
Definition: fevoices.cc:92
#define FALSE
Definition: auxiliary.h:140
f
Definition: cfModGcd.cc:4022
char * filename
Definition: fevoices.h:62
#define TRUE
Definition: auxiliary.h:144
int start_lineno
Definition: fevoices.h:71
BOOLEAN exitVoice()
Definition: fevoices.cc:336
FILE * feFopen(const char *path, const char *mode, char *where, short useWerror, short path_only)
Definition: feFopen.cc:46
#define NULL
Definition: omList.c:10
Voice * currentVoice
Definition: fevoices.cc:55
FILE * files
Definition: fevoices.h:66
void omMarkAsStaticAddr(void *addr)
feBufferInputs sw
Definition: fevoices.h:73
#define omStrDup(s)
Definition: omAllocDecl.h:263
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 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define Print
Definition: emacs.cc:83
return P p
Definition: myNF.cc:203
char * filename
Definition: fevoices.h:62
Definition: fevoices.h:57
void PrintS(const char *s)
Definition: reporter.cc:294
Voice * prev
Definition: fevoices.h:61
#define NULL
Definition: omList.c:10
Voice * currentVoice
Definition: fevoices.cc:55
const char* VoiceName ( )

Definition at line 64 of file fevoices.cc.

65 {
66  if ((currentVoice!=NULL)
67  && (currentVoice->filename!=NULL))
68  return currentVoice->filename;
69  return sNoName_fe;
70 }
char * filename
Definition: fevoices.h:62
#define NULL
Definition: omList.c:10
Voice * currentVoice
Definition: fevoices.cc:55
const char * sNoName_fe
Definition: fevoices.cc:63

Variable Documentation

Voice* currentVoice

Definition at line 55 of file fevoices.cc.

char my_yylinebuf[80]

Definition at line 48 of file febase.cc.

int yylineno

Definition at line 45 of file febase.cc.