docs: Add Rustdoc to code and comments to grammar file

Co-authored-by: aider (openai/andrew/openrouter/sonoma-sky-alpha) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-09-10 12:13:22 -03:00
parent c965e9f51c
commit 978dae32d8
2 changed files with 18 additions and 20 deletions

View File

@@ -1,19 +1,34 @@
# This Pest grammar defines the syntax for filter chains used in the Keep application.
# Filters can be chained with commas and may have named or unnamed options with JSON-like values.
WHITESPACE = _{ " " | "\t" | "\n" | "\r" } WHITESPACE = _{ " " | "\t" | "\n" | "\r" }
# Top-level rule for parsing multiple filters separated by commas.
filters = { filter ~ ("," ~ filters)? } filters = { filter ~ ("," ~ filters)? }
# A single filter consisting of a name optionally followed by parenthesized options.
filter = { filter_name ~ ("(" ~ options ~ ")")? } filter = { filter_name ~ ("(" ~ options ~ ")")? }
# The name of a filter, starting with an ASCII letter followed by alphanumeric characters or underscores.
filter_name = @{ ASCII_ALPHA ~ (ASCII_ALPHANUMERIC | "_")* } filter_name = @{ ASCII_ALPHA ~ (ASCII_ALPHANUMERIC | "_")* }
# A list of comma-separated options within parentheses.
options = { option ~ ("," ~ options)? } options = { option ~ ("," ~ options)? }
# A single option, optionally with a name followed by an equals sign and a value.
option = { (option_name ~ "=")? ~ option_value } option = { (option_name ~ "=")? ~ option_value }
# The name of an option, starting with an ASCII letter followed by alphanumeric characters or underscores.
option_name = @{ ASCII_ALPHA ~ (ASCII_ALPHANUMERIC | "_")* } option_name = @{ ASCII_ALPHA ~ (ASCII_ALPHANUMERIC | "_")* }
# The value of an option, which can be a JSON number, string, or boolean.
option_value = { option_value = {
JSON_NUMBER | JSON_NUMBER |
JSON_STRING | JSON_STRING |
JSON_BOOLEAN JSON_BOOLEAN
} }
# JSON number format supporting integers, decimals, and scientific notation.
JSON_NUMBER = @{ JSON_NUMBER = @{
("-")? ~ ("-")? ~
("0" | ASCII_NONZERO_DIGIT ~ ASCII_DIGIT*) ~ ("0" | ASCII_NONZERO_DIGIT ~ ASCII_DIGIT*) ~
@@ -21,10 +36,12 @@ JSON_NUMBER = @{
(("e" | "E") ~ ("+" | "-")? ~ ASCII_DIGIT+)? (("e" | "E") ~ ("+" | "-")? ~ ASCII_DIGIT+)?
} }
# JSON string format with escaped characters.
JSON_STRING = ${ JSON_STRING = ${
"\"" ~ "\"" ~
(("\\" ~ ANY) | (!("\"" | "\\") ~ ANY))* ~ (("\\" ~ ANY) | (!("\"" | "\\") ~ ANY))* ~
"\"" "\""
} }
# JSON boolean values: true or false.
JSON_BOOLEAN = ${ "true" | "false" } JSON_BOOLEAN = ${ "true" | "false" }

View File

@@ -371,23 +371,4 @@ fn show_list_structured(
compression: item.compression, compression: item.compression,
file_size, file_size,
file_size_formatted, file_size_formatted,
file_path: item_path.into_os_string().into_string().unwrap_or_default(), file_path: item_path.into_os_string().into_string
tags,
meta,
};
list_items.push(list_item);
}
match output_format {
OutputFormat::Json => {
println!("{}", serde_json::to_string_pretty(&list_items)?);
}
OutputFormat::Yaml => {
println!("{}", serde_yaml::to_string(&list_items)?);
}
OutputFormat::Table => unreachable!(),
}
Ok(())
}