Next: , Previous: , Up: Lexical Analysis   [Contents][Index]


10.1.5 Lexical Scoping

A lexical scope adds locality to a name. Names in one lexical scope do not interfere (collide or shadow) with another scope. Referring to a scoped identifier

reference ::= scope* identifier
scope ::= identifier "."

Dezyne defines the following scopes:

enum

The field values of an enum:

enum result {TRUE, FALSE, ERROR};

are referenced to by using the enum type name as scope:

result.TRUE
interface

A type defined in an interface:

interface ihello
{
   enum result {TRUE, FALSE, ERROR};
}

can be used in a component, e.g., to define a variable:

ihello.result status = ihello.result.TRUE;
behavior

All definitions in a behavior are local to that behavior and cannot be referenced from outside it13,

port

A port is an interface instance; events that are communicated over a port use the name of the port as their scope:

provides ihello p;
…
on p.hello (): p.world ();
instance

An instance (or component instance), is an instance of a component. A port defined in a component

component hello
{
  provides ihello p;
  requires ihello r;
}

can be referenced to by using the component instance name as their scope

component sys
{
  provides ihello sp;
  requires ihello sr;
  system
  {
    hello h;
    sp <=> h.p;
    h.r <=> sr;
  }
}
namespace

Types defined in a namespace are referenced to by using the name of the namespace as their scope.


Footnotes

(13)

This may change when Dezyne gains support for hierarchical behaviors, a.k.a. submachines.


Next: Comments, Previous: Delimiters, Up: Lexical Analysis   [Contents][Index]