platform-common-utilities/packages/combinator/example/tuple.dart

15 lines
462 B
Dart
Raw Normal View History

2021-09-11 14:05:50 +00:00
import 'package:belatuk_combinator/belatuk_combinator.dart';
2021-09-11 13:46:31 +00:00
import 'package:string_scanner/string_scanner.dart';
void main() {
var pub = match('pub').map((r) => r.span!.text).space();
var dart = match('dart').map((r) => 24).space();
var lang = match('lang').map((r) => true).space();
// Parses a Tuple3<String, int, bool>
var grammar = tuple3(pub, dart, lang);
var scanner = SpanScanner('pub dart lang');
print(grammar.parse(scanner).value);
}