aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorYuqian Yang <crupest@crupest.life>2025-10-17 08:44:07 +0800
committerYuqian Yang <crupest@crupest.life>2025-10-17 08:44:07 +0800
commitaa05a34dd5e4a56563cbfeab273785ce0e363089 (patch)
treebc23e1807fcd647d06a971c64cd5d4460a338412 /include
parent3c8d5c8f732239a8b50418be27464e30b9dddeae (diff)
downloadcru-aa05a34dd5e4a56563cbfeab273785ce0e363089.tar.gz
cru-aa05a34dd5e4a56563cbfeab273785ce0e363089.tar.bz2
cru-aa05a34dd5e4a56563cbfeab273785ce0e363089.zip
Parse remove String.
Diffstat (limited to 'include')
-rw-r--r--include/cru/parse/Grammar.h9
-rw-r--r--include/cru/parse/Nonterminal.h2
-rw-r--r--include/cru/parse/Production.h12
-rw-r--r--include/cru/parse/Symbol.h11
-rw-r--r--include/cru/parse/Terminal.h3
-rw-r--r--include/cru/parse/TokenType.h12
6 files changed, 25 insertions, 24 deletions
diff --git a/include/cru/parse/Grammar.h b/include/cru/parse/Grammar.h
index 7dd1eec0..522cc0fd 100644
--- a/include/cru/parse/Grammar.h
+++ b/include/cru/parse/Grammar.h
@@ -1,5 +1,6 @@
#pragma once
#include "Production.h"
+#include "Terminal.h"
#include <unordered_map>
#include <vector>
@@ -17,9 +18,9 @@ class CRU_PARSE_API Grammar : public Object {
public:
void SetStartSymbol(Nonterminal* start_symbol);
- Terminal* CreateTerminal(String name);
- Nonterminal* CreateNonterminal(String name);
- Production* CreateProduction(String name, Nonterminal* left,
+ Terminal* CreateTerminal(std::string name);
+ Nonterminal* CreateNonterminal(std::string name);
+ Production* CreateProduction(std::string name, Nonterminal* left,
std::vector<Symbol*> right);
bool RemoveSymbol(Symbol* symbol);
@@ -50,7 +51,7 @@ class CRU_PARSE_API Grammar : public Object {
void LeftFactor();
public:
- String ProductionsToString() const;
+ std::string ProductionsToString() const;
private:
Nonterminal* start_symbol_ = nullptr;
diff --git a/include/cru/parse/Nonterminal.h b/include/cru/parse/Nonterminal.h
index 0ea15149..21744858 100644
--- a/include/cru/parse/Nonterminal.h
+++ b/include/cru/parse/Nonterminal.h
@@ -4,7 +4,7 @@
namespace cru::parse {
class CRU_PARSE_API Nonterminal : public Symbol {
public:
- Nonterminal(Grammar* grammar, String name);
+ Nonterminal(Grammar* grammar, std::string name);
CRU_DELETE_COPY(Nonterminal)
CRU_DELETE_MOVE(Nonterminal)
diff --git a/include/cru/parse/Production.h b/include/cru/parse/Production.h
index 07bd2962..81236020 100644
--- a/include/cru/parse/Production.h
+++ b/include/cru/parse/Production.h
@@ -1,15 +1,13 @@
#pragma once
-#include "cru/base/String.h"
-
#include "Nonterminal.h"
-#include "Terminal.h"
#include <vector>
+#include <string>
namespace cru::parse {
class CRU_PARSE_API Production : public Object {
public:
- Production(Grammar* grammar, String name, Nonterminal* left,
+ Production(Grammar* grammar, std::string name, Nonterminal* left,
std::vector<Symbol*> right);
CRU_DELETE_COPY(Production)
@@ -20,8 +18,8 @@ class CRU_PARSE_API Production : public Object {
public:
Grammar* GetGrammar() const { return grammar_; }
- String GetName() const { return name_; }
- void SetName(String name) { name_ = std::move(name); }
+ std::string GetName() const { return name_; }
+ void SetName(std::string name) { name_ = std::move(name); }
Nonterminal* GetLeft() const { return left_; }
void SetLeft(Nonterminal* left);
@@ -35,7 +33,7 @@ class CRU_PARSE_API Production : public Object {
private:
Grammar* grammar_;
- String name_;
+ std::string name_;
Nonterminal* left_;
std::vector<Symbol*> right_;
diff --git a/include/cru/parse/Symbol.h b/include/cru/parse/Symbol.h
index 0252b3b7..d40243e7 100644
--- a/include/cru/parse/Symbol.h
+++ b/include/cru/parse/Symbol.h
@@ -1,7 +1,8 @@
#pragma once
#include "Base.h"
-#include "cru/base/String.h"
+#include <cru/base/Base.h>
+#include <string>
namespace cru::parse {
class Grammar;
@@ -9,7 +10,7 @@ class Grammar;
// Base class of Terminal and Nonterminal.
class CRU_PARSE_API Symbol : public Object {
public:
- explicit Symbol(Grammar* grammar, String name);
+ explicit Symbol(Grammar* grammar, std::string name);
CRU_DELETE_COPY(Symbol)
CRU_DELETE_MOVE(Symbol)
@@ -19,12 +20,12 @@ class CRU_PARSE_API Symbol : public Object {
public:
Grammar* GetGrammar() { return grammar_; }
- String GetName() const { return name_; }
- void SetName(String name) { name_ = std::move(name); }
+ std::string GetName() const { return name_; }
+ void SetName(std::string name) { name_ = std::move(name); }
private:
Grammar* grammar_;
- String name_;
+ std::string name_;
};
} // namespace cru::parse
diff --git a/include/cru/parse/Terminal.h b/include/cru/parse/Terminal.h
index d197ab29..eb3b76c8 100644
--- a/include/cru/parse/Terminal.h
+++ b/include/cru/parse/Terminal.h
@@ -1,10 +1,11 @@
#pragma once
#include "Symbol.h"
+#include <cru/base/Base.h>
namespace cru::parse {
class CRU_PARSE_API Terminal : public Symbol {
public:
- Terminal(Grammar* grammar, String name);
+ Terminal(Grammar* grammar, std::string name);
CRU_DELETE_COPY(Terminal)
CRU_DELETE_MOVE(Terminal)
diff --git a/include/cru/parse/TokenType.h b/include/cru/parse/TokenType.h
index 4e8545b1..a015a49b 100644
--- a/include/cru/parse/TokenType.h
+++ b/include/cru/parse/TokenType.h
@@ -1,13 +1,13 @@
#pragma once
#include "Base.h"
-#include "cru/base/Base.h"
-#include "cru/base/String.h"
+#include <cru/base/Base.h>
+#include <string>
namespace cru::parse {
class CRU_PARSE_API TokenType : public Object {
public:
- explicit TokenType(String name);
+ explicit TokenType(std::string name);
CRU_DELETE_COPY(TokenType)
CRU_DELETE_MOVE(TokenType)
@@ -15,10 +15,10 @@ class CRU_PARSE_API TokenType : public Object {
~TokenType() override;
public:
- String GetName() const { return name_; }
- void SetName(String name) { name_ = std::move(name); }
+ std::string GetName() const { return name_; }
+ void SetName(std::string name) { name_ = std::move(name); }
private:
- String name_;
+ std::string name_;
};
} // namespace cru::parse