From 1c8a847693c89aa205694b1f78e169fcea96d30b Mon Sep 17 00:00:00 2001 From: Alexey Date: Mon, 11 Sep 2023 18:31:21 -0700 Subject: [PATCH] v0.6.5 (#79) --- CHANGELOG.md | 5 +++++ lib/src/grammar/number.dart | 25 ++++++++++++++++++------- pubspec.yaml | 2 +- test/cases/cts | 2 +- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01c9852..7697709 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.6.5] - 2023-09-11 +### Fixed +- Certain numbers were not parsed correctly + ## [0.6.4] - 2023-08-26 ### Changed - Bump dependencies versions @@ -168,6 +172,7 @@ Previously, no modification would be made and no errors/exceptions thrown. ### Added - Basic design draft +[0.6.5]: https://github.com/f3ath/jessie/compare/0.6.4...0.6.5 [0.6.4]: https://github.com/f3ath/jessie/compare/0.6.3...0.6.4 [0.6.3]: https://github.com/f3ath/jessie/compare/0.6.2...0.6.3 [0.6.2]: https://github.com/f3ath/jessie/compare/0.6.1...0.6.2 diff --git a/lib/src/grammar/number.dart b/lib/src/grammar/number.dart index 7cad512..501634b 100644 --- a/lib/src/grammar/number.dart +++ b/lib/src/grammar/number.dart @@ -2,13 +2,24 @@ import 'package:petitparser/petitparser.dart'; final _digit1 = range('1', '9'); -final integer = (char('0') | (char('-').optional() & _digit1 & digit().star())) - .flatten('an integer number expected') - .map(int.parse); +final _integer = (char('0') | (char('-').optional() & _digit1 & digit().star())) + .flatten('an integer number expected'); -final float = +final _float = (char('-').optional() & digit().star() & char('.') & digit().plus()) - .flatten('a floating point number expected') - .map(double.parse); + .flatten('a floating point number expected'); -final Parser number = [float, integer].toChoiceParser(); +final _exp = ((_float | _integer | string('-0')) & + char('e') & + anyOf('-+').optional() & + digit().plus()) + .flatten('an exponent number expected'); + +final integer = _integer.map(int.parse); + +final Parser number = [ + _exp.map(double.parse), + _float.map(double.parse), + string('-0').map((_) => 0), + integer, +].toChoiceParser(); diff --git a/pubspec.yaml b/pubspec.yaml index 09d931b..6d54ed4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: json_path -version: 0.6.4 +version: 0.6.5 description: Implementation of JSONPath expressions like "$.store.book[2].price". Reads and writes values in parsed JSON objects. homepage: "https://github.com/f3ath/jessie" diff --git a/test/cases/cts b/test/cases/cts index 009f416..ca076c0 160000 --- a/test/cases/cts +++ b/test/cases/cts @@ -1 +1 @@ -Subproject commit 009f4160ad71651f37df36f6cfd3542d3cabb11d +Subproject commit ca076c0e55d378236e7b70fc8e6414234dcca294