Skip to content

JavaScript version ( Browser and Node.js ) of SimplePEG

License

Notifications You must be signed in to change notification settings

jamaks/JavaScript

This branch is up to date with SimplePEG/JavaScript:master.

Folders and files

NameName
Last commit message
Last commit date
Aug 16, 2017
Feb 20, 2017
Aug 16, 2017
Dec 19, 2016
Aug 16, 2017
Dec 19, 2016
Jun 26, 2016
Oct 2, 2019
Jun 22, 2016
Oct 3, 2017
Oct 2, 2019
Oct 9, 2019
Oct 2, 2019

Repository files navigation

JavaScript

Join the chat at https://gitter.im/SimplePEG/JavaScript Greenkeeper badge Build Status Coverage Status

JavaScript version ( Browser and Node.js ) of SimplePEG. A very simple implementation of PEG parser generator.

const simplepeg = require('simplepeg');
const parser = new simplepeg.SPEG();

parser.parse_grammar('GRAMMAR test a->"A";');
const ast = parser.parse_text('A');
console.log(JSON.stringify(ast, null, 4));

Grammar example

url.peg

GRAMMAR url

url       ->  scheme "://" host pathname search hash?;
scheme    ->  "http" "s"?;
host      ->  hostname port?;
hostname  ->  segment ("." segment)*;
segment   ->  [a-z0-9-]+;
port      ->  ":" [0-9]+;
pathname  ->  "/" [^ ?]*;
search    ->  ("?" [^ #]*)?;
hash      ->  "#" [^ ]*;

About

JavaScript version ( Browser and Node.js ) of SimplePEG

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%