[c6474a] | 1 | #ifndef FEBASE_H |
---|
| 2 | #define FEBASE_H |
---|
| 3 | /**************************************** |
---|
| 4 | * * Computer Algebra System SINGULAR * |
---|
| 5 | * ****************************************/ |
---|
| 6 | /* |
---|
| 7 | * * ABSTRACT: basic i/o |
---|
| 8 | * */ |
---|
| 9 | |
---|
| 10 | #include <reporter/reporter.h> |
---|
[88071a] | 11 | |
---|
[2c889f] | 12 | #include <resources/feResource.h> |
---|
[88071a] | 13 | |
---|
[c6474a] | 14 | #include <kernel/structs.h> |
---|
| 15 | |
---|
| 16 | enum feBufferTypes |
---|
| 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 | }; |
---|
| 27 | |
---|
| 28 | enum feBufferInputs |
---|
| 29 | { |
---|
| 30 | BI_stdin = 1, |
---|
| 31 | BI_buffer, |
---|
| 32 | BI_file |
---|
| 33 | }; |
---|
| 34 | enum noeof_t |
---|
| 35 | { |
---|
| 36 | noeof_brace = 1, |
---|
| 37 | noeof_asstring, |
---|
| 38 | noeof_block, |
---|
| 39 | noeof_bracket, |
---|
| 40 | noeof_comment, |
---|
| 41 | noeof_procname, |
---|
| 42 | noeof_string |
---|
| 43 | }; /* for scanner.l */ |
---|
| 44 | |
---|
| 45 | extern int myynest; |
---|
| 46 | extern int yylineno; |
---|
| 47 | extern char my_yylinebuf[80]; |
---|
[74d48c] | 48 | extern char prompt_char; /*1 either '>' or '.'*/ |
---|
| 49 | extern int si_echo; |
---|
[cb1a06] | 50 | extern int printlevel; |
---|
[c6474a] | 51 | |
---|
| 52 | #ifdef __cplusplus |
---|
| 53 | |
---|
| 54 | /* the C++-part: */ |
---|
| 55 | |
---|
| 56 | typedef enum { LANG_NONE, LANG_TOP, LANG_SINGULAR, LANG_C, LANG_MAX} language_defs; |
---|
| 57 | // LANG_TOP : Toplevel package only |
---|
| 58 | // LANG_SINGULAR: |
---|
| 59 | // LANG_C : |
---|
| 60 | // |
---|
| 61 | |
---|
| 62 | class proc_singular |
---|
| 63 | { |
---|
| 64 | public: |
---|
| 65 | long proc_start; // position where proc is starting |
---|
| 66 | long def_end; // position where proc header is ending |
---|
| 67 | long help_start; // position where help is starting |
---|
| 68 | long help_end; // position where help is starting |
---|
| 69 | long body_start; // position where proc-body is starting |
---|
| 70 | long body_end; // position where proc-body is ending |
---|
| 71 | long example_start; // position where example is starting |
---|
| 72 | long proc_end; // position where proc is ending |
---|
| 73 | int proc_lineno; |
---|
| 74 | int body_lineno; |
---|
| 75 | int example_lineno; |
---|
| 76 | char *body; |
---|
| 77 | long help_chksum; |
---|
| 78 | }; |
---|
| 79 | |
---|
| 80 | struct proc_object |
---|
| 81 | { |
---|
| 82 | //public: |
---|
| 83 | BOOLEAN (*function)(leftv res, leftv v); |
---|
| 84 | }; |
---|
| 85 | union uprocinfodata |
---|
| 86 | { |
---|
| 87 | public: |
---|
| 88 | proc_singular s; // data of Singular-procedure |
---|
| 89 | struct proc_object o; // pointer to binary-function |
---|
| 90 | }; |
---|
| 91 | |
---|
| 92 | typedef union uprocinfodata procinfodata; |
---|
| 93 | |
---|
| 94 | class procinfo; |
---|
| 95 | typedef procinfo * procinfov; |
---|
| 96 | |
---|
| 97 | class procinfo |
---|
| 98 | { |
---|
| 99 | public: |
---|
| 100 | char *libname; |
---|
| 101 | char *procname; |
---|
| 102 | package pack; |
---|
| 103 | language_defs language; |
---|
| 104 | short ref; |
---|
| 105 | char is_static; // if set, proc not accessible for user |
---|
| 106 | char trace_flag; |
---|
| 107 | procinfodata data; |
---|
| 108 | }; |
---|
| 109 | |
---|
| 110 | class Voice |
---|
| 111 | { |
---|
| 112 | public: |
---|
| 113 | Voice * next; |
---|
| 114 | Voice * prev; |
---|
| 115 | char * filename; // file name or proc name |
---|
| 116 | procinfo * pi; // proc info |
---|
| 117 | void * oldb; // internal scanner buffer |
---|
| 118 | // for files only: |
---|
| 119 | FILE * files; // file handle |
---|
| 120 | // for buffers only: |
---|
| 121 | char * buffer; // buffer pointer |
---|
| 122 | long fptr; // current position in buffer |
---|
| 123 | |
---|
| 124 | int start_lineno; // lineno, to restore in recursion |
---|
| 125 | int curr_lineno; // current lineno |
---|
| 126 | feBufferInputs sw; // BI_stdin: read from STDIN |
---|
| 127 | // BI_buffer: buffer |
---|
| 128 | // BI_file: files |
---|
| 129 | char ifsw; // if-switch: |
---|
| 130 | /*1 ifsw==0: no if statement, else is invalid |
---|
| 131 | * ==1: if (0) processed, execute else |
---|
| 132 | * ==2: if (1) processed, else allowed but not executed |
---|
| 133 | */ |
---|
| 134 | feBufferTypes typ; // buffer type: see BT_.. |
---|
| 135 | |
---|
| 136 | Voice() { memset(this,0,sizeof(*this));} |
---|
| 137 | feBufferTypes Typ(); |
---|
| 138 | void Next(); |
---|
| 139 | } ; |
---|
| 140 | |
---|
| 141 | extern Voice *currentVoice; |
---|
| 142 | |
---|
| 143 | Voice * feInitStdin(Voice *pp); |
---|
| 144 | |
---|
| 145 | /* feread.cc: */ |
---|
| 146 | |
---|
| 147 | /* the interface for reading: */ |
---|
| 148 | extern char * (*fe_fgets_stdin)(const char *pr,char *s, int size); |
---|
| 149 | |
---|
| 150 | #ifdef HAVE_DYN_RL |
---|
| 151 | char * fe_fgets_stdin_drl(const char *pr,char *s, int size); |
---|
| 152 | #endif |
---|
| 153 | |
---|
| 154 | extern "C" void fe_reset_input_mode(); |
---|
| 155 | |
---|
| 156 | extern "C" { |
---|
| 157 | #ifndef HAVE_ATEXIT |
---|
| 158 | void fe_reset_fe (int i, void *v); |
---|
| 159 | #else |
---|
| 160 | void fe_reset_fe (void); |
---|
| 161 | #endif |
---|
| 162 | } |
---|
| 163 | |
---|
| 164 | /* possible implementations: */ |
---|
| 165 | extern "C" |
---|
| 166 | { |
---|
| 167 | /* readline, linked in: */ |
---|
| 168 | char * fe_fgets_stdin_rl(const char *pr,char *s, int size); |
---|
| 169 | |
---|
| 170 | /* emulated readline: */ |
---|
| 171 | char * fe_fgets_stdin_emu(const char *pr,char *s, int size); |
---|
| 172 | |
---|
| 173 | /* fgets: */ |
---|
| 174 | char * fe_fgets(const char *pr,char *s, int size); |
---|
| 175 | |
---|
| 176 | /* dummy (for batch mode): */ |
---|
| 177 | char * fe_fgets_dummy(const char *pr,char *s, int size); |
---|
| 178 | |
---|
| 179 | } |
---|
| 180 | const char * VoiceName(); |
---|
| 181 | void VoiceBackTrack(); |
---|
| 182 | BOOLEAN contBuffer(feBufferTypes typ); |
---|
| 183 | const char * eati(const char *s, int *i); |
---|
| 184 | BOOLEAN exitBuffer(feBufferTypes typ); |
---|
| 185 | BOOLEAN exitVoice(); |
---|
| 186 | void monitor(void *F, int mode); /* FILE*, int */ |
---|
| 187 | BOOLEAN newFile(char* fname, FILE *f=NULL); |
---|
| 188 | void newBuffer(char* s, feBufferTypes t, procinfo *pname = NULL, int start_lineno = 0); |
---|
| 189 | void * myynewbuffer(); |
---|
| 190 | void myyoldbuffer(void * oldb); |
---|
[35aab3] | 191 | |
---|
[c6474a] | 192 | #endif |
---|
[9d53d0] | 193 | #endif |
---|
[f323dd1] | 194 | |
---|