[whatwg] Re: BNF documentation for validated input types
Brian Wilson
brian at opera.com
Mon Aug 30 03:46:03 PDT 2004
I wrote:
> When reading through the section on the new INPUT types, and trying to
> follow the prose descriptions of what characters are allowed/notallowed,
> I found myself wishing for a terse BNF string to reference.Perhaps
> prose-alone was chosen for a reason, but implementers - as wellas some
> of us spec monkeys - have gotten used to BNF notation for ano-nonsense
> way of making sense of validity domains. Perhaps this can beadded to the
> prose descriptions?
Then Ian replied:
> I've added this to the wishlist. I'm reluctant to do it right now since
> itwould be quite a lot of work and might introduce contradictions.
>
> In general the allowed values are pretty obvious when you think about it.
>Would BNF-like syntax realy be that much better?
>
> <number> ::= '-'? <integer> [ '.' <integer> ]? [ 'e' '-'? <integer> ]?
> <integer> ::= [ '0' .. '9']+
>
> <time> ::= <digit> <digit> ':' <digit> <digit>
> [ ':' <digit> <digit> [ '.' <digit>+ ]? ]?
Ok. Point taken. 8-D I hadn't really reflected on how truly bulky strict
BNF definitions would be.
As a possible alternative, since pattern attributes are defined using
ecmascript-ish regexps, perhaps the strictly-patterned input types could
be as well.
I'm pretty sure the following are correct for the time-related types. I'm
not sure what the exact regexps would be for email and uri though, and the
number/range ones will require some interesting expressions too:
----
datetime
\d{4,}-W\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}.\d+)?Z
datetime-local
\d{4,}-W\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}.\d+)?
date
\d{4,}-W\d{2}-\d{2}
month
\d{4,}-\d{2}
week
\d{4,}-W\d{2}
time
\d{2}:\d{2}(:\d{2}.\d+)?
If I've missed anything on these, someone please modify.
Hmm. Those aren't as "pretty" as I'd hoped they'd be (too many repeating
regexp patterns can be confusing.)
Anyway, just a possible idea for an addition.
-Brian
--
Brian Wilson
Opera Core QA
More information about the whatwg
mailing list