feat: add stable executable knowledge symbols

This commit is contained in:
cflmy committed 2026-10-23 08:24:10 +00:00
1 parent 92de46aca4
commit 0bbe735c3c
13 files changed
+841 -40

No files matched your search

+29
View File
@@ -683,6 +683,20 @@ impl<'a> Parser<'a> {
return Ok(Expr::Call(call));
}
}
// A dotted definition path in a value position is a zero-argument
// call. This makes a documented fact such as `facts.Person.birth_year`
// executable without ceremonial `()`.
if let Some(path) = split_lib_path_callee(&word) {
let callee = path.last().cloned().unwrap_or_default();
return Ok(Expr::Call(CallExpr {
callee,
path: Some(path),
receiver: None,
args: Vec::new(),
pre_modifiers: Vec::new(),
bracket_marked: false,
}));
}
self.skip_ws();
if self.starts_with("[^") {
return self.parse_index_chain(Expr::Var(word));
@@ -2075,6 +2089,21 @@ mod bracket_call_tests {
assert!(c.receiver.is_none());
}
#[test]
fn dotted_path_is_implicit_zero_arg_call() {
let c = call_of(parse_expr_prefer_var("facts.Person.birth_year").unwrap());
assert_eq!(c.callee, "birth_year");
assert_eq!(
c.path.as_deref(),
Some(&[
"facts".to_string(),
"Person".to_string(),
"birth_year".to_string(),
][..])
);
assert!(c.args.is_empty());
}
#[test]
fn paren_call_nested_in_expression() {
let c = call_of(parse_expr("加(加(1 2), 3)").unwrap());