r313: *** empty log message ***
[ctsim.git] / include / pol.h
1 /*****************************************************************************
2 **  This is part of the CTSim program
3 **  Copyright (C) 1983-2000 Kevin Rosenberg
4 **
5 **  $Id: pol.h,v 1.6 2000/12/25 21:54:26 kevin Exp $
6 **
7 **  This program is free software; you can redistribute it and/or modify
8 **  it under the terms of the GNU General Public License (version 2) as
9 **  published by the Free Software Foundation.
10 **
11 **  This program is distributed in the hope that it will be useful,
12 **  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 **  GNU General Public License for more details.
15 **
16 **  You should have received a copy of the GNU General Public License
17 **  along with this program; if not, write to the Free Software
18 **  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 ******************************************************************************/
20 #ifndef __H_POL
21 #define __H_POL
22 \r
23
24 // codes for pol_usefile 
25 enum {\r
26   P_USE_STR = 1,                // use string as input source 
27   P_USE_FILE,             // use file as input source \r
28 };
29
30 // codes for pol_int and pol_float 
31 // if in reject catagory, get new number from terminal 
32 enum {
33   P_FLTINT = 1,  // get a real or integer number 
34   P_BFLTINT,     // get a real or integer number, clip against bounds 
35   P_CBFLTINT,    // get real or int, reject if outside bounds 
36   P_FLT,           // get a real number 
37   P_BFLT,        // get a real, clip against bounds 
38   P_CBFLT,       // get a floating, reject if outside bounds 
39   P_INT,         // get a integer number 
40   P_BINT,        // get a integer, clip against bounds 
41   P_CBINT,       // get a integer, reject if outside bounds 
42 };\r
43 \r
44
45 #define LETTER   'a'
46 #define DIGIT    '0'
47
48 #define MAXTOK   200            /* maximum length of a token */
49 #define MAXLINE  255
50 #define MAXIDENT  20
51 #define MAXSKIPWORD 20
52 #define MAXSKIPCHAR 20
53
54 #define MIN_INT -32768
55 #define MAX_INT  32767
56 \r
57
58 // token types 
59 enum {
60   TT_STRING = 1,  // string token 
61   TT_INT,         // integer token 
62   TT_REAL,              // floating point token 
63   TT_ALPHA,             // alphabetic token 
64   TT_ALPNUM,            // alphanumeric token 
65   TT_NUMALPHA,
66   TT_SPECLCHAR,
67   TT_EOF,         // end of file reached 
68   TT_ERROR,       // error in token, caused by call to wrong type of token reader 
69   TT_BLANK,        // white space token.  pol_tok() skips these 
70   TT_USERTOK,     // user defined token 
71 };\r
72 \r
73
74 struct symlist {
75         char *name;
76         int code;
77         struct symlist *next;
78 };
79
80 typedef struct symlist SYMBOL;
81
82 struct token_st {
83     int ready;                          // TRUE if token is ready 
84     char tokstr[MAXTOK+1];      // token string 
85     int type;                             // type of token 'TT_' 
86     int code;                             // holds code for user defined tokens 
87     double fnum;                        // real value of token 
88     int inum;                       // integer value of token 
89 };
90
91 typedef struct token_st TOKEN;
92
93 \r
94 /* pol.c */
95 void pol_init (void);
96 void pol_skpword (char *w);
97 void pol_skpchar (char *s);
98 int pol_install (char *str, int code);
99 int pol_word (char *search, int nlet);
100 int pol_usertok (char *str, int *code);
101 int pol_string (char *str);
102 int pol_integer (int *n, int typecode, int boundcode, int bb1, int bb2);
103 int pol_float (double *n, double typecode, double boundcode, double bb1, double bb2);
104 int pol_skip (void);
105 void pol_reader (void);
106 void gettext (char *str, int lim);
107 void pol_usefile (int source, char *fn);
108 void pol_closefile (void);
109 int pol_lookchar (void);
110 int pol_inchar (void);
111 void pol_ungetch (int c);
112 int get_inputline (FILE *fp);
113 void set_inputline (const char* const line);
114
115 #endif\r
116