aboutsummaryrefslogtreecommitdiff
path: root/src/parse
diff options
context:
space:
mode:
Diffstat (limited to 'src/parse')
-rw-r--r--src/parse/CMakeLists.txt2
-rw-r--r--src/parse/ParsingAlgorithmContext.cpp2
-rw-r--r--src/parse/ParsingContext.cpp2
-rw-r--r--src/parse/RecursiveDescentAlgorithm.cpp14
-rw-r--r--src/parse/RecursiveDescentAlgorithmContext.cpp16
5 files changed, 34 insertions, 2 deletions
diff --git a/src/parse/CMakeLists.txt b/src/parse/CMakeLists.txt
index 631c9881..72bac707 100644
--- a/src/parse/CMakeLists.txt
+++ b/src/parse/CMakeLists.txt
@@ -6,6 +6,8 @@ add_library(cru_parse SHARED
ParsingContext.cpp
ParsingTreeNode.cpp
Production.cpp
+ RecursiveDescentAlgorithm.cpp
+ RecursiveDescentAlgorithmContext.cpp
Symbol.cpp
Terminal.cpp
Token.cpp
diff --git a/src/parse/ParsingAlgorithmContext.cpp b/src/parse/ParsingAlgorithmContext.cpp
index 98e2343b..686ba3e5 100644
--- a/src/parse/ParsingAlgorithmContext.cpp
+++ b/src/parse/ParsingAlgorithmContext.cpp
@@ -2,7 +2,7 @@
namespace cru::parse {
ParsingAlgorithmContext::ParsingAlgorithmContext(Grammar* grammar,
- ParsingAlgorithm* algorithm)
+ const ParsingAlgorithm* algorithm)
: grammar_(grammar), algorithm_(algorithm) {}
ParsingAlgorithmContext::~ParsingAlgorithmContext() {}
diff --git a/src/parse/ParsingContext.cpp b/src/parse/ParsingContext.cpp
index aafaa65b..25a7a133 100644
--- a/src/parse/ParsingContext.cpp
+++ b/src/parse/ParsingContext.cpp
@@ -3,7 +3,7 @@
namespace cru::parse {
ParsingContext::ParsingContext(
- ParsingAlgorithmContext* parsing_algorithm_context,
+ const ParsingAlgorithmContext* parsing_algorithm_context,
std::vector<Terminal*> input)
: parsing_algorithm_context_(parsing_algorithm_context),
input_(std::move(input)) {}
diff --git a/src/parse/RecursiveDescentAlgorithm.cpp b/src/parse/RecursiveDescentAlgorithm.cpp
new file mode 100644
index 00000000..a6549f8a
--- /dev/null
+++ b/src/parse/RecursiveDescentAlgorithm.cpp
@@ -0,0 +1,14 @@
+#include "cru/parse/RecursiveDescentAlgorithm.hpp"
+#include "cru/parse/ParsingAlgorithmContext.hpp"
+#include "cru/parse/RecursiveDescentAlgorithmContext.hpp"
+
+namespace cru::parse {
+bool RecursiveDescentAlgorithm::CanHandle(Grammar *grammar) const {
+ return true;
+}
+
+ParsingAlgorithmContext *RecursiveDescentAlgorithm::CreateContext(
+ Grammar *grammar) const {
+ return new RecursiveDescentAlgorithmContext(grammar, this);
+}
+} // namespace cru::parse
diff --git a/src/parse/RecursiveDescentAlgorithmContext.cpp b/src/parse/RecursiveDescentAlgorithmContext.cpp
new file mode 100644
index 00000000..8de0abc4
--- /dev/null
+++ b/src/parse/RecursiveDescentAlgorithmContext.cpp
@@ -0,0 +1,16 @@
+#include "cru/parse/RecursiveDescentAlgorithmContext.hpp"
+#include "cru/parse/ParsingTreeNode.hpp"
+
+namespace cru::parse {
+RecursiveDescentAlgorithmContext::RecursiveDescentAlgorithmContext(
+ Grammar* grammar, const RecursiveDescentAlgorithm* algorithm)
+ : ParsingAlgorithmContext(grammar, algorithm) {}
+
+RecursiveDescentAlgorithmContext::~RecursiveDescentAlgorithmContext() = default;
+
+ParsingTreeNode* RecursiveDescentAlgorithmContext::Parse(
+ const std::vector<Terminal*>& input) {
+ // TODO: Implement this.
+ return nullptr;
+}
+} // namespace cru::parse