On Tuesday 03 February 2026 15:12:43 (+01:00), Bethan Tovey-Walsh wrote:
You can't have an empty string,
Oh yes, strings have to contain at least one character, you're right.
but the empty alts:
()!digit
would work.
Right.
The fact that [] just fails to match feels so counterintuitive to me! I keep forgetting about it.
Michael insisted on us including it, so I suppose he had a use-case.
Steven
BTW
Sent from my iPhone
****************************************************
Dr. Bethan Tovey-Walsh
linguacelta.com <http://linguacelta.com/>
Golygydd | Editor geirfan.cymru <http://geirfan.cymru/>
Croeso i chi ysgrifennu ataf yn y Gymraeg
On 3 Feb 2026, at 13:44, Steven Pemberton <steven.pemberton@cwi.nl> wrote:
The construct A!B only succeeds if A succeeds and B doesn't. Since [] never succeeds, []!digit would never succeed either. The equivalence works though for ()!digit, or ""!digit, or anything else that matches empty.
Steven
On Tuesday 03 February 2026 13:49:21 (+01:00), Norm Tovey-Walsh wrote:
One of the use-cases I have for !A is to express maximal length, such as:
number: digit+, !digit.
I think that’s the same as:
number: digit+, []!digit .
I think I want “!” to be a separator at least conceptually. But I concede that “!digit” is a nice shortcut for “[]!digit”.
Be seeing you,
norm
--
Norm Tovey-Walsh
Saxonica