From 337a6217732217b537f2459451f4c563bc651cc8 Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Thu, 3 Dec 2020 16:42:44 +1100 Subject: Instantiation packages for text parsing --- 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 | 8 +++++++ 5 files changed, 186 insertions(+) create mode 100644 src/packrat-text-no_lex.ads create mode 100644 src/packrat-text-standard.ads create mode 100644 src/packrat-text-wide.ads create mode 100644 src/packrat-text-wide_wide.ads create mode 100644 src/packrat-text.ads diff --git a/src/packrat-text-no_lex.ads b/src/packrat-text-no_lex.ads new file mode 100644 index 0000000..2826df5 --- /dev/null +++ b/src/packrat-text-no_lex.ads @@ -0,0 +1,34 @@ + + +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 new file mode 100644 index 0000000..6e70431 --- /dev/null +++ b/src/packrat-text-standard.ads @@ -0,0 +1,48 @@ + + +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 new file mode 100644 index 0000000..7fc6ca1 --- /dev/null +++ b/src/packrat-text-wide.ads @@ -0,0 +1,48 @@ + + +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 new file mode 100644 index 0000000..dad33db --- /dev/null +++ b/src/packrat-text-wide_wide.ads @@ -0,0 +1,48 @@ + + +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 new file mode 100644 index 0000000..3d239e8 --- /dev/null +++ b/src/packrat-text.ads @@ -0,0 +1,8 @@ + + +package Packrat.Text is + + +end Packrat.Text; + + -- cgit