General Information
Tutorials
Reference Manuals
Libraries
Translation Tasks
Tools
Administration
|
LIDO - Reference ManualRule SpecificationsA 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.
SyntaxRuleSpec ::= '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
RestrictionsTwo 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 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.
ProductionsA 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.
SyntaxProduction ::= 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 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
There are two forms of productions: plain productions and 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
Computations associated with the rule of a
RestrictionsThere must be exactly one root nonterminal which does not occur on any right-hand side of a tree grammar production.
If
Named terminals may not be A literal terminal may not be the empty string.
|