Related articles |
---|
[ANNOUNCE] Rie - a compiler generator ohshima@is.titech.ac.jp (OHSHIMA Yoshiki 9007647) (1993-12-03) |
Newsgroups: | comp.compilers |
From: | OHSHIMA Yoshiki 9007647 <ohshima@is.titech.ac.jp> |
Keywords: | tools, FTP, available, parse, attribute |
Organization: | Compilers Central |
Date: | Fri, 3 Dec 1993 13:17:31 GMT |
Rie
A Compiler Generator Based On Attribute Grammar
We are pleased to announce availability of our research product
called Rie. Rie is based on a one-pass attribute grammar. LR-attributed
grammars are known to be the class of attribute grammars in which
attribute evaluation can be performed during LR parsing without creating a
parse tree. Rie is developed based on a variant of LR-attributed grammar
called ECLR-attributed grammar (Equivalence Class LR-attributed grammar),
in which equivalence relations are introduced into the LR-attributed
grammar. Rie generates a one-pass compiler from the compiler description
in attribute grammar. Many language processors have been developed using
Rie. The generated compiler is only about 1.8 times slower compared to a
handwritten compiler, which we think is highly efficient as a compiler
generated from formal descriptions.
Rie was designed by Masataka Sassa and developed by his group.
The first version of Rie was designed as a modification of Yacc parser
generator in 1985. To get rid of AT&T's restriction over the source code
of Yacc, in 1990 we rewrote Rie by modifying Bison. The work was
conducted by Masataka Sassa and his group at the University of Tsukuba.
The rewritten version of Rie has since been used in Sassa group and
several research sites in Japan for more than three years. It has been
used for production of compilers, interpreters, debuggers, GUI generators,
etc.
Rie takes language specification and generates a compiler of the
language written in C. The specification of the language to be input to
Rie is called Rie description here. The Rie description comprises
definition of the syntax and semantics of the language. The syntax is
defined in terms of context free grammar and the semantics is specified in
terms of attribute grammar. For the description of syntax, we followed
the style of Yacc and Bison for user's convenience. The semantics of the
language is given through declaration of attributes for each grammar
symbol and rules of defining attribute values (attribution rules).
Attribution rules appear in the semantic part of the associated
production.
Additional features of Rie include local attribute, context
conditions with error messages, several shorthand notations and so on.
SYNTAX OF RIE INPUT FILE
The style of Rie description is derived from that of Yacc. The
semantic section of each rule may contain attribution rules, context
conditions, `local attributes', and shorthand notations as well as C
statements, if necessary. A typical description is as follows:
statement: WHILE condition do1 statement
{ %local int wlab1 = genlabel();
%local int wlab2 = genlabel();
%transfer I_env;
statement[1].code = concat6( gen( O_LAB, 0, wlab1 ),
condition.code,
gen( O_JPC, 0, wlab2 ),
statement[2].code,
gen( O_JMP, 0, wlab1 ),
gen( O_LAB, 0, wlab2 )); } ;
This description is taken from the code generator of PL/0, which defines
syntax and semantics of while statement. The semantic part starts with
declarations of local attributes (%local ...) and shorthand notation
(%transfer ...). "%local" declares two local attributes wlab1, wlab2 and
their values. With the use of local attributes, the programmer can
eliminate common subexpressions out of the attribution rules and greatly
reduce redundancy of the description. Introduction of local attributes
also allows the programmer to avoid critical side-effects, which often
arise in writing actual compilers, while retaining the single assignment
property of attribute grammar. "%transfer I_env" is a shorthand notation
that implies copy rule over the attribute I_env. In this example,
"%transfer I_env" denotes copying of the value statement.I_env in the left
hand side to condition.I_env and statement.I_env in the right hand side.
Rie also accepts shorthand notation for which we call `thread' pattern, so
if the programmer specifies "%thread", Rie expand it into several copy
rules. "concat6" is a function defined by C language which concatenates
its arguments and returns code in the PL/0 stack machine code.
INFORMATION
Rie is free software. The conditions of using Rie is the same as that
of Bison. See "README.RIE" file for more detail.
The distribution is available via anonymous ftp under the
directory of `/pub/Rie' on the ftp site:
ftp.is.titech.ac.jp
The distribution includes:
* C source code.
* introduction and users manual of Rie (40 pages).
* A smaller example: static semantics analyzer.
* A larger example: PL/0 compiler.
Bug reports, suggestions, contributions are welcome to
rie-comments@is.titech.ac.jp
Yoshiki Ohshima
Department of Information Science
Tokyo Institute of Technology
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.