Enum libunseemly::grammar::FormPat [−][src]
pub enum FormPat {
Show 21 variants
Anyways(Ast),
Impossible,
Scan(Scanner, Option<String>),
Common(Rc<FormPat>),
Reserved(Rc<FormPat>, Vec<Name>),
Literal(Rc<FormPat>, Name),
VarRef(Rc<FormPat>),
Seq(Vec<Rc<FormPat>>),
Star(Rc<FormPat>),
Plus(Rc<FormPat>),
Alt(Vec<Rc<FormPat>>),
Biased(Rc<FormPat>, Rc<FormPat>),
Call(Name),
SynImport(Rc<FormPat>, Rc<FormPat>, SyntaxExtension),
Scope(Rc<Form>, ExportBeta),
Named(Name, Rc<FormPat>),
Pick(Rc<FormPat>, Name),
NameImport(Rc<FormPat>, Beta),
NameImportPhaseless(Rc<FormPat>, Beta),
QuoteDeepen(Rc<FormPat>, bool),
QuoteEscape(Rc<FormPat>, u8),
}
Expand description
FormPat
defines a pattern in a grammar. Think EBNF, but more extended.
Most kinds of grammar nodes produce an Ast
of either Shape
or Env
,
but Named
and Scope
are special:
everything outside of a Named
(up to a Scope
, if any) is discarded,
and Scope
produces a Node
, which maps names to what they got.
Variants
Anyways(Ast)
Tuple Fields
0: Ast
Matches 0 tokens, produces the Ast
Impossible
Never matches
Scan(Scanner, Option<String>)
Matches actual text! The regex must have a single capturing group. The optional string is a TextMate syntax category.
Common(Rc<FormPat>)
Marks this rule as too commonly-used to be informative; prevents display of this rule in parse errors,
Reserved(Rc<FormPat>, Vec<Name>)
Matches an atom or varref, but not if it’s on the list of reserved words
Literal(Rc<FormPat>, Name)
Matches if the sub-pattern equals the given name
VarRef(Rc<FormPat>)
Matches an atom, turns it into a VariableReference
Seq(Vec<Rc<FormPat>>)
Matches an ordered sequence of patterns.
Star(Rc<FormPat>)
Matches zero or more occurrences of a pattern.
Plus(Rc<FormPat>)
Matches one or more occurrences of a pattern.
Alt(Vec<Rc<FormPat>>)
Matches any of the sub-pattersn.
Biased(Rc<FormPat>, Rc<FormPat>)
Matches the LHS pattern, or, failing that, the RHS pattern.
Call(Name)
Tuple Fields
0: Name
Lookup a nonterminal in the current syntactic environment.
SynImport(Rc<FormPat>, Rc<FormPat>, SyntaxExtension)
This is where syntax gets extensible. Parses its body in the syntax environment computed from the LHS and the current syntax environment.
Scope(Rc<Form>, ExportBeta)
Makes a node and limits the region where names are meaningful. Beta
defines export.
Named(Name, Rc<FormPat>)
Matches a pattern and gives it a name (inside the current Scope
)
Pick(Rc<FormPat>, Name)
Like a Scope
, but just returns whatever has the given name
NameImport(Rc<FormPat>, Beta)
FOOTGUN: NameImport(Named(…), …) is almost always wrong. (write Named(NameImport(…, …)) instead) TODO: make this better
NameImportPhaseless(Rc<FormPat>, Beta)
Like NameImport
, but affects all phases.
QuoteDeepen(Rc<FormPat>, bool)
Quote syntax (the boolean indicates whether it’s positive or negative)
QuoteEscape(Rc<FormPat>, u8)
Escape syntax quotation (by some number of levels)
Implementations
Trait Implementations
The Unseemly type that corresponds to to the Reifiable
type.
This leaves abstract the type parameters of Self
; invoke like Self::<Irr,Irr>::ty()
.
e.g. ∀ A. Pair<A int>
TODO: rename to generic_ty
Read more
A name for that type, so that recursive types are okay.
Ignore the type parameters of Self
; invoke like Self::<Irr,Irr>::ty_name()
.
e.g. WithInteger
Read more
How to refer to this type, given an environment in which
ty_name()
is defined to be ty()
.
Parameters will be concrete.
e.g. WithInteger<Float>
(Types using this type will use this, rather than ty
)
Don’t override this. Read more
Auto Trait Implementations
impl !RefUnwindSafe for FormPat
impl !UnwindSafe for FormPat
Blanket Implementations
Mutably borrows from an owned value. Read more
Pipes by value. This is generally the method you want to use. Read more
Borrows self
and passes that borrow into the pipe function. Read more
Mutably borrows self
and passes that borrow into the pipe function. Read more
Borrows self
, then passes self.borrow()
into the pipe function. Read more
Mutably borrows self
, then passes self.borrow_mut()
into the pipe
function. Read more
Borrows self
, then passes self.as_ref()
into the pipe function.
Mutably borrows self
, then passes self.as_mut()
into the pipe
function. Read more
Borrows self
, then passes self.deref()
into the pipe function.
type Output = T
type Output = T
Should always be Self
Immutable access to the Borrow<B>
of a value. Read more
Mutable access to the BorrowMut<B>
of a value. Read more
Immutable access to the AsRef<R>
view of a value. Read more
Mutable access to the AsMut<R>
view of a value. Read more
Immutable access to the Deref::Target
of a value. Read more
Mutable access to the Deref::Target
of a value. Read more
Calls .tap()
only in debug builds, and is erased in release builds.
Calls .tap_mut()
only in debug builds, and is erased in release
builds. Read more
Calls .tap_borrow()
only in debug builds, and is erased in release
builds. Read more
Calls .tap_borrow_mut()
only in debug builds, and is erased in release
builds. Read more
Calls .tap_ref()
only in debug builds, and is erased in release
builds. Read more
Calls .tap_ref_mut()
only in debug builds, and is erased in release
builds. Read more
Calls .tap_deref()
only in debug builds, and is erased in release
builds. Read more