Closed workergnome closed 3 years ago
Cool! The part about the levels is basically that the grammar accepts everything based on the spec (and even some non-standard variations), but we try to set the level of the parsed result during parsing. That is to say, the parser will accept any valid EDTF string, but it would set level: 2
as hint if the input is only valid at level 2. If you do care about the levels then you can let the parser discard any result that is at a higher level than whatever your app supports.
So for that reason, could you take a look at the spec to see if uncertain centuries are supported? I think they're probably not, in which case, just make sure to set the level to 3 in the grammar rules that produce this. (Level 3 is made-up: we just use it for features which are not covered by the spec.)
I added a bit of additional syntax to the parser to accommodate uncertain centuries which allows the grammar to parse dates like "19?". I also added tests for the functionality and for the getter/setters for uncertainty.
I did a bit around the tests for decades, too, since I wanted to make sure they worked as I expected before adding the new code for centuries. Happy to pull them out.
I'm also not 100% sure what the
, {level: 2}) %}
bit on line 162 ofedit.ne
does (other than make the tests pass).I'm also not 100% sure that the "19?" grammar is legal EDTF (as opposed to "19XX?"), but it matches the existing code here and it's more important to me that it parses in EDTF.js than if it perfectly matches a not-yet published spec.