sage-parser 2.1.0

Parser for the Sage language
Documentation

Lexer and parser for the Sage language.

This crate provides tokenization and parsing for Sage source code, transforming source text into a typed Abstract Syntax Tree (AST).

Example

use sage_parser::{lex, parse};
use std::sync::Arc;

let source = r#"
    agent Main {
        on start {
            emit(42);
        }
    }
    run Main;
"#;

let lex_result = lex(source).expect("lexing failed");
let source_arc: Arc<str> = Arc::from(source);
let (program, errors) = parse(lex_result.tokens(), source_arc);

assert!(errors.is_empty());
assert!(program.is_some());