JSON5 in dbStatic: Lexer support for NaN and Infinity

The JSON5 spec requires exact capitalization of these strings.
Other numeric parsers such as strtod() are usually more lenient.
This commit is contained in:
Andrew Johnson
2020-07-22 00:23:50 -05:00
parent fe177e40fd
commit 0fca5fc8a9
2 changed files with 10 additions and 1 deletions

View File

@@ -33,10 +33,11 @@ exp ([eE]{sign}[0-9]+)
jsonnum ({int}{frac}?{exp}?)
intexp ({int}"."{exp}?)
fracexp ({sign}{frac}{exp}?)
specialnum ("NaN"|{sign}"Infinity")
zerox ("0x"|"0X")
hexint ({sign}{zerox}{hexdigit}+)
number ({jsonnum}|{intexp}|{fracexp}|{hexint})
number ({jsonnum}|{intexp}|{fracexp}|{specialnum}|{hexint})
%{
#undef YY_INPUT

View File

@@ -73,4 +73,12 @@ record(x, "t1") {
field(F64, -.123e4)
field(F32, -123.e4)
field(F64, -123.e4)
field(F32, Infinity)
field(F64, Infinity)
field(F32, +Infinity)
field(F64, +Infinity)
field(F32, -Infinity)
field(F64, -Infinity)
field(F32, Nan)
field(F64, Nan)
}