/** * interpreter.h * Implemented by Blueprint Technologies, Inc. */ #ifndef _interpreter_h #define _interpreter_h /** * Contains information that's global to the interpreter. */ class Context { }; /** * Declares an abstract Interpret operation that is common * to all nodes in the abstract syntax tree. */ class AbstractExpression { public: virtual void interpret( Context* context ) = 0; }; /** * Implements an Interpret operation associated with terminal * symbols in the grammar. */ class TerminalExpression: public AbstractExpression { public: virtual void interpret( Context* context ) { }; }; /** * One such class is required for every rule in the * grammar. Maintains instance variables of type AbstractExpression * for each of the symbols. */ class NonterminalExpression: public AbstractExpression { private: AbstractExpression* next; public: NonterminalExpression(): AbstractExpression(), next(0) {}; virtual void interpret( Context* context ) { // // Interpret your portion here. // // Call the next interpreter if we have one. if( next ) next -> interpret( context ); }; void setNext( AbstractExpression* next ) { this -> next = next; }; AbstractExpression* getNext() { return next; }; }; #endif