forked from mirrors/jj
templater: introduce top-level rule that wraps template terms
An epsilon rule will be moved here to disambiguate f() with f("").
This commit is contained in:
parent
c44dda55e3
commit
a5bb48d47e
3 changed files with 4 additions and 12 deletions
|
@ -2915,7 +2915,7 @@ fn cmd_debug(
|
|||
}
|
||||
DebugCommands::Template(template_matches) => {
|
||||
let parse = TemplateParser::parse(
|
||||
crate::template_parser::Rule::template,
|
||||
crate::template_parser::Rule::program,
|
||||
&template_matches.template,
|
||||
);
|
||||
writeln!(ui, "{parse:#?}")?;
|
||||
|
|
|
@ -48,3 +48,5 @@ list = _{
|
|||
template = {
|
||||
whitespace* ~ (list | term | "") ~ whitespace*
|
||||
}
|
||||
|
||||
program = _{ SOI ~ template ~ EOI }
|
||||
|
|
|
@ -381,17 +381,7 @@ pub fn parse_commit_template<'a>(
|
|||
workspace_id: &WorkspaceId,
|
||||
template_text: &str,
|
||||
) -> Box<dyn Template<Commit> + 'a> {
|
||||
let mut pairs: Pairs<Rule> = TemplateParser::parse(Rule::template, template_text).unwrap();
|
||||
|
||||
let mut pairs: Pairs<Rule> = TemplateParser::parse(Rule::program, template_text).unwrap();
|
||||
let first_pair = pairs.next().unwrap();
|
||||
assert!(pairs.next().is_none());
|
||||
|
||||
assert_eq!(
|
||||
first_pair.as_span().end(),
|
||||
template_text.len(),
|
||||
"failed to parse template past position {}",
|
||||
first_pair.as_span().end()
|
||||
);
|
||||
|
||||
parse_commit_template_rule(repo, workspace_id, first_pair)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue