Skip to content

coder-ka/parser-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Parser Template

Parser Template is a parser generator in JavaScript.

Installation

npm install @coder-ka/parser-template

Example

Creating an IPAddressV4 parser.

import { integer, seq } from "../lib/main";

const segment = integer();

const ipV4 = seq`${segment}.${segment}.${segment}.${segment}`;

const { value } = translate("192.168.1.1", ipV4);

// ["192","168","1","1"]
console.log(value);

A more complex example parsing markdown unordered list is here.

Structural Expressions

  • seq
  • flat
  • reduce
  • object

Control Expressions

  • lazy
  • or

Built-in Primitive Expressions

  • string
  • regexp
  • function(str: string): unknown
  • empty
  • end
  • any
  • exists
  • integer

Utility Expressions

  • repeat(at least 1)
  • split(delimiter, splitItemExpr)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published