Tried to translate BNF
<hname> ::= <name>*["."<name>]
<name> ::= <let>[*[<let-or-digit-or-hyphen>]<let-or-digit>]
to a parse rule...
let-char: charset[#"a" - #"z" #"A" - #"Z"]
let-digit-char: charset[#"a" - #"z" #"A" - #"Z" #"0" - #"9"]
let-digit-hyph-char: charset[#"a" - #"z" #"A" - #"Z" #"0" - #"9" #"-"]
hname-rule: [name-rule some ["." name-rule]]
name-rule: [let-char [none | [[some let-digit-hyph-char] let-digit-char]] to end]
The problem is that it returns "true" too often...
>> parse "a" name-rule
== true
OK match first let-char, and none
>> parse "-" name-rule
== false
OK does not match the first required let-char
>> parse "a-1" name-rule
== true
OK match the first let-char, the allowed extra chars, and the required
letter or digit at the end
>> parse "asdfg" name-rule
== true
OK match the first let-char, and allowed extra letters digits or
hyphens, last character is a let-char, so that is ok
>> parse "asdfg-" name-rule
== true
ERR! last character is not one of the allowed ones
>> parse "a%$#" name-rule
== true
ERR! none of the characters following the "a" are allowed
The result of the rule seems to be like I have written it as
any-char: complement charset[""]
name-rule: [let-char [none | [some let-digit-hyph-char]] to end]
What is wrong with the rule generating the too-many true's ?
/PeO