00001 /* 00002 * RuleSymbol.cpp 00003 * 00004 * Created on: 21 Feb 2014 00005 * Author: hieu 00006 */ 00007 00008 #include "RuleSymbol.h" 00009 00010 using namespace std; 00011 00012 RuleSymbol::RuleSymbol() 00013 { 00014 // TODO Auto-generated constructor stub 00015 00016 } 00017 00018 RuleSymbol::~RuleSymbol() 00019 { 00020 // TODO Auto-generated destructor stub 00021 } 00022 00023 int RuleSymbol::Compare(const RuleSymbol &other) const 00024 { 00025 if (IsNonTerm() != other.IsNonTerm()) { 00026 return IsNonTerm() ? -1 : +1; 00027 } 00028 00029 string str = GetString(); 00030 string otherStr = other.GetString(); 00031 00032 if (str == otherStr) { 00033 return 0; 00034 } else { 00035 return (str < otherStr) ? -1 : +1; 00036 } 00037 }