From 87667886ee386edb89dc18b0bddcf94675c57a00 Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Fri, 4 Dec 2020 12:35:50 +1100 Subject: Added redirects for self-referential combinators --- src/packrat-parsers.adb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/packrat-parsers.adb') 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; -- cgit