4. First-class SORT expansions

  1. 4.1. Access
  2. 4.2. Al_tag
  3. 4.3. Alignment
  4. 4.4. Bitfield_variety
  5. 4.5. Bool
  6. 4.6. Error_treatment
  7. 4.7. Exp
  8. 4.8. ExpTerm
  9. 4.9. Floating_variety
  10. 4.10. Label
  11. 4.11. Nat
  12. 4.12. Ntest
  13. 4.13. Rounding_mode
  14. 4.14. Shape
  15. 4.15. Signed_Nat
  16. 4.16. String
  17. 4.17. Tag
  18. 4.18. Token
  19. 4.19. Transfer_mode
  20. 4.20. Variety

All of the first-class sorts have similar expansions for native TDF constructions and for token applications. I shall take <Shape> as the paradigm sort and allow the reader to conjugate the following for the the other sorts.

Those first-class sorts which include the _cond constructions denote them in the same way:

<Shape> ::= SHAPE ? ( <Exp>, <Shape>, <Shape> )

This produces a shape_cond with the obvious parameters.

Each constructor for <Shape> with parameters which are first-class sorts can be expanded:

<Shape> ::= <shape_constructor> < ( <constructor_param>-List ) >-Opt

Each <constructor_param> will be the first_class SORT expansion, required by the <shape_constructor> as in the TDF specification eg the constructor, pointer, requires a <constructor_param> ::= <Alignment>.

Any <ident> which is declared to be a <shape_token> by a TOKDEF or TOKDEC can be expanded:

<Shape> ::= <shape_token> < [ <token_param>-List ] >-Opt

This will produce a shape_apply_token with the appropriate parameters. Each <token_param> will be the first-class SORT expansion required by the SORT given by the <TokDecPar> of the TOKDEF or TOKDEC which introduced <shape_token>.

4.1. Access

<Access> ::= ACCESS ? ( <Exp> , <Access> , <Access> )
<Access> ::= <access_constructor> < ( <constructor_param>-List ) >-Opt
<Access> ::= <access_token> < [ <token_param>-List ] >-Opt

There are no expansions of <Access> other than the standard ones.

4.2. Al_tag

<Al_tag> ::= <al_tag_token> < [ <token_param>-List ] >-Opt

The standard token expansion.

<Al_tag> ::= <ident>

Any <ident> found as an expansion of <Al_tag> will be declared as the name for an AL_TAG.

4.3. Alignment

<Alignment> ::= ALIGNMENT ? ( <Exp> , <Alignment> , <Alignment> )
<Alignment> ::= <alignment_constructor> < ( <constructor_param>-List ) >-Opt
<Alignment> ::= <alignment_token> < [ <token_param>-List ] >-Opt

The standard expansions.

<Alignment> ::= <Al_tag>

This results in an obtain_al_tag of the AL_TAG.

<Alignment> ::= ( <Alignment>-List-Opt )

The <Alignment>s in the <Alignment>-List are united using unite_alignments. The empty option results in the top ALIGNMENT.

4.4. Bitfield_variety

<Bitfield_variety> ::= BITFIELD_VARIETY ? ( <Exp> , <Bitfield_variety>, <Bitfield_variety>)
<Bitfield_variety> ::= <bitfield_variety_constructor> < ( <constructor_param>-List ) >-Opt
<Bitfield_variety> ::= <bitfield_variety__token> < [ <token_param>-List ] >-Opt

The standard expansions.

<Bitfield_variety> ::= <BfSign>-Opt <Nat>
<BfSign> ::= <Bool>
<BfSign> ::= Signed
<BfSign> ::= Unsigned

This expands to bfvar_bits. The empty default on the sign is Signed.

4.5. Bool

<Bool> ::= BOOL ? ( <Exp> , <Bool>, <Bool>)
<Bool> ::= <bool_constructor> < ( <constructor_param>-List ) >-Opt
<Bool> ::= <bool_token> < [ <token_param>-List ] >-Opt

There are no expansions of <Bool> other than the standard ones.

4.6. Error_treatment

<Error_treatment> ::= ERROR_TREATMENT ?
																											 ( <Exp> , <Error_treatment>, <Error_treatment>)
<Error_treatment> ::= <error_treatment_constructor> < ( <constructor_param>-List ) >-Opt
<Error_treatment> ::= <error_treatment__token> < [ <token_param>-List ] >-Opt

The standard expansions.

<Error_treatment> ::= <Label>

This gives an error_jump to the label.

<Error_treatment> ::= [ <Error_code>-List]
<Error_code> ::= overflow
<Error_code> ::= nil_access
<Error_code> ::= stack_overflow

Produces trap with the <Error_code>s as arguments.

4.7. Exp

<Exp> ::= <ExpTerm>
<Exp> ::= <ExpTerm> <BinaryOp> <ExpTerm>

The <BinaryOp>s include the arithmetic, offset, logical operators and assignment and are given in table 1. In this expansion, any error_treatments are taken to be wrap.

<BinaryOp>TDF constructor<BinaryOp>TDF constructor
AndandOror
Xorxor*+.add_to_ptr
*-*subtract_ptrs.*offset_mult
.+.offset_add.-.offset_subtract
./offset_div_by_int./.offset_div
.max.offset_max%rem2
%1rem1*mult
+plus-minus
/div2/1div1
<<shift_left>>shift_right
F*floating_multF+floating_plus
F-floating_minusF/floating_div
=assign

The names like *+. (i.e. add_to_ptr) do have a certain logic; the * indicates that the left operand must be a pointer expression and the. that the other is an offset

The further expansions of <Exp> are all <ExpTerm>s.

4.8. ExpTerm

<ExpTerm> ::= EXP ? ( <Exp> , <Exp>, <Exp>)
<ExpTerm> ::= <exp_constructor> < ( <constructor_param>-List ) >-Opt
<ExpTerm> ::= <exp_token> < [ <token_param>-List ] >-Opt

The standard expansions.

<ExpTerm> ::= <ClosedExp>

For <ClosedExp>, see section 3.3.

<ExpTerm> ::= ( <Exp> )
<ExpTerm> ::= - ( <Exp> )

The negate constructor.

<ExpTerm> ::= Sizeof ( <Shape> )

This produces the EXP OFFSET for an index multiplier for arrays of <Shape>. It is the shape_offset of <Shape> padded up to its alignment.

<ExpTerm> ::= <Tag>

This produces an obtain_tag.

<ExpTerm> ::= * <ident>

The <ident> must have been declared as a variable TAG and the construction produces a contents operation with its declared SHAPE.

<ExpTerm> ::= * ( <Shape> ) <ExpTerm>

This produces a contents operation with the given <Shape>.

<ExpTerm> ::= <Assertion>

For <Assertion>, see section 3.3.1

<ExpTerm> ::= Case <Exp> ( <RangeDest>-List )
<RangeDest> ::= <Signed_Nat> < : <Signed_Nat> >-Opt -> <Label>

This produces a case operation.

<ExpTerm> ::= Cons [ <Exp> ] ( < <Offset> : <Exp> >-List )
<Offset> ::= <Exp>

This produces a make_compound with the [ <Exp> ] as the size and fields given by < <Offset> : <Exp> >-List.

<ExpTerm> ::= [ <Variety> ] <ExpTerm>

This produces a change_variety with a wrap error_treatment.

<ExpTerm> ::= <Signed_Nat> ( <Variety> )

This produces a make_int of the <Signed_Nat> with the given variety.

<ExpTerm> ::= <floating_denotation> < E <Signed_Nat> >-Opt <Rounding_Mode>-Opt
<ExpTerm> ::= - <floating_denotation> < E <Signed_Nat> >-Opt <Rounding_Mode>-Opt

Produces a make_floating.

<ExpTerm> ::= <ProcVal> [ <Shape> ] ( <Exp>-List-Opt < Varpar <Exp> >-Opt)

<ProcVal> ::= <Tag>
<ProcVal> ::= ( <Exp> )

Produces an apply_proc with the given parameters returning the given <Shape>.

<ExpTerm> ::=						 <ProcVal> [ <Shape> ]
[ <Act_Callers>-Opt ; <Act_Callees>-Opt <; <Postlude>>-Opt ]
<ProcProps>-Opt
<Act_Callers> ::= <<Exp> <: <ident>>-Opt>-List <...>-Opt
<Act_Callees> ::= <Exp>-List <...>-Opt
<Act_Callees> ::= Dynamic ( <Exp> , <Exp> ) <...>-Opt
<Act_Callees> ::= Same
<Postlude> ::= <Exp>

Produces an apply_general_proc with the actual caller parameters given by <Act_Callers> and the calle parameters given by <Act_Callees>; the <...> option indicates that the procedure is expecting a variable number of parameters. Any <ident>s introduced in <Act_Callers> are in scope in <Postlude>.

<Exp> ::= <ProcVal> Tail_call [ <Act_Callees>-Opt ]

Produces a tail_call with the callee parameters given and same caller parameters as those of the calling procedure.

<ExpTerm> ::= Proc <Proc_defn>

Produces a make_proc. For <Proc_defn>, see section 3.1.7

<ExpTerm> ::= <String> ( <Variety> )

Produces a make_nof_int of the given variety.

<ExpTerm> ::= # <String>

This produces a TDF fail_installer; this construction is useful for narrowing down SHAPE errors detected by the translator.

4.9. Floating_variety

<Floating_variety> ::= FLOATING_VARIETY ?
( <Exp> , <Floating_variety>, <Floating_variety>)
<Floating_variety> ::= <floating_variety_constructor> < ( <constructor_param>-List ) >-Opt
<Floating_variety> ::= <floating_variety__token> < [ <token_param>-List ] >-Opt

The standard constructions.

<Floating_variety> ::= Float

An IEEE 32 bit floating variety.

<Floating_variety> ::= Double

An IEEE 64 bit floating variety.

4.10. Label

<Label> ::= <label_token> < [ <token_param>-List ] >-Opt

The standard token application.

<Label> ::= <ident>

The <ident> will be declared as a LABEL, whose scope is the current procedure.

4.11. Nat

<Nat> ::= NAT ? ( <Exp> , <Nat>, <Nat>)
<Nat> ::= <nat_constructor> < ( <constructor_param>-List ) >-Opt
<Nat> ::= <nat_token> < [ <token_param>-List ] >-Opt

The standard expansions.

<Nat> ::= <integer_denotation>

Produces a make_nat on the integer

<Nat> ::= <character>

Produces a make_nat on the ASCII value of the character.

4.12. Ntest

<Ntest> ::= NTEST ? ( <Exp> , <Ntest>, <Ntest>)
<Ntest> ::= <ntest_constructor> < ( <constructor_param>-List ) >-Opt
<Ntest> ::= <ntest_token> < [ <token_param>-List ] >-Opt

The standard expansions.

<Ntest> ::= !<

Produces not_less_than.

<Ntest> ::= !<=

Produces not_less_than_or_equal.

<Ntest> ::= !=

Produces not_equal.

<Ntest> ::= !>

Produces not_greater_than.

<Ntest> ::= !>=

Produces not_greater_than_or_equal.

<Ntest> ::= !Comparable

Produces not_comparable.

<Ntest> ::= <

Produces less_than.

<Ntest> ::= <=

Produces less_than_or_equal.

<Ntest> ::= ==

Produces equal.

<Ntest> ::= >

Produces greater_than.

<Ntest> ::= >=

Produces greater_than_or_equal.

4.13. Rounding_mode

<Rounding_mode> ::= ROUNDING_MODE?
( <Exp> , <Rounding_mode>, <Rounding_mode>)
<Rounding_mode> ::= <ntest_constructor> < ( <constructor_param>-List ) >-Opt
<Rounding_mode> ::= <ntest_token> < [ <token_param>-List ] >-Opt

There are no constructions for <Rounding_mode> other than the standard ones.

4.14. Shape

<Shape> ::= SHAPE ? ( <Exp> , <Shape>, <Shape>)
<Shape> ::= <shape_constructor> < ( <constructor_param>-List ) >-Opt
<Shape> ::= <shape_token> < [ <token_param>-List ] >-Opt

The standard expansions.

<Shape> ::= Float

The shape for an IEEE 32 bit float.

<Shape> ::= Double

The shape for an IEEE 64 bit float.

<Shape> ::= <Sign>-Opt Int
<Sign> ::= Signed
<Sign> ::= Unsigned

The shape for a 32 bit signed or unsigned integer. The default is signed.

<Shape> ::= <Sign>-Opt Long

The shape for a 32 bit signed or unsigned integer.

<Shape> ::= <Sign>-Opt Short

The shape for a 16 bit signed or unsigned integer.

<Shape> ::= <Sign>-Opt Char

The shape for a 8 bit signed or unsigned integer.

<Shape> ::= Ptr <Shape>

The SHAPE pointer(alignment(<Shape>)).

4.15. Signed_Nat

<Signed_Nat> ::= SIGNED_NAT ? ( <Exp> , <Signed_Nat>, <Signed_Nat>)
<Signed_Nat> ::= <signed_nat_constructor> < ( <constructor_param>-List ) >-Opt
<Signed_Nat> ::= <signed_nat_token> < [ <token_param>-List ] >-Opt

The standard expansions.

<Signed_Nat> ::= <integer_denotation>
<Signed_Nat> ::= - <integer_denotation>

This produces a make_signed_nat on the integer value.

<Signed_Nat> ::= <character>
<Signed_Nat> ::= - <character>

This produces a make_signed_nat on the ASCII value of the character.

<Signed_Nat> ::= LINE

This produces a make_signed_nat on the current line number of the file being compiled - useful for writing test programs.

<Signed_Nat> ::= + <Nat>
<Signed_Nat> ::= - <Nat>

This produces an appropriately signed <Signed_Nat> from a <Nat>.

4.16. String

<String> ::= STRING? ( <Exp> , <String>, <String>)
<String> ::= <string_constructor> < ( <constructor_param>-List ) >-Opt
<String> ::= <string_token> < [ <token_param>-List ] >-Opt

The standard expansions

<String> ::= <string>

Produces a make_string.

4.17. Tag

<Tag> ::= <tag_token> < [ <token_param>-List ] >-Opt

The standard token application.

<Tag> ::= <ident>

This gives an obtain_tag; the <ident> must been declared as a TAG either globally or locally.

4.18. Token

TOKEN is rather a limited first-class sort. There is no explicit construction given for token_apply_token, since the only place where it can occur is in an expansion of a token parameter of another token; here it is produced implicitly. The only place where <Token> is expanded is in an actual TOKEN parameter of a token application; other uses (e.g. as in <shape_token>) are always <ident>s.

<Token> ::= <ident>

The <ident> must have been declarered by a <Tokdec> or <Tokdec> or is a formal parameter of TOKEN.

<Token> ::= Use <Tok_Defn>

This produces a use_tokdef. For <Tok_Defn> see section 3.1.2. The critical use of this construction is to provide an actual TOKEN parameter to a token application where the <Tok_Defn> contains uses of tags or labels local to a procedure.

4.19. Transfer_mode

<Transfer_mode> ::= TRANSFER_MODE ? ( <Exp> , <Transfer_mode>, <Transfer_mode>)
<Transfer_mode> ::= <transfer_mode_constructor> < ( <constructor_param>-List ) >-Opt
<Transfer_mode> ::= <transfer_mode_token> < [ <token_param>-List ] >-Opt

There are no expansions for <Transfer_mode> other than the standard expansions.

4.20. Variety

<Variety> ::= VARIETY ? ( <Exp> , <Variety>, <Variety>)
<Variety> ::= <variety_constructor> < ( <constructor_param>-List ) >-Opt
<Variety> ::= <variety_token> < [ <token_param>-List ] >-Opt

The standard expansions.

<Variety> ::= <Signed_Nat> : <Signed_Nat>

This produces var_limits.

<Variety> ::= <Sign>-Opt Int
<Variety> ::= <Sign>-Opt Long
<Variety> ::= <Sign>-Opt Short
<Variety> ::= <Sign>-Opt Char

This produces the variety of the appropriate integer shape.