summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2020-12-04 12:35:50 +1100
committerJed Barber <jjbarber@y7mail.com>2020-12-04 12:35:50 +1100
commit87667886ee386edb89dc18b0bddcf94675c57a00 (patch)
tree0cb22989142a02424bbd92847c43dd6e9f498ec7 /src
parentcc1795dce90c4a498ddfed155c1f3a6f83a50f1d (diff)
Added redirects for self-referential combinators
Diffstat (limited to 'src')
-rw-r--r--src/packrat-parsers.adb27
-rw-r--r--src/packrat-parsers.ads21
2 files changed, 48 insertions, 0 deletions
diff --git a/src/packrat-parsers.adb b/src/packrat-parsers.adb
index f639195..df88e71 100644
--- a/src/packrat-parsers.adb
+++ b/src/packrat-parsers.adb
@@ -582,6 +582,33 @@ package body Packrat.Parsers is
+ package body Redirect is
+
+ procedure Set
+ (Target : in Combinator) is
+ begin
+ Combo := Target;
+ end Set;
+
+ function Call
+ (Input : in Traits.Element_Array;
+ Context : in out Parser_Context;
+ Start : in Positive)
+ return Combinator_Result is
+ begin
+ if Combo = null then
+ raise Parser_Error;
+ else
+ return Combo (Input, Context, Start);
+ end if;
+ end Call;
+
+ end Redirect;
+
+
+
+
+
function Sequence
(Input : in Traits.Element_Array;
Context : in out Parser_Context;
diff --git a/src/packrat-parsers.ads b/src/packrat-parsers.ads
index 99dbee7..8d0ba68 100644
--- a/src/packrat-parsers.ads
+++ b/src/packrat-parsers.ads
@@ -114,6 +114,27 @@ package Packrat.Parsers is
generic
+ package Redirect is
+
+ procedure Set
+ (Target : in Combinator);
+
+ function Call
+ (Input : in Traits.Element_Array;
+ Context : in out Parser_Context;
+ Start : in Positive)
+ return Combinator_Result;
+
+ private
+
+ Combo : Combinator := null;
+
+ end Redirect;
+
+
+
+
+ generic
Params : in Combinator_Array;
function Sequence
(Input : in Traits.Element_Array;