next up previous contents
Next: Select Up: Evaluation Rules Previous: List   Contents


Binding

<

Binding    ::= `[' BindElem*, `]'
BindElem   ::= SelfNameB | NameBind
SelfNameB  ::= Id
NameBind   ::= GenPath = Expr
GenPath    ::= GenArc { Delim GenArc }* [ Delim ]
GenArc     ::= Arc | $ Id | $ ( Expr ) | % Expr %
Arc        ::= Id | Integer | Text

<

The following desugarings apply to BindElem's within a Binding.

Id desugars to Id = Id
GenArc Delim = Expr desugars to GenArc = Expr
GenArc Delim GenPath = Expr desugars to GenArc = [ GenPath = Expr ]
$ Id = Expr desugars to $ ( Id ) = Expr
% $\mbox{Expr}_1$ % = $\mbox{Expr}_2$ desugars to $ ( $\mbox{Expr}_1$ ) = $\mbox{Expr}_2$

The SelfNameB syntactic sugar allows names from the current scope to be copied into bindings more succinctly. For example, the binding value:

  [ progs = progs, tests = tests, lib = lib ]

can instead be written:

  [ progs, tests, lib ]

The GenPath syntactic sugar allows bindings consisting of a single path to be written more succinctly. For example, the binding value:

  [ env_ovs = [ Cxx = [ switches = [ compile =
    [ debug = "-g3", optimize = "-O" ]]]]]

can instead be written:

  [ env_ovs/Cxx/switches/compile = 
    [ debug = "-g3", optimize = "-O" ]]

<

First, the rules for constructing empty and singleton bindings:

Eval( [ ]            , C) = emptybinding
Eval( [ Arc = Expr ] , C) = _bind1(id, Eval( Expr , C))

Here id is the t_text representation of Arc. The conversion from an Arc to a t_text is straightforward. If the Arc is an Id, the literal characters of the identifier become the text value. If the Arc is an Integer, the literal characters used to represent the integer in the source of the model become the text value. If the Arc is a Text, the result of Eval(Arc, C) is used. As defined in Section A.3.4.5, _bind1(id, v) evaluates to a singleton binding that associates the non-empty t_text id with the value v.

The $(Expr) syntax allows the name introduced into a binding to be computed:

Eval( [ $ ( Expr_1 ) = Expr_2 ] , C) =
  _bind1(Eval(Expr_1, C), Eval( Expr_2 , C))

When the field name is computed using the $ syntax, the expression must evaluate to a non-empty t_text (see the _bind1 primitive in Section A.3.4.5 below).

The following rule handles the case where multiple BindElem's are given.

Eval( [ BindElem_1, ..., BindElem_n ] , C) =
{
  val b1 = Eval( [ BindElem_1 ] , C);
  val b2 = Eval( [ BindElem_2, ..., BindElem_n ] , C);
  return _append(b1, b2);
}

As defined in Section A.3.4.5, _append(b1, b2) evaluates to the concatenation of the bindings b1 and b2; it requires that their domains are disjoint.


next up previous contents
Next: Select Up: Evaluation Rules Previous: List   Contents
Allan Heydon, Roy Levin, Timothy Mann, Yuan Yu