Alder
Warning: Library is under development and may be subject to change.
Hand written recursive descent and non-backtracking parsing "combinator" library designed with nice error in mind and lossless data.
Goals
- Almost no backtracking
- Lossless tree generation (for formatters and IDE approach)
- UTF-8 support
- Nice informative errors with contexts.
- AST generation based on CST (some macro and trait magic)
I'm somehow inspired by this post. It's about parser generators but I prefer writing them manually.
TODO
- Add the problem resolving in common parsers like
chomp_while
- Add more common parsers
- Remove Arc if possible
- Documentation (right now I have only WIP JSON example)
- Maybe incremental parsing...
Install
Use cargo-edit:
Or add it manually:
= "0.6.0"
You may want to enable a derive feature as well:
= { = "0.6.0" , = ["derive"] }
Example
// Doc tests are treated as a test cases for snapshots.
// To enable them use `derive` feature and add `#[alder_test]` macro.
// It also supports /** multiline comments */
/// []
/// [true]
/// [true,false]
/// [ ]
/// [ true ]
/// [ true, false ]
/// [ true, false, ]
/// [trua, falsa]
/// [truadsadsa, falsa]
/// [true, false
/// [truad sadsa, falsa]
/**
[
true,
false,
"foo"
]
*/
Parsers should return information about what happened and where it happened:
--------------------------------- SYNTAX ERROR ---------------------------------
I was parsing Boolean when found issue:
0 |[truadsadsa, falsa]\EOF
~ | ^^^^^^^^^^ I expected `true`
--------------------------------- SYNTAX ERROR ---------------------------------
I was parsing Boolean when found issue:
0 |[truadsadsa, falsa]\EOF
~ | ^^^^^ I expected `false`
Contribute
Please use git-hooks.