talira

PetitParser for Dart

Composable, type-safe parser combinators in plain Dart

open sourceMITfree

PetitParser for Dart builds parsers in plain Dart code instead of regular expressions or external code generators. You assemble small parsers like building blocks, from single characters up to whole grammars for configuration formats or programming languages, and map what they match straight into typed Dart records, syntax trees or domain objects using generics and pattern matching. It has optimized fast paths for character matching and built-in tools to inspect tokens and trace parsing in your IDE.

Problems it solves

  • write a parser in Dart without regular expressions
  • parse a configuration format or small language in Flutter
  • build a type-safe grammar in Dart without a code generator

Features

  • compose parsers with operators and methods in plain Dart
  • type-safe results with Dart records, generics and pattern matching
  • optimized character predicates and fast-path parsing
  • token inspection and parse tracing for debugging

Alternatives

The same job

These do what PetitParser for Dart does.

  1. peg Packrat parser generator for Go from Parsing Expression Grammars

Compare PetitParser for Dart with the top 3