Loading...
Searching...
No Matches
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

Voice * | feInitStdin (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 Voice * | currentVoice

## Enumeration Type Documentation

## feBufferInputs

enum feBufferInputs

Enumerator
BI_stdin |
BI_buffer |
BI_file |

Definition at line 28 of file fevoices.h.

{
BI_stdin = 1,
BI_buffer,
BI_file
};
BI_file
@ BI_file
Definition fevoices.h:32
BI_buffer
@ BI_buffer
Definition fevoices.h:31
BI_stdin
@ BI_stdin
Definition fevoices.h:30

## feBufferTypes

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

{
BT_none = 0, // entry level
BT_break = 1, // while, for
BT_proc, // proc
BT_example, // example
BT_file, // <"file"
BT_execute, // execute
BT_if, // if
BT_else // else
};
BT_none
@ BT_none
Definition fevoices.h:18
BT_else
@ BT_else
Definition fevoices.h:25
BT_if
@ BT_if
Definition fevoices.h:24
BT_break
@ BT_break
Definition fevoices.h:19
BT_example
@ BT_example
Definition fevoices.h:21
BT_execute
@ BT_execute
Definition fevoices.h:23
BT_proc
@ BT_proc
Definition fevoices.h:20
BT_file
@ 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.

{
noeof_brace = 1,
noeof_asstring,
noeof_block,
noeof_bracket,
noeof_comment,
noeof_procname,
noeof_string
}; /* for scanner.l */
noeof_string
@ noeof_string
Definition fevoices.h:42
noeof_brace
@ noeof_brace
Definition fevoices.h:36
noeof_comment
@ noeof_comment
Definition fevoices.h:40
noeof_asstring
@ noeof_asstring
Definition fevoices.h:37
noeof_block
@ noeof_block
Definition fevoices.h:38
noeof_procname
@ noeof_procname
Definition fevoices.h:41
noeof_bracket
@ noeof_bracket
Definition fevoices.h:39

## Function Documentation

## contBuffer()

BOOLEAN contBuffer | ( | feBufferTypes | typ | ) |

Definition at line 304 of file fevoices.cc.

{
//printf("contBuffer: %d(%s),(%x)\n",
// typ,BT_name[typ], currentVoice);
if (typ == BT_break) // valid inside for, while. may skip if, else
{
// first check for valid buffer type
Voice *p=currentVoice;
loop
{
if ((p->typ != BT_if)
&&(p->typ != BT_else))
{
if (p->typ == BT_break /*typ*/)
{
while (p != currentVoice)
{
exitVoice();
}
yylineno = currentVoice->start_lineno;
currentVoice->fptr=0;
return FALSE;
}
else return TRUE;
}
if (p->prev==NULL) break;
p=p->prev;
}
}
return TRUE;
}
TRUE
#define TRUE
Definition auxiliary.h:101
FALSE
#define FALSE
Definition auxiliary.h:97
p
int p
Definition cfModGcd.cc:4086
Voice
Definition fevoices.h:59
yylineno
VAR int yylineno
Definition febase.cc:40
currentVoice
VAR Voice * currentVoice
Definition fevoices.cc:49
exitVoice
BOOLEAN exitVoice()
Definition fevoices.cc:341
NULL
#define NULL
Definition omList.c:12
loop
#define loop
Definition structs.h:71

## exitBuffer()

BOOLEAN exitBuffer | ( | feBufferTypes | typ | ) |

Definition at line 236 of file fevoices.cc.

{
//printf("exitBuffer: %d(%s),(%x)\n",
// typ,BT_name[typ], currentVoice);
//Voice *p=currentVoice;
//PrintS("-----------------\ncurr:");
//do
//{
//Print("voice fn:%s\n",p->filename);
//p=p->prev;
//}
//while (p!=NULL);
//PrintS("----------------\n");
if (typ == BT_break) // valid inside for, while. may skip if, else
{
/*4 first check for valid buffer type, skip if/else*/
Voice *p=currentVoice;
loop
{
if ((p->typ != BT_if)
&&(p->typ != BT_else))
{
if (p->typ == BT_break /*typ*/)
{
while (p != currentVoice)
{
exitVoice();
}
exitVoice();
return FALSE;
}
else return TRUE;
}
if (p->prev==NULL) break;
p=p->prev;
}
/*4 break not inside a for/while: return an error*/
if (/*typ*/ BT_break != currentVoice->typ) return 1;
return exitVoice();
}
if ((typ == BT_proc)
|| (typ == BT_example))
{
Voice *p=currentVoice;
loop
{
if ((p->typ == BT_proc)
|| (p->typ == BT_example))
{
while (p != currentVoice)
{
exitVoice();
}
exitVoice();
return FALSE;
}
if (p->prev==NULL) break;
p=p->prev;
}
}
/*4 return not inside a proc: return an error*/
return TRUE;
}

## exitVoice()

BOOLEAN exitVoice | ( |  | ) |

Definition at line 341 of file fevoices.cc.

{
//printf("exitVoice: %d(%s),(%x)\n",
// currentVoice->typ,BT_name[currentVoice->typ], currentVoice);
//{
//Voice *p=currentVoice;
//PrintS("-----------------\ncurr:");
//do
//{
//Print("voice fn:%s\n",p->filename);
//p=p->prev;
//}
//while (p!=NULL);
//PrintS("----------------\n");
//}
if (currentVoice!=NULL)
{
if (currentVoice->oldb!=NULL)
{
myyoldbuffer(currentVoice->oldb);
currentVoice->oldb=NULL;
}
if (currentVoice->filename!=NULL)
{
omFree((ADDRESS)currentVoice->filename);
currentVoice->filename=NULL;
}
if (currentVoice->buffer!=NULL)
{
omFree((ADDRESS)currentVoice->buffer);
currentVoice->buffer=NULL;
}
if ((currentVoice->prev==NULL)
&&(currentVoice->sw==BI_file)
&&(currentVoice->files!=stdin))
{
currentVoice->prev=feInitStdin(currentVoice);
}
if (currentVoice->prev!=NULL)
{
//printf("exitVoice typ %d(%s)\n",
// currentVoice->typ,BT_name[currentVoice->typ]);
if (currentVoice->typ==BT_if)
{
currentVoice->prev->ifsw=2;
}
else
{
currentVoice->prev->ifsw=0;
}
if ((currentVoice->sw == BI_file)
&& (currentVoice->files!=NULL))
{
fclose(currentVoice->files);
}
yylineno=currentVoice->prev->curr_lineno;
currentVoice->prev->next=NULL;
}
Voice *p=currentVoice->prev;
delete currentVoice;
currentVoice=p;
}
return currentVoice==NULL;
}
ADDRESS
void * ADDRESS
Definition auxiliary.h:120
feInitStdin
Voice * feInitStdin(Voice *pp)
Definition fevoices.cc:677
myyoldbuffer
void myyoldbuffer(void *oldb)
Definition scanner.cc:2304
omFree
#define omFree(addr)
Definition omAllocDecl.h:261

## feInitStdin()

Voice * feInitStdin | ( | Voice * | pp | ) |

Definition at line 677 of file fevoices.cc.

{
Voice *p = new Voice;
p->files = stdin;
p->sw = (isatty(STDIN_FILENO)) ? BI_stdin : BI_file;
if ((pp!=NULL) && (pp->sw==BI_stdin) && (pp->files==stdin))
{
p->files=freopen("/dev/tty","r",stdin);
//stdin=p->files;
if (p->files==NULL)
{
p->files = stdin;
p->sw = BI_file;
}
else
p->sw = BI_stdin;
}
p->filename = omStrDup("STDIN");
p->start_lineno = 1;
omMarkAsStaticAddr(p);
omMarkAsStaticAddr(p->filename);
return p;
}
pp
CanonicalForm FACTORY_PUBLIC pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f ).
Definition cf_gcd.cc:676
STDIN_FILENO
#define STDIN_FILENO
Definition fereadl.c:52
omStrDup
#define omStrDup(s)
Definition omAllocDecl.h:263
omMarkAsStaticAddr
#define omMarkAsStaticAddr(A)
Definition xalloc.h:245

## monitor()

void monitor | ( | void * | F,
|  | int | mode )

Definition at line 68 of file febase.cc.

{
if (feProt)
{
fclose(feProtFile);
feProt = 0;
}
if (F!=NULL)
{
feProtFile = (FILE *)F;
feProt = mode;
}
}
feProt
VAR int feProt
Definition reporter.cc:56
feProtFile
VAR FILE * feProtFile
Definition reporter.cc:57

## myynewbuffer()

void * myynewbuffer | ( |  | ) |

Definition at line 2297 of file scanner.cc.

{
void * oldb = YY_CURRENT_BUFFER;
yy_switch_to_buffer(yy_create_buffer(NULL, YY_BUF_SIZE));
return oldb;
}
yy_switch_to_buffer
#define yy_switch_to_buffer
Definition libparse.cc:10
YY_CURRENT_BUFFER
#define YY_CURRENT_BUFFER
Definition libparse.cc:227
yy_create_buffer
#define yy_create_buffer
Definition libparse.cc:1
YY_BUF_SIZE
#define YY_BUF_SIZE
Definition libparse.cc:117

## myyoldbuffer()

void myyoldbuffer | ( | void * | oldb | ) |

Definition at line 2304 of file scanner.cc.

{
yy_delete_buffer(YY_CURRENT_BUFFER);
yy_switch_to_buffer((YY_BUFFER_STATE)oldb);
//yy_flush_buffer((YY_BUFFER_STATE)oldb);
}
yy_delete_buffer
#define yy_delete_buffer
Definition libparse.cc:2

## newBuffer()

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

Definition at line 166 of file fevoices.cc.

{
currentVoice->Next();
//Print(":Buffer%d(%s):%s(%x)\n",
// t,BT_name[t],pname,currentVoice);
if (pi!=NULL)
{
long l=strlen(pi->procname);
if (pi->libname!=NULL) l+=strlen(pi->libname);
currentVoice->filename = (char *)omAlloc(l+3);
*currentVoice->filename='\0';
if (pi->libname!=NULL) strcat(currentVoice->filename,pi->libname);
strcat(currentVoice->filename,"::");
strcat(currentVoice->filename,pi->procname);
currentVoice->pi = pi;
}
else
{
if(currentVoice->prev!=NULL)
{
currentVoice->filename = omStrDup(currentVoice->prev->filename);
currentVoice->pi = currentVoice->prev->pi;
}
else
{
currentVoice->filename = omStrDup("");
currentVoice->pi = pi;
}
}
currentVoice->buffer = s;
currentVoice->sw = BI_buffer;
currentVoice->typ = t;
switch (t)
{
case BT_execute:
yylineno-=2;
break;
case BT_proc:
case BT_example:
currentVoice->oldb=myynewbuffer();
yylineno = lineno+1;
break;
case BT_if:
case BT_else:
case BT_break:
yylineno = yy_blocklineno-1;
break;
//case BT_file:
default:
yylineno = 1;
break;
}
//Print("start body (%s) at line %d\n",BT_name[t],yylineno);
currentVoice->start_lineno = yylineno;
//printf("start buffer typ %d\n",t);
//Voice *p=currentVoice;
//PrintS("-----------------\ncurr:");
//do
//{
//Print("voice fn:%s\n",p->filename);
//p=p->prev;
//}
//while (p!=NULL);
//PrintS("----------------\n");
}
l
int l
Definition cfEzgcd.cc:100
s
const CanonicalForm int s
Definition facAbsFact.cc:51
myynewbuffer
void * myynewbuffer()
Definition scanner.cc:2297
pi
#define pi
Definition libparse.cc:1145
omAlloc
#define omAlloc(size)
Definition omAllocDecl.h:210
yy_blocklineno
EXTERN_VAR int yy_blocklineno
Definition reporter.h:18

## newFile()

BOOLEAN newFile | ( | char * | fname | ) |

Definition at line 129 of file fevoices.cc.

{
currentVoice->Next();
//Print(":File%d(%s):%s(%x)\n",
// currentVoice->typ,BT_name[currentVoice->typ],fname,currentVoice);
currentVoice->filename = omStrDup(fname);
omMarkAsStaticAddr(currentVoice->filename);
if (strcmp(fname,"STDIN") == 0)
{
currentVoice->files = stdin;
currentVoice->sw = BI_stdin;
currentVoice->start_lineno = 1;
}
else
{
currentVoice->sw = BI_file; /* needed by exitVoice below */
currentVoice->files = feFopen(fname,"r",NULL,TRUE);
if (currentVoice->files==NULL)
{
exitVoice();
return TRUE;
}
currentVoice->start_lineno = 0;
}
yylineno=currentVoice->start_lineno;
//Voice *p=currentVoice;
//PrintS("-----------------\ncurr:");
//do
//{
//Print("voice fn:%s\n",p->filename);
//p=p->prev;
//}
//while (p!=NULL);
//PrintS("----------------\n");
return FALSE;
}
feFopen
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.

{
Voice *p=currentVoice;
while (p->prev!=NULL)
{
p=p->prev;
char *s=p->filename;
if (s==NULL)
PrintS("-- called from ? --\n");
else
Print("-- called from %s:%d --\n",s, p->curr_lineno);
}
}
Print
#define Print
Definition emacs.cc:80
PrintS
void PrintS(const char *s)
Definition reporter.cc:288

## VoiceLine()

int VoiceLine | ( |  | ) |

Definition at line 66 of file fevoices.cc.

{
if ((currentVoice!=NULL)
&& (currentVoice->curr_lineno>=0))
return currentVoice->curr_lineno;
return -1;
}

## VoiceName()

const char * VoiceName | ( |  | ) |

Definition at line 58 of file fevoices.cc.

{
if ((currentVoice!=NULL)
&& (currentVoice->filename!=NULL))
return currentVoice->filename;
return sNoName_fe;
}
sNoName_fe
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.