mirror of
https://github.com/powdr-labs/powdr.git
synced 2026-04-20 03:03:25 -04:00
18 lines
479 B
Rust
18 lines
479 B
Rust
use crate::ast::{FunctionOpKind, Register, Statement};
|
|
|
|
pub fn parse_asm<R: Register, F: FunctionOpKind, P: Parser<R, F>>(
|
|
parser: P,
|
|
input: &str,
|
|
) -> Vec<Statement<R, F>> {
|
|
input
|
|
.split('\n')
|
|
.map(|l| l.trim())
|
|
.filter(|l| !l.is_empty())
|
|
.flat_map(|line| parser.parse(line).unwrap())
|
|
.collect()
|
|
}
|
|
|
|
pub trait Parser<R: Register, F: FunctionOpKind> {
|
|
fn parse(&self, input: &str) -> Result<Vec<Statement<R, F>>, String>;
|
|
}
|