Skip to content
Merged
Show file tree
Hide file tree
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
17 changes: 12 additions & 5 deletions crates/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,16 @@ The parser covers a subset of §16, not the whole grammar. Treat anything outsid
the accepted list as **not yet implemented** — add a corpus fixture when it lands.

- **Accepted:** every item form (`fn`, `struct`, `enum` incl. tuple/struct
variants, `actor`, `mod`, `use`, `const`, `type`, `trait`, `impl`,
variants, `actor`, `mod`, `use`, `const`, `type`, `trait` incl. generics,
supertrait bounds, and `where` clauses (bounds parsed but not stored),
`impl Type` and `impl Trait for Type` (trait ref recorded in the AST),
`onchain mod`, `extern`); types incl. generics, references, arrays/slices,
tuples, `fn`/`dyn`; expressions incl. calls, turbofish, field/index,
unary/binary (incl. `/`), `?`, `.await`, `|>`, `as`, struct literals (with the
§5.1 block-head restriction), `vec!`, and `if`/`else`; `let`, `return`,
tuples, `fn`, and `dyn Trait<Args>` incl. associated-type bindings;
expressions incl. calls, turbofish, field/index,
unary/binary (incl. `/`), `?`, `.await`, `as`, struct literals (with the
§5.1 block-head restriction), `vec!`, and `if`/`else`; `|>` with §16
`pipe_stage` stages (`callee [args] [?]` — a stage's trailing `?` wraps the
accumulated pipe application per §5.7); `let`, `return`,
`break`, `continue`, `send`, and expression/tail statements.
- **Not yet implemented:** `match`, `while`, `for`, `loop`, `if let`, and
closures (their keywords lex but have no parse production); `spawn`, `select`,
Expand All @@ -36,7 +41,9 @@ the accepted list as **not yet implemented** — add a corpus fixture when it la
`let Some(x) = ...` are rejected); `#[...]` compiler directives are not parsed
in any position (`#[cfg(test)]`, `#[target(...)]`, `#[indexed]` all fail);
`storage { }` blocks inside `onchain mod` are consumed but discarded, not
stored in the AST; generic parameters and
stored in the AST; closure pipe stages (`x |> (|v| ...)`) and turbofish on a
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
non-final pipe-stage segment are rejected with explicit
not-yet-implemented parse errors; generic parameters and
`trait`/`impl` bodies are skipped, not stored in the AST; `let mut` / `&mut`
mutability and the `send` keyword are parsed but not preserved; a block-like
expression (`if`/block) used as a non-tail statement needs a trailing `;`.
Expand Down
11 changes: 10 additions & 1 deletion crates/sploosh-ast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ pub struct Trait {

#[derive(Debug, Clone, PartialEq)]
pub struct ImplBlock {
/// `Some` for `impl Trait for Type`, `None` for an inherent `impl Type`.
pub trait_ref: Option<TraitRef>,
pub target: Type,
}

Expand All @@ -195,7 +197,14 @@ pub enum Type {
Slice(Box<Type>),
Tuple(Vec<Type>),
Function { params: Vec<Type>, ret: Box<Type> },
Dyn(Path),
Dyn(TraitRef),
}

/// `trait_ref = type_path [ type_args ]` (§16).
#[derive(Debug, Clone, PartialEq)]
pub struct TraitRef {
pub path: Path,
pub args: Vec<TypeArg>,
}

#[derive(Debug, Clone, PartialEq)]
Expand Down
Loading