Updated combinator
This commit is contained in:
parent
13ab076cab
commit
4774e6b135
24 changed files with 45 additions and 27 deletions
|
@ -1,5 +1,9 @@
|
||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
|
## 3.0.1
|
||||||
|
|
||||||
|
* Updated README
|
||||||
|
|
||||||
## 3.0.0
|
## 3.0.0
|
||||||
|
|
||||||
* Upgraded from `pendantic` to `lints` linter
|
* Upgraded from `pendantic` to `lints` linter
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Belatuk Code Buffer
|
# Belatuk Code Buffer
|
||||||
|
|
||||||
[![version](https://img.shields.io/badge/pub-v3.0.0-brightgreen)](https://pub.dartlang.org/packages/belatuk_code_buffer)
|
[![version](https://img.shields.io/badge/pub-v3.0.1-brightgreen)](https://pub.dartlang.org/packages/belatuk_code_buffer)
|
||||||
[![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety)
|
[![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety)
|
||||||
[![License](https://img.shields.io/github/license/dart-backend/belatuk-common-utilities)](https://github.com/dart-backend/belatuk-common-utilities/packages/code_buffer/LICENSE)
|
[![License](https://img.shields.io/github/license/dart-backend/belatuk-common-utilities)](https://github.com/dart-backend/belatuk-common-utilities/packages/code_buffer/LICENSE)
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
name: belatuk_code_buffer
|
name: belatuk_code_buffer
|
||||||
version: 3.0.0
|
version: 3.0.1
|
||||||
description: An advanced StringBuffer geared toward generating code, and source maps.
|
description: An advanced StringBuffer geared toward generating code, and source maps.
|
||||||
homepage: https://github.com/dart-backend/belatuk-common-utilities/tree/main/packages/code_buffer
|
homepage: https://github.com/dart-backend/belatuk-common-utilities/tree/main/packages/code_buffer
|
||||||
environment:
|
environment:
|
||||||
|
|
|
@ -4,10 +4,11 @@
|
||||||
|
|
||||||
* Upgraded from `pendantic` to `lints` linter
|
* Upgraded from `pendantic` to `lints` linter
|
||||||
* Published as `belatuk_combinator` package
|
* Published as `belatuk_combinator` package
|
||||||
|
* Resolved static analysis warnings
|
||||||
|
|
||||||
## 2.0.2
|
## 2.0.2
|
||||||
|
|
||||||
* Resolve static analysis warnings
|
* Resolved static analysis warnings
|
||||||
|
|
||||||
## 2.0.1
|
## 2.0.1
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
[![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety)
|
[![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety)
|
||||||
[![License](https://img.shields.io/github/license/dart-backend/belatuk-common-utilities)](https://github.com/dart-backend/belatuk-common-utilities/packages/combinator/LICENSE)
|
[![License](https://img.shields.io/github/license/dart-backend/belatuk-common-utilities)](https://github.com/dart-backend/belatuk-common-utilities/packages/combinator/LICENSE)
|
||||||
|
|
||||||
|
**Replacement of `package:combinator` with breaking changes to support NNBD.**
|
||||||
|
|
||||||
Packrat parser combinators that support static typing, generics, file spans, memoization, and more.
|
Packrat parser combinators that support static typing, generics, file spans, memoization, and more.
|
||||||
|
|
||||||
**RECOMMENDED:**
|
**RECOMMENDED:**
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:angel3_combinator/belatuk_combinator.dart';
|
import 'package:belatuk_combinator/belatuk_combinator.dart';
|
||||||
import 'package:string_scanner/string_scanner.dart';
|
import 'package:string_scanner/string_scanner.dart';
|
||||||
|
|
||||||
/// Parse a part of a decoded Basic auth string.
|
/// Parse a part of a decoded Basic auth string.
|
||||||
|
@ -33,7 +33,7 @@ final Parser credentialString = match<Map<String, String>?>(
|
||||||
return credentials.parse(scanner).value;
|
return credentials.parse(scanner).value;
|
||||||
});
|
});
|
||||||
|
|
||||||
final Parser basic = match<Null>('Basic').space();
|
final Parser basic = match<void>('Basic').space();
|
||||||
|
|
||||||
final Parser basicAuth = basic.then(credentialString).index(1);
|
final Parser basicAuth = basic.then(credentialString).index(1);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:angel3_combinator/belatuk_combinator.dart';
|
import 'package:belatuk_combinator/belatuk_combinator.dart';
|
||||||
import 'package:string_scanner/string_scanner.dart';
|
import 'package:string_scanner/string_scanner.dart';
|
||||||
|
|
||||||
/// Note: This grammar does not handle precedence, for the sake of simplicity.
|
/// Note: This grammar does not handle precedence, for the sake of simplicity.
|
||||||
|
@ -22,7 +22,7 @@ Parser<num> calculatorGrammar() {
|
||||||
alternatives.add(
|
alternatives.add(
|
||||||
chain<num>([
|
chain<num>([
|
||||||
expr.space(),
|
expr.space(),
|
||||||
match<Null>(op).space() as Parser<num>,
|
match<void>(op).space() as Parser<num>,
|
||||||
expr.space(),
|
expr.space(),
|
||||||
]).map((r) => f(r.value![0], r.value![2])),
|
]).map((r) => f(r.value![0], r.value![2])),
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:angel3_combinator/belatuk_combinator.dart';
|
import 'package:belatuk_combinator/belatuk_combinator.dart';
|
||||||
import 'package:string_scanner/string_scanner.dart';
|
import 'package:string_scanner/string_scanner.dart';
|
||||||
|
|
||||||
final Parser<String> id =
|
final Parser<String> id =
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:angel3_combinator/belatuk_combinator.dart';
|
import 'package:belatuk_combinator/belatuk_combinator.dart';
|
||||||
import 'package:string_scanner/string_scanner.dart';
|
import 'package:string_scanner/string_scanner.dart';
|
||||||
|
|
||||||
Parser jsonGrammar() {
|
Parser jsonGrammar() {
|
||||||
|
@ -51,13 +51,13 @@ Parser jsonGrammar() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
var JSON = jsonGrammar();
|
var json = jsonGrammar();
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
stdout.write('Enter some JSON: ');
|
stdout.write('Enter some JSON: ');
|
||||||
var line = stdin.readLineSync()!;
|
var line = stdin.readLineSync()!;
|
||||||
var scanner = SpanScanner(line, sourceUrl: 'stdin');
|
var scanner = SpanScanner(line, sourceUrl: 'stdin');
|
||||||
var result = JSON.parse(scanner);
|
var result = json.parse(scanner);
|
||||||
|
|
||||||
if (!result.successful) {
|
if (!result.successful) {
|
||||||
for (var error in result.errors) {
|
for (var error in result.errors) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:angel3_combinator/belatuk_combinator.dart';
|
import 'package:belatuk_combinator/belatuk_combinator.dart';
|
||||||
import 'package:string_scanner/string_scanner.dart';
|
import 'package:string_scanner/string_scanner.dart';
|
||||||
|
|
||||||
final Parser minus = match('-');
|
final Parser minus = match('-');
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// For some reason, this cannot be run in checked mode???
|
// For some reason, this cannot be run in checked mode???
|
||||||
|
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:angel3_combinator/belatuk_combinator.dart';
|
import 'package:belatuk_combinator/belatuk_combinator.dart';
|
||||||
import 'package:string_scanner/string_scanner.dart';
|
import 'package:string_scanner/string_scanner.dart';
|
||||||
|
|
||||||
final Parser<String> key =
|
final Parser<String> key =
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import 'dart:collection';
|
import 'dart:collection';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
import 'package:angel3_combinator/belatuk_combinator.dart';
|
import 'package:belatuk_combinator/belatuk_combinator.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';
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import 'package:angel3_combinator/belatuk_combinator.dart';
|
import 'package:belatuk_combinator/belatuk_combinator.dart';
|
||||||
import 'package:string_scanner/string_scanner.dart';
|
import 'package:string_scanner/string_scanner.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
|
|
@ -15,7 +15,7 @@ Parser<T> any<T>(Iterable<Parser<T>> parsers,
|
||||||
class _Any<T> extends Parser<T> {
|
class _Any<T> extends Parser<T> {
|
||||||
final Iterable<Parser<T>> parsers;
|
final Iterable<Parser<T>> parsers;
|
||||||
final bool backtrack;
|
final bool backtrack;
|
||||||
final errorMessage;
|
final dynamic errorMessage;
|
||||||
final SyntaxErrorSeverity severity;
|
final SyntaxErrorSeverity severity;
|
||||||
|
|
||||||
_Any(this.parsers, this.backtrack, this.errorMessage, this.severity);
|
_Any(this.parsers, this.backtrack, this.errorMessage, this.severity);
|
||||||
|
|
|
@ -2,7 +2,7 @@ library lex.src.combinator;
|
||||||
|
|
||||||
import 'dart:collection';
|
import 'dart:collection';
|
||||||
|
|
||||||
import 'package:angel3_code_buffer/angel3_code_buffer.dart';
|
import 'package:belatuk_code_buffer/belatuk_code_buffer.dart';
|
||||||
import 'package:matcher/matcher.dart';
|
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';
|
||||||
|
|
|
@ -34,7 +34,9 @@ class _Longest<T> extends Parser<T> {
|
||||||
|
|
||||||
if (result.successful && result.span != null) {
|
if (result.successful && result.span != null) {
|
||||||
results.add(result);
|
results.add(result);
|
||||||
} else if (parser is _Alt) errors.addAll(result.errors);
|
} else if (parser is _Alt) {
|
||||||
|
errors.addAll(result.errors);
|
||||||
|
}
|
||||||
|
|
||||||
args.scanner.position = replay;
|
args.scanner.position = replay;
|
||||||
}
|
}
|
||||||
|
@ -70,7 +72,9 @@ class _Longest<T> extends Parser<T> {
|
||||||
|
|
||||||
if (result.successful) {
|
if (result.successful) {
|
||||||
results.add(result);
|
results.add(result);
|
||||||
} else if (parser is _Alt) errors.addAll(result.errors);
|
} else if (parser is _Alt) {
|
||||||
|
errors.addAll(result.errors);
|
||||||
|
}
|
||||||
|
|
||||||
args.scanner.position = replay;
|
args.scanner.position = replay;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,9 @@ class _Repeat<T> extends ListParser<T> {
|
||||||
results.add(result.value!);
|
results.add(result.value!);
|
||||||
}
|
}
|
||||||
replay = args.scanner.position;
|
replay = args.scanner.position;
|
||||||
} else if (backtrack) args.scanner.position = replay;
|
} else if (backtrack) {
|
||||||
|
args.scanner.position = replay;
|
||||||
|
}
|
||||||
|
|
||||||
if (result.span != null) {
|
if (result.span != null) {
|
||||||
spans.add(result.span!);
|
spans.add(result.span!);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import 'package:angel3_combinator/belatuk_combinator.dart';
|
import 'package:belatuk_combinator/belatuk_combinator.dart';
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
import 'common.dart';
|
import 'common.dart';
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import 'package:angel3_combinator/belatuk_combinator.dart';
|
import 'package:belatuk_combinator/belatuk_combinator.dart';
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
import 'common.dart';
|
import 'common.dart';
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import 'package:angel3_combinator/belatuk_combinator.dart';
|
import 'package:belatuk_combinator/belatuk_combinator.dart';
|
||||||
import 'package:matcher/matcher.dart';
|
import 'package:matcher/matcher.dart';
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
import 'common.dart';
|
import 'common.dart';
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import 'package:angel3_combinator/belatuk_combinator.dart';
|
import 'package:belatuk_combinator/belatuk_combinator.dart';
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
import 'common.dart';
|
import 'common.dart';
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
|
## 4.0.1
|
||||||
|
|
||||||
|
* Updated README
|
||||||
|
|
||||||
## 4.0.0
|
## 4.0.0
|
||||||
|
|
||||||
* Upgraded from `pendantic` to `lints` linter
|
* Upgraded from `pendantic` to `lints` linter
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
# Belatuk Pub Sub
|
# Belatuk Pub Sub
|
||||||
|
|
||||||
[![version](https://img.shields.io/badge/pub-v4.0.0-brightgreen)](https://pub.dartlang.org/packages/belatuk_pub_sub)
|
[![version](https://img.shields.io/badge/pub-v4.0.1-brightgreen)](https://pub.dartlang.org/packages/belatuk_pub_sub)
|
||||||
[![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety)
|
[![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety)
|
||||||
[![License](https://img.shields.io/github/license/dart-backend/belatuk-common-utilities)](https://github.com/dart-backend/belatuk-common-utilities/packages/pub_sub/LICENSE)
|
|
||||||
|
**Replacement of `package:pub_sub` with breaking changes to support NNBD.**
|
||||||
|
|
||||||
Keep application instances in sync with a simple pub/sub API.
|
Keep application instances in sync with a simple pub/sub API.
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
name: belatuk_pub_sub
|
name: belatuk_pub_sub
|
||||||
version: 4.0.0
|
version: 4.0.1
|
||||||
description: Keep application instances in sync with a simple pub/sub API.
|
description: Keep application instances in sync with a simple pub/sub API.
|
||||||
homepage: https://github.com/dart-backend/belatuk-common-utilities/tree/main/packages/pub_sub
|
homepage: https://github.com/dart-backend/belatuk-common-utilities/tree/main/packages/pub_sub
|
||||||
environment:
|
environment:
|
||||||
|
|
Loading…
Reference in a new issue