tamer: nir::Nir::Todo: Add Span

This is in preparation for throwing errors (with diagnostic information) on
yet-to-be-supported tokens, so that I can confidently compile individual
packages without worrying that something is just being ignored.

This makes obvious that `ele_parse!` had a different design in mind
previously, and it's now resulting in a lot of boilerplate; I'll address
that in the future once I'm certain requirements have been settled on, since
I've spent far too much time on it to waste more.

DEV-13708
main
Mike Gerwitz 2023-04-10 14:22:44 -04:00
parent 9cb6195046
commit acafe91ab9
3 changed files with 169 additions and 169 deletions

View File

@ -59,7 +59,7 @@ use crate::{
f::Functor,
fmt::{DisplayWrapper, TtQuote},
parse::{util::SPair, Object, Token},
span::{Span, UNKNOWN_SPAN},
span::Span,
sym::SymbolId,
xir::{
attr::{Attr, AttrSpan},
@ -87,7 +87,7 @@ pub use tplshort::TplShortDesugar;
/// (e.g. XML).
#[derive(Debug, PartialEq, Eq)]
pub enum Nir {
Todo,
Todo(Span),
TodoAttr(SPair),
/// Begin the definition of some [`NirEntity`] and place it atop of the
@ -160,7 +160,7 @@ impl Nir {
use Nir::*;
match self {
Todo => None,
Todo(_) => None,
TodoAttr(spair) => Some(spair.symbol()),
Open(_, _) | Close(_, _) => None,
@ -190,7 +190,7 @@ impl Functor<SymbolId> for Nir {
use Nir::*;
match self {
Todo => self,
Todo(_) => self,
TodoAttr(spair) => TodoAttr(spair.map(f)),
Open(_, _) | Close(_, _) => self,
@ -313,7 +313,7 @@ impl Token for Nir {
use Nir::*;
match self {
Todo => UNKNOWN_SPAN,
Todo(span) => *span,
TodoAttr(spair) => spair.span(),
Open(_, span) => *span,
@ -332,7 +332,7 @@ impl Display for Nir {
use Nir::*;
match self {
Todo => write!(f, "TODO"),
Todo(_) => write!(f, "TODO"),
TodoAttr(spair) => write!(f, "TODO Attr {spair}"),
Open(entity, _) => write!(f, "open {entity} entity"),

View File

@ -242,7 +242,7 @@ impl ParseState for NirToAir {
Transition(Ready).ok(Air::DocIndepClause(clause))
}
(Ready, Todo | TodoAttr(..)) => {
(Ready, Todo(..) | TodoAttr(..)) => {
Transition(Ready).ok(Air::Todo(UNKNOWN_SPAN))
}
}

View File

@ -171,7 +171,7 @@ ele_parse! {
// program;
// see [`NirParseState`] for more information.
[super] {
[text](_sym, _span) => Todo,
[text](_sym, span) => Todo(span),
TplKw
};
@ -204,7 +204,7 @@ ele_parse! {
///
/// The term "rater" is historical,
/// since TAME was designed for producing insurance rating systems.
RaterStmt := QN_RATER {
RaterStmt := QN_RATER(_, ospan) {
@ {
QN_XMLNS => TodoAttr,
QN_XMLNS_C => TodoAttr,
@ -213,7 +213,7 @@ ele_parse! {
// TODO: Is this still needed?
// TODO: PkgName type
QN_NAME => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
ImportStmt,
PkgBodyStmt,
@ -258,11 +258,11 @@ ele_parse! {
///
/// Imports allow referencing identifiers from another package and allow
/// for composing larger systems out of smaller components.
ImportStmt := QN_IMPORT {
ImportStmt := QN_IMPORT(_, ospan) {
@ {
QN_PACKAGE => Ref,
QN_EXPORT => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
};
/// A statement that is accepted within the body of a package.
@ -302,7 +302,7 @@ ele_parse! {
/// that /at most one/ other package provides a definition for this
/// symbol and that the definition is compatible with this
/// declaration.
ExternStmt := QN_EXTERN {
ExternStmt := QN_EXTERN(_, ospan) {
@ {
QN_NAME => TodoAttr,
QN_TYPE => TodoAttr,
@ -310,14 +310,14 @@ ele_parse! {
QN_DIM => TodoAttr,
QN_PARENT => TodoAttr,
QN_YIELDS => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
};
/// Define an input parameter accepting data from an external system.
///
/// Parameters are generally populated via a map,
/// such as [`ProgramMapStmt`].
ParamStmt := QN_PARAM {
ParamStmt := QN_PARAM(_, ospan) {
@ {
QN_NAME => TodoAttr,
QN_TYPE => TodoAttr,
@ -326,7 +326,7 @@ ele_parse! {
QN_SET => TodoAttr,
QN_DEFAULT => TodoAttr,
QN_SYM => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
};
/// Associate static data with an identifier.
@ -340,7 +340,7 @@ ele_parse! {
/// constants ought to be defined as expressions that can be evaluated
/// at compile-time,
/// and re-use that familiar syntax.
ConstStmt := QN_CONST {
ConstStmt := QN_CONST(_, ospan) {
@ {
QN_NAME => TodoAttr,
QN_DESC => TodoAttr,
@ -351,7 +351,7 @@ ele_parse! {
QN_SYM => TodoAttr,
// TODO: Misnomer
QN_SET => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
ConstStmtBody,
};
@ -368,20 +368,20 @@ ele_parse! {
///
/// TODO: The use of [`QN_SET`] is a terrible misnomer representing
/// dimensionality and will be changed in future versions.
ConstMatrixRow := QN_SET {
ConstMatrixRow := QN_SET(_, ospan) {
@ {
QN_DESC => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
ConstVectorItem,
};
/// Constant vector scalar item definition.
ConstVectorItem := QN_ITEM {
ConstVectorItem := QN_ITEM(_, ospan) {
@ {
QN_VALUE => TodoAttr,
QN_DESC => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
};
/// Define a classification and associate it with an identifier.
@ -437,7 +437,7 @@ ele_parse! {
///
/// This expands into an equivalent [`RateStmt`] with a nested
/// [`SumExpr`] serving as the item-wise map.
RateEachStmt := QN_RATE_EACH {
RateEachStmt := QN_RATE_EACH(_, ospan) {
@ {
QN_CLASS => TodoAttr,
QN_NO => TodoAttr,
@ -446,18 +446,18 @@ ele_parse! {
QN_YIELDS => TodoAttr,
QN_SYM => TodoAttr,
QN_GENSYM => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
CalcExpr,
};
/// Define a new type that restricts the domain of data.
TypedefStmt := QN_TYPEDEF {
TypedefStmt := QN_TYPEDEF(_, ospan) {
@ {
QN_NAME => TodoAttr,
QN_DESC => TodoAttr,
QN_SYM => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
InnerTypedefStmt,
};
@ -469,36 +469,36 @@ ele_parse! {
///
/// This is used for primitives and allows for core types to be exposed
/// to the user.
BaseTypeStmt := QN_BASE_TYPE {
@ {} => Todo,
BaseTypeStmt := QN_BASE_TYPE(_, ospan) {
@ {} => Todo(ospan.into()),
};
/// Define an enumerated type.
///
/// Enums are types that have an explicit set of values,
/// each with associated constant identifiers.
EnumStmt := QN_ENUM {
EnumStmt := QN_ENUM(_, ospan) {
@ {
QN_TYPE => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
ItemEnumStmt,
};
/// Define an item of the domain of an enumerated type and associate it
/// with a constant identifier.
ItemEnumStmt := QN_ITEM {
ItemEnumStmt := QN_ITEM(_, ospan) {
@ {
QN_NAME => TodoAttr,
QN_VALUE => TodoAttr,
QN_DESC => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
};
/// Define a type whose domain is the union of the domains of multiple
/// other types.
UnionStmt := QN_UNION {
@ {} => Todo,
UnionStmt := QN_UNION(_, ospan) {
@ {} => Todo(ospan.into()),
TypedefStmt,
};
@ -512,8 +512,8 @@ ele_parse! {
///
/// This is being replaced with the `__yield__` template in `core`
/// (this statement predates the template system in TAME).
YieldStmt := QN_YIELD {
@ {} => Todo,
YieldStmt := QN_YIELD(_, ospan) {
@ {} => Todo(ospan.into()),
CalcExpr,
};
@ -532,21 +532,21 @@ ele_parse! {
/// the body of a section is the same as that of [`PackageStmt`],
/// with the exception of imports,
/// which must appear outside of sections.
SectionStmt := QN_SECTION {
SectionStmt := QN_SECTION(_, ospan) {
@ {
QN_TITLE => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
PkgBodyStmt,
};
/// Define a function and associate it with an identifier.
FunctionStmt := QN_FUNCTION {
FunctionStmt := QN_FUNCTION(_, ospan) {
@ {
QN_NAME => TodoAttr,
QN_DESC => TodoAttr,
QN_SYM => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
FunctionParamStmt,
CalcExpr,
@ -554,14 +554,14 @@ ele_parse! {
/// Define a function parameter and associate it with an identifier that
/// is scoped to the function body.
FunctionParamStmt := QN_PARAM {
FunctionParamStmt := QN_PARAM(_, ospan) {
@ {
QN_NAME => TodoAttr,
QN_TYPE => TodoAttr,
// _TODO: This is a misnomer.
QN_SET => TodoAttr,
QN_DESC => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
};
@ -714,10 +714,10 @@ ele_parse! {
/// as only two [`CalcExpr`] expressions
/// (though either could be a [`QuotientExpr`] as well).
/// TAMER will be relaxing that restriction.
QuotientExpr := QN_C_QUOTIENT {
QuotientExpr := QN_C_QUOTIENT(_, ospan) {
@ {
QN_LABEL => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
CalcExpr,
};
@ -732,8 +732,8 @@ ele_parse! {
/// TAME expected only a base and an exponent
/// (respectively),
/// but TAMER will be relaxing that restriction.
ExptExpr := QN_C_EXPT {
@ {} => Todo,
ExptExpr := QN_C_EXPT(_, ospan) {
@ {} => Todo(ospan.into()),
CalcExpr,
};
@ -743,12 +743,12 @@ ele_parse! {
/// with vectors requiring an [`@index`](QN_INDEX).
/// Matrices require use of a nested [`IndexExpr`] qualifier to resolve
/// a scalar.
ValueOfExpr := QN_C_VALUE_OF {
ValueOfExpr := QN_C_VALUE_OF(_, ospan) {
@ {
QN_NAME => TodoAttr,
QN_INDEX => TodoAttr,
QN_LABEL => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
IndexExpr,
WhenExpr,
@ -761,15 +761,15 @@ ele_parse! {
/// Sibling [`IndexExpr`]s evaluate to nested subscripts where the
/// subling applies to the result of the previous index operation
/// such that **M**_ⱼ,ₖ_ ≡ (**M**_ⱼ_)_ₖ_.
IndexExpr := QN_C_INDEX {
IndexExpr := QN_C_INDEX(_, ospan) {
@ {
QN_LABEL => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
CalcExpr,
};
/// Expression yielding a constant scalar value.
ConstExpr := QN_C_CONST {
ConstExpr := QN_C_CONST(_, ospan) {
@ {
QN_VALUE => TodoAttr,
// TODO: Description was historically required to avoid magic
@ -783,7 +783,7 @@ ele_parse! {
QN_DESC => TodoAttr,
// _TODO: deprecate?
QN_TYPE => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
WhenExpr,
};
@ -821,10 +821,10 @@ ele_parse! {
/// [`OtherwiseExpr`] is evaluated,
/// if pressent,
/// otherwise the value `0` is yielded.
CasesExpr := QN_C_CASES {
CasesExpr := QN_C_CASES(_, ospan) {
@ {
QN_LABEL => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
CaseExpr,
OtherwiseExpr,
@ -841,10 +841,10 @@ ele_parse! {
/// Otherwise,
/// evaluation continues with the next sibling case,
/// if any.
CaseExpr := QN_C_CASE {
CaseExpr := QN_C_CASE(_, ospan) {
@ {
QN_LABEL => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
WhenExpr,
CalcExpr,
@ -864,10 +864,10 @@ ele_parse! {
/// If this behavior is unclear within a given context,
/// then [`OtherwiseExpr`] ought to be used to make the behavior
/// explicit.
OtherwiseExpr := QN_C_OTHERWISE {
OtherwiseExpr := QN_C_OTHERWISE(_, ospan) {
@ {
QN_LABEL => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
CalcExpr,
};
@ -877,8 +877,8 @@ ele_parse! {
/// This also yields the number of rows of a matrix,
/// which are vectors of vectors.
/// It is not defined for scalars.
LengthOfExpr := QN_C_LENGTH_OF {
@ {} => Todo,
LengthOfExpr := QN_C_LENGTH_OF(_, ospan) {
@ {} => Todo(ospan.into()),
CalcExpr,
};
@ -891,8 +891,8 @@ ele_parse! {
/// lexically scoped to the inner [`CalcExpr`].
/// The result of the let expression is the result of the inner
/// [`CalcExpr`].
LetExpr := QN_C_LET {
@ {} => Todo,
LetExpr := QN_C_LET(_, ospan) {
@ {} => Todo(ospan.into()),
LetValues,
CalcExpr,
};
@ -901,8 +901,8 @@ ele_parse! {
/// to be lexically scoped to the sibling [`CalcExpr`].
///
/// See [`LetExpr`] for more information.
LetValues := QN_C_VALUES {
@ {} => Todo,
LetValues := QN_C_VALUES(_, ospan) {
@ {} => Todo(ospan.into()),
LetValue,
};
@ -912,24 +912,24 @@ ele_parse! {
/// A value cannot observe sibling values,
/// but it can observe values of an ancestor [`LetExpr`] that is not
/// its parent.
LetValue := QN_C_VALUE {
LetValue := QN_C_VALUE(_, ospan) {
@ {
QN_NAME => TodoAttr,
QN_TYPE => TodoAttr,
// Misnomer
QN_SET => TodoAttr,
QN_DESC => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
CalcExpr,
};
/// An expression yielding a vector consisting of each of its child
/// expressions' values as respective items.
VectorExpr := QN_C_VECTOR {
VectorExpr := QN_C_VECTOR(_, ospan) {
@ {
QN_LABEL => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
CalcExpr,
};
@ -945,10 +945,10 @@ ele_parse! {
/// body [`ValueOfExpr`] such that `α="x"` expands into
/// `<`[`c:arg`](QN_C_ARG)` name="α"><`[`c:value-of`](QN_C_VALUE_OF)
/// `name="x" /></c:arg>`.
ApplyExpr := QN_C_APPLY {
@ {} => Todo,
ApplyExpr := QN_C_APPLY(_, ospan) {
@ {} => Todo(ospan.into()),
[attr](_attr) => Todo,
[attr](attr) => TodoAttr(SPair(attr.value(), attr.span())),
ApplyArg,
};
@ -958,10 +958,10 @@ ele_parse! {
/// Alternatively,
/// the parent element [`ApplyExpr`] may contain short-hand arguments
/// as attributes.
ApplyArg := QN_C_ARG {
ApplyArg := QN_C_ARG(_, ospan) {
@ {
QN_NAME => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
CalcExpr,
};
@ -975,10 +975,10 @@ ele_parse! {
/// arguments of the parent,
/// allowing for concise recursion in terms of only what has changed
/// in that recursive step.
RecurseExpr := QN_C_RECURSE {
@ {} => Todo,
RecurseExpr := QN_C_RECURSE(_, ospan) {
@ {} => Todo(ospan.into()),
[attr](_attr) => Todo,
[attr](attr) => TodoAttr(SPair(attr.value(), attr.span())),
ApplyArg,
};
@ -988,18 +988,18 @@ ele_parse! {
///
/// This terminology originates from Lisp.
/// It is equivalent to an `unshift` operation.
ConsExpr := QN_C_CONS {
@ {} => Todo,
ConsExpr := QN_C_CONS(_, ospan) {
@ {} => Todo(ospan.into()),
CalcExpr,
};
/// Retrieve the first element in a list (vector).
///
/// This terminology originates from Lisp.
CarExpr := QN_C_CAR {
CarExpr := QN_C_CAR(_, ospan) {
@ {
QN_LABEL => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
CalcExpr,
};
@ -1008,10 +1008,10 @@ ele_parse! {
/// This terminology originates from Lisp,
/// and is pronounced "could-er".
/// It is also called "tail".
CdrExpr := QN_C_CDR {
CdrExpr := QN_C_CDR(_, ospan) {
@ {
QN_LABEL => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
CalcExpr,
};
@ -1028,12 +1028,12 @@ ele_parse! {
/// The exception is [`CaseExpr`],
/// which requires [`WhenExpr`] as part of its grammar to define
/// conditions for which case to evaluate.
WhenExpr := QN_C_WHEN {
WhenExpr := QN_C_WHEN(_, ospan) {
@ {
QN_NAME => TodoAttr,
QN_INDEX => TodoAttr,
QN_VALUE => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
CalcPredExpr,
};
@ -1052,38 +1052,38 @@ ele_parse! {
);
/// Equality predicate (=).
EqCalcPredExpr := QN_C_EQ {
@ {} => Todo,
EqCalcPredExpr := QN_C_EQ(_, ospan) {
@ {} => Todo(ospan.into()),
CalcExpr,
};
/// Non-equality predicate (≠).
NeCalcPredExpr := QN_C_NE {
@ {} => Todo,
NeCalcPredExpr := QN_C_NE(_, ospan) {
@ {} => Todo(ospan.into()),
CalcExpr,
};
/// Less-than predicate (<).
LtCalcPredExpr := QN_C_LT {
@ {} => Todo,
LtCalcPredExpr := QN_C_LT(_, ospan) {
@ {} => Todo(ospan.into()),
CalcExpr,
};
/// Greater-than predicate (>).
GtCalcPredExpr := QN_C_GT {
@ {} => Todo,
GtCalcPredExpr := QN_C_GT(_, ospan) {
@ {} => Todo(ospan.into()),
CalcExpr,
};
/// Less-than or equality predicate (≤).
LteCalcPredExpr := QN_C_LTE {
@ {} => Todo,
LteCalcPredExpr := QN_C_LTE(_, ospan) {
@ {} => Todo(ospan.into()),
CalcExpr,
};
/// Greater-than or equality predicate (≥).
GteCalcPredExpr := QN_C_GTE {
@ {} => Todo,
GteCalcPredExpr := QN_C_GTE(_, ospan) {
@ {} => Todo(ospan.into()),
CalcExpr,
};
@ -1105,12 +1105,12 @@ ele_parse! {
/// The mapping occurs between the bucket and TAME params.
///
/// This will be generalized in the future.
ProgramMapStmt := QN_PROGRAM_MAP {
ProgramMapStmt := QN_PROGRAM_MAP(_, ospan) {
@ {
QN_XMLNS => TodoAttr,
QN_XMLNS_LV => TodoAttr,
QN_SRC => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
MapPkgImportStmt,
MapImportStmt,
@ -1124,11 +1124,11 @@ ele_parse! {
/// the caller.
/// This is also the only place where TAME is able to produce dynamic
/// string values.
ReturnMapStmt := QN_RETURN_MAP {
ReturnMapStmt := QN_RETURN_MAP(_, ospan) {
@ {
QN_XMLNS => TodoAttr,
QN_XMLNS_LV => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
MapPkgImportStmt,
MapImportStmt,
@ -1140,11 +1140,11 @@ ele_parse! {
/// This is only necessary because of [`MapImportStmt`];
/// both that and [`MapPkgImportStmt`] will be removed in the future
/// in favor of [`ImportStmt`].
MapPkgImportStmt := QN_LV_IMPORT {
MapPkgImportStmt := QN_LV_IMPORT(_, ospan) {
@ {
QN_PACKAGE => TodoAttr,
QN_EXPORT => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
};
/// Import a map package.
@ -1152,10 +1152,10 @@ ele_parse! {
/// The distinction between this an [`ImportStmt`] is historical and is
/// no longer meaningful;
/// it will be removed in the future.
MapImportStmt := QN_IMPORT {
MapImportStmt := QN_IMPORT(_, ospan) {
@ {
QN_PATH => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
};
/// Define the value of a key in the destination.
@ -1164,20 +1164,20 @@ ele_parse! {
/// Map a value into a key of the destination without modification.
///
/// See also [`MapStmt`] if the value needs to be modified in some way.
MapPassStmt := QN_PASS {
MapPassStmt := QN_PASS(_, ospan) {
@ {
QN_NAME => TodoAttr,
QN_DEFAULT => TodoAttr,
QN_SCALAR => TodoAttr,
QN_OVERRIDE => TodoAttr,
QN_NOVALIDATE => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
};
/// Map a value into a key of the destination.
///
/// See also [`MapPassStmt`] if the value does not need modification.
MapStmt := QN_MAP {
MapStmt := QN_MAP(_, ospan) {
@ {
QN_TO => TodoAttr,
QN_FROM => TodoAttr,
@ -1190,7 +1190,7 @@ ele_parse! {
QN_SCALAR => TodoAttr,
QN_OVERRIDE => TodoAttr,
QN_NOVALIDATE => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
MapStmtBody,
};
@ -1199,23 +1199,23 @@ ele_parse! {
MapStmtBody := (MapFromStmt | MapSetStmt | MapTransformStmt);
/// Source of data for a map operation.
MapFromStmt := QN_FROM {
MapFromStmt := QN_FROM(_, ospan) {
@ {
QN_NAME => TodoAttr,
QN_DEFAULT => TodoAttr,
QN_SCALAR => TodoAttr,
QN_NOVALIDATE => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
MapTranslateStmt,
};
/// List of 1:1 value translations for a map.
MapTranslateStmt := QN_TRANSLATE {
MapTranslateStmt := QN_TRANSLATE(_, ospan) {
@ {
QN_KEY => TodoAttr,
QN_VALUE => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
};
/// Yield a vector of values where each item corresponds to the
@ -1224,8 +1224,8 @@ ele_parse! {
/// TODO: This is a misnomer,
/// since the result is a vector,
/// not a set.
MapSetStmt := QN_SET {
@ {} => Todo,
MapSetStmt := QN_SET(_, ospan) {
@ {} => Todo(ospan.into()),
MapSetBody,
};
@ -1234,10 +1234,10 @@ ele_parse! {
MapSetBody := (MapFromStmt | MapConstStmt);
/// Map from a constant value.
MapConstStmt := QN_CONST {
MapConstStmt := QN_CONST(_, ospan) {
@ {
QN_VALUE => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
};
/// Transform a value using some function.
@ -1246,10 +1246,10 @@ ele_parse! {
/// for example to convert input string case and hash values.
///
/// Transformations may be composed via nesting.
MapTransformStmt := QN_TRANSFORM {
MapTransformStmt := QN_TRANSFORM(_, ospan) {
@ {
QN_METHOD => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
MapStmtBody,
};
@ -1275,13 +1275,13 @@ ele_parse! {
///
/// Calculations are rendered in the order in which they appear in this
/// definition.
WorksheetStmt := QN_WORKSHEET {
WorksheetStmt := QN_WORKSHEET(_, ospan) {
@ {
QN_XMLNS => TodoAttr,
QN_NAME => TodoAttr,
QN_PACKAGE => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
ExpandFunctionStmt,
DisplayStmt,
@ -1295,18 +1295,18 @@ ele_parse! {
/// The default behavior is intended to encapsulate details of functions
/// that happen to be used by the system but that the user is unlikely
/// to care about.
ExpandFunctionStmt := QN_EXPAND_FUNCTION {
ExpandFunctionStmt := QN_EXPAND_FUNCTION(_, ospan) {
@ {
QN_NAME => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
};
/// Render a simplified, human-readable display of the calculation,
/// along with its result.
DisplayStmt := QN_DISPLAY {
DisplayStmt := QN_DISPLAY(_, ospan) {
@ {
QN_NAME => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
};
@ -1421,11 +1421,11 @@ ele_parse! {
/// Parameters are treated as string data during application,
/// but their final type depends on the context into which they are
/// expanded.
TplParamStmt := QN_PARAM {
TplParamStmt := QN_PARAM(_, ospan) {
@ {
QN_NAME => TodoAttr,
QN_DESC => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
TplParamDefault,
};
@ -1455,10 +1455,10 @@ ele_parse! {
/// providing constant values.
/// The result will be as if the user typed the text themselves in the
/// associated template application argument.
TplText := QN_TEXT {
TplText := QN_TEXT(_, ospan) {
@ {
QN_UNIQUE => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
};
/// Default the param to the value of another template param,
@ -1470,7 +1470,7 @@ ele_parse! {
/// This list will be refined further in TAMER,
/// since manipulation of values in the XSLT-based TAME was
/// cumbersome and slow
TplParamValue := QN_PARAM_VALUE {
TplParamValue := QN_PARAM_VALUE(_, ospan) {
@ {
QN_NAME => TodoAttr,
QN_DASH => TodoAttr,
@ -1481,7 +1481,7 @@ ele_parse! {
QN_RMUNDERSCORE => TodoAttr,
QN_IDENTIFIER => TodoAttr,
QN_SNAKE => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
};
/// Inherit a default value from a metavalue.
@ -1493,21 +1493,21 @@ ele_parse! {
/// from siblings and ancestors,
/// which is defined lexically relative to the expansion position
/// of the template.
TplParamInherit := QN_PARAM_INHERIT {
TplParamInherit := QN_PARAM_INHERIT(_, ospan) {
@ {
QN_META => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
};
/// Sum a numeric value with a numeric template parameter.
///
/// Combined with [`TplParamInherit`],
/// this can be used to perform bounded recursive template expansion.
TplParamAdd := QN_PARAM_ADD {
TplParamAdd := QN_PARAM_ADD(_, ospan) {
@ {
QN_NAME => TodoAttr,
QN_VALUE => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
};
/// Look up the [`@yields`](QN_YIELDS) of a [`ClassifyStmt`].
@ -1525,10 +1525,10 @@ ele_parse! {
/// defined,
/// so this will always produce some valid identifier for a
/// classification.
TplParamClassToYields := QN_PARAM_CLASS_TO_YIELDS {
TplParamClassToYields := QN_PARAM_CLASS_TO_YIELDS(_, ospan) {
@ {
QN_NAME => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
};
/// Given a numeric literal,
@ -1569,21 +1569,21 @@ ele_parse! {
/// Without the use of types,
/// querying for a constant numeric value would be ambiguous and
/// potentially yield false matches.
TplParamTypedefLookup := QN_PARAM_TYPEDEF_LOOKUP {
TplParamTypedefLookup := QN_PARAM_TYPEDEF_LOOKUP(_, ospan) {
@ {
QN_NAME => TodoAttr,
QN_VALUE => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
};
/// Look up an attribute from the symbol table for a given identifier.
TplParamSymValue := QN_PARAM_SYM_VALUE {
TplParamSymValue := QN_PARAM_SYM_VALUE(_, ospan) {
@ {
QN_NAME => TodoAttr,
QN_VALUE => TodoAttr,
QN_PREFIX => TodoAttr,
QN_IGNORE_MISSING => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
};
/// Keywords that trigger template expansion.
@ -1623,10 +1623,10 @@ ele_parse! {
// TODO: This has to go away so that we can always statically lower all
// primitives without having to perform template expansion in order to
// determine what they may be.
DynNode := QN_DYN_NODE {
DynNode := QN_DYN_NODE(_, ospan) {
@ {
QN_NAME => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
// But we can at least restrict it for now by ensuring that it's
// used only to contain expressions.
@ -1641,8 +1641,8 @@ ele_parse! {
/// Errors will result in a compilation failure.
/// See also [`WarningKw`] to provide a message to the user as
/// compiler output without failing compilation.
ErrorKw := QN_ERROR {
@ {} => Todo,
ErrorKw := QN_ERROR(_, ospan) {
@ {} => Todo(ospan.into()),
// In addition to text that is globally permitted.
TplParamValue,
@ -1657,8 +1657,8 @@ ele_parse! {
/// missed in a sea of build output;
/// you should consider using [`ErrorKw`] whenever possible to
/// ensure that problems are immediately resolved.
WarningKw := QN_WARNING {
@ {} => Todo,
WarningKw := QN_WARNING(_, ospan) {
@ {} => Todo(ospan.into()),
// In addition to text that is globally permitted.
TplParamValue,
@ -1751,8 +1751,8 @@ ele_parse! {
/// [`InlineTemplateForEach`],
/// and have the unique ability to perform symbol table
/// introspection using [`InlineTemplateSymSet`].
InlineTemplate := QN_INLINE_TEMPLATE {
@ {} => Todo,
InlineTemplate := QN_INLINE_TEMPLATE(_, ospan) {
@ {} => Todo(ospan.into()),
InlineTemplateForEach,
AnyStmtOrExpr,
@ -1766,8 +1766,8 @@ ele_parse! {
/// N times,
/// each with the respective [`InlineTemplateArgs`] set as its
/// arguments.
InlineTemplateForEach := QN_FOR_EACH {
@ {} => Todo,
InlineTemplateForEach := QN_FOR_EACH(_, ospan) {
@ {} => Todo(ospan.into()),
InlineTemplateArgs,
};
@ -1783,11 +1783,11 @@ ele_parse! {
/// parameter as an argument.
///
/// See also parent [`InlineTemplateForEach`].
InlineTemplateArgSet := QN_SET {
@ {} => Todo,
InlineTemplateArgSet := QN_SET(_, ospan) {
@ {} => Todo(ospan.into()),
// Streaming attribute parsing.
[attr](_attr) => Todo,
[attr](attr) => TodoAttr(SPair(attr.value(), attr.span())),
// TODO: REMOVE ME
// (bug in `ele_parse!` requiring at least one NT in this
@ -1807,12 +1807,12 @@ ele_parse! {
///
/// TODO: This is a really powerful feature that needs plenty of
/// documentation and examples.
InlineTemplateSymSet := QN_SYM_SET {
InlineTemplateSymSet := QN_SYM_SET(_, ospan) {
@ {
QN_NAME_PREFIX => TodoAttr,
QN_TYPE => TodoAttr,
// TODO: Look at XSL sources for others
} => Todo,
} => Todo(ospan.into()),
};
/// Perform template expansion on each successive child node in order,
@ -1841,8 +1841,8 @@ ele_parse! {
/// and error-prone.
/// The concept originates from TeX's `\expandafter`, `\edef`, and
/// related macros.
ExpandSequence := QN_EXPAND_SEQUENCE {
@ {} => Todo,
ExpandSequence := QN_EXPAND_SEQUENCE(_, ospan) {
@ {} => Todo(ospan.into()),
AnyStmtOrExpr,
};
@ -1851,8 +1851,8 @@ ele_parse! {
/// This exists to work around performance pitfalls of the XSLT-based
/// implementation of [`ExpandSequence`];
/// see that NT for more information.
ExpandGroup := QN_EXPAND_GROUP {
@ {} => Todo,
ExpandGroup := QN_EXPAND_GROUP(_, ospan) {
@ {} => Todo(ospan.into()),
AnyStmtOrExpr,
};
@ -1861,8 +1861,8 @@ ele_parse! {
/// An expansion barrier is a seldom-needed feature that stops the
/// template system from expanding its body beyond a certain point,
/// which is sometimes needed for template-producing templates.
ExpandBarrier := QN_EXPAND_BARRIER {
@ {} => Todo,
ExpandBarrier := QN_EXPAND_BARRIER(_, ospan) {
@ {} => Todo(ospan.into()),
AnyStmtOrExpr,
};
@ -1872,25 +1872,25 @@ ele_parse! {
/// whose value is (conceptually) an XML tree.
///
/// This allows creating templates that accept children.
TplParamCopy := QN_PARAM_COPY {
TplParamCopy := QN_PARAM_COPY(_, ospan) {
@ {
QN_NAME => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
};
/// Define a metavalue at this point in the expansion environment.
///
/// For more information on how these values are used,
/// see [`TplParamInherit`].
TplParamMeta := QN_PARAM_META {
TplParamMeta := QN_PARAM_META(_, ospan) {
@ {
QN_NAME => TodoAttr,
QN_VALUE => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
};
/// Conditionally expand the body if the provided predicate matches.
TplIf := QN_IF {
TplIf := QN_IF(_, ospan) {
@ {
QN_NAME => TodoAttr,
QN_EQ => TodoAttr,
@ -1900,7 +1900,7 @@ ele_parse! {
QN_LTE => TodoAttr,
QN_PREFIX => TodoAttr,
QN_SUFFIX => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
AnyStmtOrExpr,
};
@ -1910,7 +1910,7 @@ ele_parse! {
///
/// This can be used as a sibling of [`TplIf`] to create the equivalent
/// of an `else` clause.
TplUnless := QN_UNLESS {
TplUnless := QN_UNLESS(_, ospan) {
@ {
QN_NAME => TodoAttr,
QN_EQ => TodoAttr,
@ -1920,7 +1920,7 @@ ele_parse! {
QN_LTE => TodoAttr,
QN_PREFIX => TodoAttr,
QN_SUFFIX => TodoAttr,
} => Todo,
} => Todo(ospan.into()),
AnyStmtOrExpr,
};