Skip to main content

Module pest

Module pest 

Source
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ยง

ContractParser ๐Ÿ”’
Parser derived from grammar.pest.

Enumsยง

Rule

Constantsยง

_PEST_GRAMMAR_ContractParser ๐Ÿ”’

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>() (optionally std::mem:: / core::mem:: prefixed) into SizeOf / 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 a NumericPredicate.
relop_from_str ๐Ÿ”’
singleton_or_wrap ๐Ÿ”’
Unwrap a single-element list, otherwise wrap it with wrap.