Expand description
pest parser and semantic converter for the contract DSL.
The grammar (grammar.pest) is the single source of truth for the
contract-DSL surface; ContractParser is derived from it, and the
conversion functions turn the resulting Pairs<Rule> into the contract AST
(types.rs / compound.rs).
Places (fields, projections) are bridged through the place.rs / resolve.rs
helpers via a syn round-trip, since resolving a field name to a Ty still
needs the rustc type context. The arithmetic / call / if / constant layers
are converted directly from the pest tree.
Re-exportsยง
use pest::Parser;๐use pest::iterators::Pair;๐use pest_derive::Parser;๐use rustc_hir::def_id::DefId;๐use rustc_middle::ty::TyCtxt;๐use super::compound::CompoundArg;๐use super::compound::CompoundBody;๐use super::ContractExpr;๐use super::BinOp;๐use super::NumericPredicate;๐use super::UnaryOp;๐use super::RelOp;๐use crate::util::name::match_ty_with_ident;๐
Structsยง
- Contract
Parser ๐ - Parser derived from
grammar.pest.
Enumsยง
Constantsยง
Functionsยง
- conv_
additive ๐ - conv_
arg_ ๐expr - conv_
bit_ ๐and - conv_
bit_ ๐or - conv_
bit_ ๐xor - conv_
call ๐ - conv_
compound_ ๐and - conv_
compound_ ๐call - conv_
compound_ ๐leaf - conv_
compound_ ๐or - conv_
const_ ๐path - conv_
expr ๐ - conv_if ๐
- conv_
left_ ๐assoc - conv_
multiplicative ๐ - conv_
place_ ๐bridge - Bridge a place through the syn-based parser for field and method projections.
- conv_
predicate ๐ - conv_
primary ๐ - conv_
size_ ๐of_ call - Convert
size_of::<T>()/align_of::<T>()(optionallystd::mem::/core::mem::prefixed) intoSizeOf/AlignOf. - conv_
unary ๐ - only_
child ๐ - op_
from_ ๐str - parse_
compound_ ๐body - Parse a compound-property body into a DNF tree.
||binds looser than&&. - parse_
expr_ ๐pest - Parse a numeric expression (no comparison) into a
ContractExpr. - parse_
predicate_ ๐pest - Parse a predicate (comparison /
!x.is_empty()/ bare expr) into aNumericPredicate. - relop_
from_ ๐str - singleton_
or_ ๐wrap - Unwrap a single-element list, otherwise wrap it with
wrap.