summaryrefslogtreecommitdiff
path: root/src/packrat-tokens.adb
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2019-01-12 00:38:45 +1100
committerJed Barber <jjbarber@y7mail.com>2019-01-12 00:38:45 +1100
commitdc3078a06b5ee52751cfb6fd6cf13b3790632ac4 (patch)
tree25187b953479f943947e919b7acc1f4a3ca41fe6 /src/packrat-tokens.adb
parent554d2ab14921c48d628b0ffa86cc7492836477ac (diff)
Packrat.Lexer.Combinators specs and tests complete
Diffstat (limited to 'src/packrat-tokens.adb')
-rw-r--r--src/packrat-tokens.adb18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/packrat-tokens.adb b/src/packrat-tokens.adb
index 70a866a..240ecee 100644
--- a/src/packrat-tokens.adb
+++ b/src/packrat-tokens.adb
@@ -30,13 +30,17 @@ package body Tokens is
procedure Adjust
- (This : in out Token)
- is
- New_Array : Element_Array_Access :=
- new Element_Array (This.Token_Value'Range);
+ (This : in out Token) is
begin
- New_Array.all := This.Token_Value.all;
- This.Token_Value := New_Array;
+ if This.Token_Value /= null then
+ declare
+ New_Array : Element_Array_Access :=
+ new Element_Array (1 .. This.Token_Value'Length);
+ begin
+ New_Array.all := This.Token_Value.all;
+ This.Token_Value := New_Array;
+ end;
+ end if;
end Adjust;
@@ -64,7 +68,7 @@ package body Tokens is
This.Identifier := Ident;
This.Start_At := Start;
This.Finish_At := Finish;
- This.Token_Value := new Element_Array (Value'Range);
+ This.Token_Value := new Element_Array (1 .. Value'Length);
This.Token_Value.all := Value;
return This;
end Create;