poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [WIP][PATCH 2/2] pkl,pvm: add support for regular expression


From: Jose E. Marchesi
Subject: Re: [WIP][PATCH 2/2] pkl,pvm: add support for regular expression
Date: Wed, 15 Feb 2023 11:01:01 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

> diff --git a/libpoke/std.pk b/libpoke/std.pk
> index 8ed331d9..bcc0d1cc 100644
> --- a/libpoke/std.pk
> +++ b/libpoke/std.pk
> @@ -861,3 +861,25 @@ fun pk_vercmp = (any _a, any _b) int<32>:
>    diff = cmp (a.offset, b.offset);
>    return diff;
>  }
> +
> +/* Regular expression functions.  */
> +
> +fun pk_regexp_match = (string regex, string str, int<32> start = 0) int<32>:
> +{
> +  return _pkl_re_match (regex, str, start);
> +}
> +
> +type Pk_Regexp_Match =
> +  struct
> +  {
> +    int<32> count;
> +    int<32>[2][] submatches;
> +  };
> +
> +fun pk_regexp_gmatch = (string regex, string str,
> +                        int<32> start = 0) Pk_Regexp_Match:
> +{
> +  var result = _pkl_re_gmatch (regex, str, start);
> +
> +  return Pk_Regexp_Match {count=result.count, submatches=result.submatches};
> +}

I don't think it is a good idea to expose the regexp machinery in std
like this.

I thought we were targetting adding support for STRING ~ REGEXP at the
language level?  The compiler can then generate calls to _pkl_re_gmatch
and DTRT...



reply via email to

[Prev in Thread] Current Thread [Next in Thread]