summaryrefslogtreecommitdiff
path: root/src/packrat-errors.ads
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2020-11-13 11:36:41 +1100
committerJed Barber <jjbarber@y7mail.com>2020-11-13 11:36:41 +1100
commit43eea37daf162473c8c8e8279c9159d8b052ffdf (patch)
treed3fdd283a9b0d1bc5b0a5cafb6b4c18534eeefe5 /src/packrat-errors.ads
parent2e075ca317211553a19d7c8706a9d66fabcc9d8d (diff)
Refactored Tokens, Errors, Traits
Diffstat (limited to 'src/packrat-errors.ads')
-rw-r--r--src/packrat-errors.ads81
1 files changed, 81 insertions, 0 deletions
diff --git a/src/packrat-errors.ads b/src/packrat-errors.ads
new file mode 100644
index 0000000..57d7b9b
--- /dev/null
+++ b/src/packrat-errors.ads
@@ -0,0 +1,81 @@
+
+
+package Packrat.Errors is
+
+
+ subtype Error_Message is String
+ with Dynamic_Predicate => Valid_Message (Error_Message);
+
+ type Error_Info is record
+ Symbol : Ada.Strings.Unbounded.Unbounded_String;
+ Position : Natural;
+ end record;
+
+ type Error_Info_Array is array (Positive range <>) of Error_Info;
+
+
+ -- Note: No consideration is given to ordering of Error_Info items
+ -- encoded into an Error_Message string.
+
+ -- Note: Using "&" to join two Valid Error_Messages together
+ -- will result in an Error_Message that is also Valid,
+ -- but for best results Join should be used instead to
+ -- prevent duplication of Error_Info in the message.
+
+
+ function Valid_Identifier
+ (Check : in String)
+ return Boolean;
+
+ function Valid_Identifier
+ (Check : in Ada.Strings.Unbounded.Unbounded_String)
+ return Boolean;
+
+ function Valid_Identifier_Array
+ (Check : in Error_Info_Array)
+ return Boolean;
+
+ function Valid_Message
+ (Check : in String)
+ return Boolean;
+
+ function Debug_String
+ (This : in Error_Message)
+ return String;
+
+
+ function Join
+ (Left, Right : in Error_Message)
+ return Error_Message;
+
+
+ function Encode
+ (Name : in String;
+ Pos : in Natural)
+ return Error_Message
+ with Pre => Valid_Identifier (Name);
+
+ function Encode
+ (Name : in Ada.Strings.Unbounded.Unbounded_String;
+ Pos : in Natural)
+ return Error_Message
+ with Pre => Valid_Identifier (Name);
+
+ function Encode
+ (Info : in Error_Info)
+ return Error_Message
+ with Pre => Valid_Identifier (Info.Symbol);
+
+ function Encode_Array
+ (Info : in Error_Info_Array)
+ return Error_Message
+ with Pre => Valid_Identifier_Array (Info);
+
+ function Decode
+ (Msg : in Error_Message)
+ return Error_Info_Array;
+
+
+end Packrat.Errors;
+
+