Skip to main content

Crate atoxide_parser

Crate atoxide_parser 

Source
Expand description

Parser for the Ato hardware description language.

This crate provides a complete parser for the Ato DSL, producing a typed AST with error recovery using the chumsky parser combinator library.

§Example

use atoxide_parser::parse;

let source = r#"
module MyModule:
    pin p1
    signal sig
    p1 ~ sig
"#;

match parse(source) {
    Ok(file) => {
        println!("Parsed {} statements", file.statements.len());
    }
    Err(errors) => {
        for e in errors {
            eprintln!("Parse error: {}", e);
        }
    }
}

§Error Recovery

The parser supports error recovery, allowing it to continue parsing after encountering errors. Use parse_with_recovery to get both the AST and errors:

use atoxide_parser::parse_with_recovery;

let source = "module M:\n    pass\n";
let (ast, errors) = parse_with_recovery(source);

if let Some(file) = ast {
    println!("Parsed {} statements", file.statements.len());
}
for error in &errors {
    eprintln!("Error: {}", error);
}

Re-exports§

pub use error::ParseError;
pub use error::ParseResult;
pub use ast::*;

Modules§

ast
Abstract Syntax Tree types for the Ato language.
error
Error types for the Ato parser with miette integration.

Structs§

ChumskyParseError
A parse error with context for display.

Functions§

format_errors
Format a list of parse errors using ariadne for beautiful output.
parse
Parse Ato source code into an AST.
parse_with_formatted_errors
Parse Ato source code and format any errors using ariadne.
parse_with_recovery
Parse Ato source code with error recovery.
parse_with_source
Parse Ato source code, returning both the AST and a source code wrapper for error display.