00001 /* 00002 * RulePhrase.h 00003 * 00004 * Created on: 26 Feb 2014 00005 * Author: hieu 00006 */ 00007 00008 #ifndef RULEPHRASE_H_ 00009 #define RULEPHRASE_H_ 00010 00011 #include <vector> 00012 #include <cstddef> 00013 #include <iostream> 00014 00015 class RuleSymbol; 00016 00017 // a phrase of terms and non-terms for 1 side of a rule 00018 class RulePhrase 00019 { 00020 public: 00021 typedef std::vector<const RuleSymbol*> Coll; 00022 Coll m_coll; 00023 00024 size_t GetSize() const { 00025 return m_coll.size(); 00026 } 00027 00028 void Add(const RuleSymbol *symbol) { 00029 m_coll.push_back(symbol); 00030 } 00031 00032 const RuleSymbol* operator[](size_t index) const { 00033 return m_coll[index]; 00034 } 00035 00036 const RuleSymbol* Front() const { 00037 return m_coll.front(); 00038 } 00039 const RuleSymbol* Back() const { 00040 return m_coll.back(); 00041 } 00042 00043 int Compare(const RulePhrase &other) const; 00044 00045 void Output(std::ostream &out) const; 00046 std::string Debug() const; 00047 }; 00048 00049 #endif /* RULEPHRASE_H_ */