Skip to content

aaaidan/parserlib

Repository files navigation

parserlib

A simple parser combinator written in JS.

Note: This is not ready for real use. There are probably better javascript parser combinators out there.

Usage

Build up complex, useful parsers out of basic built-in parsers, such as or and seq.

Here's a hammy parser that parses a fake (and silly) idea for what makes a valid email address.

var user = or('aidan', 'billy', 'catness');

var domain = seq(
	or(
		'google',
		'apple',
		'microsoft',
		'facebook'
	),
	'.',
	or(
		'com',
		'org',
		'net'
	)
);

var email = seq(user, "@", domain);

email.parse("aidan@google.net"); // "aidan@google.net"
email.parse("billy@facebook.org"); // "billy@facebook.org"
email.parse("zara@lolfactory.biz"); // null

About

Yet another parser combinator written in JS.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors