summaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2020-12-04 12:55:49 +1100
committerJed Barber <jjbarber@y7mail.com>2020-12-04 12:55:49 +1100
commitad215be09de49dfb60245285d6ce20a0b58fdeac (patch)
treecdd6bdb62212c2017a8b61cfc0b4feda2402783c /example
parent6c918045828db04960a75494c2d1247dab6a1351 (diff)
More generic token predicates
Diffstat (limited to 'example')
-rw-r--r--example/sentence.adb41
1 files changed, 9 insertions, 32 deletions
diff --git a/example/sentence.adb b/example/sentence.adb
index 7e9114b..c8493cb 100644
--- a/example/sentence.adb
+++ b/example/sentence.adb
@@ -3,8 +3,6 @@
with
Ada.Text_IO,
- Ada.Characters.Latin_1,
- Ada.Strings.Maps,
Packrat.Text.Standard,
Packrat.Utilities;
@@ -16,16 +14,8 @@ use
procedure Sentence is
- package Latin renames Ada.Characters.Latin_1;
-
-
-
-
Input : String := "i saw a man in the park with a bat";
-
-
-
type Lexer_Labels is (Word, Whitespace);
type Parser_Labels is (S, NP, PP, VP, Det, Noun, Verb, Prep);
@@ -47,28 +37,15 @@ procedure Sentence is
- generic
- Match : in String;
- function Is_Value
- (Element : in My_Rat.Lexer_Traits.Tokens.Token)
- return Boolean;
-
- function Is_Value
- (Element : in My_Rat.Lexer_Traits.Tokens.Token)
- return Boolean is
- begin
- return My_Rat.Lexer_Traits.Tokens.Value (Element) = Match;
- end Is_Value;
-
- function Is_I is new Is_Value ("i");
- function Is_Saw is new Is_Value ("saw");
- function Is_A is new Is_Value ("a");
- function Is_Man is new Is_Value ("man");
- function Is_In is new Is_Value ("in");
- function Is_The is new Is_Value ("the");
- function Is_Park is new Is_Value ("park");
- function Is_With is new Is_Value ("with");
- function Is_Bat is new Is_Value ("bat");
+ 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 Sat_In is new My_Rat.Parsers.Satisfy (Is_In);
function Sat_With is new My_Rat.Parsers.Satisfy (Is_With);