2022-11-26 23:57:50 +00:00
|
|
|
// Copyright 2020 The Jujutsu Authors
|
2020-12-12 08:00:42 +00:00
|
|
|
//
|
|
|
|
// 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)
|
|
|
|
|
2023-01-28 10:02:07 +00:00
|
|
|
whitespace = _{ " " | "\n" }
|
2020-12-12 08:00:42 +00:00
|
|
|
|
|
|
|
escape = @{ "\\" ~ ("n" | "\"" | "\\") }
|
|
|
|
literal_char = @{ !("\"" | "\\") ~ ANY }
|
|
|
|
raw_literal = @{ literal_char+ }
|
|
|
|
literal = { "\"" ~ (raw_literal | escape)* ~ "\"" }
|
|
|
|
|
2023-02-04 12:33:31 +00:00
|
|
|
identifier = @{ (ASCII_ALPHA | "_") ~ (ASCII_ALPHANUMERIC | "_")* }
|
2020-12-12 08:00:42 +00:00
|
|
|
|
2023-01-29 03:39:51 +00:00
|
|
|
function = { identifier ~ "(" ~ function_arguments ~ ")" }
|
|
|
|
function_arguments = {
|
|
|
|
template ~ ("," ~ template)*
|
2023-01-29 03:59:46 +00:00
|
|
|
| whitespace*
|
2023-01-29 03:39:51 +00:00
|
|
|
}
|
2020-12-12 08:00:42 +00:00
|
|
|
|
|
|
|
// Note that "x(y)" is a function call but "x (y)" concatenates "x" and "y"
|
2023-02-04 12:28:14 +00:00
|
|
|
primary = _{
|
|
|
|
("(" ~ template ~ ")")
|
|
|
|
| function
|
|
|
|
| identifier
|
|
|
|
| literal
|
|
|
|
}
|
|
|
|
|
2020-12-12 08:00:42 +00:00
|
|
|
term = {
|
2023-02-04 12:28:14 +00:00
|
|
|
primary ~ ("." ~ function)*
|
2020-12-12 08:00:42 +00:00
|
|
|
}
|
|
|
|
|
2023-01-28 11:09:13 +00:00
|
|
|
list = _{
|
2023-01-28 10:23:39 +00:00
|
|
|
term ~ (whitespace+ ~ term)+
|
2020-12-12 08:00:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template = {
|
2023-01-29 03:59:46 +00:00
|
|
|
whitespace* ~ (list | term) ~ whitespace*
|
2020-12-12 08:00:42 +00:00
|
|
|
}
|
2023-01-29 03:50:12 +00:00
|
|
|
|
2023-01-29 03:59:46 +00:00
|
|
|
program = _{ SOI ~ (template | whitespace*) ~ EOI }
|