2023-03-07 14:00:46 -05:00
|
|
|
// ASG IR template parsing
|
|
|
|
//
|
|
|
|
// Copyright (C) 2014-2023 Ryan Specialty, LLC.
|
|
|
|
//
|
|
|
|
// This file is part of TAME.
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
//! AIR template parser.
|
|
|
|
//!
|
|
|
|
//! See the [parent module](super) for more information.
|
|
|
|
|
|
|
|
use super::{
|
2023-03-24 00:22:22 -04:00
|
|
|
super::{graph::object::Tpl, Asg, AsgError, ObjectIndex},
|
2023-03-08 11:18:51 -05:00
|
|
|
expr::AirExprAggregateStoreDangling,
|
2023-03-11 00:40:54 -05:00
|
|
|
ir::AirTemplatable,
|
tamer: asg::air: AirAggregateCtx: New AirAggregate::Context
Future changes to `AirAggregate` are going to require additional context (a
stack, specifically), but the `Context` is currently utilized
by `Asg`. This introduces a layer of abstraction that will allow us to add
the stack.
Alongside these changes, `ParseState` has been augmented with a `PubContext`
type that is utilized on public APIs, both maintaining BC with existing code
and keeping these implementation details encapsulated.
This does make a bit of a mess of the internal implementation, though, with
`asg_mut()` sprinkled about, so maybe the next commit can clean that up a
bit. EDIT: After adding `AsMut` to a bunch of asg::graph::object::*
methods, I decided against it, because it messes with the inferred
ownership, requiring explicit borrows via `as_mut()` where they were not
required before. I think the existing code is easier to reason about than
what would otherwise result from having `mut asg: impl AsMut<Asg>`
everwhere.
DEV-13708
2023-03-27 11:47:11 -04:00
|
|
|
AirAggregateCtx, AirExprAggregate,
|
2023-03-07 14:00:46 -05:00
|
|
|
};
|
|
|
|
use crate::{
|
2023-03-28 16:14:09 -04:00
|
|
|
asg::graph::object::{Meta, ObjectIndexRelTo},
|
2023-03-17 10:37:14 -04:00
|
|
|
diagnose::Annotate,
|
|
|
|
diagnostic_todo,
|
2023-03-07 14:00:46 -05:00
|
|
|
fmt::{DisplayWrapper, TtQuote},
|
|
|
|
parse::prelude::*,
|
tamer: Very basic support for template application NIR -> xmli
This this a big change that's difficult to break up, and I don't have the
energy after it.
This introduces nullary template application, short- and long-form. Note
that a body of the short form is a `@values@` argument, so that's not
supported yet.
This continues to formalize the idea of what "template application" and
"template expansion" mean in TAMER. It makes a separate `TplApply`
unnecessary, because now application is simply a reference to a
template. Expansion and application are one and the same: when a template
expands, it'll re-bind metavariables to the parent context. So in a
template context, this amounts to application.
But applying a closed template will have nothing to bind, and so is
equivalent to expansion. And since `Meta` objects are not valid outside of
a `Tpl` context, applying a non-closed template outside of another template
will be invalid.
So we get all of this with a single primitive (getting the "value" of a
template).
The expansion is conceptually like `,@` in Lisp, where we're splicing trees.
It's a mess in some spots, but I want to get this committed before I do a
little bit of cleanup.
2023-03-17 10:25:56 -04:00
|
|
|
span::Span,
|
2023-03-07 14:00:46 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
/// Template parser and token aggregator.
|
|
|
|
///
|
|
|
|
/// A template consists of
|
|
|
|
///
|
|
|
|
/// - Metadata about the template,
|
|
|
|
/// including its parameters; and
|
2023-03-11 00:40:54 -05:00
|
|
|
/// - A collection of [`AirTemplatable`] tokens representing the body of
|
|
|
|
/// the template that will be expanded into the application site when
|
|
|
|
/// the template is applied.
|
2023-03-07 14:00:46 -05:00
|
|
|
///
|
|
|
|
/// This contains an embedded [`AirExprAggregate`] parser for handling
|
|
|
|
/// expressions just the same as [`super::AirAggregate`] does with
|
|
|
|
/// packages.
|
2023-03-07 16:28:32 -05:00
|
|
|
#[derive(Debug, PartialEq)]
|
2023-03-28 16:14:09 -04:00
|
|
|
pub enum AirTplAggregate {
|
2023-03-07 14:00:46 -05:00
|
|
|
/// Ready for a template,
|
|
|
|
/// defined as part of the given package.
|
|
|
|
///
|
2023-03-07 16:28:32 -05:00
|
|
|
/// This state also includes the template header;
|
2023-03-07 14:00:46 -05:00
|
|
|
/// unlike NIR,
|
|
|
|
/// AIR has no restrictions on when template header tokens are
|
|
|
|
/// provided,
|
|
|
|
/// which simplifies AIR generation.
|
2023-03-28 16:14:09 -04:00
|
|
|
Ready,
|
2023-03-07 14:00:46 -05:00
|
|
|
|
2023-03-23 00:04:53 -04:00
|
|
|
/// Toplevel template context.
|
|
|
|
///
|
|
|
|
/// Conceptually,
|
|
|
|
/// tokens that are received in this state are interpreted as directly
|
|
|
|
/// applying to the template itself,
|
|
|
|
/// or creating an object directly owned by the template.
|
2023-03-28 16:14:09 -04:00
|
|
|
Toplevel(TplState, AirExprAggregateStoreDangling<Tpl>),
|
2023-03-08 14:47:31 -05:00
|
|
|
|
2023-03-23 00:04:53 -04:00
|
|
|
/// Defining a template metavariable.
|
|
|
|
TplMeta(
|
|
|
|
TplState,
|
|
|
|
AirExprAggregateStoreDangling<Tpl>,
|
|
|
|
ObjectIndex<Meta>,
|
|
|
|
),
|
|
|
|
|
2023-03-07 14:00:46 -05:00
|
|
|
/// Aggregating tokens into a template.
|
2023-03-28 16:14:09 -04:00
|
|
|
TplExpr(TplState, AirExprAggregateStoreDangling<Tpl>),
|
2023-03-07 14:00:46 -05:00
|
|
|
}
|
|
|
|
|
2023-03-28 16:14:09 -04:00
|
|
|
impl Display for AirTplAggregate {
|
2023-03-07 14:00:46 -05:00
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
|
|
match self {
|
2023-03-28 16:14:09 -04:00
|
|
|
Self::Ready => write!(f, "ready for template definition"),
|
2023-03-08 14:47:31 -05:00
|
|
|
|
2023-03-28 16:14:09 -04:00
|
|
|
Self::Toplevel(tpl, expr) | Self::TplExpr(tpl, expr) => {
|
2023-03-16 15:08:15 -04:00
|
|
|
write!(f, "building {tpl} with {expr}")
|
2023-03-07 14:00:46 -05:00
|
|
|
}
|
2023-03-23 00:04:53 -04:00
|
|
|
|
2023-03-28 16:14:09 -04:00
|
|
|
Self::TplMeta(tpl, _, _) => {
|
2023-03-23 00:04:53 -04:00
|
|
|
write!(f, "building {tpl} metavariable")
|
|
|
|
}
|
2023-03-16 15:08:15 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-03-08 14:47:31 -05:00
|
|
|
|
2023-03-16 15:08:15 -04:00
|
|
|
/// The current reachability status of the template.
|
|
|
|
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
|
|
|
pub enum TplState {
|
|
|
|
/// Template is dangling and cannot be referenced by anything else.
|
|
|
|
Dangling(ObjectIndex<Tpl>),
|
|
|
|
|
|
|
|
/// Template is anonymous and is not reachable by an identifier,
|
|
|
|
/// but is reachable in the current context.
|
|
|
|
AnonymousReachable(ObjectIndex<Tpl>),
|
|
|
|
|
|
|
|
/// Template is reachable via an identifier.
|
|
|
|
///
|
|
|
|
/// This uses an [`SPair`] as evidence for that assertion rather than an
|
|
|
|
/// [`ObjectIndex`] so that it provides useful output via [`Display`]
|
|
|
|
/// in parser traces.
|
|
|
|
Identified(ObjectIndex<Tpl>, SPair),
|
|
|
|
}
|
|
|
|
|
|
|
|
impl TplState {
|
|
|
|
fn oi(&self) -> ObjectIndex<Tpl> {
|
|
|
|
match self {
|
|
|
|
TplState::Dangling(oi)
|
|
|
|
| TplState::AnonymousReachable(oi)
|
|
|
|
| TplState::Identified(oi, _) => *oi,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn identify(self, id: SPair) -> Self {
|
|
|
|
Self::Identified(self.oi(), id)
|
|
|
|
}
|
tamer: Very basic support for template application NIR -> xmli
This this a big change that's difficult to break up, and I don't have the
energy after it.
This introduces nullary template application, short- and long-form. Note
that a body of the short form is a `@values@` argument, so that's not
supported yet.
This continues to formalize the idea of what "template application" and
"template expansion" mean in TAMER. It makes a separate `TplApply`
unnecessary, because now application is simply a reference to a
template. Expansion and application are one and the same: when a template
expands, it'll re-bind metavariables to the parent context. So in a
template context, this amounts to application.
But applying a closed template will have nothing to bind, and so is
equivalent to expansion. And since `Meta` objects are not valid outside of
a `Tpl` context, applying a non-closed template outside of another template
will be invalid.
So we get all of this with a single primitive (getting the "value" of a
template).
The expansion is conceptually like `,@` in Lisp, where we're splicing trees.
It's a mess in some spots, but I want to get this committed before I do a
little bit of cleanup.
2023-03-17 10:25:56 -04:00
|
|
|
|
|
|
|
fn anonymous_reachable(self) -> Self {
|
|
|
|
Self::AnonymousReachable(self.oi())
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Attempt to complete a template definition.
|
|
|
|
///
|
|
|
|
/// If `self` is [`Self::Dangling`],
|
|
|
|
/// then an [`AsgError::DanglingTpl`] will be returned.
|
|
|
|
///
|
|
|
|
/// This updates the span of the template to encompass the entire
|
|
|
|
/// definition,
|
|
|
|
/// even if an error occurs.
|
|
|
|
fn close(self, asg: &mut Asg, close_span: Span) -> Result<(), AsgError> {
|
|
|
|
let oi = self.oi().close(asg, close_span);
|
|
|
|
|
|
|
|
match self {
|
|
|
|
Self::Dangling(_) => {
|
|
|
|
Err(AsgError::DanglingTpl(oi.resolve(asg).span()))
|
|
|
|
}
|
|
|
|
Self::AnonymousReachable(..) | Self::Identified(..) => Ok(()),
|
|
|
|
}
|
|
|
|
}
|
2023-03-16 15:08:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Display for TplState {
|
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
|
|
match self {
|
|
|
|
TplState::Dangling(_) => write!(f, "anonymous dangling template"),
|
|
|
|
TplState::AnonymousReachable(_) => {
|
|
|
|
write!(f, "anonymous reachable template")
|
|
|
|
}
|
|
|
|
TplState::Identified(_, id) => {
|
|
|
|
write!(f, "identified template {}", TtQuote::wrap(id))
|
2023-03-07 14:00:46 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-28 16:14:09 -04:00
|
|
|
impl ParseState for AirTplAggregate {
|
2023-03-11 00:40:54 -05:00
|
|
|
type Token = AirTemplatable;
|
2023-03-07 14:00:46 -05:00
|
|
|
type Object = ();
|
|
|
|
type Error = AsgError;
|
tamer: asg::air: AirAggregateCtx: New AirAggregate::Context
Future changes to `AirAggregate` are going to require additional context (a
stack, specifically), but the `Context` is currently utilized
by `Asg`. This introduces a layer of abstraction that will allow us to add
the stack.
Alongside these changes, `ParseState` has been augmented with a `PubContext`
type that is utilized on public APIs, both maintaining BC with existing code
and keeping these implementation details encapsulated.
This does make a bit of a mess of the internal implementation, though, with
`asg_mut()` sprinkled about, so maybe the next commit can clean that up a
bit. EDIT: After adding `AsMut` to a bunch of asg::graph::object::*
methods, I decided against it, because it messes with the inferred
ownership, requiring explicit borrows via `as_mut()` where they were not
required before. I think the existing code is easier to reason about than
what would otherwise result from having `mut asg: impl AsMut<Asg>`
everwhere.
DEV-13708
2023-03-27 11:47:11 -04:00
|
|
|
type Context = AirAggregateCtx;
|
2023-03-07 14:00:46 -05:00
|
|
|
|
|
|
|
fn parse_token(
|
|
|
|
self,
|
|
|
|
tok: Self::Token,
|
tamer: asg::air: AirAggregateCtx: New AirAggregate::Context
Future changes to `AirAggregate` are going to require additional context (a
stack, specifically), but the `Context` is currently utilized
by `Asg`. This introduces a layer of abstraction that will allow us to add
the stack.
Alongside these changes, `ParseState` has been augmented with a `PubContext`
type that is utilized on public APIs, both maintaining BC with existing code
and keeping these implementation details encapsulated.
This does make a bit of a mess of the internal implementation, though, with
`asg_mut()` sprinkled about, so maybe the next commit can clean that up a
bit. EDIT: After adding `AsMut` to a bunch of asg::graph::object::*
methods, I decided against it, because it messes with the inferred
ownership, requiring explicit borrows via `as_mut()` where they were not
required before. I think the existing code is easier to reason about than
what would otherwise result from having `mut asg: impl AsMut<Asg>`
everwhere.
DEV-13708
2023-03-27 11:47:11 -04:00
|
|
|
ctx: &mut Self::Context,
|
2023-03-07 14:00:46 -05:00
|
|
|
) -> TransitionResult<Self::Super> {
|
2023-03-11 00:40:54 -05:00
|
|
|
use super::ir::{AirBind::*, AirTpl::*};
|
|
|
|
use AirTemplatable::*;
|
2023-03-07 14:00:46 -05:00
|
|
|
use AirTplAggregate::*;
|
|
|
|
|
2023-03-11 00:40:54 -05:00
|
|
|
match (self, tok) {
|
2023-03-28 16:14:09 -04:00
|
|
|
(Ready, AirTpl(TplStart(span))) => {
|
tamer: asg::air: AirAggregateCtx: New AirAggregate::Context
Future changes to `AirAggregate` are going to require additional context (a
stack, specifically), but the `Context` is currently utilized
by `Asg`. This introduces a layer of abstraction that will allow us to add
the stack.
Alongside these changes, `ParseState` has been augmented with a `PubContext`
type that is utilized on public APIs, both maintaining BC with existing code
and keeping these implementation details encapsulated.
This does make a bit of a mess of the internal implementation, though, with
`asg_mut()` sprinkled about, so maybe the next commit can clean that up a
bit. EDIT: After adding `AsMut` to a bunch of asg::graph::object::*
methods, I decided against it, because it messes with the inferred
ownership, requiring explicit borrows via `as_mut()` where they were not
required before. I think the existing code is easier to reason about than
what would otherwise result from having `mut asg: impl AsMut<Asg>`
everwhere.
DEV-13708
2023-03-27 11:47:11 -04:00
|
|
|
let oi_tpl = ctx.asg_mut().create(Tpl::new(span));
|
2023-03-07 14:00:46 -05:00
|
|
|
|
2023-03-08 14:47:31 -05:00
|
|
|
Transition(Toplevel(
|
2023-03-16 15:08:15 -04:00
|
|
|
TplState::Dangling(oi_tpl),
|
2023-03-07 16:28:32 -05:00
|
|
|
AirExprAggregate::new_in(oi_tpl),
|
|
|
|
))
|
|
|
|
.incomplete()
|
2023-03-07 14:00:46 -05:00
|
|
|
}
|
|
|
|
|
2023-03-17 10:37:14 -04:00
|
|
|
(Toplevel(..), AirTpl(TplStart(span))) => diagnostic_todo!(
|
|
|
|
vec![span.note("for this template")],
|
|
|
|
"nested tpl open"
|
|
|
|
),
|
2023-03-08 14:47:31 -05:00
|
|
|
|
2023-03-28 16:14:09 -04:00
|
|
|
(Toplevel(tpl, expr), AirBind(BindIdent(id))) => {
|
|
|
|
let oi_root = ctx.stack_mut().rooting_oi().expect("TODO");
|
tamer: asg::air: AirAggregateCtx: New AirAggregate::Context
Future changes to `AirAggregate` are going to require additional context (a
stack, specifically), but the `Context` is currently utilized
by `Asg`. This introduces a layer of abstraction that will allow us to add
the stack.
Alongside these changes, `ParseState` has been augmented with a `PubContext`
type that is utilized on public APIs, both maintaining BC with existing code
and keeping these implementation details encapsulated.
This does make a bit of a mess of the internal implementation, though, with
`asg_mut()` sprinkled about, so maybe the next commit can clean that up a
bit. EDIT: After adding `AsMut` to a bunch of asg::graph::object::*
methods, I decided against it, because it messes with the inferred
ownership, requiring explicit borrows via `as_mut()` where they were not
required before. I think the existing code is easier to reason about than
what would otherwise result from having `mut asg: impl AsMut<Asg>`
everwhere.
DEV-13708
2023-03-27 11:47:11 -04:00
|
|
|
let asg = ctx.asg_mut();
|
|
|
|
|
|
|
|
asg.lookup_global_or_missing(id)
|
|
|
|
.bind_definition(asg, id, tpl.oi())
|
2023-03-28 16:14:09 -04:00
|
|
|
.map(|oi_ident| oi_root.defines(asg, oi_ident))
|
tamer: asg::air: AirAggregateCtx: New AirAggregate::Context
Future changes to `AirAggregate` are going to require additional context (a
stack, specifically), but the `Context` is currently utilized
by `Asg`. This introduces a layer of abstraction that will allow us to add
the stack.
Alongside these changes, `ParseState` has been augmented with a `PubContext`
type that is utilized on public APIs, both maintaining BC with existing code
and keeping these implementation details encapsulated.
This does make a bit of a mess of the internal implementation, though, with
`asg_mut()` sprinkled about, so maybe the next commit can clean that up a
bit. EDIT: After adding `AsMut` to a bunch of asg::graph::object::*
methods, I decided against it, because it messes with the inferred
ownership, requiring explicit borrows via `as_mut()` where they were not
required before. I think the existing code is easier to reason about than
what would otherwise result from having `mut asg: impl AsMut<Asg>`
everwhere.
DEV-13708
2023-03-27 11:47:11 -04:00
|
|
|
.map(|_| ())
|
2023-03-28 16:14:09 -04:00
|
|
|
.transition(Toplevel(tpl.identify(id), expr))
|
tamer: asg::air: AirAggregateCtx: New AirAggregate::Context
Future changes to `AirAggregate` are going to require additional context (a
stack, specifically), but the `Context` is currently utilized
by `Asg`. This introduces a layer of abstraction that will allow us to add
the stack.
Alongside these changes, `ParseState` has been augmented with a `PubContext`
type that is utilized on public APIs, both maintaining BC with existing code
and keeping these implementation details encapsulated.
This does make a bit of a mess of the internal implementation, though, with
`asg_mut()` sprinkled about, so maybe the next commit can clean that up a
bit. EDIT: After adding `AsMut` to a bunch of asg::graph::object::*
methods, I decided against it, because it messes with the inferred
ownership, requiring explicit borrows via `as_mut()` where they were not
required before. I think the existing code is easier to reason about than
what would otherwise result from having `mut asg: impl AsMut<Asg>`
everwhere.
DEV-13708
2023-03-27 11:47:11 -04:00
|
|
|
}
|
2023-03-08 14:47:31 -05:00
|
|
|
|
2023-03-28 16:14:09 -04:00
|
|
|
(Toplevel(tpl, expr), AirBind(RefIdent(id))) => {
|
tamer: asg::air: AirAggregateCtx: New AirAggregate::Context
Future changes to `AirAggregate` are going to require additional context (a
stack, specifically), but the `Context` is currently utilized
by `Asg`. This introduces a layer of abstraction that will allow us to add
the stack.
Alongside these changes, `ParseState` has been augmented with a `PubContext`
type that is utilized on public APIs, both maintaining BC with existing code
and keeping these implementation details encapsulated.
This does make a bit of a mess of the internal implementation, though, with
`asg_mut()` sprinkled about, so maybe the next commit can clean that up a
bit. EDIT: After adding `AsMut` to a bunch of asg::graph::object::*
methods, I decided against it, because it messes with the inferred
ownership, requiring explicit borrows via `as_mut()` where they were not
required before. I think the existing code is easier to reason about than
what would otherwise result from having `mut asg: impl AsMut<Asg>`
everwhere.
DEV-13708
2023-03-27 11:47:11 -04:00
|
|
|
tpl.oi().apply_named_tpl(ctx.asg_mut(), id);
|
2023-03-28 16:14:09 -04:00
|
|
|
Transition(Toplevel(tpl, expr)).incomplete()
|
2023-03-08 14:47:31 -05:00
|
|
|
}
|
2023-03-07 14:00:46 -05:00
|
|
|
|
2023-03-28 16:14:09 -04:00
|
|
|
(Toplevel(tpl, expr), AirTpl(TplMetaStart(span))) => {
|
tamer: asg::air: AirAggregateCtx: New AirAggregate::Context
Future changes to `AirAggregate` are going to require additional context (a
stack, specifically), but the `Context` is currently utilized
by `Asg`. This introduces a layer of abstraction that will allow us to add
the stack.
Alongside these changes, `ParseState` has been augmented with a `PubContext`
type that is utilized on public APIs, both maintaining BC with existing code
and keeping these implementation details encapsulated.
This does make a bit of a mess of the internal implementation, though, with
`asg_mut()` sprinkled about, so maybe the next commit can clean that up a
bit. EDIT: After adding `AsMut` to a bunch of asg::graph::object::*
methods, I decided against it, because it messes with the inferred
ownership, requiring explicit borrows via `as_mut()` where they were not
required before. I think the existing code is easier to reason about than
what would otherwise result from having `mut asg: impl AsMut<Asg>`
everwhere.
DEV-13708
2023-03-27 11:47:11 -04:00
|
|
|
let oi_meta = ctx.asg_mut().create(Meta::new_required(span));
|
2023-03-28 16:14:09 -04:00
|
|
|
Transition(TplMeta(tpl, expr, oi_meta)).incomplete()
|
2023-03-23 00:04:53 -04:00
|
|
|
}
|
2023-03-28 16:14:09 -04:00
|
|
|
(TplMeta(tpl, expr, oi_meta), AirTpl(TplMetaEnd(cspan))) => {
|
tamer: asg::air: AirAggregateCtx: New AirAggregate::Context
Future changes to `AirAggregate` are going to require additional context (a
stack, specifically), but the `Context` is currently utilized
by `Asg`. This introduces a layer of abstraction that will allow us to add
the stack.
Alongside these changes, `ParseState` has been augmented with a `PubContext`
type that is utilized on public APIs, both maintaining BC with existing code
and keeping these implementation details encapsulated.
This does make a bit of a mess of the internal implementation, though, with
`asg_mut()` sprinkled about, so maybe the next commit can clean that up a
bit. EDIT: After adding `AsMut` to a bunch of asg::graph::object::*
methods, I decided against it, because it messes with the inferred
ownership, requiring explicit borrows via `as_mut()` where they were not
required before. I think the existing code is easier to reason about than
what would otherwise result from having `mut asg: impl AsMut<Asg>`
everwhere.
DEV-13708
2023-03-27 11:47:11 -04:00
|
|
|
oi_meta.close(ctx.asg_mut(), cspan);
|
2023-03-28 16:14:09 -04:00
|
|
|
Transition(Toplevel(tpl, expr)).incomplete()
|
2023-03-23 00:04:53 -04:00
|
|
|
}
|
|
|
|
|
2023-03-28 16:14:09 -04:00
|
|
|
(TplMeta(tpl, expr, oi_meta), AirTpl(TplLexeme(lexeme))) => {
|
2023-03-24 00:22:22 -04:00
|
|
|
Transition(TplMeta(
|
|
|
|
tpl,
|
|
|
|
expr,
|
tamer: asg::air: AirAggregateCtx: New AirAggregate::Context
Future changes to `AirAggregate` are going to require additional context (a
stack, specifically), but the `Context` is currently utilized
by `Asg`. This introduces a layer of abstraction that will allow us to add
the stack.
Alongside these changes, `ParseState` has been augmented with a `PubContext`
type that is utilized on public APIs, both maintaining BC with existing code
and keeping these implementation details encapsulated.
This does make a bit of a mess of the internal implementation, though, with
`asg_mut()` sprinkled about, so maybe the next commit can clean that up a
bit. EDIT: After adding `AsMut` to a bunch of asg::graph::object::*
methods, I decided against it, because it messes with the inferred
ownership, requiring explicit borrows via `as_mut()` where they were not
required before. I think the existing code is easier to reason about than
what would otherwise result from having `mut asg: impl AsMut<Asg>`
everwhere.
DEV-13708
2023-03-27 11:47:11 -04:00
|
|
|
oi_meta.assign_lexeme(ctx.asg_mut(), lexeme),
|
2023-03-24 00:22:22 -04:00
|
|
|
))
|
|
|
|
.incomplete()
|
|
|
|
}
|
|
|
|
|
2023-03-28 16:14:09 -04:00
|
|
|
(TplMeta(tpl, expr, oi_meta), AirBind(BindIdent(name))) => {
|
tamer: asg::air: AirAggregateCtx: New AirAggregate::Context
Future changes to `AirAggregate` are going to require additional context (a
stack, specifically), but the `Context` is currently utilized
by `Asg`. This introduces a layer of abstraction that will allow us to add
the stack.
Alongside these changes, `ParseState` has been augmented with a `PubContext`
type that is utilized on public APIs, both maintaining BC with existing code
and keeping these implementation details encapsulated.
This does make a bit of a mess of the internal implementation, though, with
`asg_mut()` sprinkled about, so maybe the next commit can clean that up a
bit. EDIT: After adding `AsMut` to a bunch of asg::graph::object::*
methods, I decided against it, because it messes with the inferred
ownership, requiring explicit borrows via `as_mut()` where they were not
required before. I think the existing code is easier to reason about than
what would otherwise result from having `mut asg: impl AsMut<Asg>`
everwhere.
DEV-13708
2023-03-27 11:47:11 -04:00
|
|
|
oi_meta.identify_as_tpl_param(ctx.asg_mut(), tpl.oi(), name);
|
2023-03-28 16:14:09 -04:00
|
|
|
Transition(TplMeta(tpl, expr, oi_meta)).incomplete()
|
2023-03-23 00:04:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
(TplMeta(..), tok @ AirBind(RefIdent(..))) => {
|
|
|
|
diagnostic_todo!(
|
|
|
|
vec![tok.note("this token")],
|
|
|
|
"AirBind in metavar context (param-value)"
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
(TplMeta(..), tok @ AirExpr(..)) => {
|
|
|
|
diagnostic_todo!(
|
|
|
|
vec![tok.note("this token")],
|
|
|
|
"AirExpr in metavar context (e.g. @values@)"
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
(
|
|
|
|
TplMeta(..),
|
|
|
|
tok @ AirTpl(
|
|
|
|
TplStart(..) | TplMetaStart(..) | TplEnd(..)
|
|
|
|
| TplEndRef(..),
|
|
|
|
),
|
|
|
|
) => {
|
|
|
|
diagnostic_todo!(vec![tok.note("this token")], "AirTpl variant")
|
|
|
|
}
|
|
|
|
|
|
|
|
(Toplevel(..), tok @ AirTpl(TplMetaEnd(..))) => {
|
2023-03-17 10:37:14 -04:00
|
|
|
diagnostic_todo!(
|
2023-03-23 00:04:53 -04:00
|
|
|
vec![tok.note("this token")],
|
|
|
|
"unbalanced meta"
|
2023-03-17 10:37:14 -04:00
|
|
|
)
|
tamer: src::asg: Scaffolding for metasyntactic variables
Also known as metavariables or template parameters.
This is a bit of a tortured excursion, trying to figure out how I want to
best represent this. I have a number of pages of hand-written notes that
I'd like to distill over time, but the rendered graph ontology (via
`asg-ontviz`) demonstrates the broad idea.
`AirTpl::TplApply` highlights some remaining questions. What I had _wanted_
to do is to separate the concepts of application and expansion, and support
partial application and such. But it's going to be too much work for now,
when it isn't needed---partial application can be worked around by simply
creating new templates and duplicating params, as we do today, although that
sucks and is a maintenance issue. But I'd rather address that head-on in
the future.
So it's looking like Option B is going to be the approach for now, with
templates being closed (as in, no free metavariables) and expanded at the
same time. This simplifies the parser and error conditions significantly
and makes it easier to utilize anonymous templates, since it'll still be the
active context.
My intent is to get at least the graph construction sorted out---not the
actual expansion and binding yet---enough that I can use templates to
represent parts of NIR that do not have proper graph representations or
desugaring yet, so that I can spit them back out again in the `xmli` file
and incrementally handle them. That was an option I had considered some
months ago, but didn't want to entertain it at the time because I wasn't
sure what doing so would look like; while it was an attractive approach
since it pushes existing primitives into the template system (something I've
wanted to do for years), I didn't want to potentially tank performance or
compromise the design for it after I had spent so much effort on all of this
so far.
But my efforts have yielded a system that significantly exceeds my initial
performance expectations, with a decent abstractions, and so this seems
viable.
DEV-13708
2023-03-15 11:49:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
(Toplevel(..), tok @ AirTpl(TplLexeme(..))) => {
|
2023-03-17 10:37:14 -04:00
|
|
|
diagnostic_todo!(
|
2023-03-23 00:04:53 -04:00
|
|
|
vec![tok.note("this token")],
|
|
|
|
"err: TplLexeme outside of metavar"
|
2023-03-17 10:37:14 -04:00
|
|
|
)
|
tamer: src::asg: Scaffolding for metasyntactic variables
Also known as metavariables or template parameters.
This is a bit of a tortured excursion, trying to figure out how I want to
best represent this. I have a number of pages of hand-written notes that
I'd like to distill over time, but the rendered graph ontology (via
`asg-ontviz`) demonstrates the broad idea.
`AirTpl::TplApply` highlights some remaining questions. What I had _wanted_
to do is to separate the concepts of application and expansion, and support
partial application and such. But it's going to be too much work for now,
when it isn't needed---partial application can be worked around by simply
creating new templates and duplicating params, as we do today, although that
sucks and is a maintenance issue. But I'd rather address that head-on in
the future.
So it's looking like Option B is going to be the approach for now, with
templates being closed (as in, no free metavariables) and expanded at the
same time. This simplifies the parser and error conditions significantly
and makes it easier to utilize anonymous templates, since it'll still be the
active context.
My intent is to get at least the graph construction sorted out---not the
actual expansion and binding yet---enough that I can use templates to
represent parts of NIR that do not have proper graph representations or
desugaring yet, so that I can spit them back out again in the `xmli` file
and incrementally handle them. That was an option I had considered some
months ago, but didn't want to entertain it at the time because I wasn't
sure what doing so would look like; while it was an attractive approach
since it pushes existing primitives into the template system (something I've
wanted to do for years), I didn't want to potentially tank performance or
compromise the design for it after I had spent so much effort on all of this
so far.
But my efforts have yielded a system that significantly exceeds my initial
performance expectations, with a decent abstractions, and so this seems
viable.
DEV-13708
2023-03-15 11:49:13 -04:00
|
|
|
}
|
|
|
|
|
2023-03-28 16:14:09 -04:00
|
|
|
(Toplevel(tpl, _expr_done), AirTpl(TplEnd(span))) => {
|
|
|
|
tpl.close(ctx.asg_mut(), span).transition(Ready)
|
2023-03-07 14:00:46 -05:00
|
|
|
}
|
|
|
|
|
2023-03-28 16:14:09 -04:00
|
|
|
(TplExpr(tpl, expr), AirTpl(TplEnd(span))) => {
|
2023-03-08 14:47:31 -05:00
|
|
|
// TODO: duplicated with AirAggregate
|
tamer: asg::air: AirAggregateCtx: New AirAggregate::Context
Future changes to `AirAggregate` are going to require additional context (a
stack, specifically), but the `Context` is currently utilized
by `Asg`. This introduces a layer of abstraction that will allow us to add
the stack.
Alongside these changes, `ParseState` has been augmented with a `PubContext`
type that is utilized on public APIs, both maintaining BC with existing code
and keeping these implementation details encapsulated.
This does make a bit of a mess of the internal implementation, though, with
`asg_mut()` sprinkled about, so maybe the next commit can clean that up a
bit. EDIT: After adding `AsMut` to a bunch of asg::graph::object::*
methods, I decided against it, because it messes with the inferred
ownership, requiring explicit borrows via `as_mut()` where they were not
required before. I think the existing code is easier to reason about than
what would otherwise result from having `mut asg: impl AsMut<Asg>`
everwhere.
DEV-13708
2023-03-27 11:47:11 -04:00
|
|
|
if expr.is_accepting(ctx) {
|
2023-03-28 16:14:09 -04:00
|
|
|
tpl.close(ctx.asg_mut(), span).transition(Ready)
|
tamer: Very basic support for template application NIR -> xmli
This this a big change that's difficult to break up, and I don't have the
energy after it.
This introduces nullary template application, short- and long-form. Note
that a body of the short form is a `@values@` argument, so that's not
supported yet.
This continues to formalize the idea of what "template application" and
"template expansion" mean in TAMER. It makes a separate `TplApply`
unnecessary, because now application is simply a reference to a
template. Expansion and application are one and the same: when a template
expands, it'll re-bind metavariables to the parent context. So in a
template context, this amounts to application.
But applying a closed template will have nothing to bind, and so is
equivalent to expansion. And since `Meta` objects are not valid outside of
a `Tpl` context, applying a non-closed template outside of another template
will be invalid.
So we get all of this with a single primitive (getting the "value" of a
template).
The expansion is conceptually like `,@` in Lisp, where we're splicing trees.
It's a mess in some spots, but I want to get this committed before I do a
little bit of cleanup.
2023-03-17 10:25:56 -04:00
|
|
|
} else {
|
2023-03-28 16:14:09 -04:00
|
|
|
Transition(TplExpr(tpl, expr))
|
tamer: Very basic support for template application NIR -> xmli
This this a big change that's difficult to break up, and I don't have the
energy after it.
This introduces nullary template application, short- and long-form. Note
that a body of the short form is a `@values@` argument, so that's not
supported yet.
This continues to formalize the idea of what "template application" and
"template expansion" mean in TAMER. It makes a separate `TplApply`
unnecessary, because now application is simply a reference to a
template. Expansion and application are one and the same: when a template
expands, it'll re-bind metavariables to the parent context. So in a
template context, this amounts to application.
But applying a closed template will have nothing to bind, and so is
equivalent to expansion. And since `Meta` objects are not valid outside of
a `Tpl` context, applying a non-closed template outside of another template
will be invalid.
So we get all of this with a single primitive (getting the "value" of a
template).
The expansion is conceptually like `,@` in Lisp, where we're splicing trees.
It's a mess in some spots, but I want to get this committed before I do a
little bit of cleanup.
2023-03-17 10:25:56 -04:00
|
|
|
.err(AsgError::InvalidTplEndContext(span))
|
2023-03-08 14:47:31 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-28 16:14:09 -04:00
|
|
|
(Toplevel(tpl, expr_done), AirTpl(TplEndRef(span))) => {
|
|
|
|
let oi_target = ctx.stack_mut().expansion_oi().expect("TODO");
|
|
|
|
tpl.oi().expand_into(ctx.asg_mut(), oi_target);
|
tamer: Very basic support for template application NIR -> xmli
This this a big change that's difficult to break up, and I don't have the
energy after it.
This introduces nullary template application, short- and long-form. Note
that a body of the short form is a `@values@` argument, so that's not
supported yet.
This continues to formalize the idea of what "template application" and
"template expansion" mean in TAMER. It makes a separate `TplApply`
unnecessary, because now application is simply a reference to a
template. Expansion and application are one and the same: when a template
expands, it'll re-bind metavariables to the parent context. So in a
template context, this amounts to application.
But applying a closed template will have nothing to bind, and so is
equivalent to expansion. And since `Meta` objects are not valid outside of
a `Tpl` context, applying a non-closed template outside of another template
will be invalid.
So we get all of this with a single primitive (getting the "value" of a
template).
The expansion is conceptually like `,@` in Lisp, where we're splicing trees.
It's a mess in some spots, but I want to get this committed before I do a
little bit of cleanup.
2023-03-17 10:25:56 -04:00
|
|
|
|
2023-03-28 16:14:09 -04:00
|
|
|
Transition(Toplevel(tpl.anonymous_reachable(), expr_done))
|
2023-03-24 00:22:22 -04:00
|
|
|
.incomplete()
|
|
|
|
.with_lookahead(AirTpl(TplEnd(span)))
|
tamer: Very basic support for template application NIR -> xmli
This this a big change that's difficult to break up, and I don't have the
energy after it.
This introduces nullary template application, short- and long-form. Note
that a body of the short form is a `@values@` argument, so that's not
supported yet.
This continues to formalize the idea of what "template application" and
"template expansion" mean in TAMER. It makes a separate `TplApply`
unnecessary, because now application is simply a reference to a
template. Expansion and application are one and the same: when a template
expands, it'll re-bind metavariables to the parent context. So in a
template context, this amounts to application.
But applying a closed template will have nothing to bind, and so is
equivalent to expansion. And since `Meta` objects are not valid outside of
a `Tpl` context, applying a non-closed template outside of another template
will be invalid.
So we get all of this with a single primitive (getting the "value" of a
template).
The expansion is conceptually like `,@` in Lisp, where we're splicing trees.
It's a mess in some spots, but I want to get this committed before I do a
little bit of cleanup.
2023-03-17 10:25:56 -04:00
|
|
|
}
|
|
|
|
|
2023-03-28 16:14:09 -04:00
|
|
|
(TplExpr(tpl, expr_done), AirTpl(TplEndRef(span))) => {
|
|
|
|
let oi_target = ctx.stack_mut().expansion_oi().expect("TODO");
|
|
|
|
tpl.oi().expand_into(ctx.asg_mut(), oi_target);
|
tamer: Very basic support for template application NIR -> xmli
This this a big change that's difficult to break up, and I don't have the
energy after it.
This introduces nullary template application, short- and long-form. Note
that a body of the short form is a `@values@` argument, so that's not
supported yet.
This continues to formalize the idea of what "template application" and
"template expansion" mean in TAMER. It makes a separate `TplApply`
unnecessary, because now application is simply a reference to a
template. Expansion and application are one and the same: when a template
expands, it'll re-bind metavariables to the parent context. So in a
template context, this amounts to application.
But applying a closed template will have nothing to bind, and so is
equivalent to expansion. And since `Meta` objects are not valid outside of
a `Tpl` context, applying a non-closed template outside of another template
will be invalid.
So we get all of this with a single primitive (getting the "value" of a
template).
The expansion is conceptually like `,@` in Lisp, where we're splicing trees.
It's a mess in some spots, but I want to get this committed before I do a
little bit of cleanup.
2023-03-17 10:25:56 -04:00
|
|
|
|
2023-03-28 16:14:09 -04:00
|
|
|
// TODO: We have to make sure the expression ended first!
|
|
|
|
Transition(TplExpr(tpl.anonymous_reachable(), expr_done))
|
2023-03-24 00:22:22 -04:00
|
|
|
.incomplete()
|
|
|
|
.with_lookahead(AirTpl(TplEnd(span)))
|
2023-03-15 15:03:47 -04:00
|
|
|
}
|
|
|
|
|
2023-03-28 16:14:09 -04:00
|
|
|
(Toplevel(tpl, expr), AirExpr(etok)) => {
|
|
|
|
Self::delegate_expr(ctx, tpl, expr, etok)
|
|
|
|
}
|
|
|
|
|
|
|
|
(TplExpr(tpl, expr), AirExpr(etok)) => {
|
|
|
|
Self::delegate_expr(ctx, tpl, expr, etok)
|
|
|
|
}
|
2023-03-08 14:47:31 -05:00
|
|
|
|
2023-03-28 16:14:09 -04:00
|
|
|
(TplExpr(tpl, expr), AirBind(etok)) => {
|
|
|
|
Self::delegate_expr(ctx, tpl, expr, etok)
|
2023-03-08 14:47:31 -05:00
|
|
|
}
|
|
|
|
|
2023-03-17 10:37:14 -04:00
|
|
|
(TplExpr(..), AirTpl(TplStart(span))) => {
|
|
|
|
diagnostic_todo!(
|
|
|
|
vec![span.note("for this token")],
|
|
|
|
"nested template (template-generated template)"
|
|
|
|
)
|
2023-03-08 14:47:31 -05:00
|
|
|
}
|
2023-03-07 14:00:46 -05:00
|
|
|
|
tamer: src::asg: Scaffolding for metasyntactic variables
Also known as metavariables or template parameters.
This is a bit of a tortured excursion, trying to figure out how I want to
best represent this. I have a number of pages of hand-written notes that
I'd like to distill over time, but the rendered graph ontology (via
`asg-ontviz`) demonstrates the broad idea.
`AirTpl::TplApply` highlights some remaining questions. What I had _wanted_
to do is to separate the concepts of application and expansion, and support
partial application and such. But it's going to be too much work for now,
when it isn't needed---partial application can be worked around by simply
creating new templates and duplicating params, as we do today, although that
sucks and is a maintenance issue. But I'd rather address that head-on in
the future.
So it's looking like Option B is going to be the approach for now, with
templates being closed (as in, no free metavariables) and expanded at the
same time. This simplifies the parser and error conditions significantly
and makes it easier to utilize anonymous templates, since it'll still be the
active context.
My intent is to get at least the graph construction sorted out---not the
actual expansion and binding yet---enough that I can use templates to
represent parts of NIR that do not have proper graph representations or
desugaring yet, so that I can spit them back out again in the `xmli` file
and incrementally handle them. That was an option I had considered some
months ago, but didn't want to entertain it at the time because I wasn't
sure what doing so would look like; while it was an attractive approach
since it pushes existing primitives into the template system (something I've
wanted to do for years), I didn't want to potentially tank performance or
compromise the design for it after I had spent so much effort on all of this
so far.
But my efforts have yielded a system that significantly exceeds my initial
performance expectations, with a decent abstractions, and so this seems
viable.
DEV-13708
2023-03-15 11:49:13 -04:00
|
|
|
(
|
2023-03-28 16:14:09 -04:00
|
|
|
Ready | TplExpr(..),
|
2023-03-17 13:46:06 -04:00
|
|
|
tok @ AirTpl(TplMetaStart(..) | TplLexeme(..) | TplMetaEnd(..)),
|
tamer: src::asg: Scaffolding for metasyntactic variables
Also known as metavariables or template parameters.
This is a bit of a tortured excursion, trying to figure out how I want to
best represent this. I have a number of pages of hand-written notes that
I'd like to distill over time, but the rendered graph ontology (via
`asg-ontviz`) demonstrates the broad idea.
`AirTpl::TplApply` highlights some remaining questions. What I had _wanted_
to do is to separate the concepts of application and expansion, and support
partial application and such. But it's going to be too much work for now,
when it isn't needed---partial application can be worked around by simply
creating new templates and duplicating params, as we do today, although that
sucks and is a maintenance issue. But I'd rather address that head-on in
the future.
So it's looking like Option B is going to be the approach for now, with
templates being closed (as in, no free metavariables) and expanded at the
same time. This simplifies the parser and error conditions significantly
and makes it easier to utilize anonymous templates, since it'll still be the
active context.
My intent is to get at least the graph construction sorted out---not the
actual expansion and binding yet---enough that I can use templates to
represent parts of NIR that do not have proper graph representations or
desugaring yet, so that I can spit them back out again in the `xmli` file
and incrementally handle them. That was an option I had considered some
months ago, but didn't want to entertain it at the time because I wasn't
sure what doing so would look like; while it was an attractive approach
since it pushes existing primitives into the template system (something I've
wanted to do for years), I didn't want to potentially tank performance or
compromise the design for it after I had spent so much effort on all of this
so far.
But my efforts have yielded a system that significantly exceeds my initial
performance expectations, with a decent abstractions, and so this seems
viable.
DEV-13708
2023-03-15 11:49:13 -04:00
|
|
|
) => {
|
2023-03-17 10:37:14 -04:00
|
|
|
diagnostic_todo!(
|
|
|
|
vec![tok.note("for this token")],
|
tamer: src::asg: Scaffolding for metasyntactic variables
Also known as metavariables or template parameters.
This is a bit of a tortured excursion, trying to figure out how I want to
best represent this. I have a number of pages of hand-written notes that
I'd like to distill over time, but the rendered graph ontology (via
`asg-ontviz`) demonstrates the broad idea.
`AirTpl::TplApply` highlights some remaining questions. What I had _wanted_
to do is to separate the concepts of application and expansion, and support
partial application and such. But it's going to be too much work for now,
when it isn't needed---partial application can be worked around by simply
creating new templates and duplicating params, as we do today, although that
sucks and is a maintenance issue. But I'd rather address that head-on in
the future.
So it's looking like Option B is going to be the approach for now, with
templates being closed (as in, no free metavariables) and expanded at the
same time. This simplifies the parser and error conditions significantly
and makes it easier to utilize anonymous templates, since it'll still be the
active context.
My intent is to get at least the graph construction sorted out---not the
actual expansion and binding yet---enough that I can use templates to
represent parts of NIR that do not have proper graph representations or
desugaring yet, so that I can spit them back out again in the `xmli` file
and incrementally handle them. That was an option I had considered some
months ago, but didn't want to entertain it at the time because I wasn't
sure what doing so would look like; while it was an attractive approach
since it pushes existing primitives into the template system (something I've
wanted to do for years), I didn't want to potentially tank performance or
compromise the design for it after I had spent so much effort on all of this
so far.
But my efforts have yielded a system that significantly exceeds my initial
performance expectations, with a decent abstractions, and so this seems
viable.
DEV-13708
2023-03-15 11:49:13 -04:00
|
|
|
"metasyntactic token in non-tpl-toplevel context: {tok:?}"
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2023-03-28 16:14:09 -04:00
|
|
|
(st @ Ready, AirTpl(TplEnd(span) | TplEndRef(span))) => {
|
2023-03-07 14:00:46 -05:00
|
|
|
Transition(st).err(AsgError::UnbalancedTpl(span))
|
|
|
|
}
|
|
|
|
|
2023-03-28 16:14:09 -04:00
|
|
|
(st @ Ready, tok @ (AirExpr(..) | AirBind(..))) => {
|
2023-03-11 00:40:54 -05:00
|
|
|
Transition(st).dead(tok)
|
|
|
|
}
|
2023-03-07 14:00:46 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn is_accepting(&self, _: &Self::Context) -> bool {
|
2023-03-28 16:14:09 -04:00
|
|
|
matches!(self, Self::Ready)
|
2023-03-07 14:00:46 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-28 16:14:09 -04:00
|
|
|
impl AirTplAggregate {
|
|
|
|
pub(super) fn new() -> Self {
|
|
|
|
Self::Ready
|
2023-03-07 14:00:46 -05:00
|
|
|
}
|
2023-03-08 14:47:31 -05:00
|
|
|
|
|
|
|
/// Delegate to the expression parser [`AirExprAggregate`].
|
|
|
|
fn delegate_expr(
|
|
|
|
asg: &mut <Self as ParseState>::Context,
|
2023-03-16 15:08:15 -04:00
|
|
|
tpl: TplState,
|
2023-03-08 14:47:31 -05:00
|
|
|
expr: AirExprAggregateStoreDangling<Tpl>,
|
|
|
|
etok: impl Into<<AirExprAggregateStoreDangling<Tpl> as ParseState>::Token>,
|
|
|
|
) -> TransitionResult<Self> {
|
|
|
|
let tok = etok.into();
|
|
|
|
|
|
|
|
expr.parse_token(tok, asg).branch_dead::<Self, _>(
|
2023-03-28 16:14:09 -04:00
|
|
|
|expr, ()| Transition(Self::Toplevel(tpl, expr)).incomplete(),
|
2023-03-08 14:47:31 -05:00
|
|
|
|expr, result, ()| {
|
|
|
|
result
|
|
|
|
.map(ParseStatus::reflexivity)
|
2023-03-28 16:14:09 -04:00
|
|
|
.transition(Self::TplExpr(tpl, expr))
|
2023-03-08 14:47:31 -05:00
|
|
|
},
|
|
|
|
(),
|
|
|
|
)
|
|
|
|
}
|
2023-03-07 14:00:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod test;
|