72e54f4fd3
The surface-form file extension changes from .ailx to .ail. AILang's
authoring surface now uses the same .ail stem as its canonical JSON
form (.ail.json), giving the language a single coherent extension
family: .ail is the LLM-authored Form A, .ail.json is the canonical
JSON-AST Form B.
Scope (touched):
- 61 example renames examples/**/*.ailx → .ail (git mv)
- 1 rename experiments/.../rendered/ailx.md → ail.md
- 35 content-edited live-toolchain files (crates/, docs/DESIGN.md,
docs/roadmap.md, docs/PROSE_ROUNDTRIP.md, skills/, bench/reference/*.c,
experiment crates under experiments/.../{render,harness,master})
- Experiment-crate cohort rename Cohort::Ailx → Cohort::Ail,
Form::Ailx → Form::Ail, per_cohort/ailx → per_cohort/ail,
{form-only: ailx} → {form-only: ail}, ```ailx → ```ail
Out of scope (deliberately untouched, to preserve honest history):
- docs/journal-archive.md (content-frozen per CLAUDE.md)
- docs/journals/, docs/specs/, docs/plans/, bench/orchestrator-stats/
- experiments/.../runs/ (frozen LLM-output artefacts; models actually
saw .ailx — renaming would falsify the experimental record)
Verification: cargo build/test --workspace green; experiment crate
cargo test green; bench/check.py + compile_check.py + cross_lang.py
all 0-regressed; negative grep for ailx|Ailx|AILX outside the
out-of-scope paths returns zero matches.
Opens immediate follow-up: roadmap.md P2 todo `ail check`/build/run
accept .ail extension — after this rename, .ail is canonical
authoring surface but the CLI still produces a misleading JSON-parse
error on `ail check foo.ail`. That's the next iter.
93 lines
2.8 KiB
Rust
93 lines
2.8 KiB
Rust
//! Directive splitter for master/spec.md.
|
|
//!
|
|
//! Recognises three directives, one per line, no nesting:
|
|
//! {form-only: json} … {/form-only}
|
|
//! {form-only: ail} … {/form-only}
|
|
//! {example: <id>}
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
pub enum Form {
|
|
Json,
|
|
Ail,
|
|
}
|
|
|
|
impl Form {
|
|
fn parse(name: &str) -> Option<Form> {
|
|
match name {
|
|
"json" => Some(Form::Json),
|
|
"ail" => Some(Form::Ail),
|
|
_ => None,
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub enum Segment {
|
|
Prose(String),
|
|
FormOnly { form: Form, body: String },
|
|
Example(String),
|
|
}
|
|
|
|
/// Split a master/spec.md text into a sequence of segments.
|
|
///
|
|
/// Panics on malformed input (unknown form name, unclosed form-only block).
|
|
/// The renderer treats these as authoring bugs that should fail the test
|
|
/// suite rather than silently produce diverging mini-specs.
|
|
pub fn split(input: &str) -> Vec<Segment> {
|
|
let mut out: Vec<Segment> = Vec::new();
|
|
let mut current_prose = String::new();
|
|
let mut current_block: Option<(Form, String)> = None;
|
|
|
|
for line in input.split_inclusive('\n') {
|
|
let trimmed = line.trim_end_matches('\n');
|
|
|
|
// Inside a form-only block: collect until the closing marker.
|
|
if let Some((form, body)) = current_block.as_mut() {
|
|
if trimmed == "{/form-only}" {
|
|
let body_owned = std::mem::take(body);
|
|
out.push(Segment::FormOnly { form: *form, body: body_owned });
|
|
current_block = None;
|
|
} else {
|
|
body.push_str(line);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
// {form-only: <name>}
|
|
if let Some(rest) = trimmed.strip_prefix("{form-only: ").and_then(|r| r.strip_suffix("}")) {
|
|
flush_prose(&mut current_prose, &mut out);
|
|
let form = Form::parse(rest)
|
|
.unwrap_or_else(|| panic!("unknown form name in directive: {}", rest));
|
|
current_block = Some((form, String::new()));
|
|
continue;
|
|
}
|
|
|
|
// {example: <id>}
|
|
if let Some(id) = trimmed.strip_prefix("{example: ").and_then(|r| r.strip_suffix("}")) {
|
|
flush_prose(&mut current_prose, &mut out);
|
|
out.push(Segment::Example(id.to_string()));
|
|
continue;
|
|
}
|
|
|
|
// Stray closer with no opener.
|
|
if trimmed == "{/form-only}" {
|
|
panic!("stray {{/form-only}} without matching opener");
|
|
}
|
|
|
|
// Plain prose line.
|
|
current_prose.push_str(line);
|
|
}
|
|
|
|
if current_block.is_some() {
|
|
panic!("unclosed form-only block at end of input");
|
|
}
|
|
flush_prose(&mut current_prose, &mut out);
|
|
out
|
|
}
|
|
|
|
fn flush_prose(buf: &mut String, out: &mut Vec<Segment>) {
|
|
if !buf.is_empty() {
|
|
out.push(Segment::Prose(std::mem::take(buf)));
|
|
}
|
|
}
|