#ifndef SIMPLESEMIEXP_H #define SIMPLESEMIEXP_H ///////////////////////////////////////////////////////////////// // simpleSemiExp.h - SemiExp extractor // // ver 1.0 // // Language: Visual C++, ver 7.1 // // Platform: Dell Dimension 8300, Windows XP Prof, SP 2 // // Application: CSE687 prototype for project #1, Spring 2005 // // Author: Jim Fawcett, CST 2-187, Syracuse University // // (315) 443-3948, jfawcett@twcny.rr.com // ///////////////////////////////////////////////////////////////// /* * Module Operations * ----------------- * A SemiExpression is a sequence of tokens ending in ";", "{", "}", * or newline if first token is "#". This sequence is designed to * be enough to detect some grammatical construct, like function * definition, without getting tokens that participate in other * constructs. * * Public Interface * ---------------- * istringstream in("set of tokens"); * SimpleToker toker(in); // construct with any stream * SimpleSemiExp semi(toker); // pass toker to semi object * while(semi.good()) // good tests stream state * semi.get(); // extracts sequence of tokens * string tok = semi[1]; // looks at 2nd token in sequence * int pos = semi.find(tok); // looks for tok in sequence * int len = semi.length(); // returns number of tokens * */ /* Build Process * ------------- * Required Files: * SimpleSemiExp.h, SimpleSemiExp.cpp, SimpleToker.h SimpleToker.cpp * Compile Command: * cl /DTEST_SIMPLESEMIEXP SimpleSemiExp.cpp SimpleToker.cpp * * Maintenance History * ------------------- * ver 1.0 : 23 Jan 05 * - first release * */ // #include #include "..\\SimpleToker\\SimpleToker.h" class SimpleSemiExp { public: SimpleSemiExp(SimpleToker &toker); void get(); std::string& operator[](int i); std::string operator[](int i) const; unsigned int length() const; unsigned int find(const std::string &tok) const; std::string last() const; bool good(); private: SimpleToker* pToker; std::vector semi; }; inline unsigned int SimpleSemiExp::length() const { return semi.size(); } inline bool SimpleSemiExp::good() { return pToker->good(); } void show(const SimpleSemiExp &se); #endif