From fe177e40fd8821953ebaac34360a97f91c12c728 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Tue, 21 Jul 2020 23:55:00 -0500 Subject: [PATCH] JSON5 in dbStatic: Add lexer support for hex integers dbLex.l accepts hex notation in JSON numbers. Tested in dbStaticTest.db as before. --- modules/database/src/ioc/dbStatic/dbLex.l | 5 +++- modules/database/test/ioc/db/dbStaticTest.db | 28 ++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/modules/database/src/ioc/dbStatic/dbLex.l b/modules/database/src/ioc/dbStatic/dbLex.l index 5c28044f8..542959231 100644 --- a/modules/database/src/ioc/dbStatic/dbLex.l +++ b/modules/database/src/ioc/dbStatic/dbLex.l @@ -33,7 +33,10 @@ exp ([eE]{sign}[0-9]+) jsonnum ({int}{frac}?{exp}?) intexp ({int}"."{exp}?) fracexp ({sign}{frac}{exp}?) -number ({jsonnum}|{intexp}|{fracexp}) + +zerox ("0x"|"0X") +hexint ({sign}{zerox}{hexdigit}+) +number ({jsonnum}|{intexp}|{fracexp}|{hexint}) %{ #undef YY_INPUT diff --git a/modules/database/test/ioc/db/dbStaticTest.db b/modules/database/test/ioc/db/dbStaticTest.db index 03ffaf4b9..546cb0bbb 100644 --- a/modules/database/test/ioc/db/dbStaticTest.db +++ b/modules/database/test/ioc/db/dbStaticTest.db @@ -17,6 +17,34 @@ record(x, "t1") { field(U32, +1234567) field(I64, +12345678) field(U64, +123456789) + field( C8, 0x1) + field( U8, 0x12) + field(I16, 0x123) + field(U16, 0x1234) + field(I32, 0x12345) + field(U32, 0x123456) + field(I64, 0x1234567) + field(U64, 0x12345678) + field( C8, +0x1) + field( U8, -0x12) + field(I16, +0x123) + field(U16, -0x1234) + field(I32, +0x12345) + field(U32, -0x123456) + field(I64, +0x1234567) + field(U64, -0x12345678) + field( C8, 0x7f) + field( U8, 0xff) + field(I16, 0x7fff) + field(I16, -0x8000) + field(U16, 0xffff) + field(I32, 0x7fffffff) + field(I32, -0x80000000) + field(U32, 0xffffffff) + field(I64, 0x7fffffffffffffff) + field(I64, -0x8000000000000000) + field(U64, 0xffffffffffffffff) + field(F32, .123) field(F64, .123) field(F32, 123.)