Amb-expr/tyname
Fixtype of ambiguous expressions or type names.
This is a product type introduced by fty::defprod.
Fields
- expr — expr
- tyname — tyname
Certain parts of the syntax may be either expressions or type names.
An example is the argument of sizeof, which is followed by
either a parenthesized type name or a parenthesized expression
(it can be also followed by a non-parenthesized expression,
but in that case there is no ambiguity).
The syntactic overlap between expressions and type names is complex.
The simplest case is a single identifier I,
which can be either a variable (which is an expression)
or a typedef name
(which is a type specifier,
and thus a type name without abstract declarator).
But also I(I1) is ambiguous, if I1 is also an identifier:
it could be either a function call (which is an expression),
or a typedef name followed by a function abstract declarator,
in which case I1 is a parameter declaration
consisting of a typedef name I1.
Things can be nested: I(I1(I2(...(In)...))).
It is also possible to have multiple arguments or parameters,
e.g. I(I1,I2), or things can be nested more deeply.
There are also cases involving square brackets, such as
I[E], where I is an identifier and E is an expression:
this can be an array subscripting expression,
or a typedef name I followed by an array abstract declarator.
It may take a bit of work to accurately characterize
the syntactic ``intersection'' of expressions and type names.
Therefore, at least for now, we introduce a fixtype to capture
the notiion of an ambiguous expression or type name.
A value of this fixtype consists of both an expression and a type name:
the idea is that they are the same in concrete syntax,
although there is no explicit requirement in this fixtype.
Assuming that this requirement is met,
a value of this fixtype provides the two possible interpretations,
the expression and the type name (both in abstract syntax, of course).
Subtopics
- Amb-expr/tyname-equiv
- Basic equivalence relation for amb-expr/tyname structures.
- Make-amb-expr/tyname
- Basic constructor macro for amb-expr/tyname structures.
- Change-amb-expr/tyname
- Modifying constructor for amb-expr/tyname structures.
- Amb-expr/tyname->tyname
- Get the tyname field from a amb-expr/tyname.
- Amb-expr/tyname->expr
- Get the expr field from a amb-expr/tyname.
- Amb-expr/tyname-p
- Recognizer for amb-expr/tyname structures.
- Amb-expr/tyname-fix
- Fixing function for amb-expr/tyname structures.
- Amb-expr/tyname-count
- Measure for recurring over amb-expr/tyname structures.