Summary
Rename four KDL keywords for clarity and consistency, with backwards compatibility via deprecation warnings.
Parent: #176
Blocked by: #178
Keyword Changes
| Before |
After |
Purpose |
map X from="col" |
alias X column="col" |
Data column rename |
set X alias=g |
set X as=g |
Set shorthand |
control x lower=0 |
var x lower=0 |
Decision variable |
filter { cond } |
where { cond } |
Set subsetting |
Acceptance Criteria
Implementation Notes
Location: crates/arco-kdl/src/source/parser.rs
Pattern per keyword:
match child.name().value() {
"alias" => { /* new syntax */ }
"map" => {
context.warn(Deprecation::new("map", "alias", child.span()));
/* parse as alias */
}
// ...
}
- AFK — straightforward parser additions with clear pattern
TDD Implementation Plan
Prerequisites
RED/GREEN Cycles
Cycle 1: var keyword (simplest, isolated)
RED: Test that var x lower=0 {...} parses to same AST as control
#[test]
fn var_keyword_parses_as_control() {
let new_syntax = r#"model M { var x lower=0 { index a } minimize O { x[a] } }"#;
let old_syntax = r#"model M { control x lower=0 { index a } minimize O { x[a] } }"#;
// Assert both produce identical ControlDecl
}
GREEN: Add "var" => arm in parse_model() (line 85) calling parse_control()
Cycle 2: control deprecation warning
RED: Test that control emits deprecation warning
#[test]
fn control_keyword_emits_deprecation() {
let text = r#"model M { control x { index a } minimize O { x[a] } }"#;
// Assert warning contains "control", "var", migration hint
}
GREEN: Add deprecation emission before parse_control() call for "control" arm
Cycle 3: alias keyword (data block)
RED: Test alias X column="col" parses as MapDecl
#[test]
fn alias_keyword_parses_in_data_block() {
let text = r#"data D source="f.csv" { alias X column="name" }"#;
// Assert MapDecl with name="X", source="name"
}
GREEN: Add "alias" => arm in parse_data() (line 133) with column property
Cycle 4: map deprecation warning
RED: Test map emits deprecation
GREEN: Add deprecation to "map" arm
Cycle 5: set as= property
RED: Test set X as=g parses with alias "g"
#[test]
fn set_as_property_parses() {
let text = r#"set X as=g"#;
// Assert SetDecl has alias = Some("g")
}
GREEN: Add .get("as") fallback in parse_set() (line 255)
Cycle 6: set alias= deprecation
RED: Test alias= emits deprecation
GREEN: Check for alias= property and emit warning
Cycle 7: where keyword (set filter)
RED: Test where { cond } parses as filter
#[test]
fn where_keyword_parses_as_filter() {
let text = r#"set thermal { in gen; where { type == "thermal" } }"#;
// Assert filter_expression is set
}
GREEN: Add "where" => arm in:
parse_set() (line 233)
parser_helpers.rs (lines 54, 94)
surface.rs (lines 10, 121)
Cycle 8: filter deprecation
RED: Test filter emits deprecation
GREEN: Add deprecation to all "filter" arms
Cycle 9: Mixed syntax integration
RED: Test file with mix of old/new syntax
GREEN: Should already pass if cycles 1-8 are complete
Files to Modify
crates/arco-kdl/src/source/parser.rs
crates/arco-kdl/src/source/parser_helpers.rs
crates/arco-kdl/src/source/surface.rs
Acceptance Verification
cargo test -p arco-kdl
cargo clippy -p arco-kdl -- -D warnings
Summary
Rename four KDL keywords for clarity and consistency, with backwards compatibility via deprecation warnings.
Parent: #176
Blocked by: #178
Keyword Changes
map X from="col"alias X column="col"set X alias=gset X as=gcontrol x lower=0var x lower=0filter { cond }where { cond }Acceptance Criteria
alias X column="col"; deprecatesmap X from="col"set X as=g; deprecatesset X alias=gvar x lower=0; deprecatescontrol x lower=0where { cond }; deprecatesfilter { cond }Implementation Notes
Location:
crates/arco-kdl/src/source/parser.rsPattern per keyword:
TDD Implementation Plan
Prerequisites
RED/GREEN Cycles
Cycle 1:
varkeyword (simplest, isolated)RED: Test that
var x lower=0 {...}parses to same AST ascontrolGREEN: Add
"var" =>arm inparse_model()(line 85) callingparse_control()Cycle 2:
controldeprecation warningRED: Test that
controlemits deprecation warningGREEN: Add deprecation emission before
parse_control()call for"control"armCycle 3:
aliaskeyword (data block)RED: Test
alias X column="col"parses as MapDeclGREEN: Add
"alias" =>arm inparse_data()(line 133) withcolumnpropertyCycle 4:
mapdeprecation warningRED: Test
mapemits deprecationGREEN: Add deprecation to
"map"armCycle 5:
set as=propertyRED: Test
set X as=gparses with alias "g"GREEN: Add
.get("as")fallback inparse_set()(line 255)Cycle 6:
set alias=deprecationRED: Test
alias=emits deprecationGREEN: Check for
alias=property and emit warningCycle 7:
wherekeyword (set filter)RED: Test
where { cond }parses as filterGREEN: Add
"where" =>arm in:parse_set()(line 233)parser_helpers.rs(lines 54, 94)surface.rs(lines 10, 121)Cycle 8:
filterdeprecationRED: Test
filteremits deprecationGREEN: Add deprecation to all
"filter"armsCycle 9: Mixed syntax integration
RED: Test file with mix of old/new syntax
GREEN: Should already pass if cycles 1-8 are complete
Files to Modify
crates/arco-kdl/src/source/parser.rscrates/arco-kdl/src/source/parser_helpers.rscrates/arco-kdl/src/source/surface.rsAcceptance Verification
cargo test -p arco-kdl cargo clippy -p arco-kdl -- -D warnings