You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You will perhaps be relieved † to hear that I wasn’t sufficiently interested in the intellectual challenge of working out if I could constrain year such that it would be possible to handle February in non-leap years correctly.
All of this is a bit tedious especially because there's a dead easy way to specify a date type: xs:date. And there's lots of software that will validate that your input conforms to an xs:date. That got me thinking, what if I could write this:
date!date = year, -'-', month, -'-', day .
Where the !date part means that the nonterminal must be a valid xs:datein addition to satisfying the grammatical constraints expressed on the right hand side.
If we allow implementations to provide their own data type libraries (as, for example, RELAX NG does for simple data types), it would open up a wide range of possibilities for solving otherwise very difficult problems.
I had a proof of concept implemented (in my Earley parser, anyway) in the space of about half an hour. FWIW.
I was toying about with a grammar that included a nonterminal to match an ISO 8601 date.
I started with this:
That’s probably fine most of the time. But I was noodling about for fun so, naturally, I wanted to do better than that.
I quickly moved on to:
That’s better and only marginally more complicated. It still lets every month have 31 days though.
The next level of improvement is obvious, if not especially tidy:
You will perhaps be relieved † to hear that I wasn’t sufficiently interested in the intellectual challenge of working out if I could constrain
year
such that it would be possible to handle February in non-leap years correctly.All of this is a bit tedious especially because there's a dead easy way to specify a date type:
xs:date
. And there's lots of software that will validate that your input conforms to anxs:date
. That got me thinking, what if I could write this:Where the
!date
part means that the nonterminal must be a validxs:date
in addition to satisfying the grammatical constraints expressed on the right hand side.If we allow implementations to provide their own data type libraries (as, for example, RELAX NG does for simple data types), it would open up a wide range of possibilities for solving otherwise very difficult problems.
I had a proof of concept implemented (in my Earley parser, anyway) in the space of about half an hour. FWIW.
† I lied
But I am genuinely going to leave the 400 year cycle problem to someone else.
The text was updated successfully, but these errors were encountered: