parzec_deno
parzec_deno is a Deno port of the Parzec NPM package.
Parser Combinators for Typescript
Parzec is a parser combinator library adapted from Haskell’s famous Parsec library. A parser combinator library consist of higher order functions which make it easy to build recursive descent parsers. Parsers composed from Parzec’s combinators can recognize languages in the PEG class of grammars. PEG grammars can be context-sensitive, so the parsers have infinite lookahead and backtracking capabilities.
Parzec also supports efficient parsing of LL(1) grammars by enabling the backtracking only when a special combinator is used. Also, to improve performance, some combinators have been inlined rather than built from lower level combinators.
Parzec’s input is represented by an abstract interface. Consequently, the parsers’ input can be anything from simple strings to files, or even tokenized data streams. Parzec includes functionality to create lexical analyzers or lexers from regular expressions. The lexer converts input strings into tokens, and makes the parsing simpler and more efficient.
Motivation
The original Parzec library (at deno.land/x/parzec) does not seem to currently support Deno.
Changes
In order to make the NPM based Parzec compatible with Deno, some changes have to be made. Parzec fortunately has no run-time dependencies, so only local imports need to be updated. These are parzec_deno’s contributions to the original Parzec repository:
- Update docs and metadata.
- Translated the NPM project structure to Deno.
- Fixed errors discovered by
deno fmt
anddeno lint
.- Formatted all files with
deno fmt
. - Added
// deno-lint-ignore no-explicit-any
where necessary. - Replaced
let
withconst
where possible. - Removed unnecessary
async
keywords in tests.
- Formatted all files with
- Added new build and CI tools.
Usage
import * as pz from "https://deno.land/x/parzec_deno/mod.ts";