source: git/kernel/febase.h @ 64f0ca

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