Wildcards without the ? prefix (#422)
This commit is contained in:
parent
7e04eb51ff
commit
5de08da32c
15 changed files with 287 additions and 262 deletions
|
|
@ -11,15 +11,14 @@ WHITESPACE = _{ (" " | "\t" | NEWLINE)+ }
|
|||
// COMMENT matches a line comment (//...\n) or block comment (/*...*/).
|
||||
COMMENT = _{ ("//" ~ (!NEWLINE ~ ANY)* | "/*" ~ (!"*/" ~ ANY)* ~ "*/" ) }
|
||||
|
||||
// Define rules for identifiers (predicate names, variable names without '?')
|
||||
reserved_identifier = { "private" | "true" | "false" }
|
||||
|
||||
// Define rules for identifiers (predicate names, wildcard names)
|
||||
// Must start with alpha or _, followed by alpha, numeric, or _
|
||||
identifier = @{ !("private") ~ (ASCII_ALPHA | "_") ~ (ASCII_ALPHANUMERIC | "_")* }
|
||||
identifier = @{ !reserved_identifier ~ (ASCII_ALPHA | "_") ~ (ASCII_ALPHANUMERIC | "_")* }
|
||||
|
||||
private_kw = { "private:" }
|
||||
|
||||
// Define wildcard names (start with '?')
|
||||
wildcard = @{ "?" ~ identifier }
|
||||
|
||||
arg_section = {
|
||||
public_arg_list ~ ("," ~ private_kw ~ private_arg_list)?
|
||||
}
|
||||
|
|
@ -49,15 +48,15 @@ custom_predicate_def = {
|
|||
|
||||
statement_list = { statement+ }
|
||||
|
||||
statement_arg = { anchored_key | wildcard | literal_value }
|
||||
statement_arg = { literal_value | anchored_key | identifier }
|
||||
statement_arg_list = { statement_arg ~ ("," ~ statement_arg)* }
|
||||
|
||||
statement = { identifier ~ "(" ~ statement_arg_list? ~ ")" }
|
||||
|
||||
// Anchored Key: ?Var["key_literal"] or ?Var.key_identifier
|
||||
// Anchored Key: Var["key_literal"] or Var.key_identifier
|
||||
anchored_key = {
|
||||
(wildcard ~ "[" ~ literal_string ~ "]")
|
||||
| (wildcard ~ "." ~ identifier)
|
||||
(identifier ~ "[" ~ literal_string ~ "]")
|
||||
| (identifier ~ "." ~ identifier)
|
||||
}
|
||||
|
||||
// Literal Values (ordered to avoid ambiguity, e.g., string before int)
|
||||
|
|
@ -110,10 +109,10 @@ dict_pair = { literal_string ~ ":" ~ literal_value }
|
|||
|
||||
// --- Rules for testing full input matching ---
|
||||
test_identifier = { SOI ~ identifier ~ EOI }
|
||||
test_wildcard = { SOI ~ wildcard ~ EOI }
|
||||
test_literal_int = { SOI ~ literal_int ~ EOI }
|
||||
test_hash_hex = { SOI ~ hash_hex ~ EOI }
|
||||
test_literal_raw = { SOI ~ literal_raw ~ EOI }
|
||||
test_literal_value = { SOI ~ literal_value ~ EOI }
|
||||
test_statement = { SOI ~ statement ~ EOI }
|
||||
test_statement_arg = { SOI ~ statement_arg ~ EOI }
|
||||
test_custom_predicate_def = { SOI ~ custom_predicate_def ~ EOI }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue