| Polaris: VDL.h Source File | ||
|
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members
VDL.hGo to the documentation of this file.00001 /// 00002 /// file VDL.h 00003 /// 00004 #ifndef _VDL_H 00005 #define _VDL_H 00006 /// 00007 /// \class VDL 00008 /// \brief a class for reading an ASCII VDL file and generating a BinRep. 00009 /// \defgroup Polaris 00010 /// \ingroup Polaris 00011 /// Base 00012 /// \see VDL.h 00013 /// \see VDL.h 00014 /// \see VDL.cc 00015 /// 00016 /// \endcode 00017 /// \section Overview Overview 00018 /// This classes is intended for reading an ASCII file (or pipe) and 00019 /// generating a BinRep object. 00020 /// 00021 /// \endcode 00022 /// \section Description Description 00023 /// The external communication protocal in Polaris is loosely based upon the 00024 /// internal representation in Delta. Delta is written in SETL and the 00025 /// internal representation is a recursive structure implemented with 00026 /// sets and tuples. The VDL class is designed to change the ASCII 00027 /// representation of a program object into the binary interface 00028 /// representation (BinRep) used internally by Polaris. 00029 /// 00030 #ifdef POLARIS_GNU_PRAGMAS 00031 #pragma interface 00032 #endif 00033 /// 00034 #include "ClassNames.h" 00035 #include <fstream.h> 00036 /// 00037 #include "BinRep.h" 00038 #include "Collection/List.h" 00039 #include "Collection/Map.h" 00040 #include "Expression/Expression.h" 00041 #include "IntElem.h" 00042 #include "Boolean.h" 00043 /// 00044 class VDL { 00045 private: 00046 BinRep *_bs; 00047 ///< the BinRep that will be created. 00048 00049 List<BinRep> _stack; 00050 ///< the Stack of open BinRep constructs. 00051 00052 Map<Expression,IntElem> _map; 00053 ///< the map to remember which Expressions have been used already. 00054 00055 ifstream *ifs; 00056 ///< the input file stream that we are reading from. 00057 00058 char _c; 00059 ///< the last character that was read. 00060 00061 protected: 00062 void _append( BinRep *b ); 00063 ///< Append a BinRep object to the end of the current collection. 00064 int _parse_set(); 00065 ///< parse the file and read a set. 00066 int _parse_tuple(); 00067 ///< parse the file and read a tuple. 00068 int _parse_digit(); 00069 ///< parse the file and read an integer. 00070 int _parse_alpha(); 00071 ///< parse the file and read a token. 00072 int _parse_string(); 00073 ///< parse the file and read a string. 00074 00075 int _parse(); 00076 ///< parse the file and read the data. 00077 00078 public: 00079 VDL(); 00080 ///< create a VDL object. 00081 00082 ~VDL(); 00083 ///< destroy a VDL object. 00084 00085 void open(const char * fname); 00086 ///< open the file and read the ASCII VDL data. 00087 00088 BinRep *read(); 00089 ///< read a BinRep from the input data. 00090 00091 Boolean eof(); 00092 ///< check to see if we are at the end of the file. 00093 00094 void close(); 00095 ///< close the VDL object. 00096 00097 const BinRep *data_ref() const; 00098 ///< return a pointer to the internal data buffer; 00099 00100 BinRep *give_up_data(); 00101 ///< transfer control of the internal data buffer; 00102 00103 00104 00105 int look_up_expr( Expression & ex ); 00106 ///< Look up the Expression in the map and return it's index. 00107 ///< Return -1 is it does not exist. 00108 00109 int install_expr( Expression & ex, int index ); 00110 ///< Install the Expression in the map with the value index. 00111 00112 00113 ///< The following functions are meant for creating a BinRep object 00114 ///< for output. 00115 00116 void start_object(); 00117 ///< Initialize the top-level BinRep obejct. 00118 void end_object(); 00119 ///< Close all outstanding BinRep collections. 00120 00121 void start_set(); 00122 ///< Open a set. 00123 void end_set(); 00124 ///< Close a set. 00125 00126 void start_tuple(); 00127 ///< Open a tuple. 00128 void end_tuple(); 00129 ///< Close a tuple. 00130 00131 void append_omega(); 00132 ///< Add an OM symbol to the current collection. 00133 void append_integer(int value); 00134 ///< Add an integer to the current collection. 00135 void append_boolean(Boolean value); 00136 ///< Add a boolean to the current collection. 00137 void append_string(String &s); 00138 ///< Add a String to the current collection. 00139 void append_string(const char *p); 00140 ///< Add a string to the current collection. 00141 00142 00143 }; 00144 00145 #endif |
||
|