pub enum Rule {
Show 78 variants
EOI,
WHITESPACE,
COMMENT,
file,
use_decl,
module_decl,
doc_block,
doc_line,
top_level_item,
test_decl,
given_block,
given_binding,
entity_constructor,
constructor_field,
when_block,
then_block,
then_fails,
then_asserts,
entity_decl,
field_decl,
action_decl,
action_doc,
param_decl,
requires_block,
ensures_block,
ensures_item,
when_clause,
properties_block,
prop_entry,
prop_value,
invariant_decl,
edge_cases_decl,
edge_rule,
edge_action,
type_expr,
optional_marker,
union_type,
base_type,
list_type,
set_type,
map_type,
parameterized_type,
type_param,
simple_type,
expr,
implies_expr,
implies_op,
or_expr,
or_op,
and_expr,
and_op,
not_expr,
not_op,
cmp_expr,
cmp_op,
add_expr,
add_op,
primary,
atom,
old_expr,
quantifier_expr,
quantifier_kw,
paren_expr,
call_or_ident,
call_args,
call_arg,
named_arg,
null_literal,
bool_literal,
number_literal,
string_literal,
string_inner,
escape_seq,
list_literal,
obj_literal,
obj_field,
ident,
type_ident,
}Variants§
EOI
End-of-input
WHITESPACE
Whitespace: spaces, tabs, carriage returns, newlines. Pest silently consumes these between every pair of tokens in non-atomic rules.
COMMENT
Single-line comments: // to end of line.
file
A complete .intent file: one module declaration, an optional doc block,
zero or more use imports, and zero or more top-level items.
use_decl
use ModuleName or use ModuleName.ItemName — import from another module.
(SPEC.md § Phase 7: Module Imports)
module_decl
Module declaration — every file begins with module ModuleName.
(SPEC.md § Composable Contracts)
doc_block
A documentation block: one or more --- lines of natural language.
(SPEC.md § Natural language descriptions via --- doc blocks)
doc_line
A single doc line. Atomic so whitespace handling doesn’t eat the content.
top_level_item
Any top-level declaration that may appear after the module header.
test_decl
test "name" { given { ... } when Action { ... } then { ... } }
Defines a test scenario that exercises an action with concrete values.
given_block
given { bindings } — concrete variable bindings for test setup.
given_binding
name = TypeName { field: value, ... } or name = expr — a single test binding.
entity_constructor
TypeName { field: value, ... } — constructs an entity instance with concrete values.
constructor_field
name: expr — a field inside an entity constructor or when block.
when_block
when ActionName { param: value, ... } — the action to invoke.
then_block
then { assertions } or then fails — expected outcome.
then_fails
fails with optional violation kind (e.g. fails precondition).
then_asserts
{ expr* } — assertions to check against new state.
entity_decl
entity EntityName { field* }
Defines a domain object with typed fields.
field_decl
field_name: TypeExpr — a named, typed field within an entity.
action_decl
action ActionName { doc? param* requires? ensures? properties? }
Defines a behavioral operation with pre/postconditions.
action_doc
Optional doc block inside an action (appears before params).
param_decl
Action parameter — same shape as a field declaration.
requires_block
requires { condition* } — preconditions that must hold before execution.
(SPEC.md § requires / ensures — Pre/postcondition blocks)
ensures_block
ensures { postcondition* } — postconditions that must hold after execution.
Items can be plain expressions or when condition => consequence.
(SPEC.md § requires / ensures, old() references)
ensures_item
A single postcondition: either a conditional when clause or a bare expression.
when_clause
when condition => consequence — conditional postcondition.
The condition is parsed as or_expr (stops before =>), so the =>
is unambiguously the when-separator, not the implies operator.
properties_block
properties { entry* } — declarative behavioral annotations.
(SPEC.md § properties — Declarative behavioral annotations)
prop_entry
key: value within a properties block.
prop_value
A property value: an object literal, list literal, string, number, bool, or identifier.
invariant_decl
invariant InvariantName { doc? expr }
System-wide constraint that must always hold.
edge_cases_decl
edge_cases { rule* } — explicit handling of boundary conditions.
edge_rule
when condition => action(args) — a single edge case rule.
Like when_clause, the condition stops at or_expr to avoid => ambiguity.
edge_action
The right-hand side of an edge rule: a function call like reject(...) or allow(...).
type_expr
Full type expression: a union type optionally followed by ? for optional.
Examples: String, Active | Frozen | Closed, DateTime?, List<T>?
optional_marker
? suffix marking a type as optional.
union_type
One or more base types separated by |.
A | B | C is a union/enum type.
base_type
A single type: collection generic, parameterized type, or simple named type.
list_type
List<T> — ordered collection.
set_type
Set<T> — unique collection.
map_type
Map<K, V> — key-value collection.
parameterized_type
TypeName(param: value, ...) — parameterized type, e.g. Decimal(precision: 2).
type_param
name: literal inside a parameterized type.
simple_type
A plain named type: UUID, String, Int, Bool, DateTime, Email,
CurrencyCode, URL, or any user-defined PascalCase type.
Also matches enum variant names like Active, Frozen, Completed.
expr
Top-level expression — starts at the implies precedence level.
implies_expr
a => b — logical implication. Parsed as or_expr ("=>" or_expr)*.
(SPEC.md § Operators — Logical: =>)
implies_op
or_expr
a || b — logical OR.
or_op
and_expr
a && b — logical AND. Can span multiple lines (see auth.intent ensures block).
and_op
not_expr
!a — logical NOT (prefix). Can be chained: !!x.
Falls through to cmp_expr for non-negated expressions.
not_op
cmp_expr
a == b, a != b, a > b, etc. — comparison (non-associative, at most one operator).
(SPEC.md § Operators — Comparison)
cmp_op
add_expr
a + b, a - b — additive arithmetic.
Used in postconditions like from.balance == old(from.balance) - amount.
add_op
primary
A primary expression, optionally followed by .field access chains.
Putting field access here lets lookup(User, email).status work naturally.
atom
The core of a primary expression — ordered so keywords are tried before ident.
old_expr
old(expr) — reference to pre-execution state.
(SPEC.md § old() references)
quantifier_expr
forall x: Type => body or exists x: Type => body — quantified expressions.
The body is a full expr, so the quantifier binds everything to its right.
(SPEC.md § Quantifiers: forall, exists)
quantifier_kw
paren_expr
Parenthesized sub-expression for explicit grouping.
call_or_ident
Either a function call name(args) or a plain identifier name.
The optional ( disambiguates: if present, it’s a call; otherwise, an ident reference.
Examples: now(), lookup(User, email), amount, Active.
call_args
Comma-separated call arguments (positional or named).
call_arg
A single argument: either name: expr (named) or expr (positional).
Named form is tried first; on failure, falls back to positional.
named_arg
name: expr — a named/keyword argument.
null_literal
null — the null/absent value.
bool_literal
true or false.
number_literal
Numeric literal: integer or decimal. Atomic to prevent whitespace insertion.
Examples: 0, 42, 10000.00, -1.
string_literal
String literal: "...". Compound-atomic so inner content is captured.
string_inner
The content between string quotes. Supports escaped quotes via \".
escape_seq
Escape sequences within strings.
list_literal
List literal: [a, b, c].
obj_literal
Object literal: { key: value, ... }. Used in property values.
obj_field
key: value inside an object literal.
ident
A general identifier: snake_case, camelCase, or PascalCase.
Keywords are context-sensitive in PEG — they are matched by literal strings
in the grammar rules above, so ident never needs to exclude them explicitly.
type_ident
A type-position identifier: must start with an uppercase letter. Used for module names, entity names, action names, type references.
Implementations§
Trait Implementations§
Source§impl Ord for Rule
impl Ord for Rule
Source§impl Parser<Rule> for IntentParser
impl Parser<Rule> for IntentParser
Source§impl PartialOrd for Rule
impl PartialOrd for Rule
impl Copy for Rule
impl Eq for Rule
impl StructuralPartialEq for Rule
Auto Trait Implementations§
impl Freeze for Rule
impl RefUnwindSafe for Rule
impl Send for Rule
impl Sync for Rule
impl Unpin for Rule
impl UnsafeUnpin for Rule
impl UnwindSafe for Rule
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more