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.

Structure.con[12]:
Constants[14]
Lists[15]
Fields[17]
Statement labeling[18]
Precedence and association[19]
Dangling else[20]
Declaration sequence[21]
Extensions[22]
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:

Structure.map[13]:
MAPSYM

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

operator ::= sign multiplying_operator adding_operator relational_operator .

Decl ::=
  constant_definition
  type_definition record_section
  variable_declaration
  procedure_declaration
  function_declaration .

statement ::= unlabeled_statement .

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

MAPRULE

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



Subsections
next up previous
Next: Constants Up: Structural Analysis Previous: Identifiers
2008-08-29