From ad215be09de49dfb60245285d6ce20a0b58fdeac Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Fri, 4 Dec 2020 12:55:49 +1100 Subject: More generic token predicates --- src/packrat-tokens.adb | 27 +++++++++++++++++++++++++++ src/packrat-tokens.ads | 19 +++++++++++++++++++ 2 files changed, 46 insertions(+) (limited to 'src') diff --git a/src/packrat-tokens.adb b/src/packrat-tokens.adb index c07408c..81d68c3 100644 --- a/src/packrat-tokens.adb +++ b/src/packrat-tokens.adb @@ -111,6 +111,33 @@ package body Packrat.Tokens is end Value; + + + + function Is_Label + (This : in Token) + return Boolean is + begin + return This.Identifier = Ident; + end Is_Label; + + + function Is_Start + (This : in Token) + return Boolean is + begin + return This.Start_At = Start; + end Is_Start; + + + function Is_Value + (This : in Token) + return Boolean is + begin + return This.Token_Value.Element = Value; + end Is_Value; + + end Packrat.Tokens; diff --git a/src/packrat-tokens.ads b/src/packrat-tokens.ads index cd691b5..b731b13 100644 --- a/src/packrat-tokens.ads +++ b/src/packrat-tokens.ads @@ -60,6 +60,25 @@ package Packrat.Tokens is return Element_Array; + generic + Ident : in Label_Enum; + function Is_Label + (This : in Token) + return Boolean; + + generic + Start : in Positive; + function Is_Start + (This : in Token) + return Boolean; + + generic + Value : in Element_Array; + function Is_Value + (This : in Token) + return Boolean; + + private -- cgit