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

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

Definition at line 233 of file fevoices.cc.

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

Definition at line 338 of file fevoices.cc.

339 {
340  //printf("exitVoice: %d(%s),(%x)\n",
341  // currentVoice->typ,BT_name[currentVoice->typ], currentVoice);
342  //{
343  //Voice *p=currentVoice;
344  //Print("-----------------\ncurr:");
345  //do
346  //{
347  //Print("voice fn:%s\n",p->filename);
348  //p=p->prev;
349  //}
350  //while (p!=NULL);
351  //Print("----------------\n");
352  //}
353  if (currentVoice!=NULL)
354  {
355  if (currentVoice->oldb!=NULL)
356  {
359  }
361  {
363  }
364  if (currentVoice->prev!=NULL)
365  {
366  //printf("exitVoice typ %d(%s)\n",
367  // currentVoice->typ,BT_name[currentVoice->typ]);
368  if (currentVoice->typ==BT_if)
369  {
370  currentVoice->prev->ifsw=2;
371  }
372  else
373  {
374  currentVoice->prev->ifsw=0;
375  }
376  if ((currentVoice->sw == BI_file)
377  && (currentVoice->files!=NULL))
378  {
379  fclose(currentVoice->files);
380  }
381  if (currentVoice->filename!=NULL)
382  {
385  }
386  if (currentVoice->buffer!=NULL)
387  {
390  }
393  }
395  delete currentVoice;
396  currentVoice=p;
397  }
398  return currentVoice==NULL;
399 }
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:651
#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:57
FILE * files
Definition: fevoices.h:66
feBufferInputs sw
Definition: fevoices.h:73
Voice* feInitStdin ( Voice pp)

Definition at line 651 of file fevoices.cc.

652 {
653  Voice *p = new Voice;
654  p->files = stdin;
655  p->sw = (isatty(STDIN_FILENO)) ? BI_stdin : BI_file;
656  if ((pp!=NULL) && (pp->files==stdin))
657  {
658  p->files=freopen("/dev/tty","r",stdin);
659  //stdin=p->files;
660  p->sw = BI_stdin;
661  }
662  p->filename = omStrDup("STDIN");
663  p->start_lineno = 1;
666  return p;
667 }
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:649
#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 171 of file fevoices.cc.

172 {
173  currentVoice->Next();
174  //Print(":Buffer%d(%s):%s(%x)\n",
175  // t,BT_name[t],pname,currentVoice);
176  if (pi!=NULL)
177  {
178  long l=strlen(pi->procname);
179  if (pi->libname!=NULL) l+=strlen(pi->libname);
180  currentVoice->filename = (char *)omAlloc(l+3);
181  *currentVoice->filename='\0';
182  if (pi->libname!=NULL) strcat(currentVoice->filename,pi->libname);
183  strcat(currentVoice->filename,"::");
184  strcat(currentVoice->filename,pi->procname);
185  currentVoice->pi = pi;
186  }
187  else
188  {
191  }
192  currentVoice->buffer = s;
194  currentVoice->typ = t;
195  switch (t)
196  {
197  case BT_execute:
198  yylineno-=2;
199  break;
200  case BT_proc:
201  case BT_example:
203  yylineno = lineno+1;
204  break;
205  case BT_if:
206  case BT_else:
207  case BT_break:
209  break;
210  //case BT_file:
211  default:
212  yylineno = 1;
213  break;
214  }
215  //Print("start body (%s) at line %d\n",BT_name[t],yylineno);
217  //printf("start buffer typ %d\n",t);
218  //Voice *p=currentVoice;
219  //Print("-----------------\ncurr:");
220  //do
221  //{
222  //Print("voice fn:%s\n",p->filename);
223  //p=p->prev;
224  //}
225  //while (p!=NULL);
226  //Print("----------------\n");
227 }
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:94
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:56
#define NULL
Definition: omList.c:10
Voice * currentVoice
Definition: fevoices.cc:57
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 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  if (f!=NULL)
146  currentVoice->files = f;
147  else
148  {
149  currentVoice->files = feFopen(fname,"r",NULL,TRUE);
150  if (currentVoice->files==NULL)
151  {
152  exitVoice();
153  return TRUE;
154  }
155  }
157  }
159  //Voice *p=currentVoice;
160  //Print("-----------------\ncurr:");
161  //do
162  //{
163  //Print("voice fn:%s\n",p->filename);
164  //p=p->prev;
165  //}
166  //while (p!=NULL);
167  //Print("----------------\n");
168  return FALSE;
169 }
int yylineno
Definition: febase.cc:45
void Next()
Definition: fevoices.cc:94
#define FALSE
Definition: auxiliary.h:140
char * filename
Definition: fevoices.h:62
#define TRUE
Definition: auxiliary.h:144
int start_lineno
Definition: fevoices.h:71
BOOLEAN exitVoice()
Definition: fevoices.cc:338
FILE * feFopen(const char *path, const char *mode, char *where, short useWerror, short path_only)
Definition: feFopen.cc:46
FILE * f
Definition: checklibs.c:7
#define NULL
Definition: omList.c:10
Voice * currentVoice
Definition: fevoices.cc:57
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 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 }
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:57
const char* VoiceName ( )

Definition at line 66 of file fevoices.cc.

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

Variable Documentation

Voice* currentVoice

Definition at line 57 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.