parsers 1.0.0

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 79

Parser Combinators for Dart

Check out the user guide (work in progress) and the API reference.

Quick Start

import 'package:parsers/parsers.dart';
import 'dart:math';

// grammar

final number = digit.many1       ^ digits2int
             | string('none')    ^ none
             | string('answer')  ^ answer;

final comma = char(',') < spaces;

final numbers = number.sepBy(comma) < eof;

// actions

digits2int(digits) => parseInt(Strings.concatAll(digits));
none(_) => null;
answer(_) => 42;

// parsing

main() {
  print(numbers.parse('0,1, none, 3,answer'));
  // [0, 1, null, 3, 42]

  print(numbers.parse('0,1, boom, 3,answer'));
  // line 1, character 6: expected digit, 'none' or 'answer', got 'b'.
}

See the example directory for advanced usage.

About

This library is heavily inspired by Parsec, but differs on some points. In particular, the | operator has a sane backtracking semantics, as in Polyparse. As a consequence it is slower but also easier to use. I've also introduced some syntax for transforming parsing results that doesn't require any knowledge of monads or applicative functors and features uncurried functions, which are nicer-looking than curried ones in Dart.

Parsers Changelog

1.0.0

  • Make strong mode and dart 2 compatible.
  • Introduce non-infix generic methods for all the infix operators.

0.14.5

  • Lazy computation of the error messages (PR #18).

0.14.4

  • Support setting the value of a tabstop in position calculation (PR #16).

0.14.3

  • Move run_all_tests.sh to tests/run.sh to adhere to pub.drone.io's conventions.

0.14.2

  • Fix type annotation leading to failure in checked mode

0.14.1

  • Added CHANGELOG.md
  • Fix type annotation leading to failure in checked mode

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  parsers: "^1.0.0"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


      import 'package:parsers/parsers.dart';
  
Version Uploaded Documentation Archive
1.0.0 Mar 16, 2018 Go to the documentation of parsers 1.0.0 Download parsers 1.0.0 archive
0.14.5 Nov 10, 2015 Go to the documentation of parsers 0.14.5 Download parsers 0.14.5 archive
0.14.4 Aug 3, 2015 Go to the documentation of parsers 0.14.4 Download parsers 0.14.4 archive
0.14.3 Sep 18, 2014 Go to the documentation of parsers 0.14.3 Download parsers 0.14.3 archive
0.14.2 Sep 3, 2014 Go to the documentation of parsers 0.14.2 Download parsers 0.14.2 archive
0.14.1 Aug 27, 2014 Go to the documentation of parsers 0.14.1 Download parsers 0.14.1 archive
0.14.0 Nov 8, 2013 Go to the documentation of parsers 0.14.0 Download parsers 0.14.0 archive
0.13.7 Oct 25, 2013 Go to the documentation of parsers 0.13.7 Download parsers 0.13.7 archive
0.13.6 Oct 2, 2013 Go to the documentation of parsers 0.13.6 Download parsers 0.13.6 archive
0.13.5 Sep 24, 2013 Go to the documentation of parsers 0.13.5 Download parsers 0.13.5 archive

All 47 versions...

Analysis

We analyzed this package on Jun 19, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
58 / 100
Health:
Code health derived from static analysis. [more]
100 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
79
Learn more about scoring.

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:parsers/parsers.dart.

Suggestions

  • Maintain an example.

    None of the files in your example/ directory matches a known example patterns. Common file name patterns include: main.dart, example.dart or you could also use parsers.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.0 <2.0.0
persistent ^1.0.0 1.0.0
Dev dependencies
unittest ^0.11.0