From 4e42761354c2de557c0166d46aabe9dcd9b77073 Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Tue, 15 Jan 2019 19:34:37 +1100 Subject: Redesigned Lexer Scan functions slightly, added tests for them --- src/packrat-lexer.adb | 31 +++++++++++-------------------- src/packrat-lexer.ads | 41 +++++++++++++++++++---------------------- 2 files changed, 30 insertions(+), 42 deletions(-) (limited to 'src') diff --git a/src/packrat-lexer.adb b/src/packrat-lexer.adb index a563f69..7cbd527 100644 --- a/src/packrat-lexer.adb +++ b/src/packrat-lexer.adb @@ -164,15 +164,6 @@ package body Packrat.Lexer is end Scan; - procedure Scan_Set - (Input : in Element_Array; - Context : in out Lexer_Context; - Output : out Gen_Tokens.Token_Array) is - begin - null; - end Scan_Set; - - function Scan_Only (Input : in Element_Array; Context : in out Lexer_Context) @@ -184,17 +175,8 @@ package body Packrat.Lexer is end Scan_Only; - procedure Scan_Set_Only - (Input : in Element_Array; - Context : in out Lexer_Context; - Output : out Gen_Tokens.Token_Array) is - begin - null; - end Scan_Set_Only; - - function Scan_With - (Input : in Element_Array; + (Input : in Lexer_With_Input; Context : in out Lexer_Context) return Gen_Tokens.Token_Array is @@ -204,12 +186,21 @@ package body Packrat.Lexer is end Scan_With; - procedure Scan_Set_With + procedure Scan_Set (Input : in Element_Array; Context : in out Lexer_Context; Output : out Gen_Tokens.Token_Array) is begin null; + end Scan_Set; + + + procedure Scan_Set_With + (Input : in Lexer_With_Input; + Context : in out Lexer_Context; + Output : out Gen_Tokens.Token_Array) is + begin + null; end Scan_Set_With; diff --git a/src/packrat-lexer.ads b/src/packrat-lexer.ads index 1da9662..2d152bf 100644 --- a/src/packrat-lexer.ads +++ b/src/packrat-lexer.ads @@ -48,6 +48,12 @@ package Packrat.Lexer is + type Lexer_With_Input is access function + return Element_Array; + + + + generic Label : in Label_Enum; with function Combo @@ -59,6 +65,7 @@ package Packrat.Lexer is Context : in out Lexer_Context); generic + Label : in Label_Enum; with function Combo (Input : in Element_Array; Start : in Positive) @@ -79,43 +86,33 @@ package Packrat.Lexer is generic Components : in Component_Array; - Padding : in Gen_Tokens.Token; - procedure Scan_Set + function Scan_Only (Input : in Element_Array; - Context : in out Lexer_Context; - Output : out Gen_Tokens.Token_Array); + Context : in out Lexer_Context) + return Gen_Tokens.Token_Array; generic Components : in Component_Array; - function Scan_Only - (Input : in Element_Array; + function Scan_With + (Input : in Lexer_With_Input; Context : in out Lexer_Context) return Gen_Tokens.Token_Array; generic - Gomponents : in Component_Array; - Padding : in Gen_Tokens.Token; - procedure Scan_Set_Only + Components : in Component_Array; + Pad_In : in Element; + Pad_Out : in Gen_Tokens.Token; + procedure Scan_Set (Input : in Element_Array; Context : in out Lexer_Context; Output : out Gen_Tokens.Token_Array); generic Components : in Component_Array; - with function More - return Element_Array; - function Scan_With - (Input : in Element_Array; - Context : in out Lexer_Context) - return Gen_Tokens.Token_Array; - - generic - Components : in Component_Array; - Padding : in Gen_Tokens.Token; - with function More - return Element_Array; + Pad_In : in Element; + Pad_Out : in Gen_Tokens.Token; procedure Scan_Set_With - (Input : in Element_Array; + (Input : in Lexer_With_Input; Context : in out Lexer_Context; Output : out Gen_Tokens.Token_Array); -- cgit