From 0abd0d9444164cbb85df0e5a50451b5f98fef3db Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Fri, 4 Dec 2020 15:28:52 +1100 Subject: Instantiation package improvements --- src/packrat-no_lex.ads | 41 ++++++++++++++++++++++++++++++ src/packrat-standard.ads | 57 ++++++++++++++++++++++++++++++++++++++++++ src/packrat-text-no_lex.ads | 34 ------------------------- src/packrat-text-standard.ads | 48 ----------------------------------- src/packrat-text-wide.ads | 48 ----------------------------------- src/packrat-text-wide_wide.ads | 48 ----------------------------------- src/packrat-text.ads | 29 +++++++++++++++++++++ 7 files changed, 127 insertions(+), 178 deletions(-) create mode 100644 src/packrat-no_lex.ads create mode 100644 src/packrat-standard.ads delete mode 100644 src/packrat-text-no_lex.ads delete mode 100644 src/packrat-text-standard.ads delete mode 100644 src/packrat-text-wide.ads delete mode 100644 src/packrat-text-wide_wide.ads (limited to 'src') diff --git a/src/packrat-no_lex.ads b/src/packrat-no_lex.ads new file mode 100644 index 0000000..bde416f --- /dev/null +++ b/src/packrat-no_lex.ads @@ -0,0 +1,41 @@ + + +with + + Packrat.Traits, + Packrat.Parse_Graphs, + Packrat.Parsers; + + +generic + + type Parser_Labels is (<>); + + type Element_Type is private; + type Element_Array is array (Positive range <>) of Element_Type; + + with function "<" (Left, Right : in Element_Type) return Boolean is <>; + +package Packrat.No_Lex is + + + package Parser_Traits is new Packrat.Traits + (Label_Enum => Parser_Labels, + Element_Type => Element_Type, + Element_Array => Element_Array); + + package Parse_Graphs is new Packrat.Parse_Graphs + (Traits => Parser_Traits); + + package Parsers is new Packrat.Parsers + (Traits => Parser_Traits, + Graphs => Parse_Graphs); + + package Parser_Tokens renames Parser_Traits.Tokens; + + subtype Parser_Result is Parse_Graphs.Parse_Graph; + + +end Packrat.No_Lex; + + diff --git a/src/packrat-standard.ads b/src/packrat-standard.ads new file mode 100644 index 0000000..bf0b815 --- /dev/null +++ b/src/packrat-standard.ads @@ -0,0 +1,57 @@ + + +with + + Packrat.Traits, + Packrat.Lexers, + Packrat.Parse_Graphs, + Packrat.Parsers; + + +generic + + type Lexer_Labels is (<>); + type Parser_Labels is (<>); + + type Element_Type is private; + type Element_Array is array (Positive range <>) of Element_Type; + + with function "<" (Left, Right : in Element_Type) return Boolean is <>; + +package Packrat.Standard is + + + package Lexer_Traits is new Packrat.Traits + (Label_Enum => Lexer_Labels, + Element_Type => Element_Type, + Element_Array => Element_Array); + + package Lexers is new Packrat.Lexers + (Traits => Lexer_Traits); + + package Lexer_Tokens renames Lexer_Traits.Tokens; + + subtype Lexer_Result is Lexer_Tokens.Token_Array; + + + package Parser_Traits is new Packrat.Traits + (Label_Enum => Parser_Labels, + Element_Type => Lexer_Tokens.Token, + Element_Array => Lexer_Tokens.Token_Array, + "<" => Lexer_Tokens."<"); + + package Parse_Graphs is new Packrat.Parse_Graphs + (Traits => Parser_Traits); + + package Parsers is new Packrat.Parsers + (Traits => Parser_Traits, + Graphs => Parse_Graphs); + + package Parser_Tokens renames Parser_Traits.Tokens; + + subtype Parser_Result is Parse_Graphs.Parse_Graph; + + +end Packrat.Standard; + + diff --git a/src/packrat-text-no_lex.ads b/src/packrat-text-no_lex.ads deleted file mode 100644 index 2826df5..0000000 --- a/src/packrat-text-no_lex.ads +++ /dev/null @@ -1,34 +0,0 @@ - - -with - - Packrat.Traits, - Packrat.Parse_Graphs, - Packrat.Parsers; - - -generic - - type Parser_Labels is (<>); - -package Packrat.Text.No_Lex is - - - package Parser_Traits is new Packrat.Traits - (Label_Enum => Parser_Labels, - Element_Type => Character, - Element_Array => String); - - package Parse_Graphs is new Packrat.Parse_Graphs - (Traits => Parser_Traits); - - package Parsers is new Packrat.Parsers - (Traits => Parser_Traits, - Graphs => Parse_Graphs); - - subtype Parser_Result is Parse_Graphs.Parse_Graph; - - -end Packrat.Text.No_Lex; - - diff --git a/src/packrat-text-standard.ads b/src/packrat-text-standard.ads deleted file mode 100644 index 6e70431..0000000 --- a/src/packrat-text-standard.ads +++ /dev/null @@ -1,48 +0,0 @@ - - -with - - Packrat.Traits, - Packrat.Lexers, - Packrat.Parse_Graphs, - Packrat.Parsers; - - -generic - - type Lexer_Labels is (<>); - type Parser_Labels is (<>); - -package Packrat.Text.Standard is - - - package Lexer_Traits is new Packrat.Traits - (Label_Enum => Lexer_Labels, - Element_Type => Character, - Element_Array => String); - - package Lexers is new Packrat.Lexers - (Traits => Lexer_Traits); - - subtype Lexer_Result is Lexer_Traits.Tokens.Token_Array; - - - package Parser_Traits is new Packrat.Traits - (Label_Enum => Parser_Labels, - Element_Type => Lexer_Traits.Tokens.Token, - Element_Array => Lexer_Traits.Tokens.Token_Array, - "<" => Lexer_Traits.Tokens."<"); - - package Parse_Graphs is new Packrat.Parse_Graphs - (Traits => Parser_Traits); - - package Parsers is new Packrat.Parsers - (Traits => Parser_Traits, - Graphs => Parse_Graphs); - - subtype Parser_Result is Parse_Graphs.Parse_Graph; - - -end Packrat.Text.Standard; - - diff --git a/src/packrat-text-wide.ads b/src/packrat-text-wide.ads deleted file mode 100644 index 7fc6ca1..0000000 --- a/src/packrat-text-wide.ads +++ /dev/null @@ -1,48 +0,0 @@ - - -with - - Packrat.Traits, - Packrat.Lexers, - Packrat.Parse_Graphs, - Packrat.Parsers; - - -generic - - type Lexer_Labels is (<>); - type Parser_Labels is (<>); - -package Packrat.Text.Wide is - - - package Lexer_Traits is new Packrat.Traits - (Label_Enum => Lexer_Labels, - Element_Type => Wide_Character, - Element_Array => Wide_String); - - package Lexers is new Packrat.Lexers - (Traits => Lexer_Traits); - - subtype Lexer_Result is Lexer_Traits.Tokens.Token_Array; - - - package Parser_Traits is new Packrat.Traits - (Label_Enum => Parser_Labels, - Element_Type => Lexer_Traits.Tokens.Token, - Element_Array => Lexer_Traits.Tokens.Token_Array, - "<" => Lexer_Traits.Tokens."<"); - - package Parse_Graphs is new Packrat.Parse_Graphs - (Traits => Parser_Traits); - - package Parsers is new Packrat.Parsers - (Traits => Parser_Traits, - Graphs => Parse_Graphs); - - subtype Parser_Result is Parse_Graphs.Parse_Graph; - - -end Packrat.Text.Wide; - - diff --git a/src/packrat-text-wide_wide.ads b/src/packrat-text-wide_wide.ads deleted file mode 100644 index dad33db..0000000 --- a/src/packrat-text-wide_wide.ads +++ /dev/null @@ -1,48 +0,0 @@ - - -with - - Packrat.Traits, - Packrat.Lexers, - Packrat.Parse_Graphs, - Packrat.Parsers; - - -generic - - type Lexer_Labels is (<>); - type Parser_Labels is (<>); - -package Packrat.Text.Wide_Wide is - - - package Lexer_Traits is new Packrat.Traits - (Label_Enum => Lexer_Labels, - Element_Type => Wide_Wide_Character, - Element_Array => Wide_Wide_String); - - package Lexers is new Packrat.Lexers - (Traits => Lexer_Traits); - - subtype Lexer_Result is Lexer_Traits.Tokens.Token_Array; - - - package Parser_Traits is new Packrat.Traits - (Label_Enum => Parser_Labels, - Element_Type => Lexer_Traits.Tokens.Token, - Element_Array => Lexer_Traits.Tokens.Token_Array, - "<" => Lexer_Traits.Tokens."<"); - - package Parse_Graphs is new Packrat.Parse_Graphs - (Traits => Parser_Traits); - - package Parsers is new Packrat.Parsers - (Traits => Parser_Traits, - Graphs => Parse_Graphs); - - subtype Parser_Result is Parse_Graphs.Parse_Graph; - - -end Packrat.Text.Wide_Wide; - - diff --git a/src/packrat-text.ads b/src/packrat-text.ads index 3d239e8..c3a5c51 100644 --- a/src/packrat-text.ads +++ b/src/packrat-text.ads @@ -1,8 +1,37 @@ +with + + Packrat.Standard; + + +generic + + type Lexer_Labels is (<>); + type Parser_Labels is (<>); + package Packrat.Text is + package Standard is new Packrat.Standard + (Lexer_Labels => Lexer_Labels, + Parser_Labels => Parser_Labels, + Element_Type => Character, + Element_Array => String); + + package Wide is new Packrat.Standard + (Lexer_Labels => Lexer_Labels, + Parser_Labels => Parser_Labels, + Element_Type => Wide_Character, + Element_Array => Wide_String); + + package Wide_Wide is new Packrat.Standard + (Lexer_Labels => Lexer_Labels, + Parser_Labels => Parser_Labels, + Element_Type => Wide_Wide_Character, + Element_Array => Wide_Wide_String); + + end Packrat.Text; -- cgit