#ifndef GRAMMAR_H #define GRAMMAR_H ///////////////////////////////////////////////////////////////////// // grammar.h - provides detectors for grammatical constructs // // ver 1.2 // // // // Language: Visual C++, ver 7.0 // // Platfrom: Dell Dimension 8100, Windows 2000, SP 2.0 // // Application: Prototype for CSE687 Pr#2, Spring 2003 // // Author: Jim Fawcett, CST 2-187, Syracuse University // // (315) 443-3948, jfawcett@twcny.rr.com // ///////////////////////////////////////////////////////////////////// /* Module Operation: ================= The grammar module provides a set of detector functions that identify gramatical constructs captured by the tokens in a CSemiExp object. Public Interface: ================= CSemiExp se(in); // create a CSemiExp object grammar g(se); // create a grammar object bool b = g.functionDef(); // is a function definition? bool b = g.include(); // is an include statement? */ ///////////////////////////////////////////////////////////////////// // Build Process // ///////////////////////////////////////////////////////////////////// // Required Files: // // grammar.h, grammar.cpp, CppSemiExp.h, CppSemiExp.cpp, // // CppToker.h, CppToker.cpp // // // // Compiler command: // // cl /DTEST_GRAMMAR grammar.cpp display.cpp\ // // CppSemiExp.cpp CppToker.cpp // ///////////////////////////////////////////////////////////////////// /* Maintenance History: ==================== ver 1.2 : 24 Feb 04 - remove registerDefaultFilters() and replaced with individual calls to registerFilter(&aFilter). ver 1.1 : 02/08/04 - several small changes to accomodate using CppSemiExp and CppToker modules instead of Semi and Tok. ver 1.0 : 02/08/03 - first release */ // #include "CppSemiExp.h" namespace Scanner { class grammar { public: grammar(CSemiExp &se); bool include(); bool functionDef(); bool invocation(); bool declar(); private: bool specialKeys(const std::string &s); CSemiExp& _se; // don't copy }; //----< initializes a grammar object with a semiExp >---------- inline grammar::grammar(CSemiExp &se) : _se(se) {} //----< detects #include statements >-------------------------- inline bool grammar::include() { return (_se[0]=="#" && _se[1]=="include"); } } #endif