source: git/kernel/febase.h @ 601105

spielwiese
Last change on this file since 601105 was 2c889f, checked in by Oleksandr Motsak <motsak@…>, 11 years ago
Code update corresponding to renaming findexec into resources
  • Property mode set to 100644
File size: 4.6 KB
Line 
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>
11
12#include <resources/feResource.h>
13
14#include <kernel/structs.h>
15
16enum   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
28enum   feBufferInputs
29{
30  BI_stdin = 1,
31  BI_buffer,
32  BI_file
33};
34enum 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
45extern int myynest;
46extern int yylineno;
47extern char     my_yylinebuf[80];
48extern char    prompt_char; /*1 either '>' or '.'*/
49extern int    si_echo;
50extern int    printlevel;
51
52#ifdef __cplusplus
53
54/* the C++-part: */
55
56typedef 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
62class proc_singular
63{
64public:
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
80struct proc_object
81{
82//public:
83  BOOLEAN (*function)(leftv res, leftv v);
84};
85union uprocinfodata
86{
87public:
88  proc_singular  s;        // data of Singular-procedure
89  struct proc_object    o; // pointer to binary-function
90};
91
92typedef union uprocinfodata procinfodata;
93
94class procinfo;
95typedef procinfo *         procinfov;
96
97class procinfo
98{
99public:
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
110class 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
141extern Voice  *currentVoice;
142
143Voice * feInitStdin(Voice *pp);
144
145/* feread.cc: */
146
147/* the interface for reading: */
148extern  char * (*fe_fgets_stdin)(const char *pr,char *s, int size);
149
150#ifdef HAVE_DYN_RL
151char * fe_fgets_stdin_drl(const char *pr,char *s, int size);
152#endif
153
154extern "C" void fe_reset_input_mode();
155
156extern "C" {
157#ifndef HAVE_ATEXIT
158void fe_reset_fe (int i, void *v);
159#else
160void fe_reset_fe (void);
161#endif
162}
163
164/* possible implementations: */
165extern "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}
180const  char * VoiceName();
181void    VoiceBackTrack();
182BOOLEAN contBuffer(feBufferTypes typ);
183const char *  eati(const char *s, int *i);
184BOOLEAN exitBuffer(feBufferTypes typ);
185BOOLEAN exitVoice();
186void    monitor(void *F, int mode); /* FILE*, int */
187BOOLEAN newFile(char* fname, FILE *f=NULL);
188void    newBuffer(char* s, feBufferTypes t, procinfo *pname = NULL, int start_lineno = 0);
189void *  myynewbuffer();
190void    myyoldbuffer(void * oldb);
191
192#endif
193#endif
194
Note: See TracBrowser for help on using the repository browser.