jj/src/template.pest
Martin von Zweigbergk d8feed9be4 copyright: change from "Google LLC" to "The Jujutsu Authors"
Let's acknowledge everyone's contributions by replacing "Google LLC"
in the copyright header by "The Jujutsu Authors". If I understand
correctly, it won't have any legal effect, but maybe it still helps
reduce concerns from contributors (though I haven't heard any
concerns).

Google employees can read about Google's policy at
go/releasing/contributions#copyright.
2022-11-28 06:05:45 -10:00

52 lines
1.5 KiB
Text

// Copyright 2020 The Jujutsu Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Example:
// "commit: " short(commit_id) "\n"
// predecessors % ("predecessor: " commit_id)
// parents % (commit_id " is a parent of " super.commit_id)
whitespace = { " " | "\n" }
escape = @{ "\\" ~ ("n" | "\"" | "\\") }
literal_char = @{ !("\"" | "\\") ~ ANY }
raw_literal = @{ literal_char+ }
literal = { "\"" ~ (raw_literal | escape)* ~ "\"" }
identifier = @{ (ASCII_ALPHANUMERIC | "_")+ }
function = { identifier ~ "(" ~ template ~ ("," ~ template)* ~ ")" }
method = { "." ~ identifier ~ "(" ~ template ~ ("," ~ template)* ~ ")" ~ maybe_method }
maybe_method = { method | "" }
// Note that "x(y)" is a function call but "x (y)" concatenates "x" and "y"
term = {
("(" ~ term ~ ")") ~ maybe_method
| function ~ maybe_method
| identifier ~ maybe_method
| literal ~ maybe_method
| ""
}
list = {
("(" ~ list ~ ")")
| term ~ (whitespace+ ~ term)+
}
template = {
list
| term
}