tamer: asg::air::ir: Remove TplApply
The implementation decided upon in the previous commits have made this unnecessary, using `RefIdent` to produce `Tpl->Ident[->Tpl]` instead. DEV-13708main
parent
669302700a
commit
3e9f407527
|
@ -628,13 +628,47 @@ sum_ir! {
|
||||||
/// metasyntactic variables,
|
/// metasyntactic variables,
|
||||||
/// defined by [`AirTpl::TplMetaStart`].
|
/// defined by [`AirTpl::TplMetaStart`].
|
||||||
///
|
///
|
||||||
/// If a template contains any metavariables (parameters) without
|
/// Template Application
|
||||||
/// bound values,
|
/// ====================
|
||||||
/// those metavariables are said to be _free_.
|
/// _Application_ is triggered by a [`Air::RefIdent`] to a [`Tpl`]
|
||||||
/// Values may be applied to templates using [`AirTpl::TplApply`],
|
/// or a [`Air::TplEndRef`] and will re-bind an inner template to
|
||||||
/// binding those values to their associated metavariables.
|
/// the metavariables in the current context and expand the
|
||||||
/// A template with no free metavariables is _closed_ and may be
|
/// template in place.
|
||||||
/// expanded in-place.
|
/// A metavariable is _free_ if it has no bound value.
|
||||||
|
/// A template is _closed_ if it has no free metavariables.
|
||||||
|
/// Application _expands_ into its context,
|
||||||
|
/// and application of a closed template is equivalent to the
|
||||||
|
/// notion of template application in NIR / TAME's source language.
|
||||||
|
///
|
||||||
|
/// Let α be the current template definition context
|
||||||
|
/// (via [`Air::TplStart`])
|
||||||
|
/// and let β be the inner template.
|
||||||
|
/// All free metavariables in β that contain default values in α
|
||||||
|
/// (via [`Air::TplMetaStart`])
|
||||||
|
/// corresponding to the same [`Ident`] will be _bound_ to
|
||||||
|
/// that value.
|
||||||
|
/// The body of the inner template β will be expanded into the
|
||||||
|
/// body of α.
|
||||||
|
/// The result is a template α which is the application of its
|
||||||
|
/// parameters to β.
|
||||||
|
///
|
||||||
|
/// Partial application is not yet supported,
|
||||||
|
/// but can be added if it is worth the effort of doing so.
|
||||||
|
/// This simplifies the semantics of this operation:
|
||||||
|
///
|
||||||
|
/// - All metavariables that are still free in β after binding
|
||||||
|
/// will assume their default values, if any; and
|
||||||
|
/// - All metavariables that are still free in β after
|
||||||
|
/// applying defaults will result in an error.
|
||||||
|
///
|
||||||
|
/// Consequently,
|
||||||
|
/// the template α will always be closed after this operation.
|
||||||
|
/// This can be thought of like a lexical thunk.
|
||||||
|
///
|
||||||
|
/// α can then be expanded in place using [`Air::TplEndRef`] if
|
||||||
|
/// it is anonymous.
|
||||||
|
/// If α is named,
|
||||||
|
/// [`Air::RefIdent`] can be used to trigger expansion.
|
||||||
enum AirTpl {
|
enum AirTpl {
|
||||||
/// Create a new [`Tpl`] on the graph and switch to template parsing.
|
/// Create a new [`Tpl`] on the graph and switch to template parsing.
|
||||||
///
|
///
|
||||||
|
@ -657,14 +691,14 @@ sum_ir! {
|
||||||
/// [`AirBind::BindIdent`] before [`Self::TplMetaEnd`].
|
/// [`AirBind::BindIdent`] before [`Self::TplMetaEnd`].
|
||||||
///
|
///
|
||||||
/// Metavariables may contain default values,
|
/// Metavariables may contain default values,
|
||||||
/// making their specification during [`Self::TplApply`] optional.
|
/// making their specification during application optional.
|
||||||
/// A metavariable may contain an ordered mixture of references
|
/// A metavariable may contain an ordered mixture of references
|
||||||
/// to another metavariables via [`AirBind::RefIdent`] and
|
/// to another metavariables via [`AirBind::RefIdent`] and
|
||||||
/// literals via [`Self::TplLexeme`].
|
/// literals via [`Self::TplLexeme`].
|
||||||
/// Once all metavariable references have been satisfied during
|
/// Once all metavariable references have been satisfied during
|
||||||
/// [`Self::TplApply`],
|
/// application,
|
||||||
/// all children will be combined into a single lexeme to
|
/// all children will be combined into a single lexeme to
|
||||||
/// serve as a final identifier.
|
/// serve as a final identifier.
|
||||||
///
|
///
|
||||||
/// The interpretation of a metavariable depends solely on the
|
/// The interpretation of a metavariable depends solely on the
|
||||||
/// context in which it is referenced.
|
/// context in which it is referenced.
|
||||||
|
@ -694,43 +728,6 @@ sum_ir! {
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
||||||
/// Re-bind an inner template to the metavariables in the
|
|
||||||
/// current context and expand the template in place.
|
|
||||||
///
|
|
||||||
/// Let α be the current template definition context
|
|
||||||
/// (via [`Self::TplStart`])
|
|
||||||
/// and let β be the inner template.
|
|
||||||
/// All free metavariables in β that contain default values in α
|
|
||||||
/// (via [`Self::TplMetaStart`])
|
|
||||||
/// corresponding to the same [`Ident`] will be _bound_ to
|
|
||||||
/// that value.
|
|
||||||
/// The body of the inner template β will be expanded into the
|
|
||||||
/// body of α.
|
|
||||||
/// The result is a template α which is the application of its
|
|
||||||
/// parameters to β.
|
|
||||||
///
|
|
||||||
/// Partial application is not yet supported,
|
|
||||||
/// but can be added if it is worth the effort of doing so.
|
|
||||||
/// This simplifies the semantics of this operation:
|
|
||||||
///
|
|
||||||
/// - All metavariables that are still free in β after binding
|
|
||||||
/// will assume their default values, if any; and
|
|
||||||
/// - All metavariables that are still free in β after
|
|
||||||
/// applying defaults will result in an error.
|
|
||||||
///
|
|
||||||
/// Consequently,
|
|
||||||
/// the template α will always be closed after this operation.
|
|
||||||
/// This can be thought of like a lexical thunk.
|
|
||||||
///
|
|
||||||
/// α can then be expanded in place using [`Self::TplEndRef`] if
|
|
||||||
/// it is anonymous.
|
|
||||||
/// If α is named,
|
|
||||||
/// [`Air::RefIdent`] can be used to trigger expansion.
|
|
||||||
TplApply(span: Span) => {
|
|
||||||
span: span,
|
|
||||||
display: |f| write!(f, "apply param bindings to inner template"),
|
|
||||||
},
|
|
||||||
|
|
||||||
/// Complete the active [`Tpl`] and exit template parsing.
|
/// Complete the active [`Tpl`] and exit template parsing.
|
||||||
///
|
///
|
||||||
/// The expression stack will be restored to its prior state.
|
/// The expression stack will be restored to its prior state.
|
||||||
|
|
|
@ -202,10 +202,7 @@ impl ParseState for AirTplAggregate {
|
||||||
Transition(Toplevel(oi_pkg, tpl, expr)).incomplete()
|
Transition(Toplevel(oi_pkg, tpl, expr)).incomplete()
|
||||||
}
|
}
|
||||||
|
|
||||||
(
|
(Toplevel(..), tok @ AirTpl(TplMetaStart(..) | TplMetaEnd(..))) => {
|
||||||
Toplevel(..),
|
|
||||||
tok @ AirTpl(TplMetaStart(..) | TplMetaEnd(..) | TplApply(..)),
|
|
||||||
) => {
|
|
||||||
diagnostic_todo!(
|
diagnostic_todo!(
|
||||||
vec![tok.note("for this token")],
|
vec![tok.note("for this token")],
|
||||||
"Toplevel meta"
|
"Toplevel meta"
|
||||||
|
@ -275,10 +272,7 @@ impl ParseState for AirTplAggregate {
|
||||||
|
|
||||||
(
|
(
|
||||||
Ready(..) | TplExpr(..),
|
Ready(..) | TplExpr(..),
|
||||||
tok @ AirTpl(
|
tok @ AirTpl(TplMetaStart(..) | TplLexeme(..) | TplMetaEnd(..)),
|
||||||
TplMetaStart(..) | TplLexeme(..) | TplMetaEnd(..)
|
|
||||||
| TplApply(..),
|
|
||||||
),
|
|
||||||
) => {
|
) => {
|
||||||
diagnostic_todo!(
|
diagnostic_todo!(
|
||||||
vec![tok.note("for this token")],
|
vec![tok.note("for this token")],
|
||||||
|
|
Loading…
Reference in New Issue