From 5a0f4ed7470a6351e21569e94c6a682ed2c09b00 Mon Sep 17 00:00:00 2001 From: cflmy Date: Thu, 22 Oct 2026 15:08:55 +0800 Subject: [PATCH] =?UTF-8?q?refactor(parse):=20M1=20=E6=94=B6=E5=B0=BE=20?= =?UTF-8?q?=E2=80=94=20=E5=88=A0=E9=99=A4=E9=87=8D=E6=9E=84=E5=90=8E?= =?UTF-8?q?=E5=8F=98=E6=88=90=E6=AD=BB=E4=BB=A3=E7=A0=81=E7=9A=84=E4=B8=A4?= =?UTF-8?q?=E4=B8=AA=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - parse_call_arg_value_prefer_var:统一成 parse_call_arg_value_mode 后无调用点 - Parser::new_plain:改回 new(唯一构造点) cargo build --release 警告清零;cargo test --lib 248 passed。 --- src/parse/expr.rs | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/parse/expr.rs b/src/parse/expr.rs index a31480b..6bef9bf 100644 --- a/src/parse/expr.rs +++ b/src/parse/expr.rs @@ -19,7 +19,7 @@ fn parse_expr_mode(input: &str, prefer_var: bool) -> Result { /// Parse a full expression; `allow_paren_call` controls `name(args)` postfix calls. fn parse_expr_opts(input: &str, prefer_var: bool, allow_paren_call: bool) -> Result { - let mut p = Parser::new_plain(input.trim(), prefer_var, allow_paren_call); + let mut p = Parser::new(input.trim(), prefer_var, allow_paren_call); let e = p.parse_or()?; p.skip_ws(); if !p.rest().is_empty() { @@ -104,10 +104,6 @@ fn parse_call_arg_value_mode(input: &str, prefer_var: bool, allow_call: bool) -> /// Like [`parse_call_arg_value`], but for call args inside `*…*` / `**…**` /// value-expression segments: a bare word is a **variable** (not a text literal). /// Quoted strings, hyphenated prose, and `/path` prose stay text; `` `x` `` still works. -pub fn parse_call_arg_value_prefer_var(input: &str) -> Result { - parse_call_arg_value_mode(input, true, false) -} - fn is_text_only_div_chain(e: &Expr) -> bool { match e { Expr::Literal(Literal::Text(_)) => true, @@ -243,16 +239,7 @@ struct Parser<'a> { } impl<'a> Parser<'a> { - fn new(src: &'a str, prefer_var: bool) -> Self { - Self { - src, - i: 0, - prefer_var, - allow_paren_call: true, - } - } - - fn new_plain(src: &'a str, prefer_var: bool, allow_paren_call: bool) -> Self { + fn new(src: &'a str, prefer_var: bool, allow_paren_call: bool) -> Self { Self { src, i: 0,