Eli   Documents

General Information

 o Eli: Translator Construction Made Easy
 o Global Index
 o Frequently Asked Questions
 o Typical Eli Usage Errors

Tutorials

 o Quick Reference Card
 o Guide For new Eli Users
 o Release Notes of Eli
 o Tutorial on Name Analysis
 o Tutorial on Scope Graphs
 o Tutorial on Type Analysis
 o Typical Eli Usage Errors

Reference Manuals

 o User Interface
 o Eli products and parameters
 o LIDO Reference Manual
 o Typical Eli Usage Errors

Libraries

 o Eli library routines
 o Specification Module Library

Translation Tasks

 o Lexical analysis specification
 o Syntactic Analysis Manual
 o Computation in Trees

Tools

 o LIGA Control Language
 o Debugging Information for LIDO
 o Graphical ORder TOol

 o FunnelWeb User's Manual

 o Pattern-based Text Generator
 o Property Definition Language
 o Operator Identification Language
 o Tree Grammar Specification Language
 o Command Line Processing
 o COLA Options Reference Manual

 o Generating Unparsing Code

 o Monitoring a Processor's Execution

Administration

 o System Administration Guide

Mail Home

LIDO - Reference Manual

Previous Chapter Next Chapter Table of Contents


Rule Specifications

A rule specification specifies a production of the tree grammar, and may associate some computations with the rule context. They are executed in every context which represents that rule in a particular tree.

Syntax

    RuleSpec ::= 'RULE' [RuleName] ':' Production Computations 'END'

Example:

    RULE p: Stmt  ::= 'while' Expr 'do' Stmt COMPUTE
      Expr.postType = boolType
    END;

There may be several rule specifications that refer to the same rule. In that case the associated computations are accumulated.

The set of productions of all rules forms the tree grammar. It must have exactly one root symbol that does not occur on any right-hand side of a production.

Eli usually generates some rule specifications (without computations) from the concrete grammar in order to complete the tree grammar.

In general the RuleName is omitted. The rule is then identified by the production. LIGA generates a name of the form rule_i, with a unique number i for such a rule. A meaningful RuleName should be specified for rules that are part of computed subtrees, since the name of the tree construction function is derived from it (see Computed Subtrees). Also using the RuleFct feature may give rise to explicitly name rules (see Predefined Entities).

Restrictions

Two unnamed rule specifications refer to the same rule if their productions are identical.

A named rule specification and an unnamed one refer to the same rule if their productions are identical. In that case there must not be another rule specification with the same production but a different name.

Two named rule specifications with the same RuleName must have the same production.

Note: Two rule specifications with different names, but equal productions, are only reasonable if they belong to computed subtrees rather to subtrees constructed by a parser.

Productions

A production as part of a rule specification describes the structure of the rule context. Computations associated with the rule may use or define attributes of nonterminal symbols that occur in the production. The set of all productions in a LIDO specification defines the tree grammar.

Syntax

    Production     ::= SymbName '::=' Symbols
                     | SymbName 'LISTOF' Elements

    Symbols        ::= Symbols Symbols |
                     | SymbName | Literal

    Elements       ::=  Elements '|' Elements |
                     | SymbName

    TermSpec       ::= 'TERM' SymbNames ':' TypeName






Examples

    Stmt ::= 'while' Expr 'do' Stmt
    DefIdent ::= Identifier
    Declarations LISTOF ProcDecl | VarDecl
    TERM Identifier: int;

Productions are composed of nonterminal symbols, named terminal symbols, and literal terminals.

The SymbName on the left-hand side of a production is a nonterminal. A SymbName that does not occur on the left-hand side of any production denotes a named terminal. A nonterminal symbol that does not occur on the right-hand side of any production is the root of the tree grammar.

We say the rule context is a lower context for the left-hand side nonterminal, and an upper context for any right-hand side nonterminal.

Literal terminals are denoted by arbitrary non empty strings enclosed in single quotes. A quote that is part of such string is denoted by two single quotes.

Literal terminals do not contribute to the trees specified by the tree grammar. They only relate tree productions to concrete productions describing the input text, and distinguish otherwise equal productions.

Named terminal symbols do not contribute to the trees specified by the tree grammar. They are related to named terminal symbols of corresponding concrete productions describing the input text. A value derived from such an input token may be used in computations which are associated with the rule of the production or with the symbol on the left-hand side of the production. (If the tree context is constructed by a computation, rather than by parsing the input text, then that value is supplied as an argument to the call of the construction function (see Tree Construction Functions).)

The type of the value provided by a named terminal symbol is specified by a TERM specification. If there is no such specification the type int is assumed.

There are two forms of productions: plain productions and LISTOF productions.

A plain production defines tree contexts with a node for the left-hand side nonterminal having a sequence of subtrees, one for each nonterminal on the right-hand side.

Computations may refer to any attribute of any nonterminal in the production. If one nonterminal occurs more than once in the production references to the occurrences in computations are distinguished by indices (starting from 1).

A LISTOF production defines tree contexts with a node for the left-hand side nonterminal having an arbitrary long sequence of subtrees each rooted by a nonterminal specified as a LISTOF element. That sequence may be empty, even if there is no empty LISTOF element specified.

Computations associated with the rule of a LISTOF production may only refer to attributes of the left-hand side symbol. Attributes of the element subtrees are referenced only by remote attribute access (see Remote Attribute Access).

Restrictions

There must be exactly one root nonterminal which does not occur on any right-hand side of a tree grammar production.

If X is the left-hand side symbol of a LISTOF production, then there may not be a different production (neither LISTOF nor plain) that also has X on its left-hand side.

Named terminals may not be LISTOF elements.

A literal terminal may not be the empty string.


Previous Chapter Next Chapter Table of Contents