pub struct OpDef {}Expand description
One entry of the op option map: the definition of an operator.
src carries one source string for a prefix, suffix or infix
operator and two for a ternary (["?", ":"]); a paren operator uses
osrc and csrc instead. A key operator’s src is the member name
that marks a site, $ref say.
Fields§
§src: Vec<String>§osrc: String§csrc: String§left: Option<i64>§right: Option<i64>§prefix: bool§suffix: bool§infix: bool§ternary: bool§paren: bool§preval: Option<PrevalDef>§use_data: ValueCustom operator data, handed back to an evaluator as op.use.
key: boolA STRUCTURAL operator: an occurrence is a map that owns the member
named by src, recognised by its shape when a tree is folded
(fold), never by a token. No fixed token is registered for it,
so the base grammar keeps the key position, and no binding power
applies: its two terms are fixed by the shape, the member’s value
and the map of the other members.
dynamic: boolA key operator a fold recognises and reports but never evaluates,
such as $dynamicRef, whose meaning depends on a scope the parser
does not have. Its map folds as a plain map.
Implementations§
Source§impl OpDef
impl OpDef
Sourcepub fn infix(src: impl Into<String>, left: i64, right: i64) -> Self
pub fn infix(src: impl Into<String>, left: i64, right: i64) -> Self
An infix operator with the given source and binding powers.
Sourcepub fn prefix(src: impl Into<String>, right: i64) -> Self
pub fn prefix(src: impl Into<String>, right: i64) -> Self
A prefix operator with the given source and right binding power.
Sourcepub fn suffix(src: impl Into<String>, left: i64) -> Self
pub fn suffix(src: impl Into<String>, left: i64) -> Self
A suffix operator with the given source and left binding power.
Sourcepub fn ternary(first: impl Into<String>, second: impl Into<String>) -> Self
pub fn ternary(first: impl Into<String>, second: impl Into<String>) -> Self
A ternary operator with its two source strings.
Sourcepub fn paren(osrc: impl Into<String>, csrc: impl Into<String>) -> Self
pub fn paren(osrc: impl Into<String>, csrc: impl Into<String>) -> Self
A paren operator with its opening and closing source strings.
Sourcepub fn key(src: impl Into<String>) -> Self
pub fn key(src: impl Into<String>) -> Self
A key operator: a map that owns the member src is an occurrence
of it when a tree is folded.
Sourcepub fn dynamic_key(src: impl Into<String>) -> Self
pub fn dynamic_key(src: impl Into<String>) -> Self
A dynamic key operator: recognised and reported by a fold, never evaluated.
Sourcepub fn with_preval(self, preval: PrevalDef) -> Self
pub fn with_preval(self, preval: PrevalDef) -> Self
Give a paren operator a preval configuration.