1 /*****************************************************************************
2 ** This is part of the CTSim program
3 ** Copyright (C) 1983-2000 Kevin Rosenberg
5 ** $Id: pol.h,v 1.6 2000/12/25 21:54:26 kevin Exp $
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.
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.
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 ******************************************************************************/
24 // codes for pol_usefile
26 P_USE_STR = 1, // use string as input source
27 P_USE_FILE, // use file as input source
\r
30 // codes for pol_int and pol_float
31 // if in reject catagory, get new number from terminal
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
48 #define MAXTOK 200 /* maximum length of a token */
51 #define MAXSKIPWORD 20
52 #define MAXSKIPCHAR 20
54 #define MIN_INT -32768
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
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
80 typedef struct symlist SYMBOL;
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
91 typedef struct token_st TOKEN;
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);
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);