tamer: asg::air::ir::AirMeta: Remove `Tpl` prefix from tokens

Cleanup from the previous commit.

DEV-13162
main
Mike Gerwitz 2023-05-23 14:44:16 -04:00
parent c12bf439ae
commit e8335c57d4
7 changed files with 39 additions and 39 deletions

View File

@ -634,7 +634,7 @@ sum_ir! {
///
/// Templates serve as containers for objects that reference
/// metasyntactic variables,
/// defined by [`AirMeta::TplMetaStart`].
/// defined by [`AirMeta::MetaStart`].
///
/// Template Application
/// ====================
@ -652,7 +652,7 @@ sum_ir! {
/// (via [`Air::TplStart`])
/// and let β be the inner template.
/// All free metavariables in β that contain default values in α
/// (via [`Air::TplMetaStart`])
/// (via [`Air::MetaStart`])
/// corresponding to the same [`Ident`] will be _bound_ to
/// that value.
/// The body of the inner template β will be expanded into the
@ -738,13 +738,13 @@ sum_ir! {
/// Begin a metavariable definition.
///
/// A metavariable is anonymous unless identified via
/// [`AirBind::BindIdent`] before [`Self::TplMetaEnd`].
/// [`AirBind::BindIdent`] before [`Self::MetaEnd`].
///
/// Metavariables may contain default values,
/// making their specification during application optional.
/// A metavariable may contain an ordered mixture of references
/// to another metavariables via [`AirBind::RefIdent`] and
/// literals via [`Self::TplLexeme`].
/// literals via [`Self::MetaLexeme`].
/// Once all metavariable references have been satisfied during
/// application,
/// all children will be combined into a single lexeme to
@ -752,7 +752,7 @@ sum_ir! {
///
/// The interpretation of a metavariable depends solely on the
/// context in which it is referenced.
TplMetaStart(span: Span) => {
MetaStart(span: Span) => {
span: span,
display: |f| write!(
f,
@ -762,15 +762,15 @@ sum_ir! {
/// A lexeme to be interpreted in the context of a template
/// expansion.
TplLexeme(lex: SPair) => {
MetaLexeme(lex: SPair) => {
span: lex,
display: |f| write!(f, "lexeme {}", TtQuote::wrap(lex)),
},
/// Complete a metavariable definition.
///
/// See [`Self::TplMetaStart`] for more information.
TplMetaEnd(span: Span) => {
/// See [`Self::MetaStart`] for more information.
MetaEnd(span: Span) => {
span: span,
display: |f| write!(
f,

View File

@ -69,16 +69,16 @@ impl ParseState for AirMetaAggregate {
use AirMetaAggregate::*;
match (self, tok) {
(Ready, AirMeta(TplMetaStart(span))) => {
(Ready, AirMeta(MetaStart(span))) => {
let oi_meta = ctx.asg_mut().create(Meta::new_required(span));
Transition(TplMeta(oi_meta)).incomplete()
}
(TplMeta(oi_meta), AirMeta(TplMetaEnd(cspan))) => {
(TplMeta(oi_meta), AirMeta(MetaEnd(cspan))) => {
oi_meta.close(ctx.asg_mut(), cspan);
Transition(Ready).incomplete()
}
(TplMeta(oi_meta), AirMeta(TplLexeme(lexeme))) => Transition(
(TplMeta(oi_meta), AirMeta(MetaLexeme(lexeme))) => Transition(
TplMeta(oi_meta.assign_lexeme(ctx.asg_mut(), lexeme)),
)
.incomplete(),
@ -98,21 +98,21 @@ impl ParseState for AirMetaAggregate {
)
}
(TplMeta(..), tok @ AirMeta(TplMetaStart(..))) => {
(TplMeta(..), tok @ AirMeta(MetaStart(..))) => {
diagnostic_todo!(
vec![tok.note("this token")],
"AirMeta variant"
)
}
(Ready, tok @ AirMeta(TplMetaEnd(..))) => {
(Ready, tok @ AirMeta(MetaEnd(..))) => {
diagnostic_todo!(
vec![tok.note("this token")],
"unbalanced meta"
)
}
(Ready, tok @ AirMeta(TplLexeme(..))) => {
(Ready, tok @ AirMeta(MetaLexeme(..))) => {
diagnostic_todo!(
vec![tok.note("this token")],
"unexpected lexeme"

View File

@ -186,9 +186,9 @@ test_scopes! {
// ENV: 2 tpl // | :
BindIdent(tpl_outer), // |v :v
// | :
TplMetaStart(S4), // | :
MetaStart(S4), // | :
BindIdent(meta_outer), // vl|s :
TplMetaEnd(S6), // | :
MetaEnd(S6), // | :
// | :
ExprStart(ExprOp::Sum, S7), // | :
BindIdent(expr_outer), // vd|s :
@ -198,9 +198,9 @@ test_scopes! {
// ENV: 3 tpl // | | :
BindIdent(tpl_inner), // |v |s :
// | | :
TplMetaStart(S12), // | | :
MetaStart(S12), // | | :
BindIdent(meta_inner), // vl|s |s :
TplMetaEnd(S14), // | | :
MetaEnd(S14), // | | :
// 3| 2| 1: 0
ExprStart(ExprOp::Sum, S15), // | | :
BindIdent(expr_inner), // vd|s |s :
@ -355,18 +355,18 @@ test_scopes! {
// ENV: 2 tpl // | :
BindIdent(tpl_outer), // |~ :
// | :
TplMetaStart(S4), // | :
MetaStart(S4), // | :
BindIdent(meta_same_a), // vl|s : <--.
TplMetaEnd(S6), // | : |
MetaEnd(S6), // | : |
TplEnd(S7), //----' : |
// : |s
TplStart(S8), //----. : |a
// ENV: 3 tpl // | : |m
BindIdent(tpl_inner), // |~ : |e
// | : |
TplMetaStart(S10), // | : |
MetaStart(S10), // | : |
BindIdent(meta_same_b), // vl|s : <--'
TplMetaEnd(S12), // | :
MetaEnd(S12), // | :
TplEnd(S13), //----' : ~ = ignored for
PkgEnd(S14), //- - - -' these tests
]

View File

@ -469,15 +469,15 @@ fn tpl_with_param() {
Air::BindIdent(id_tpl),
// Metavariable with a value.
Air::TplMetaStart(S3),
Air::MetaStart(S3),
Air::BindIdent(id_param1),
Air::TplLexeme(pval1),
Air::TplMetaEnd(S6),
Air::MetaLexeme(pval1),
Air::MetaEnd(S6),
// Required metavariable (no value).
Air::TplMetaStart(S7),
Air::MetaStart(S7),
Air::BindIdent(id_param2),
Air::TplMetaEnd(S9),
Air::MetaEnd(S9),
Air::TplEnd(S10),
];

View File

@ -214,10 +214,10 @@ fn traverses_ontological_tree_tpl_apply() {
TplStart(S5),
RefIdent(ref_tpl),
TplMetaStart(S7),
MetaStart(S7),
BindIdent(id_param),
TplLexeme(value_param),
TplMetaEnd(S10),
MetaLexeme(value_param),
MetaEnd(S10),
TplEndRef(S11), // notice the `Ref` at the end
PkgEnd(S12),
];

View File

@ -225,13 +225,13 @@ impl ParseState for NirToAir {
}
(Ready, Open(TplParam, span)) => {
Transition(Meta(span)).ok(Air::TplMetaStart(span))
Transition(Meta(span)).ok(Air::MetaStart(span))
}
(Meta(mspan), Text(lexeme)) => {
Transition(Meta(mspan)).ok(Air::TplLexeme(lexeme))
Transition(Meta(mspan)).ok(Air::MetaLexeme(lexeme))
}
(Ready | Meta(_), Close(TplParam, span)) => {
Transition(Ready).ok(Air::TplMetaEnd(span))
Transition(Ready).ok(Air::MetaEnd(span))
}
// Some of these will be permitted in the future.
(

View File

@ -229,15 +229,15 @@ fn apply_template_long_form_args() {
O(Air::TplStart(S1)),
O(Air::RefIdent(name)),
O(Air::TplMetaStart(S3)),
O(Air::MetaStart(S3)),
O(Air::BindIdent(p1)),
O(Air::TplLexeme(v1)),
O(Air::TplMetaEnd(S6)),
O(Air::MetaLexeme(v1)),
O(Air::MetaEnd(S6)),
O(Air::TplMetaStart(S7)),
O(Air::MetaStart(S7)),
O(Air::BindIdent(p2)),
O(Air::TplLexeme(v2)),
O(Air::TplMetaEnd(S10)),
O(Air::MetaLexeme(v2)),
O(Air::MetaEnd(S10)),
O(Air::TplEndRef(S11)),
]),
Sut::parse(toks.into_iter()).collect(),