Skip to content

Add Nom for Rust #314

@DagBjorndal

Description

@DagBjorndal

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)
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions