Question

I want to translate a given ABNF grammar into a valid ParseKit grammar. Actually I'm trying to find a solution for this kind of statement:

tag = 1*<any Symbol except "C">

with

Symbol = "A" / "B" / "C" / "D" // a lot more symbols here...

The symbol definition is simplified for this question and normally contains a lot of special characters. My current solution is to hard code all allowed symbols for tag, like

tag = ('A' | 'B' | 'D')+;

But what I really want is something like a "without operator"

tag = Symbol \ 'C';

Is there any construct that allows me to keep my symbol list and define some excludes?

Was it helpful?

Solution

Developer of ParseKit here.

Yes, there is a feature for exactly this. Here's an example:

allItems = 'A' | 'B' | 'C' | 'D';
someItems = allItems - 'C';

Use the - operator.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top