Re: The semantics of the disambiguation constructs

I'm not sure this is actually much different from the semantics you propose for !B - that is to say,  "!B, C" seems to do the same thing as "C!B".
That was my suspicion,  but I hadn't yet seen a formal definition, and wondered if we agreed.


Personally, I prefer a syntax like C!B as it makes it more obvious that !B is a negative match which won't consume anything.
I agree, I like things like "identifier: word!keyword" to specify that an identifier is any word as long as it isn't a keyword. 


But perhaps I'm missing an argument in favour of being able to specify the negated element without saying what we *do* expect to find at that position?
This is partly why I wanted us to collect use-cases, to test proposed solutions against. You can indeed say that "A!B" is equivalent to "!B, A", but you can also say that !A is equivalent to "" ! A, and so in that case I prefer to write !A.


One of the use-cases I have for !A is to express maximal length, such as: 


 number: digit+, !digit.


An example I have in my advanced tutorial is to take a string like


 abc...def123def!


and produce


 <input>
    <word>abc</word>
    <punc>...</punc>
    <word>def</word>
    <number>123</number>
    <word>def</word>
    <punc>!</punc>
 </input>


and while it is possible in ixml currently, it is tricky, and gets trickier with each class of character you add.


But with !A you can define


 input: (word; number; punc)*.
 word: letter+, !letter.
 number: digit+, !digit.
 punc: [P]+, ![P].
 letter: [L].
 digit: ["0"-"9"].


and adding a new class becomes easy.


Steven




BTW



****************************************************

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 2 Feb 2026, at 17:35, Steven Pemberton <steven.pemberton@cwi.nl> wrote:


In my piece about ambiguity, I mentioned the two constructs we have currently proposed for dealing with ambiguity, there notated as:

   !A and A!B.

The semantics of ! are as follows. In an alternative like

   A, !B, C

if B succeeds, then !B fails, and so the whole alternative fails; if B fails, then !B succeeds, consuming no input characters, and so the rest of the alternative starts at the same character position that !B started at.

My question, what are the proposed semantics of A!B (or A - B if you like)? For instance, is there are a requirement that A and B span the same character positions? Does B have to be a subset of A, or is the exclusion of the intersection of the two implied?
Steven

Received on Tuesday, 3 February 2026 11:46:54 UTC