Represents an LR(0) item used in LR automata construction. More...
#include <lr0_item.hpp>
Public Member Functions | |
Lr0Item (std::string antecedent, std::vector< std::string > consequent, std::string epsilon, std::string eol) | |
Constructs an LR(0) item with the dot at position 0. | |
Lr0Item (std::string antecedent, std::vector< std::string > consequent, unsigned int dot, std::string epsilon, std::string eol) | |
Constructs an LR(0) item with a custom dot position. | |
std::string | NextToDot () const |
Returns the symbol immediately after the dot, or empty if the dot is at the end. | |
void | PrintItem () const |
Prints the LR(0) item to the standard output in a human-readable format. | |
std::string | ToString () const |
Converts the item to a string representation, including the dot position. | |
void | AdvanceDot () |
Advances the dot one position to the right. | |
bool | IsComplete () const |
Checks whether the dot has reached the end of the production. | |
bool | operator== (const Lr0Item &other) const |
Equality operator for comparing two LR(0) items. | |
Public Attributes | |
std::string | antecedent_ |
The non-terminal on the left-hand side of the production. | |
std::vector< std::string > | consequent_ |
The sequence of symbols on the right-hand side of the production. | |
std::string | epsilon_ |
The symbol representing the empty string (ε). | |
std::string | eol_ |
The symbol representing end-of-line or end-of-input ($). | |
unsigned int | dot_ = 0 |
The position of the dot (·) in the production. | |
Represents an LR(0) item used in LR automata construction.
An LR(0) item has a production of the form A → α·β, where the dot indicates the current parsing position. This structure tracks the antecedent (left-hand side), consequent (right-hand side), the dot position, and special symbols like EPSILON and end-of-line ($).
Lr0Item::Lr0Item | ( | std::string | antecedent, |
std::vector< std::string > | consequent, | ||
std::string | epsilon, | ||
std::string | eol ) |
Constructs an LR(0) item with the dot at position 0.
antecedent | The left-hand side non-terminal. |
consequent | The right-hand side of the production. |
epsilon | The EPSILON symbol. |
eol | The end-of-line symbol. |
Lr0Item::Lr0Item | ( | std::string | antecedent, |
std::vector< std::string > | consequent, | ||
unsigned int | dot, | ||
std::string | epsilon, | ||
std::string | eol ) |
Constructs an LR(0) item with a custom dot position.
antecedent | The left-hand side non-terminal. |
consequent | The right-hand side of the production. |
dot | The position of the dot. |
epsilon | The EPSILON symbol. |
eol | The end-of-line symbol. |
void Lr0Item::AdvanceDot | ( | ) |
Advances the dot one position to the right.
bool Lr0Item::IsComplete | ( | ) | const |
Checks whether the dot has reached the end of the production.
std::string Lr0Item::NextToDot | ( | ) | const |
Returns the symbol immediately after the dot, or empty if the dot is at the end.
bool Lr0Item::operator== | ( | const Lr0Item & | other | ) | const |
Equality operator for comparing two LR(0) items.
other | The item to compare with. |
void Lr0Item::PrintItem | ( | ) | const |
Prints the LR(0) item to the standard output in a human-readable format.
std::string Lr0Item::ToString | ( | ) | const |
Converts the item to a string representation, including the dot position.
std::string Lr0Item::antecedent_ |
The non-terminal on the left-hand side of the production.
std::vector<std::string> Lr0Item::consequent_ |
The sequence of symbols on the right-hand side of the production.
unsigned int Lr0Item::dot_ = 0 |
The position of the dot (·) in the production.
std::string Lr0Item::eol_ |
The symbol representing end-of-line or end-of-input ($).
std::string Lr0Item::epsilon_ |
The symbol representing the empty string (ε).