usethesource / rascal

The implementation of the Rascal meta-programming language (including interpreter, type checker, parser generator, compiler and JVM based run-time system)
http://www.rascal-mpl.org
Other
406 stars 78 forks source link

correct datetime literals fail to parse #1443

Open jurgenvinju opened 4 years ago

jurgenvinju commented 4 years ago

Describe the bug

rascal>$2013-07-15T09:15:23.123+03:00$
datetime: $2013-07-15T09:15:23.123+03:00$
rascal>$2013-07-15T09:15:23.12$
|prompt:///|(0,24,<1,0>,<1,24>): Invalid datetime input: Error reading time, expected digit, found: 36
Advice: |http://tutor.rascal-mpl.org/Errors/Static/DateTimeSyntax/DateTimeSyntax.html|
ok
rascal>$2013-07-15T09:15:23$
|prompt:///|(0,21,<1,0>,<1,21>): Invalid datetime input: Error reading time, expected '.', found: 36
Advice: |http://tutor.rascal-mpl.org/Errors/Static/DateTimeSyntax/DateTimeSyntax.html|
ok
jurgenvinju commented 4 years ago

the parsing of the literal is deferred to the StandardTextReader of vallang, and this has hardcoded to only accept "full" datetime literals including "." and timezone offsets. It looks like this was never implemented correctly, but I believe that we did also have the simpler notation...

DavyLandman commented 3 years ago

this commit can be cherry-picked to fix this issue: https://github.com/usethesource/rascal/pull/1508/commits/68562706bcfcefcef728cc1bde2ba451d883fe91

Just checked, the standard text reader is still enforcing full offsets.

jurgenvinju commented 2 years ago

I get this weird behavior while checking the documentation examples:

rascal>$2010-07-15T07:15:23.123+0100$.justTime
datetime: $T07:15:23.123+01:00$
rascal>$T07:15:23.123+01:00$
|prompt:///|(0,21,<1,0>,<1,21>): Invalid datetime input: Error reading time, expected ':', found: 49
Advice: |http://tutor.rascal-mpl.org/Errors/Static/DateTimeSyntax/DateTimeSyntax.html|

so we can project a "time-only" syntax but we can not parse it anymore.