Re: Excluding a factor that is not a character set

On 08/10/2025 07:41, Norm Tovey-Walsh wrote:
> The more general case “not this nonterminal” is more difficult.
> There have been a few discussions around subtraction or exception operators. Seehttps://github.com/invisiblexml/ixml/issues/249 for example, but nothing really solid has developed so far.

My workbench https://johnlumley.github.io/jwiXML.xhtml supports an 
experimental subtraction operator (¬). So with a grammar:

ixml version "1.1".
S: (["a"-"z"]+) ¬  ("cat";"dog").

the inputs "ca", "catch", "do" and "dodge" all match and parse, but 
"cat" and "dog" don't.

The semantics effectively are that the left-hand operand matches 
provided the right hand *doesn't* match over the same character range of 
the input.

Seems to work on simple cases, but null-matching edge cases are very 
dodgy. But as Norm and others point out, this is an area much under 
discussion and the appropriate robust semantics are far from clear

-- 
*John Lumley* MA PhD CEng FIEE
john@saxonica.com

Received on Wednesday, 8 October 2025 10:03:27 UTC