<?xml version="1.0" ?>

<documento html="other" latex="article">

<titulo> Lrc: A Purely Functional, Higher-Order Attribute Grammar based System
</titulo>

<autor>
Joćo Saraiva <br/>
<link href="mailto:jas@di.uminho.pt"> jas@di.uminho.pt </link>
</autor>

<instituicao>

A system developed at Utrecht University by: Matthijs Kuiper, Doaitse
Swierstra, Marteen Pennings, Harald Vogt, Joćo Saraiva

<par/>

<it><small>(this page was produced/processed by <it>DocProc</it>: a tool
generated by Lrc. The Lrc logo (left) was also produced by another
tool/AG library included in Lrc)</small></it>

</instituicao>

<par/>




<capitulo nome="What is lrc?">

Lrc is a system for generating efficient incremental attribute
evaluators. Lrc can be used to generate language based editors and
other advanced interactive environments.

</capitulo>


<capitulo nome="Features of lrc">


The following features distinguish lrc from other attribute grammar
systems.

<itemize>

<item> accepts higher order attribute grammars and normal attribute
grammars </item>

<item> processes attribute grammars that are written in the
Synthesizer Specification Language </item>

<item> generates purely functional evaluators (C and Haskell-based)
</item>

<item> generates evaluators that use function memoing to realise
efficient incremental reevaluation </item>

<item>  generates editors with advanced interactive interfaces 
</item>

<item>  can bootstrap itself 
</item>

</itemize>

</capitulo>

<capitulo nome="History">

The Lrc system is a generator for purely functional language-based
systems developed at the 
<link href="http://www.cs.uu.nl">
department of Computer Science </link> at Utrecht University. Matthijs
Kuiper started constructing Lrc during his research on parallel
attribute evaluation and he is the main developer of the system.

<par/>

After having introduced higher-order attribute grammars, Harald Vogt,
Doaitse Swierstra and Matthijs Kuiper extended the Lrc system to
process higher-order attribute grammars. 

<par/>

Maarten Pennings conducted the first implementation experiments on
incremental evaluation.

<par/>

Joćo Saraiva worked on deriving purely functional attribute evaluators
for higher-order attribute grammars, and added a Haskell back-end to
the Lrc system.

<par/>

In 1998, Matthijs Kuiper moved to <link href="http://ordina.nl">Ordina
Institute</link> where he continued the development of Lrc. Matthijs
Kuiper developed a new advanced graphical user interface for Lrc, and
he is using Lrc in several industrial renovation projects.

<par/>

In 1999, Joćo Saraiva finished his PhD thesis and returned to the
<link href="http://www.di.uminho.pt">department of informatics </link>
at Minho University where he is now using the Lrc system both in
research and teaching activities. A set of generic, off-the-shelf
attribute grammar components have been incorporated to the system.

</capitulo>


<capitulo nome="Features of LRC In More detail">


<bold><it><cor cor="green">Input:</cor></it></bold>

<itemize>
<item> Higher-Order Attribute Grammar

   <par/>

   Attribute Grammar Specification Language: SSL 
   
   <par/>

   <bold><it><cor cor="black">
        Features of the higher-order attribute grammar formalism:
   </cor></it></bold>

   <par/>

   <itemize> 
   <item> The Abstract Syntax Tree is not fixed during Evaluation </item>
   <item> Semantic Functions are Redundant: 
           <par/>
           <it><cor cor="black"> Every Inductive Function can be Written in the
           AG formalism</cor></it>
           <par/>
           <it><cor cor="black"> No (foreign/alien) declarative language
             (and its processor) has to be included in the AG system 
           </cor></it> <par/>
     </item>
   <item> Provides a Component-based style of Programming for the AG 
          formalism </item>

   </itemize> 
 
   <par/>
 
   There are two Ordered Scheduling Algorithms defined in LRC:
   <it><cor cor="black">Kastens and Pennings Algorithms</cor></it>

   <itemize>
     <item> They statically schedule the traversal functions 

           <par/>

           <it><cor cor="black">
           Thus, the AG writer does not concern himself in breaking-up
           his (elegant) algorithm into traversal functions and to
           glue such functions.
           </cor></it>
           
     </item>
     <item> They statically detect circularities 

          <par/>
          <it><cor cor="black">Termination of programs is statically guaranteed (for ordered AGs) </cor></it>

           <par/>
           <it><cor cor="black">
           But, Semantic functions are not considered/analised by the standard AG techniques...  
           </cor> </it>

     </item>       
   </itemize>



</item>
</itemize>

<bold><it><cor cor="green">Output:</cor></it></bold>

<itemize>

<item> Language-based Processors (<it>eg</it>, compilers, document
processors, textual database processors, etc)
</item>

<item> Programming Environments (C based) 
  <itemize> 
  <item> Advanced Interfaces are easily specified 
          (within the AG formalism) </item>
  <item> The Interface is incrementally computed </item>
  </itemize>
</item>

<item> Purely, Strict Functional Evaluators (C and Haskell based) 
</item>

<item> Incremental Evaluators (C based) 
   <itemize> 
   <item> Tree's are collapse into DAGs using the <it>Hash Consing Techniques</it>
           <itemize> 
               <item> <it><cor cor="black">No repeated value is stored on the heap: Optimal Memory Consumption </cor></it> </item>
               <item> <it><cor cor="black">Efficient Equality Test Between Terms: A simple Pointer Comparison Suffixes</cor></it> </item>
           </itemize>
   </item>


   <item> Incremental Computation is obtained through Function Memoization
   </item>


   </itemize> 
</item>

</itemize>


<seccao nome="Other Features">

<itemize>
<item> It is partially bootstrapped
  <itemize> 
   <item>LRC front-end is written in LRC itself (The largest HAG ever written)

   <par/>
     <it><cor cor="black">
       The scheduling algorithm induces a <cor cor="red"> 11 traversal
       attribute evaluator </cor></cor></it>

   <par/>
     <it><cor cor="black"> It would be very complicated to hand-write such an evaluator </cor></it>
     
   <par/>
   </item>
  </itemize>
</item>

<item>  It produces portable C and Haskell code. 
  <itemize> 
   <item>LRC itself and the generated tools can be installed in any 
         system with an ANSI C compiler and the Tcl/Tk toolkit. </item>
  </itemize>
</item>

<item> It generates deforested attribute evaluators (Haskell-based)
</item>

<item> It generates sliced attribute evaluators (Haskell-based)

<par/>

<it><cor cor="black">(or, it extracts Aspects from an Attribute Grammar)</cor></it>
<par/>
</item>



<item> It generates readable attribute evaluators 
  <itemize> 
   <item>It generates a colored LaTeX view of the Haskell based evaluators

   </item>
  </itemize>
</item>

</itemize>

</seccao>


</capitulo>


<capitulo nome="Downloads">


An older implementation of the Lrc system is public domain and it is
available at the (former)

<link href="http://www.cs.uu.nl/groups/ST/Software/LRC/">
Lrc Homepage
</link>

This version of the system is not maintened/updated anymore. The new
Lrc system (version 4.7) will be available here soon.

<itemize>
<item> <bold>Current Version: </bold> Lrc-4.7

<par/>

By HTTP: 

<link   href="http://www.di.uminho.pt/~jas/Research/LRC/sources/lrc-4.7-1_redhat7.1.i386.rpm">
rpm for red-hat 7.1
</link> <cor cor="red">(not available yet)</cor>

</item>
</itemize>


</capitulo>





<capitulo nome="Interactive Interfaces in LRC">


<itemize>

<item> Lrc Includes a Modern GUI, ie: 

   <itemize>
     <item> Buttons, that can be pressed </item>
     <item> Menus, that can be selected </item>
     <item> <it>etc</it> </item>
   </itemize>
</item>


<item> The interface of the tools is defined within the AG formalism

  <itemize>
    <item> The interface is one attribute of the AG
  
       <itemize>
         <item> Therefor, under an incremental model of attribute 
                evaluation, the interface is incrementally computed </item>

 
       </itemize>
    </item>
  </itemize>
</item>

<item> And, the interface is incrementally displayed 
</item>


</itemize>

The Interactive Interfaces of Lrc are briefly described in this
<link   href="http://www.di.uminho.pt/~jas/Research/LRC/docs/LrcInterfaces.ps">
text </link>.

</capitulo>




<capitulo nome="Component-based programming in LRC">

The Lrc system provides a component-based style of programming within
the (higher-order) attribute grammar formalism. This style of AG
programming is described in the paper:


<itemize>
<item> Joćo Saraiva, <it> Component-based Programming for Higher-Order
Attribute Grammars</it>, proceedings of the ACM SIGPLAN SIGSOFT
Conference on Generative and Component-Based Software Engineering
(GPCE/PLI'02), Pittsburgh, USA, October 2002. (to appear) 
<link
href="http://www.di.uminho.pt/~jas/Research/Papers/GPCE02/gpce02.ps.gz"> ps
</link>,
<link
href="http://www.di.uminho.pt/~jas/Research/Papers/GPCE02/abstract.html"> abstract
</link>,
<link
href="http://www.di.uminho.pt/~jas/Research/Papers/GPCE02/bibentry.html"> bibentry
</link>
<br/>
</item>
</itemize>



<seccao nome="Modular Specifications">

<itemize>
  <item> Different semantic domains (i.e., Aspects) can be splitted into 
         different modules 

       <itemize> 
         <item>They are fused by production to form a monolithic AG</item>
       </itemize>

  </item>
  <item> The AG can be parameterized with the semantic functions 

  <par/> <it><cor cor="black">
    The semantic functions are expressed by higher-order attributes that 
    are inherited by the HAG
  </cor></it>
  <par/>

  </item>

  <item>
    AG components can be plugged-into larger AGs through higher-order
    attributes
  </item>


</itemize>

</seccao>



<seccao nome="Library of AG Components">

There are pre-defined in LRC a set of Attribute Grammar Components:


<itemize>

<item> Text Processor
</item>

<item> Document Processor 
</item>

<item> Bibliographic Textual Database Processor </item>

<item> Table Formatter 
</item>


<item> Pretty Printing Combinators </item>

<item> Html Combinators 
</item>

<item> Simple Expression Evaluator </item>
 
</itemize>

<it><cor cor="black"> They are easily plugged-in into any AG
specification within the AG formalism.  For example, the document
processor AG re-uses all the other components.
</cor></it>

<par/>

If you have a nice generic AG specification, let us know so that we
could add it to the LRC component library.


</seccao>


</capitulo>




<capitulo nome="Applications of LRC">



<itemize>

<item> Used to Specify the Front-End of Lrc</item>

<item> Used in Several Industrial Renovation Projects at Ordina Institute:
<link href="http://ordina.nl">Ordina Institute.</link>
</item>

<item> Used to Support Compiler Construction Courses 
 <itemize> 
   <item> University of Minho </item>
   <item> Utrecht University </item>
 </itemize>
</item>


<itemize>
  <item> Used to develop domain-specific languages 

     <itemize>
       <item> To Develop Combinator Libraries 
         <itemize>
           <item> Table Formatter </item>
           <item> Haskell Pretty-Printing Combinators </item>
           <item> Abstract Document Combinators </item>
         </itemize>  
       </item>
     </itemize>
  </item>

  <item> Spreadsheet-like Tools </item>

  <item> Processors and Generators of HTML and XML pages </item>
</itemize> 

</itemize>


</capitulo>




<capitulo nome="Example: The BibTex Processor">

The bibtex language is becoming a <it>de facto</it> standard for
bibliographic databases. We have defined a simple programming
environment for bibtext in Lrc. (The main part of this tool was
defined in two days: in order to be included in the introduction of my
thesis.)

<par/>

<link   href="http://www.di.uminho.pt/~jas/Research/LRC/examples/bibtex.tgz">
bibtex will be available soon
</link>



</capitulo>


<capitulo nome="Example: The Students Spreadsheet">


<itemize>

<item> This tool was proposed as the <cor cor="black">(second)</cor>
project the students had to develop in the Course on Language
Processing in the scholar year 2000/2001.
</item>

<item> It re-uses the following AG components:

<itemize> 
<item> Interactive Interface Combinators </item>
<item> Simple Expression Evaluator <cor cor="black">(first project)</cor> </item>
<item> Table Formatter Combinators </item>
<item> Html Combinators </item>
</itemize>

</item>
</itemize>

<par/>

<bold><cor cor="black"> The Attribute Grammar for this tool does not
include a single semantic function definition. Every computation is
defined within the AG formalism. Therefor, the ordered scheduling
algorithm statically guarantees the termination of this tool for all
possible (finite) inputs </cor></bold>

<par/>

<bold><cor cor="blue">
Indeed, attribute grammar programming is programming with attributes
and their equations!
</cor></bold>

<par/>

<link   href="http://www.di.uminho.pt/~jas/Research/LRC/examples/students.tgz">
The students spreadsheet will be available soon
</link>



</capitulo>




<biblio>

  
<artigo key="lrc">
  <aut>     Joćo Saraiva and Matthijs Kuiper </aut>
  <tit>     Lrc - A Generator for Incremental Language-Oriented Tools </tit>
  <ano>     1998                                                 </ano>
  <editora> 7th International Conference on Compiler Construction, CC/ETAPS'98,
            Kay Koskimies, LNCS 1383 </editora>
</artigo>

<artigo key="SAS98">
  <aut>     Doaitse Swierstra and Pablo Azero and Joćo Saraiva </aut>
  <tit>     Designing and Implementing Combinator Languages  </tit>
  <ano>     1998                                                 </ano>
  <editora> Third Summer School on Advanced Functional Programming,
            LNCS 1608 </editora>
</artigo>

<artigo key="SD99">
  <aut>     Joćo Saraiva and Doaitse Swierstra                   </aut>
  <tit>     Data Structure Free Compilation                      </tit>
  <ano>     1999                                                 </ano>
  <editora> 8th International Conference on Compiler Construction, CC/ETAPS'99,
            Stefan Jahnichen, LNCS 1575 </editora>
</artigo>


<artigo key="SSK00">
  <aut>     Joćo Saraiva  and Doaitse Swierstra and Matthijs Kuiper </aut>
  <tit>     Functional Incremental Attribute Evaluation     </tit>
  <ano>     2000                                                 </ano>
  <editora> 9th International Conference on Compiler Construction, CC/ETAPS'00,
            David Watt, LNCS 1781 </editora>
</artigo>

<artigo key="SA01">
  <aut>     Joćo Saraiva  and Pablo Azero </aut>
  <tit>     Component-based Programming for Attribute Grammars  </tit>
  <ano>     2001                                                 </ano>
  <editora> Joint Conference on Declarative Programming, 
            Luis M. Perreira e Paulo Quaresma</editora>
</artigo>


<livro key="Pennings94">
  <aut>     Maarten Pennings </aut>
  <tit>     Generating Incremental Evaluators    </tit>
  <ano>     1994                                  </ano>
</livro>

<livro key="saraiva99">
  <urlps>   ftp://ftp.cs.uu.nl/pub/RUU/CS/phdtheses/Saraiva/ </urlps>
  <aut> Joćo Saraiva                                        </aut>
  <tit> Purely Functional Implementation of Attribute Grammars </tit>
  <ano> 1999 </ano>
</livro>

</biblio>

</documento>



