source: git/kernel/febase.h @ 74d48c

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