blob: 8123602029c68aa8c84381eefff288bbf43b3309 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#pragma once
#include "Nonterminal.h"
#include <vector>
#include <string>
namespace cru::parse {
class CRU_PARSE_API Production : public Object {
public:
Production(Grammar* grammar, std::string name, Nonterminal* left,
std::vector<Symbol*> right);
CRU_DELETE_COPY(Production)
CRU_DELETE_MOVE(Production)
~Production() override;
public:
Grammar* GetGrammar() const { return grammar_; }
std::string GetName() const { return name_; }
void SetName(std::string name) { name_ = std::move(name); }
Nonterminal* GetLeft() const { return left_; }
void SetLeft(Nonterminal* left);
const std::vector<Symbol*>& GetRight() const { return right_; }
void SetRight(std::vector<Symbol*> right);
bool IsLeftRecursion() const {
return !right_.empty() && left_ == right_.front();
}
private:
Grammar* grammar_;
std::string name_;
Nonterminal* left_;
std::vector<Symbol*> right_;
};
} // namespace cru::parse
|