Enum libunseemly::grammar::FormPat[][src]

pub enum FormPat {
Show 21 variants Anyways(Ast), Impossible, Scan(ScannerOption<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(NameRc<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(ScannerOption<String>)

Tuple Fields

Matches actual text! The regex must have a single capturing group. The optional string is a TextMate syntax category.

Common(Rc<FormPat>)

Tuple Fields

0: 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>)

Tuple Fields

0: Rc<FormPat>
1: Vec<Name>

Matches an atom or varref, but not if it’s on the list of reserved words

Literal(Rc<FormPat>, Name)

Tuple Fields

0: Rc<FormPat>
1: Name

Matches if the sub-pattern equals the given name

VarRef(Rc<FormPat>)

Tuple Fields

0: Rc<FormPat>

Matches an atom, turns it into a VariableReference

Seq(Vec<Rc<FormPat>>)

Tuple Fields

0: Vec<Rc<FormPat>>

Matches an ordered sequence of patterns.

Star(Rc<FormPat>)

Tuple Fields

0: Rc<FormPat>

Matches zero or more occurrences of a pattern.

Plus(Rc<FormPat>)

Tuple Fields

0: Rc<FormPat>

Matches one or more occurrences of a pattern.

Alt(Vec<Rc<FormPat>>)

Tuple Fields

0: Vec<Rc<FormPat>>

Matches any of the sub-pattersn.

Biased(Rc<FormPat>, Rc<FormPat>)

Tuple Fields

0: Rc<FormPat>
1: 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)

Tuple Fields

0: Rc<FormPat>
1: Rc<FormPat>

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)

Tuple Fields

0: Rc<Form>

Makes a node and limits the region where names are meaningful. Beta defines export.

Named(NameRc<FormPat>)

Tuple Fields

0: Name
1: Rc<FormPat>

Matches a pattern and gives it a name (inside the current Scope)

Pick(Rc<FormPat>, Name)

Tuple Fields

0: Rc<FormPat>
1: Name

Like a Scope, but just returns whatever has the given name

NameImport(Rc<FormPat>, Beta)

Tuple Fields

0: Rc<FormPat>
1: Beta

FOOTGUN: NameImport(Named(…), …) is almost always wrong. (write Named(NameImport(…, …)) instead) TODO: make this better

NameImportPhaseless(Rc<FormPat>, Beta)

Tuple Fields

0: Rc<FormPat>
1: Beta

Like NameImport, but affects all phases.

QuoteDeepen(Rc<FormPat>, bool)

Tuple Fields

0: Rc<FormPat>
1: bool

Quote syntax (the boolean indicates whether it’s positive or negative)

QuoteEscape(Rc<FormPat>, u8)

Tuple Fields

0: Rc<FormPat>
1: u8

Escape syntax quotation (by some number of levels)

Implementations

Map regular expressions (as strings) to their TextMate categories. This is a loose approximation of the impossible task of syntax-highlighting a FormPat.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

The Unseemly value that corresponds to a value.

Get a value from an Unseemly value

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

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Converts self into T using Into<T>. Read more

Performs the conversion.

Performs the conversion.

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.

Mutably borrows self, then passes self.deref_mut() into the pipe function. Read more

Should always be Self

Immutable access to a value. Read more

Mutable access to a value. Read more

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

Calls .tap_deref_mut() only in debug builds, and is erased in release builds. Read more

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

Attempts to convert self into T using TryInto<T>. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.