Stmt
Fixtype of statements [C:6.8] [C:A.2.3].
This is a tagged union type, introduced by fty::deftagsum.
Member Tags → Types
- :labeled → stmt-labeled
- :compound → stmt-compound
- :expr → stmt-expr
- :if → stmt-if
- :ifelse → stmt-ifelse
- :switch → stmt-switch
- :while → stmt-while
- :dowhile → stmt-dowhile
- :for-expr → stmt-for-expr
- :for-decl → stmt-for-decl
- :for-ambig → stmt-for-ambig
- :goto → stmt-goto
- :continue → stmt-continue
- :break → stmt-break
- :return → stmt-return
- :asm → stmt-asm
This corresponds to statement in the grammar in [C].
We inline
labeled-stament,
expression-statement,
selection-statement,
iteration-statement, and
jump-statement.
For labeled statements,
we use label to factor the three kinds of labels.
There are two forms of for loops:
one where the initialization part is an (optional) expression,
and one where the initialization part is a declaration.
There is also a third ambiguous form,
which applies when the initialization part could be
either an expression or a declaration, syntactically:
this is captured exactly by amb-decl/stmt,
because the statement in an ambiguous declaration or statement
is a statement expression,
which is exactly what
the initialization part of a for looks like,
when it is an expression.
As a GCC extension, we also include assembler statements.
These are based on their definition in the ABNF grammar,
which is in turn derived from the GCC documentation.
As is in the grammar,
we unify the representation of basic and extended assembler statements.
The grammar contains four nested optional parts (output operands etc.);
the nesting is such that any prefix of the sequence of four parts,
ranging from no parts to all four parts, may be present.
In the abstract syntax, we include a component
that counts the number of parts, or equivalently the number of colons,
since each part starts with a colon.
Then each part consists of a list of things, four lists, one per part.
If num-colons is less than 4,
the fourth list must be empty;
if num-colons is less than 3,
the fourth and third lists must be empty;
and so on, but we do not explicitly capture
these constraints in the fixtype.
Subtopics
- Stmtp
- Recognizer for stmt structures.
- Stmt-case
- Case macro for the different kinds of stmt structures.
- Stmt-asm
- Stmt-for-expr
- Stmt-for-decl
- Stmt-for-ambig
- Stmt-equiv
- Basic equivalence relation for stmt structures.
- Stmt-ifelse
- Stmt-while
- Stmt-switch
- Stmt-labeled
- Stmt-if
- Stmt-dowhile
- Stmt-kind
- Get the kind (tag) of a stmt structure.
- Stmt-return
- Stmt-expr
- Stmt-compound
- Stmt-goto
- Stmt-continue
- Stmt-break
- Stmt-fix
- Fixing function for stmt structures.
- Stmt-count
- Measure for recurring over stmt structures.