Commit Graph

18 Commits

Author SHA1 Message Date
jangko c35151b035
v0.2.2 2023-12-27 12:14:02 +07:00
jangko 1996de769b
Add fuzz test 2023-12-26 16:03:47 +07:00
jangko 9b5fbf8a0c
v0.2.0 2023-12-22 08:45:45 +07:00
tersec b068e1440d
make nimble file consistent with CI setup (#58) 2023-06-10 05:15:58 +00:00
jangko dc2cf52386
remove appveyor and travis script 2023-04-17 10:46:35 +07:00
Jacek Sieka a7d815ed92
normalise nimble, update CI (#52) 2022-11-24 13:49:34 +01:00
Jordan Hrycaj 3509706517
Lazy JSON parser (#42)
* Proper error handling when parsed number exceeds uint64

details:
  Returns an "errNonPortableInt" error

* need legacy flag for unit tests

* lazy numeric token parser

why:
  Numeric data may have a custom format. In particular,numeric data may be
  Uint256 which is not a JSON standard and might lead to an overflow.

details:
  Numeric values are assigned a preliminary token type tkNumeric without
  being fully parsed. This can be used to insert a custom parser.
  Otherwise the value is parsed implicitly when querying/fetching the
  token type.

  + tok:     replaced by getter tok() resolving lazy stuff (if necessary)
  + tokKind: current type without auto-resolving

  This lazy scheme could be extended to other custom types as long as
  the first token letter determines the custom type.

* activate lazy parsing in reader

howto:
  + no code change if a custom reader refers to an existing reader
    type FancyInt = distinct int
    proc readValue(reader: var JsonReader, value: var FancyInt) =
      value = reader.readValue(int).FancyInt

  + bespoke reader for cusom parsing
    type FancyUint = distinct uint
    proc readValue(reader: var JsonReader, value: var FancyUint) =
      if reader.lexer.lazyTok == tkNumeric:
        var accu: FancyUint
        reader.lexer.customIntValueIt:
          accu = accu * 10 + it.u256
        value = accu
      elif reader.lexer.tok == tkString:
        value = reader.lexer.strVal.parseUint.FancyUint
        ...
      reader.lexer.next

  + full code explanation at json_serialisation/reader.readValue()

* Add lazy parsing for customised string objects

why:
  This allows parsing large or specialised strings without storing it
  in the lexer state descriptor.

details:
  Similar logic applies as for the cusomised number parser. For mostly
  all practical cases, a DSL template is available serving as wrapper
  around the character/byte item processor code.

* fix typo in unit test
2022-05-05 17:33:40 +01:00
Ștefan Talpalaru 4b8f487d2d
CI: test with multiple Nim versions (#35) 2022-01-06 20:10:03 +01:00
Tanguy 010aa238cf Enable styleCheck:usages 2021-12-15 13:17:38 +02:00
Ștefan Talpalaru 652099a959
CI: refactor Nim compiler caching (#28) 2021-06-03 02:16:30 +02:00
jangko 5d36ea5900
fixes test 2020-12-24 16:32:59 +07:00
Zahary Karadjov c108ba90e6
Update the lexer test and add it to nimble test 2020-03-25 18:43:56 +02:00
Jacek Sieka f349761b76
std_shims -> stew 2019-07-07 11:46:32 +02:00
Ștefan Talpalaru 0bf9b6ed78
*.nimble: remove import 2019-03-25 22:32:41 +01:00
Ștefan Talpalaru 002c6bbb38
assert() -> doAssert()
and an explicit "test" task for the sake of nimble.sh
2019-03-14 00:39:10 +01:00
Zahary Karadjov 6d3fae7df2 Json deserialisation; Tests 2018-12-19 12:47:53 +02:00
Zahary Karadjov e5da7654d5 Use the proper field enumeration logic; Add some high-level helpers and tests 2018-11-11 13:46:19 +02:00
Zahary Karadjov 4728844a32 Initial JSON serializer 2018-11-10 02:16:09 +02:00