r348: fix linefeed problem
[ctsim.git] / include / pol.h
index 1d149896801205c8621c6fe971ecaaf0bb70644f..f8f44e5f263636375b472bb9ddf6990bc49a6ef8 100644 (file)
@@ -2,7 +2,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: pol.h,v 1.10 2000/12/29 20:11:42 kevin Exp $
+**  $Id: pol.h,v 1.11 2001/01/02 16:02:12 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
 ******************************************************************************/
 #ifndef __H_POL
 #define __H_POL
-\r
-#include "hashtable.h"\r
-#include <stack>\r
+
+#include "hashtable.h"
+#include <stack>
 
 class POL {
   
   public:
     
-    // codes for pol_usefile \r
-    enum {\r
-      P_USE_STR = 1,           // use string as input source \r
-      P_USE_FILE,                // use file as input source \r
-    };\r
-\r
-  \r
+    // codes for pol_usefile 
+    enum {
+      P_USE_STR = 1,           // use string as input source 
+      P_USE_FILE,                // use file as input source 
+    };
+
+  
     POL();
     ~POL();
     
@@ -57,157 +57,157 @@ class POL {
     int get_inputline (FILE *fp);
     void set_inputline (const char* const line);
     
-\r
-  enum {\r
-    MAXTOK = 200,              // maximum length of a token \r
-      MAXLINE = 1024,       // maximum line length\r
-      MAXIDENT = 20,\r
-      MAXSKIPWORD = 20,\r
-      MAXSKIPCHAR = 20,\r
-      MIN_INT = -2000000000,\r
-      MAX_INT =  2000000000,\r
-  };\r
-  \r
-  // token types \r
-  enum {\r
-    TT_STRING = 1,  // string token \r
-      TT_INT,         // integer token \r
-      TT_REAL,                 // floating point token \r
-      TT_ALPHA,                // alphabetic token \r
-      TT_ALPNUM,               // alphanumeric token \r
-      TT_NUMALPHA,\r
-      TT_SPECLCHAR,\r
-      TT_EOF,         // end of file reached \r
-      TT_ERROR,       // error in token, caused by call to wrong type of token reader \r
-      TT_BLANK,        // white space token.  pol_tok() skips these \r
-      TT_USERTOK,     // user defined token \r
-  };\r
-\r
-  \r
-private:\r
-  \r
-  // codes for pol_int and pol_float \r
-  // if in reject catagory, get new number from terminal \r
-  enum {\r
-    P_FLTINT = 1,       // get a real or integer number \r
-      P_BFLTINT,     // get a real or integer number, clip against bounds \r
-      P_CBFLTINT,       // get real or int, reject if outside bounds \r
-      P_FLT,              // get a real number \r
-      P_BFLT,        // get a real, clip against bounds \r
-      P_CBFLT,       // get a floating, reject if outside bounds \r
-      P_INT,         // get a integer number \r
-      P_BINT,        // get a integer, clip against bounds \r
-      P_CBINT,       // get a integer, reject if outside bounds \r
-  };\r
-  \r
-#define LETTER   'a'\r
-#define DIGIT    '0'\r
-  \r
-  \r
-//  typedef std::map<std::string,int> KeywordCodeList;\r
-  \r
-  struct token_st {\r
-    int ready;                         // TRUE if token is ready \r
-  //  std::string tokstr;      // token string \r
-    char tokstr[MAXTOK+1];\r
-    int type;                            // type of token 'TT_' \r
-    int code;                            // holds code for user defined tokens \r
-    double fnum;                       // real value of token \r
-    int inum;                      // integer value of token \r
-  };\r
-  typedef struct token_st TOKEN;\r
-  struct token_st token;                               // current token \r
-   \r
-  // Tables words stored with install() & found with lookup() \r
-  KeywordCodeHashTable skiptable;              // words to ignore and skip \r
-  KeywordCodeHashTable cmdtable;               // pol parameter commands \r
-  KeywordCodeHashTable usertable;              // user defined symbols \r
-  \r
-  struct metachar {\r
-    char eoc;          /* end of command character */\r
-    char str;          /* string delimiter */\r
-    char com;          /* comment character */\r
-    char cmd;          /* pol parameter command character */\r
-    char prg;          /* program load character */\r
-    char con;          /* continuation across newline character */\r
-    char out;          /* character that delimits output to terminal */\r
-    char ter;          /* character indicates insertion of input from terminal */\r
-    char inb;          /* input from graphics device */\r
-  } meta;\r
-  \r
-  \r
-  char m_szSkipChars [MAXSKIPCHAR]; // characters to skip\r
-  bool m_bTrace;\r
-  bool m_bNewlineIsEOC;\r
-  \r
-  struct KeywordCodeList {\r
-    char *keyword;\r
-    int  code;\r
-  };\r
-  \r
-  static const struct KeywordCodeList cmdlist[];\r
-  static const unsigned int NUMCMD;\r
-  \r
-  // Internal codes for pol commands \r
-  enum {\r
-    PC_EOC = 1,\r
-      PC_STR,\r
-      PC_COM,\r
-      PC_CMD,\r
-      PC_PRG,\r
-      PC_CON,  \r
-      PC_OUT,\r
-      PC_TER,\r
-      PC_INB,     \r
-      PC_NL_EOC,\r
-      PC_NL_NEOC,\r
-      PC_TRON,\r
-      PC_TROFF,\r
-      PC_FILE,\r
-      PC_DUMP,\r
-  };\r
-  \r
-  enum {\r
-    INPUT_STREAM = 1,\r
-    INPUT_FILE,\r
-    INPUT_STRING,\r
-  };\r
-\r
-  int m_iInputType;\r
-  std::istream* m_pInputStream;\r
-  FILE* m_pInputFile;\r
-  char* m_pszInputString;\r
-\r
-  enum {\r
-    MAXFILE = 8,\r
-  };\r
-  \r
-  int currentf;                /* pointer to current fp */\r
-  FILE *filep[MAXFILE];                /* == NULL for string input */\r
-  char *fname[MAXFILE];                /* pointer to filename */\r
-  \r
-  char inputline[MAXLINE];             /* current input line */\r
-  int lineptr;                 /* current position in inputline */\r
-  \r
-  std::stack<int> m_stackPushBackInput;\r
-\r
-  bool skipSingleToken (char term[]);\r
-  int tok (struct token_st *token);\r
-  void dumptok (struct token_st *token);\r
-  \r
-  \r
-  int getpol_tok (struct token_st *token);\r
-  int getcmd ();\r
-  int gettok (TOKEN *tok);\r
-  void getblank (char *s, int toksiz);\r
-  int getalpha (char *s, int toksiz);\r
-  void getquote (char *qs, int toksiz);\r
-  void getescape (char *s, int delim, int toksiz);\r
-  int getnumber (char str[], int strsize, double *fnum, int *inum);\r
-  void eatline ();\r
-  int type (int c);\r
-  int getch (FILE *fp);\r
-  \r
+
+  enum {
+    MAXTOK = 200,              // maximum length of a token 
+      MAXLINE = 1024,       // maximum line length
+      MAXIDENT = 20,
+      MAXSKIPWORD = 20,
+      MAXSKIPCHAR = 20,
+      MIN_INT = -2000000000,
+      MAX_INT =  2000000000,
+  };
+  
+  // token types 
+  enum {
+    TT_STRING = 1,  // string token 
+      TT_INT,         // integer token 
+      TT_REAL,                 // floating point token 
+      TT_ALPHA,                // alphabetic token 
+      TT_ALPNUM,               // alphanumeric token 
+      TT_NUMALPHA,
+      TT_SPECLCHAR,
+      TT_EOF,         // end of file reached 
+      TT_ERROR,       // error in token, caused by call to wrong type of token reader 
+      TT_BLANK,        // white space token.  pol_tok() skips these 
+      TT_USERTOK,     // user defined token 
+  };
+
+  
+private:
+  
+  // codes for pol_int and pol_float 
+  // if in reject catagory, get new number from terminal 
+  enum {
+    P_FLTINT = 1,       // get a real or integer number 
+      P_BFLTINT,     // get a real or integer number, clip against bounds 
+      P_CBFLTINT,       // get real or int, reject if outside bounds 
+      P_FLT,              // get a real number 
+      P_BFLT,        // get a real, clip against bounds 
+      P_CBFLT,       // get a floating, reject if outside bounds 
+      P_INT,         // get a integer number 
+      P_BINT,        // get a integer, clip against bounds 
+      P_CBINT,       // get a integer, reject if outside bounds 
+  };
+  
+#define LETTER   'a'
+#define DIGIT    '0'
+  
+  
+//  typedef std::map<std::string,int> KeywordCodeList;
+  
+  struct token_st {
+    int ready;                         // TRUE if token is ready 
+  //  std::string tokstr;      // token string 
+    char tokstr[MAXTOK+1];
+    int type;                            // type of token 'TT_' 
+    int code;                            // holds code for user defined tokens 
+    double fnum;                       // real value of token 
+    int inum;                      // integer value of token 
+  };
+  typedef struct token_st TOKEN;
+  struct token_st token;                               // current token 
+   
+  // Tables words stored with install() & found with lookup() 
+  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 */
+    char str;          /* string delimiter */
+    char com;          /* comment character */
+    char cmd;          /* pol parameter command character */
+    char prg;          /* program load character */
+    char con;          /* continuation across newline character */
+    char out;          /* character that delimits output to terminal */
+    char ter;          /* character indicates insertion of input from terminal */
+    char inb;          /* input from graphics device */
+  } meta;
+  
+  
+  char m_szSkipChars [MAXSKIPCHAR]; // characters to skip
+  bool m_bTrace;
+  bool m_bNewlineIsEOC;
+  
+  struct KeywordCodeList {
+    char *keyword;
+    int  code;
+  };
+  
+  static const struct KeywordCodeList cmdlist[];
+  static const unsigned int NUMCMD;
+  
+  // Internal codes for pol commands 
+  enum {
+    PC_EOC = 1,
+      PC_STR,
+      PC_COM,
+      PC_CMD,
+      PC_PRG,
+      PC_CON,  
+      PC_OUT,
+      PC_TER,
+      PC_INB,     
+      PC_NL_EOC,
+      PC_NL_NEOC,
+      PC_TRON,
+      PC_TROFF,
+      PC_FILE,
+      PC_DUMP,
+  };
+  
+  enum {
+    INPUT_STREAM = 1,
+    INPUT_FILE,
+    INPUT_STRING,
+  };
+
+  int m_iInputType;
+  std::istream* m_pInputStream;
+  FILE* m_pInputFile;
+  char* m_pszInputString;
+
+  enum {
+    MAXFILE = 8,
+  };
+  
+  int currentf;                /* pointer to current fp */
+  FILE *filep[MAXFILE];                /* == NULL for string input */
+  char *fname[MAXFILE];                /* pointer to filename */
+  
+  char inputline[MAXLINE];             /* current input line */
+  int lineptr;                 /* current position in inputline */
+  
+  std::stack<int> m_stackPushBackInput;
+
+  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 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);
+  int getnumber (char str[], int strsize, double *fnum, int *inum);
+  void eatline ();
+  int type (int c);
+  int getch (FILE *fp);
+  
 };
 
 #endif