LR0: Renamed _reducesTo to _transitionsTo

This commit is contained in:
Paul Beckingham 2016-01-07 18:17:21 -05:00
parent bc0a904b50
commit 928597c425
2 changed files with 11 additions and 11 deletions

View file

@ -286,7 +286,7 @@ LR0::Item::Item (const std::vector <std::string>& rule)
: _rule (rule) : _rule (rule)
, _cursor (2) , _cursor (2)
, _grammarRule (-1) , _grammarRule (-1)
, _reducesTo (-1) , _transitionsTo (-1)
{ {
if (_rule.size () == 3 && _rule[2] == "є") if (_rule.size () == 3 && _rule[2] == "є")
_rule.pop_back (); _rule.pop_back ();
@ -297,7 +297,7 @@ bool LR0::Item::operator== (const Item& other)
{ {
if (_cursor != other._cursor || if (_cursor != other._cursor ||
_grammarRule != other._grammarRule || _grammarRule != other._grammarRule ||
_reducesTo != other._reducesTo || _transitionsTo != other._transitionsTo ||
_rule.size () != other._rule.size ()) _rule.size () != other._rule.size ())
return false; return false;
@ -315,9 +315,9 @@ void LR0::Item::setGrammarRuleIndex (const int rule)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void LR0::Item::setReductionRule (const int rule) void LR0::Item::setTransition (const int state)
{ {
_reducesTo = rule; _transitionsTo = state;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -364,8 +364,8 @@ std::string LR0::Item::dump () const
if (_grammarRule != -1) if (_grammarRule != -1)
out << " [g" << _grammarRule << "]"; out << " [g" << _grammarRule << "]";
if (_reducesTo != -1) if (_transitionsTo != -1)
out << " [r" << _reducesTo << "]"; out << " [s" << _transitionsTo << "]";
return out.str (); return out.str ();
} }

View file

@ -47,7 +47,7 @@ public:
Item (const std::vector <std::string>&); Item (const std::vector <std::string>&);
bool operator== (const LR0::Item&); bool operator== (const LR0::Item&);
void setGrammarRuleIndex (const int); void setGrammarRuleIndex (const int);
void setReductionRule (const int); void setTransition (const int);
bool advance (); bool advance ();
bool done () const; bool done () const;
std::string next () const; std::string next () const;
@ -57,7 +57,7 @@ public:
std::vector <std::string> _rule; std::vector <std::string> _rule;
unsigned int _cursor; unsigned int _cursor;
int _grammarRule; int _grammarRule;
int _reducesTo; int _transitionsTo;
}; };
class Closure : public std::vector <Item> class Closure : public std::vector <Item>