chappi-syntax 0.1.0

Canonical S-expression parser and serializer for the Chappi cognitive-state language
Documentation
use chappi_syntax::{Atom, FormKind, parse_document};

#[test]
fn parses_header_form() {
    let document = parse_document("(chappi 1)\n").expect("header should parse");

    assert_eq!(document.forms.len(), 1);
    let FormKind::List(items) = &document.forms[0].kind else {
        panic!("header must be a list");
    };
    assert!(matches!(items[0].kind, FormKind::Atom(Atom::Symbol(ref value)) if value == "chappi"));
    assert!(matches!(items[1].kind, FormKind::Atom(Atom::Integer(ref value)) if value == "1"));
}

#[test]
fn parses_multiple_top_level_forms() {
    let document = parse_document("(chappi 1)\n(node n2)\n").expect("forms should parse");

    assert_eq!(document.forms.len(), 2);
}