mixfix
v0.0.2
Published
mixfix expression parser
Downloads
2
Readme
mixfix
mixfix expression parser
Based on: Parsing Mixfix Operators
parser
Parser a = List token → Error ∨ NonEmptyList (a × List token)
Parsers are functions taking list of tokens and returning either error or possible parse results.
In actual implementation List token
is represented by an array of tokens and an index into it.
parser.parse(@: Parser a, tokens: List token): a
Parse
tokens
. Returns first parse result.parser.map(@: Parser a, f: a -> b): Parser b
parser.uniq(@: Parser a): Parser a
parser.satisfy(@: Parser a, predicate: a -> Boolean): Parser a
parser.end(@: Parser a): Parser a
parser.many(@: Parser a): Parser (Array a)
parser.some(@: Parser a): Parser (Array a)
parser.left(@: Parser a, other: Parser b): Parser a
parser.right(@: Parser a, other: Parser b): Parser b
pure(x: a): Parser a
fail(error: Err): Parser a
any: Parser a
combine(p: Parser a..., f: a... -> b): Parser b
choice(p: Parser a | List (Parser a)...): Parser a
lazy(f: => Parser a): Parser a
lexer
A very simple lexer.
lexer.create(specification: List (String | RegExp)): String -> List String
Creates a tokenizer function.
Release History
- 0.0.2 — 2015-01-07 — Simple lexer
- 0.0.1 — 2014-11-23 — Parser combinators
Contributing
README.md
is generated from the source with ljs- Before creating a pull request run
make test
, yet travis will do it for you.