- Notifications
You must be signed in to change notification settings - Fork 9
Description
Please complete the following information about the package:
Package name: Nom
Language name: Rust
Website: https://github.com/rust-bakery/nom
Following are optional, but will help us consider adding:
Why is this useful?
When it comes to parsing in Rust; nom is virtually as popular as regex. Arguably, nom is the most rust idiomatic.
Example Code:
The currency in nom is parsers. Parser are built on top of other parsers and then combined in different ways. In the Assembler interpreter (part II), a top level parser to select between different assembly instructions could look something like this:
pub fn tokenize_other(input: &str) -> IResult<&str, Token> {
alt((movri, movrr, addri, addrr, subri, subrr, mulri, mulrr, divri, divrr, cmpri, cmprr, incr, decr,
alt((end, ret, call, jmp, je, jne, jle, jl, jg, jge, label))
))(input)
}