Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions command_filter/LANGUAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,37 @@ types. User-defined names must be plain `<name>` with no modifier.
User-defined names are distinguished from built-in types by their presence in
a `define` statement.

### Prefixed placeholders

A literal prefix immediately followed by a placeholder (no separating space)
forms a single element that matches one argument:

```
--color=<string> # matches --color=auto, --color=never, …
--output=<path:w> # matches --output=/tmp/out (path must be writable)
/LOG:<path:w> # matches /LOG:build.log (any literal prefix works)
```

The argument must start with the literal prefix, and the remainder (everything
after the prefix) is validated by the placeholder.

The placeholder's normal matching rules apply to the remainder. For example,
`--flag=<string>` rejects `--flag=-x` because `<string>` does not accept
arguments starting with `-`, while `--flag=<string:->` accepts it.

User-defined names are also valid after a prefix, provided every path through
the definition consumes exactly one argument:

```
define <level> (debug | info | warn | error)

allow logger --level=<level> # ok: <level> is single-argument
```

A definition whose expansion contains multi-element sequences, repetition, or
optional groups is not single-argument and is rejected in prefix position at
parse time.

### Groups and alternatives

Parentheses `()` and square brackets `[]` both group elements. Pipe `|`
Expand Down
Loading