source: git/Singular/febase.h @ cc94b0a

spielwiese
Last change on this file since cc94b0a was cc94b0a, checked in by Hans Schönemann <hannes@…>, 26 years ago
Tue Mar 31 10:47:06 MET DST 1998 hannes * feread.cc: fixed handling of empty history * clapsing.cc: fixed gcd(0,..) and gcd(..,0) -> pOne() * febase.h/febase.inc: renaming of scanner variables ( yy_blocklineno, yy_noeof) * febase.inc: increased speed in feReadLine * minor changes in scanner/grammar/iparith.cc (example) git-svn-id: file:///usr/local/Singular/svn/trunk@1291 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • 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,v 1.9 1998-03-31 09:00:43 Singular Exp $ */
7/*
8* ABSTRACT
9*/
10#include <stdio.h>
11#include <string.h>
12#include "structs.h"
13
14extern char*  feErrors;
15extern FILE*  feProtFile;
16extern FILE*  feFilePending; /*temp. storage for grammar.y */
17extern char   fe_promptstr[];
18extern int    si_echo, printlevel;
19extern int    pagelength, colmax;
20extern int    yy_blocklineno;
21extern int    yy_noeof;
22extern char   prompt_char;
23#ifdef HAVE_TCL
24extern BOOLEAN tclmode;
25#endif
26extern BOOLEAN errorreported;
27extern BOOLEAN fe_use_fgets;
28extern BOOLEAN feBatch;
29extern BOOLEAN feProt;
30
31#define PROT_NONE 0
32#define PROT_I    1
33#define PROT_O    2
34#define PROT_IO   3
35
36/* the C-part: */
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41void   Werror(char *fmt, ...);
42void   WerrorS(char *s);
43
44#ifdef __cplusplus
45}
46/* the C++-part: */
47
48enum   feBufferTypes
49{
50  BT_none  = 0,  // entry level
51  BT_break = 1,  // while, for
52  BT_proc,       // proc
53  BT_example,    // example
54  BT_file,       // <"file"
55  BT_execute,    // execute
56  BT_if,         // if
57  BT_else        // else
58};
59
60enum   feBufferInputs
61{
62  BI_stdin = 1,
63  BI_buffer,
64  BI_file
65};
66
67FILE *  feFopen(char *path, char *mode, char *where=NULL, int useWerror=FALSE);
68void    fePause(void);
69void    Print(char* fmt, ...);
70void    PrintS(char* s);
71void     PrintLn();
72void    PrintTCLS(char c, char * s);
73#ifndef macintosh
74inline void PrintTCL(char c, int l,char *s)
75{
76#ifdef HAVE_TCL
77  if (s!=NULL) printf("%c:%d:%s\n",c,l,s);
78  else         printf("%c:%d:\n",c,l);
79  fflush(stdout);
80#endif
81}
82#endif
83
84char *  StringAppend(char *fmt, ...);
85char *  StringAppendS(char *s);
86char *  StringSet(char *fmt, ...);
87char *  StringSetS(char* s);
88const  char * VoiceName();
89void    VoiceBackTrack();
90void    WarnS(char *s);
91void    Warn(char *fmt, ...);
92BOOLEAN contBuffer(feBufferTypes typ);
93char *  eati(char *s, int *i);
94BOOLEAN exitBuffer(feBufferTypes typ);
95BOOLEAN exitVoice();
96#define mflush() fflush(stdout)
97void    monitor(char* s,int mode);
98BOOLEAN newFile(char* fname, FILE *f=NULL);
99void    newBuffer(char* s, feBufferTypes t, procinfo *pname = NULL, int start_lineno = 0);
100void *  myynewbuffer();
101void    myyoldbuffer(void * oldb);
102
103/* assume(x) -- a handy macro for assumptions */
104#ifdef NDEBUG
105/* empty macro, if NDEBUG */
106#define assume(x) ((void*) 0)
107#else /* ! NDEBUG */
108#define assume(x) _assume(x, __FILE__, __LINE__)
109#define _assume(x, f, l)                                        \
110do                                                              \
111{                                                               \
112  if (! (x))                                                    \
113  {                                                             \
114    Warn("Internal assume violation: file %s line %d\n", f, l); \
115  }                                                             \
116}                                                               \
117while (0)
118#endif /* NDEBUG */
119
120class Voice
121{
122  public:
123    Voice  * next;
124    Voice  * prev;
125    char   * filename;    // file name or proc name
126    procinfo * pi;        // proc info
127    void   * oldb;        // internal scanner buffer
128    int    start_lineno;  // lineno, to restore in recursion
129    int    curr_lineno;   // current lineno
130    feBufferInputs   sw;  // BI_stdin: read from STDIN
131                          // BI_buffer: buffer
132                          // BI_file: files
133    char   ifsw;          // if-switch:
134            /*1 ifsw==0: no if statement, else is invalid
135            *       ==1: if (0) processed, execute else
136            *       ==2: if (1) processed, else allowed but not executed
137            */
138    feBufferTypes   typ;  // buffer type: see BT_..
139    // for files only:
140    FILE * files;         // file handle
141    // for buffers only:
142    char * buffer;        // buffer pointer
143    long   fptr;          // current position in buffer
144
145  Voice() { memset(this,0,sizeof(*this));}
146  feBufferTypes Typ();
147  void Next();
148} ;
149
150extern Voice  *currentVoice;
151
152Voice * feInitStdin();
153
154/* feread.cc: */
155#ifdef HAVE_FEREAD
156  void fe_set_input_mode (void);
157  void fe_temp_set (void);
158  void fe_temp_reset (void);
159  char * fe_fgets_stdin(char *s, int size);
160  #ifndef MSDOS
161    #ifdef HAVE_ATEXIT
162      void fe_reset_input_mode (void);
163    #else
164      void fe_reset_input_mode (int i, void *v);
165    #endif
166  #else
167    #define fe_reset_input_mode()
168  #endif
169#else
170  #ifdef HAVE_READLINE
171    void fe_set_input_mode (void);
172    void fe_reset_input_mode (void);
173    char * fe_fgets_stdin_rl(char *pr,char *s, int size);
174    #define fe_fgets_stdin(A,B) fe_fgets_stdin_rl(fe_promptstr,A,B)
175  #else
176    #define fe_fgets_stdin(A,B) fgets(A,B,stdin)
177  #endif
178#endif
179#endif
180#endif
Note: See TracBrowser for help on using the repository browser.