summaryrefslogtreecommitdiff
path: root/src/packrat-parsers.ads
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2020-12-03 22:39:00 +1100
committerJed Barber <jjbarber@y7mail.com>2020-12-03 22:39:00 +1100
commitcc1795dce90c4a498ddfed155c1f3a6f83a50f1d (patch)
tree0510e22bbd33640e9641acdc47a7d761b0ceb0e7 /src/packrat-parsers.ads
parent81ac04a3b7981403229bc6a8949ddcd0911adb80 (diff)
Parser constraint error bugs fixed
Diffstat (limited to 'src/packrat-parsers.ads')
-rw-r--r--src/packrat-parsers.ads54
1 files changed, 12 insertions, 42 deletions
diff --git a/src/packrat-parsers.ads b/src/packrat-parsers.ads
index 93ad258..99dbee7 100644
--- a/src/packrat-parsers.ads
+++ b/src/packrat-parsers.ads
@@ -7,6 +7,7 @@ with
private with
+ Ada.Strings.Unbounded,
Ada.Containers.Vectors,
Ada.Containers.Ordered_Maps,
Ada.Containers.Ordered_Sets,
@@ -21,28 +22,6 @@ generic
package Packrat.Parsers is
- -- Memoize only adds to the Parse_Graph result when it is successful
- -- so the Parser_Context will need to keep track of unsuccessful combinator
- -- at given positions
-
- -- If all combinators are memoized in a memotable then no need to keep track of call stack
- -- To do that, use start point and function access as the key?
-
- -- If a combinator at a position is already in the memotable, return result
- -- Else run combinator, add/update result in memotable, then return result
- -- As a side effect of this, the entry in the memotable will be updated several times
- -- while left recursion unwinds
-
- -- Combinators need to return value strings as well as the finish sets
-
- -- Two functions, Symbolize and Ignore?, to create a node in the graph and to discard
- -- the current return value string
-
- -- Some way to join tokens-of-tokens into just tokens
-
-
-
-
type Parser_Context is private;
Empty_Context : constant Parser_Context;
@@ -315,17 +294,6 @@ private
-- does the lexer handle input that doesn't start from 1 at the beginning?
- -- results need to record what combinators were curtailed, if any, with leftrec count
-
- -- choice combinators can be curtailed by multiple combinators at once
-
- -- results need to deal with tokens to put in the graph somehow
-
-
- -- Curtail when leftrec count exceeds number of remaining tokens plus 1
- -- for a given combinator/position
-
-
package Elem_Holds is new Ada.Containers.Indefinite_Holders
(Element_Type => Traits.Element_Array,
"=" => Traits."=");
@@ -342,6 +310,14 @@ private
(Left, Right : in Tok_Holds.Holder)
return Boolean;
+ function Element
+ (Hold : in Elem_Holds.Holder)
+ return Traits.Element_Array;
+
+ function Element
+ (Hold : in Tok_Holds.Holder)
+ return Graphs.Finished_Token_Array;
+
@@ -399,15 +375,6 @@ private
- -- If there's anything in the Curtails, then Results should be empty
- -- and vice versa... union?
-
- -- need to add a record of the total length of input available when
- -- result was computed, to allow for knowing when to recompute
- -- optional_more/need_more results
-
- -- actually no, just not putting optional/needmore results in the
- -- memotable will work fine, but how to figure out how much to pass forward?
type Combinator_Result is record
Results : Result_Sets.Set := Result_Sets.Empty_Set;
Curtails : Curtail_Maps.Map := Curtail_Maps.Empty_Map;
@@ -443,6 +410,7 @@ private
Current_Position : Positive := 1;
Needs_More : Needs_Sets.Set;
Pass_Forward : Elem_Holds.Holder;
+ Error_String : Ada.Strings.Unbounded.Unbounded_String;
Memotable : Memotables.Map;
Leftrectable : Leftrectables.Map;
Allow_Incomplete : Boolean := True;
@@ -455,6 +423,7 @@ private
Current_Position => 1,
Needs_More => Needs_Sets.Empty_Set,
Pass_Forward => Elem_Holds.Empty_Holder,
+ Error_String => +"",
Memotable => Memotables.Empty_Map,
Leftrectable => Leftrectables.Empty_Map,
Allow_Incomplete => True);
@@ -547,6 +516,7 @@ private
+ -- Should this be factored out into the main Packrat package?
function Slide
(Input : in Traits.Element_Array;
Position : in Positive)