next up previous
Next: Constants Up: Structural Analysis Previous: Identifiers

Phrase structure

Most of the phrase structure of Pascal can be deduced from the abstract syntax given in Section 1.1. In a number of cases, however, the abstract syntax is either ambiguous or designed to capture the semantics of a construct more cleanly than the phrase structure allows. Concrete syntax rules are introduced to define the phrase structure in those situations.

Statement labeling[18]
Precedence and association[19]
Dangling else[20]
Declaration sequence[21]
This macro is attached to a product file.

Eli uses pattern matching to determine the relationship between phrases defined by a concrete syntax and AST nodes defined by an abstract syntax. It recognizes simple identities like that of rule pgrm in Figure 1, and LISTOF rules are properly associated with concrete syntax rules that use extended BNF notation to describe iteration.

The concrete syntax for Pascal uses a number of symbols that do not appear in the abstract grammar. For example, the operator precedence rules of the language are described by using distinct symbols for expressions at each precedence level. Symbol mappings convert all of these distinct expression symbols into the single symbol expression used in the abstract grammar.

Several shorthand notations, such as multi-dimensional arrays, are incorporated into the concrete syntax. These shorthands are converted into their long form in the abstract syntax by rule mappings.

Eli cannot deduce these mappings from the grammars themselves; an additional specification is needed:[13]:

expression ::= simple_expression term factor .
constant   ::= selector .

operator ::= sign multiplying_operator adding_operator relational_operator .

Decl ::=
  type_definition record_section
  function_declaration .

statement ::= unlabeled_statement .

List symbol mapping[16]
Extension symbol mapping[23]


Extension rule mapping[24]
This macro is attached to a product file.

next up previous
Next: Constants Up: Structural Analysis Previous: Identifiers