X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=include%2Fpol.h;h=262cccbc1c93aa557ac4374d66733c04db7e7e58;hp=7ac752595ec83979195bc31d836c8073ccf4501b;hb=df761d2b3cac3d347f4ef0f9f69e88d3bb66b2fa;hpb=65732cc5d8dbf867ed56a021c07c5636cea93b5a diff --git a/include/pol.h b/include/pol.h index 7ac7525..262cccb 100644 --- a/include/pol.h +++ b/include/pol.h @@ -2,7 +2,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: pol.h,v 1.7 2000/12/27 03:16:02 kevin Exp $ +** $Id: pol.h,v 1.8 2000/12/27 20:09:19 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -19,34 +19,36 @@ ******************************************************************************/ #ifndef __H_POL #define __H_POL - + +#include "hashtable.h" + class POL { public: - // codes for pol_usefile - enum { - P_USE_STR = 1, // use string as input source + // codes for pol_usefile + enum { + P_USE_STR = 1, // use string as input source P_USE_FILE, // use file as input source - }; + }; - POL(); + POL(); ~POL(); void init (); - void skpword (char *w); - void skpchar (char *s); - int installKeyword (char *str, int code); - int word (char *search, int nlet); - int usertok (char *str, int *code); - int string (char *str); - int integer (int *n, int typecode, int boundcode, int bb1, int bb2); - bool readfloat (double *n, double typecode, double boundcode, double bb1, double bb2); - int skip (); + void addSkipWord (const char const *w); + void addSkipChar (int c); + void addKeyword (const char* const str, int code); + bool readWord (char *search, int nlet); + bool readUserToken (char *str, int *code); + bool readString (char *str); + bool readInteger (int *n, int typecode, bool boundcode, int bb1, int bb2); + bool readFloat (double *n, double typecode, bool boundcode, double bb1, double bb2); + bool skipTokens (); void reader (); - void gettext (char *str, int lim); + bool readText (char *str, int lim); void usefile (int source, char *fn); void closefile (); int lookchar (); @@ -104,13 +106,6 @@ private: // typedef std::map KeywordCodeList; - struct symlist { - char *name; - int code; - struct symlist *next; - }; - typedef struct symlist SYMBOL; - struct token_st { int ready; // TRUE if token is ready // std::string tokstr; // token string @@ -121,17 +116,12 @@ private: int inum; // integer value of token }; typedef struct token_st TOKEN; - - struct token_st token; // current token - enum { - HASHSIZE = 100, - }; - + // Tables words stored with install() & found with lookup() - SYMBOL *skiptable[HASHSIZE]; // words to ignore and skip - SYMBOL *cmdtable[HASHSIZE]; // pol parameter commands - SYMBOL *usertable[HASHSIZE]; // user defined symbols + KeywordCodeHashTable skiptable; // words to ignore and skip + KeywordCodeHashTable cmdtable; // pol parameter commands + KeywordCodeHashTable usertable; // user defined symbols struct metachar { char eoc; /* end of command character */ @@ -146,14 +136,9 @@ private: } meta; - // current pol state - struct pol_st { - char skipchars[MAXSKIPCHAR]; // characters to skip - int nl_eoc; // TRUE if newline character ends a command - int trace; // TRUE if trace is on - }; - - struct pol_st pol; + char m_szSkipChars [MAXSKIPCHAR]; // characters to skip + bool m_bTrace; + bool m_bNewlineIsEOC; struct KeywordCodeList { char *keyword; @@ -161,7 +146,7 @@ private: }; static const struct KeywordCodeList cmdlist[]; - static const int NUMCMD; + static const unsigned int NUMCMD; // Internal codes for pol commands enum { @@ -199,27 +184,22 @@ private: int bp; // pointer to next free position int buf[BUFSIZE]; // pushed back input characters - int skiptok(char term[]); - int tok(struct token_st *token); - void dumptok(struct token_st *token); + bool skipSingleToken (char term[]); + int tok (struct token_st *token); + void dumptok (struct token_st *token); - int getpol_tok(struct token_st *token); - int getcmd(); + int getpol_tok (struct token_st *token); + int getcmd (); int gettok (TOKEN *tok); - void getblank(char *s, int toksiz); - int getalpha(char *s, int toksiz); - void getquote(char *qs, int toksiz); - void getescape(char *s, int delim, int toksiz); + void getblank (char *s, int toksiz); + int getalpha (char *s, int toksiz); + void getquote (char *qs, int toksiz); + void getescape (char *s, int delim, int toksiz); int getnumber (char str[], int strsize, double *fnum, int *inum); - void eatline(); - int type(int c); - void inittable(SYMBOL *table[]); - void freetable(SYMBOL *table[]); - int hash(char *s); - SYMBOL *lookup(SYMBOL *table[], char *s); - SYMBOL *install(SYMBOL *table[], char *s, int def); - int getch(FILE *fp); + void eatline (); + int type (int c); + int getch (FILE *fp); };