Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rxwei/Parsey

Swift Parser Combinators
https://github.com/rxwei/Parsey

parser parser-combinators swift

Last synced: about 1 month ago
JSON representation

Swift Parser Combinators

Awesome Lists containing this project

README

        

# Parsey
Swift Parser Combinator Framework

In addition to simple combinators, **Parsey** supports source location/range tracking,
backtracking prevention, and custom error messages.

![Parsey Playground](https://pbs.twimg.com/media/CrVaoBeVYAAWWoj.jpg:large)

## Features

- Combinator interface
- `|`, `~~`, `~~>`, `<~~`, `^^` combinator operators

- Lexer primitives:
- `Lexer.whitespace`, `Lexer.signedInteger`, ...

- Regex-like combinators:
- Postfix `.+` for `.many()`.
- Example: `let arrayLiteral = "[" ~~> expression.+ <~~ "]"`
- Postfix `.*` for `.manyOrNone()`.
- Example: `let classDef = (attribute | method).*`
- Postfix `.?` for `.optional()`.
- Example: `let declaration = "let" ~~> id ~~ (":" ~~> type).? ~~ ("=" ~~> expression)`
- Postfix `+` for `.manyConcatenated()`.
- Example: `let skippedSpaces = (Lexer.space | Lexer.tab)+`
- Infix `+` for `.concatenatingResult(with:)`.
- Example: `let type = Lexer.upperLetter + Lexer.letter*`
- `Lexer.regex(_:)` for directly applying regular expressions.
- Example: `let id = Lexer.regex("[a-zA-Z][a-zA-Z0-9]*")`

- Backtracking prevention
- `.!` postfix operator or `.nonbacktracking()`

- Parser tagging for error messages
- `