diff options
-rw-r--r-- | example/sentence.adb | 23 | ||||
-rw-r--r-- | src/packrat-no_lex.ads (renamed from src/packrat-text-no_lex.ads) | 15 | ||||
-rw-r--r-- | src/packrat-standard.ads (renamed from src/packrat-text-standard.ads) | 25 | ||||
-rw-r--r-- | src/packrat-text-wide.ads | 48 | ||||
-rw-r--r-- | src/packrat-text-wide_wide.ads | 48 | ||||
-rw-r--r-- | src/packrat-text.ads | 29 |
6 files changed, 69 insertions, 119 deletions
diff --git a/example/sentence.adb b/example/sentence.adb index c8493cb..288deeb 100644 --- a/example/sentence.adb +++ b/example/sentence.adb @@ -3,7 +3,7 @@ with Ada.Text_IO, - Packrat.Text.Standard, + Packrat.Text, Packrat.Utilities; use @@ -19,7 +19,8 @@ procedure Sentence is type Lexer_Labels is (Word, Whitespace); type Parser_Labels is (S, NP, PP, VP, Det, Noun, Verb, Prep); - package My_Rat is new Packrat.Text.Standard (Lexer_Labels, Parser_Labels); + package Text_Rat is new Packrat.Text (Lexer_Labels, Parser_Labels); + package My_Rat renames Text_Rat.Standard; @@ -37,15 +38,15 @@ procedure Sentence is - function Is_I is new My_Rat.Lexer_Traits.Tokens.Is_Value ("i"); - function Is_Saw is new My_Rat.Lexer_Traits.Tokens.Is_Value ("saw"); - function Is_A is new My_Rat.Lexer_Traits.Tokens.Is_Value ("a"); - function Is_Man is new My_Rat.Lexer_Traits.Tokens.Is_Value ("man"); - function Is_In is new My_Rat.Lexer_Traits.Tokens.Is_Value ("in"); - function Is_The is new My_Rat.Lexer_Traits.Tokens.Is_Value ("the"); - function Is_Park is new My_Rat.Lexer_Traits.Tokens.Is_Value ("park"); - function Is_With is new My_Rat.Lexer_Traits.Tokens.Is_Value ("with"); - function Is_Bat is new My_Rat.Lexer_Traits.Tokens.Is_Value ("bat"); + function Is_I is new My_Rat.Lexer_Tokens.Is_Value ("i"); + function Is_Saw is new My_Rat.Lexer_Tokens.Is_Value ("saw"); + function Is_A is new My_Rat.Lexer_Tokens.Is_Value ("a"); + function Is_Man is new My_Rat.Lexer_Tokens.Is_Value ("man"); + function Is_In is new My_Rat.Lexer_Tokens.Is_Value ("in"); + function Is_The is new My_Rat.Lexer_Tokens.Is_Value ("the"); + function Is_Park is new My_Rat.Lexer_Tokens.Is_Value ("park"); + function Is_With is new My_Rat.Lexer_Tokens.Is_Value ("with"); + function Is_Bat is new My_Rat.Lexer_Tokens.Is_Value ("bat"); function Sat_In is new My_Rat.Parsers.Satisfy (Is_In); function Sat_With is new My_Rat.Parsers.Satisfy (Is_With); diff --git a/src/packrat-text-no_lex.ads b/src/packrat-no_lex.ads index 2826df5..bde416f 100644 --- a/src/packrat-text-no_lex.ads +++ b/src/packrat-no_lex.ads @@ -11,13 +11,18 @@ generic type Parser_Labels is (<>); -package Packrat.Text.No_Lex 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 => Character, - Element_Array => String); + Element_Type => Element_Type, + Element_Array => Element_Array); package Parse_Graphs is new Packrat.Parse_Graphs (Traits => Parser_Traits); @@ -26,9 +31,11 @@ package Packrat.Text.No_Lex is (Traits => Parser_Traits, Graphs => Parse_Graphs); + package Parser_Tokens renames Parser_Traits.Tokens; + subtype Parser_Result is Parse_Graphs.Parse_Graph; -end Packrat.Text.No_Lex; +end Packrat.No_Lex; diff --git a/src/packrat-text-standard.ads b/src/packrat-standard.ads index 6e70431..bf0b815 100644 --- a/src/packrat-text-standard.ads +++ b/src/packrat-standard.ads @@ -13,25 +13,32 @@ generic type Lexer_Labels is (<>); type Parser_Labels is (<>); -package Packrat.Text.Standard 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 => Character, - Element_Array => String); + Element_Type => Element_Type, + Element_Array => Element_Array); package Lexers is new Packrat.Lexers (Traits => Lexer_Traits); - subtype Lexer_Result is Lexer_Traits.Tokens.Token_Array; + 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_Traits.Tokens.Token, - Element_Array => Lexer_Traits.Tokens.Token_Array, - "<" => Lexer_Traits.Tokens."<"); + Element_Type => Lexer_Tokens.Token, + Element_Array => Lexer_Tokens.Token_Array, + "<" => Lexer_Tokens."<"); package Parse_Graphs is new Packrat.Parse_Graphs (Traits => Parser_Traits); @@ -40,9 +47,11 @@ package Packrat.Text.Standard is (Traits => Parser_Traits, Graphs => Parse_Graphs); + package Parser_Tokens renames Parser_Traits.Tokens; + subtype Parser_Result is Parse_Graphs.Parse_Graph; -end Packrat.Text.Standard; +end Packrat.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; |