diff --git a/packages/combinator/lib/src/combinator/chain.dart b/packages/combinator/lib/src/combinator/chain.dart index e2c5377f..03022f2f 100644 --- a/packages/combinator/lib/src/combinator/chain.dart +++ b/packages/combinator/lib/src/combinator/chain.dart @@ -43,7 +43,7 @@ class _Chain extends ListParser { @override ParseResult> __parse(ParseArgs args) { var errors = []; - var results = []; + var results = []; var spans = []; bool successful = true; @@ -62,9 +62,14 @@ class _Chain extends ListParser { } //TODO: To be looked at - //if (result.value != null) { - results.add(result.value); - //} + if (result.value != null) { + //print(result.value.runtimeType); + results.add(result.value!); + } else { + //print("Add NULL"); + // Add dummy "NULL" String + results.add("NULL" as T); + } if (result.span != null) { spans.add(result.span!); diff --git a/packages/combinator/lib/src/combinator/combinator.dart b/packages/combinator/lib/src/combinator/combinator.dart index 8f7429ae..821b8991 100644 --- a/packages/combinator/lib/src/combinator/combinator.dart +++ b/packages/combinator/lib/src/combinator/combinator.dart @@ -7,7 +7,6 @@ import 'package:matcher/matcher.dart'; import 'package:source_span/source_span.dart'; import 'package:string_scanner/string_scanner.dart'; import 'package:tuple/tuple.dart'; -import 'package:optional/optional.dart'; import '../error.dart'; part 'any.dart'; @@ -199,7 +198,7 @@ abstract class Parser { } var preceding = v.isEmpty ? [] : (v[0] == null ? [] : [v[0]]); var out = List.from(preceding); - if (v[1] != null) { + if (v[1] != null && v[1] != "NULL") { v[1].forEach((element) { out.add(element as T); }); diff --git a/packages/combinator/lib/src/combinator/index.dart b/packages/combinator/lib/src/combinator/index.dart index a92561e7..e52860a7 100644 --- a/packages/combinator/lib/src/combinator/index.dart +++ b/packages/combinator/lib/src/combinator/index.dart @@ -8,7 +8,7 @@ class _Index extends Parser { @override ParseResult __parse(ParseArgs args) { - ParseResult?> result = parser._parse(args.increaseDepth()); + ParseResult> result = parser._parse(args.increaseDepth()); Object? value; if (result.successful) { diff --git a/packages/combinator/pubspec.yaml b/packages/combinator/pubspec.yaml index 95fec8f4..1ba7ae13 100644 --- a/packages/combinator/pubspec.yaml +++ b/packages/combinator/pubspec.yaml @@ -15,6 +15,5 @@ dependencies: source_span: ^1.8.1 string_scanner: ^1.1.0 tuple: ^2.0.0 - optional: ^6.0.0-nullsafety.2 dev_dependencies: test: ^1.17.3 \ No newline at end of file diff --git a/packages/route/lib/src/grammar.dart b/packages/route/lib/src/grammar.dart index 59fab6ec..05c59149 100644 --- a/packages/route/lib/src/grammar.dart +++ b/packages/route/lib/src/grammar.dart @@ -20,7 +20,12 @@ class RouteGrammar { regExp.opt(), ]).map((r) { var match = r.value![0] as Match; - var rgxMatch = r.value![2] as Match?; + + var r2 = r.value![2]; + Match? rgxMatch; + if (r2 != 'NULL') { + rgxMatch = r2 as Match?; + } var pre = match[1] ?? ''; var post = match[3] ?? ''; diff --git a/packages/route/pubspec.yaml b/packages/route/pubspec.yaml index cdea689c..527a12bc 100644 --- a/packages/route/pubspec.yaml +++ b/packages/route/pubspec.yaml @@ -7,11 +7,11 @@ environment: sdk: '>=2.12.0 <3.0.0' dependencies: combinator: - path: ../combinator -# git: -# url: https://github.com/dukefirehawk/angel.git -# ref: sdk-2.12.x_nnbd -# path: packages/combinator +# path: ../combinator + git: + url: https://github.com/dukefirehawk/angel.git + ref: sdk-2.12.x_nnbd + path: packages/combinator string_scanner: ^1.0.0 dev_dependencies: build_runner: ^1.11.5