source: git/kernel/febase.h @ a10fdf

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