[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Static validation of Lua String Patterns?
- From: Dirk Laurie <dirk.laurie@...>
- Date: Fri, 21 Apr 2017 22:40:46 +0200
2017-04-21 10:09 GMT+02:00 steve donovan <email@example.com>:
> I have a use case where it's important to guarantee that a lua string
> pattern is valid up front.
> (The use case is providing a Rust binding to the Lua pattern code -
> like Go, panicking in library code is considered very bad form, and
> passing on errors complicates the whole API.)
> Generally we only know when the pattern is actually used, but has
> there been any prior work on static validation? Before I start
> hacking, that is ;)
Is there such a thing as a pattern whose validity depends on what
string it is being applied to? If not, pcall(string.match, pattern, "")
should be adequate to test validity.