source: git/Singular/febase.h @ f92fa13

spielwiese
Last change on this file since f92fa13 was f92fa13, checked in by Olaf Bachmann <obachman@…>, 26 years ago
1998-03-16 Olaf Bachmann <obachman@mathematik.uni-kl.de> * polys-impl.h: #define COMP_FAST * configure.in,Makefile.in: check for flex -P; increased version number to 1.1.7 1998-03-04 Olaf Bachmann <obachman@mathematik.uni-kl.de> * febase.h: added macro assume() * spSpolyLoop.cc: Automatic generation of SpolyLoops using spSpolyLoop.pl * kstd*.cc: New calling interface to get SpolyLoop * ring.h: Introduced rOrderType_t git-svn-id: file:///usr/local/Singular/svn/trunk@1236 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.8 1998-03-16 14:56:30 obachman 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    blocklineno;
21extern char   prompt_char;
22#ifdef HAVE_TCL
23extern BOOLEAN tclmode;
24#endif
25extern BOOLEAN errorreported;
26extern BOOLEAN fe_use_fgets;
27extern BOOLEAN feBatch;
28extern BOOLEAN feProt;
29
30#define PROT_NONE 0
31#define PROT_I    1
32#define PROT_O    2
33#define PROT_IO   3
34
35/* the C-part: */
36#ifdef __cplusplus
37extern "C" {
38#endif
39
40void   Werror(char *fmt, ...);
41void   WerrorS(char *s);
42
43#ifdef __cplusplus
44}
45/* the C++-part: */
46
47enum   feBufferTypes
48{
49  BT_none  = 0,  // entry level
50  BT_break = 1,  // while, for
51  BT_proc,       // proc
52  BT_example,    // example
53  BT_file,       // <"file"
54  BT_execute,    // execute
55  BT_if,         // if
56  BT_else        // else
57};
58
59enum   feBufferInputs
60{
61  BI_stdin = 1,
62  BI_buffer,
63  BI_file
64};
65
66FILE *  feFopen(char *path, char *mode, char *where=NULL, int useWerror=FALSE);
67void    fePause(void);
68void    Print(char* fmt, ...);
69void    PrintS(char* s);
70void     PrintLn();
71void    PrintTCLS(char c, char * s);
72#ifndef macintosh
73inline void PrintTCL(char c, int l,char *s)
74{
75#ifdef HAVE_TCL
76  if (s!=NULL) printf("%c:%d:%s\n",c,l,s);
77  else         printf("%c:%d:\n",c,l);
78  fflush(stdout);
79#endif
80}
81#endif
82
83char *  StringAppend(char *fmt, ...);
84char *  StringAppendS(char *s);
85char *  StringSet(char *fmt, ...);
86char *  StringSetS(char* s);
87const  char * VoiceName();
88void    VoiceBackTrack();
89void    WarnS(char *s);
90void    Warn(char *fmt, ...);
91BOOLEAN contBuffer(feBufferTypes typ);
92char *  eati(char *s, int *i);
93BOOLEAN exitBuffer(feBufferTypes typ);
94BOOLEAN exitVoice();
95#define mflush() fflush(stdout)
96void    monitor(char* s,int mode);
97BOOLEAN newFile(char* fname, FILE *f=NULL);
98void    newBuffer(char* s, feBufferTypes t, procinfo *pname = NULL, int start_lineno = 0);
99void *  myynewbuffer();
100void    myyoldbuffer(void * oldb);
101
102/* assume(x) -- a handy macro for assumptions */
103#ifdef NDEBUG
104/* empty macro, if NDEBUG */
105#define assume(x) ((void*) 0)
106#else /* ! NDEBUG */
107#define assume(x) _assume(x, __FILE__, __LINE__)
108#define _assume(x, f, l)                                        \
109do                                                              \
110{                                                               \
111  if (! (x))                                                    \
112  {                                                             \
113    Warn("Internal assume violation: file %s line %d\n", f, l); \
114  }                                                             \
115}                                                               \
116while (0)
117#endif /* NDEBUG */
118
119class Voice
120{
121  public:
122    Voice  * next;
123    Voice  * prev;
124    char   * filename;    // file name or proc name
125    procinfo * pi;        // proc info
126    void   * oldb;        // internal scanner buffer
127    int    start_lineno;  // lineno, to restore in recursion
128    int    curr_lineno;   // current lineno
129    feBufferInputs   sw;  // BI_stdin: read from STDIN
130                          // BI_buffer: buffer
131                          // BI_file: files
132    char   ifsw;          // if-switch:
133            /*1 ifsw==0: no if statement, else is invalid
134            *       ==1: if (0) processed, execute else
135            *       ==2: if (1) processed, else allowed but not executed
136            */
137    feBufferTypes   typ;  // buffer type: see BT_..
138    // for files only:
139    FILE * files;         // file handle
140    // for buffers only:
141    char * buffer;        // buffer pointer
142    long   fptr;          // current position in buffer
143
144  Voice() { memset(this,0,sizeof(*this));}
145  feBufferTypes Typ();
146  void Next();
147} ;
148
149extern Voice  *currentVoice;
150
151Voice * feInitStdin();
152
153/* feread.cc: */
154#ifdef HAVE_FEREAD
155  void fe_set_input_mode (void);
156  void fe_temp_set (void);
157  void fe_temp_reset (void);
158  char * fe_fgets_stdin(char *s, int size);
159  #ifndef MSDOS
160    #ifdef HAVE_ATEXIT
161      void fe_reset_input_mode (void);
162    #else
163      void fe_reset_input_mode (int i, void *v);
164    #endif
165  #else
166    #define fe_reset_input_mode()
167  #endif
168#else
169  #ifdef HAVE_READLINE
170    void fe_set_input_mode (void);
171    void fe_reset_input_mode (void);
172    char * fe_fgets_stdin_rl(char *pr,char *s, int size);
173    #define fe_fgets_stdin(A,B) fe_fgets_stdin_rl(fe_promptstr,A,B)
174  #else
175    #define fe_fgets_stdin(A,B) fgets(A,B,stdin)
176  #endif
177#endif
178#endif
179#endif
Note: See TracBrowser for help on using the repository browser.