Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

ObjectFile.h

00001 /*
00002   File: ObjectFile.h
00003 
00004   Copyright(C) C. Kotterink, Computed Graphics
00005 */
00006 #ifndef OBJECTFILE_H
00007 #define OBJECTFILE_H
00008 
00009 #include<Token.h>
00010 #include<TextFile.h>
00011 
00012 #include<map>
00013 #include<stack>
00014 
00019 class ObjectFile
00020 {
00021 public:
00023     static TokenId findKeyword(const string &keyword);
00024 
00026     static TokenId declareKeyword(const string &keyword);
00027 
00029     ObjectFile() : peeked(false) {
00030     }
00031 
00033     ObjectFile(const string &name) : peeked(false) {
00034         open(name);
00035     }
00036 
00038     void open(const string &name);
00039 
00041     bool eof() {
00042         return (file.size() == 1) && file.top().eof();
00043     }
00044 
00046     void error(const string errorString);
00047 
00049     void warning(const string errorString);
00050 
00052     void unexpected(const Token &t);
00053 
00055     void next(Token &token);
00056 
00058     void check(TokenId type, const Token &token);
00059 
00061     Token &peek();
00062 
00064     Token accept(TokenId type);
00065 
00066 protected:
00068     static TokenId lastToken;
00069 
00071     static map<string, TokenId> keywordTable;
00072 
00074     void readToken(Token &token);
00075 
00077     void push(const string &name);
00078 
00080     void pop();
00081 
00083     void getChar();
00084 
00086     void skipSpaces();
00087 
00089     stack<TextFile> file;
00090 
00092     Token peekToken;
00093 
00095     bool peeked;
00096 
00098     int ch;
00099 };
00100 
00106 inline ObjectFile &operator>>(ObjectFile &f, Token &token)
00107 {
00108     f.next(token);
00109     return f;
00110 }
00111 
00117 inline ObjectFile &operator>>(ObjectFile &f, const TokenId token)
00118 {
00119     f.accept(token);
00120     return f;
00121 }
00122 
00123 // Primitive stream operators
00124 
00126 ObjectFile &operator>>(ObjectFile &f, float &d);
00127 
00129 ObjectFile &operator>>(ObjectFile &f, double &d);
00130 
00132 ObjectFile &operator>>(ObjectFile &f, unsigned short &i);
00133 
00135 ObjectFile &operator>>(ObjectFile &f, short &i);
00136 
00138 ObjectFile &operator>>(ObjectFile &f, unsigned int &i);
00139 
00141 ObjectFile &operator>>(ObjectFile &f, int &i);
00142 
00144 ObjectFile &operator>>(ObjectFile &f, string &str);
00145 
00146 #endif

This documentation was generated using doxygen. If you have any comments or additions please mail me.