Open pyoor opened 3 years ago
Sorta works...
"A - B" will be rejected, but "A - C" will pass.
expression -> [A-Z] " - " [A-Z] {%
function(data, location, reject) {
if(data[2] === "B") {
return reject;
} else {
return data;
}
}
%}
Or this...
"A - B" will be rejected, but "A - 1" will pass.
expression -> [A-Z] " - " [^A-Z]
But I'm guessing you want to specific one value rather than two? In which case use the function to reject? Not as clean as "A - B", but workable.
expression -> [A-Z] {%
function(data, location, reject) {
if(data[0] === "B") {
return reject;
} else {
return data;
}
}
%}
I'm trying to translate the W3C ABNF notation into nearley and I'm not quite sure how to express a rule that matches anything matching
this
but notthat
as per:A - B # matches any string that matches A but does not match B.
Is this possible without using a preprocessor?