From 8749a325e9cef71e8ac9f8d7c672b25652f5b1be Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Thu, 9 Feb 2023 18:32:29 +0900 Subject: [PATCH] templater: move whitespace rule out of template node For the same reason as b2825c22d70e "revset: move whitespace rule out of expression." --- src/template.pest | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/template.pest b/src/template.pest index a18e3d2c5..039d66fc9 100644 --- a/src/template.pest +++ b/src/template.pest @@ -31,15 +31,15 @@ integer_literal = { identifier = @{ (ASCII_ALPHA | "_") ~ (ASCII_ALPHANUMERIC | "_")* } -function = { identifier ~ "(" ~ function_arguments ~ ")" } +function = { identifier ~ "(" ~ whitespace* ~ function_arguments ~ whitespace* ~ ")" } function_arguments = { - template ~ ("," ~ template)* ~ ("," ~ whitespace*)? - | whitespace* + template ~ (whitespace* ~ "," ~ whitespace* ~ template)* ~ (whitespace* ~ ",")? + | "" } // Note that "x(y)" is a function call but "x (y)" concatenates "x" and "y" primary = _{ - ("(" ~ template ~ ")") + ("(" ~ whitespace* ~ template ~ whitespace* ~ ")") | function | identifier | literal @@ -54,8 +54,6 @@ list = _{ term ~ (whitespace+ ~ term)+ } -template = { - whitespace* ~ (list | term) ~ whitespace* -} +template = { list | term } -program = _{ SOI ~ (template | whitespace*) ~ EOI } +program = _{ SOI ~ whitespace* ~ template? ~ whitespace* ~ EOI }