Fixed route test cases
This commit is contained in:
parent
25af334f4d
commit
7d5e75e440
6 changed files with 22 additions and 14 deletions
|
@ -43,7 +43,7 @@ class _Chain<T> extends ListParser<T> {
|
||||||
@override
|
@override
|
||||||
ParseResult<List<T>> __parse(ParseArgs args) {
|
ParseResult<List<T>> __parse(ParseArgs args) {
|
||||||
var errors = <SyntaxError>[];
|
var errors = <SyntaxError>[];
|
||||||
var results = <T?>[];
|
var results = <T>[];
|
||||||
var spans = <FileSpan>[];
|
var spans = <FileSpan>[];
|
||||||
bool successful = true;
|
bool successful = true;
|
||||||
|
|
||||||
|
@ -62,9 +62,14 @@ class _Chain<T> extends ListParser<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: To be looked at
|
//TODO: To be looked at
|
||||||
//if (result.value != null) {
|
if (result.value != null) {
|
||||||
results.add(result.value);
|
//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) {
|
if (result.span != null) {
|
||||||
spans.add(result.span!);
|
spans.add(result.span!);
|
||||||
|
|
|
@ -7,7 +7,6 @@ import 'package:matcher/matcher.dart';
|
||||||
import 'package:source_span/source_span.dart';
|
import 'package:source_span/source_span.dart';
|
||||||
import 'package:string_scanner/string_scanner.dart';
|
import 'package:string_scanner/string_scanner.dart';
|
||||||
import 'package:tuple/tuple.dart';
|
import 'package:tuple/tuple.dart';
|
||||||
import 'package:optional/optional.dart';
|
|
||||||
import '../error.dart';
|
import '../error.dart';
|
||||||
|
|
||||||
part 'any.dart';
|
part 'any.dart';
|
||||||
|
@ -199,7 +198,7 @@ abstract class Parser<T> {
|
||||||
}
|
}
|
||||||
var preceding = v.isEmpty ? [] : (v[0] == null ? [] : [v[0]]);
|
var preceding = v.isEmpty ? [] : (v[0] == null ? [] : [v[0]]);
|
||||||
var out = List<T>.from(preceding);
|
var out = List<T>.from(preceding);
|
||||||
if (v[1] != null) {
|
if (v[1] != null && v[1] != "NULL") {
|
||||||
v[1].forEach((element) {
|
v[1].forEach((element) {
|
||||||
out.add(element as T);
|
out.add(element as T);
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,7 +8,7 @@ class _Index<T> extends Parser<T> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
ParseResult<T> __parse(ParseArgs args) {
|
ParseResult<T> __parse(ParseArgs args) {
|
||||||
ParseResult<List<T>?> result = parser._parse(args.increaseDepth());
|
ParseResult<List<T>> result = parser._parse(args.increaseDepth());
|
||||||
Object? value;
|
Object? value;
|
||||||
|
|
||||||
if (result.successful) {
|
if (result.successful) {
|
||||||
|
|
|
@ -15,6 +15,5 @@ dependencies:
|
||||||
source_span: ^1.8.1
|
source_span: ^1.8.1
|
||||||
string_scanner: ^1.1.0
|
string_scanner: ^1.1.0
|
||||||
tuple: ^2.0.0
|
tuple: ^2.0.0
|
||||||
optional: ^6.0.0-nullsafety.2
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
test: ^1.17.3
|
test: ^1.17.3
|
|
@ -20,7 +20,12 @@ class RouteGrammar {
|
||||||
regExp.opt(),
|
regExp.opt(),
|
||||||
]).map((r) {
|
]).map((r) {
|
||||||
var match = r.value![0] as Match;
|
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 pre = match[1] ?? '';
|
||||||
var post = match[3] ?? '';
|
var post = match[3] ?? '';
|
||||||
|
|
|
@ -7,11 +7,11 @@ environment:
|
||||||
sdk: '>=2.12.0 <3.0.0'
|
sdk: '>=2.12.0 <3.0.0'
|
||||||
dependencies:
|
dependencies:
|
||||||
combinator:
|
combinator:
|
||||||
path: ../combinator
|
# path: ../combinator
|
||||||
# git:
|
git:
|
||||||
# url: https://github.com/dukefirehawk/angel.git
|
url: https://github.com/dukefirehawk/angel.git
|
||||||
# ref: sdk-2.12.x_nnbd
|
ref: sdk-2.12.x_nnbd
|
||||||
# path: packages/combinator
|
path: packages/combinator
|
||||||
string_scanner: ^1.0.0
|
string_scanner: ^1.0.0
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
build_runner: ^1.11.5
|
build_runner: ^1.11.5
|
||||||
|
|
Loading…
Reference in a new issue