![]() |
The Accent Compiler Compiler
Overview |
Accent Overview Tutorial Language Installation Usage Lex Algorithms Distribution |
Compiler CompilersCompiler compilers like Yacc or Accent are used to generate language processors (such as compilers, translators, or interpreters) from high-level descriptions. You specify the grammar of your language, and the compiler compiler creates a program that processes input text written in your language. This program hierarchically decomposes the input text into phrases. For each kind of phrase you can attach semantic actions to your grammar which are elaborated when the corresponding phrase is processed.Technology from classical compiler construction becomes more and more important in the fields of domain specific languages, document processing, and automatic software generation. Authors working in these areas are experts in their field, but not necessary experts in the field of parsing technology. Whereas most programmers are familiar with the notion of grammars, it requires special education to write a grammar in such a way that it fulfills the requirements of a specific parsing approach. The Accent compiler compiler does not impose any restrictions on the user's specification. It can process the entire class of context-free grammars. So one can provide the "natural" grammar for a language and concentrate on the semantics. Yacc and Other Compiler CompilersCompiler compilers like Yacc are based on the LALR approach. This results in very efficient parsers and covers a large range of grammars. But unfortunately a user has to be familiar with this technique when his or her grammar does not fulfill its restrictions. When confronted with "shift/reduce" or "reduce/reduce" conflicts (that indicate a violation of the LALR property) the user has to adapt the grammar. This often requires an insight into the working of the parser and in many cases complicates the description of the language.Other systems use LL parsing. Conflicts that are reported by an LL generator have a more intuitive interpretation than LALR conflicts. On the other hand, these systems are even more restrictive. For example, the natural grammar for arithmetic expressions cannot be used because the approach cannot deal with left-recursive rules. In both cases the design of the grammar is influenced by the parser implementation technique. This can be avoided with Accent. The Accent Compiler CompilerAccent does not rely on specific subclasses of context-free grammars.Accent can be used like Yacc. It also cooperates with Lex. The specification language of Accent is similar to that of Yacc, but Accent uses symbolic names for attributes instead of Yacc's error-prone numbers. Accent supports both, inherited and synthezised attributes. It allows you to write your grammar in the Extended-Backus-Naur-Form, in which you can specify repetition, choices, and optional parts without introducing special rules for this purpose. In Accent, semantic actions can be inserted anywhere, there are no restrictions caused by the parser implementation. Accent even allows ambiguous grammars (grammars that can structure the same input in different ways). But if there is more than one way to parse the input, the grammar must specify which to select. When using an LALR or LL generator, ambiguous grammars result in conflicts during parser generation. In certain cases the user can select a specific choice by stating how to deal with such conflicts. This again requires knowledge of the implementation technique. For Accent we have developed an annotation framework to resolve ambiguities. It is on the abstract level of grammars and does not reflect the parsing algorithm. Moreover, this calculus is complete in the sense that it can handle each ambiguity in any grammar. "What Tool Should I Use ?"Accent grammars are much easier to write than Yacc grammars. But the generality has its price: Accent parsers require significantly more resources than parsers generated by Yacc. Nevertheless Accent is an alternative for a wide range of applications. An Accent parser for Java can process thousands of lines in a few seconds.If you don't have problems with LALR conflicts use Yacc or Bison. If you are developing a compiler that will be used by many people many times a day (or if you have to process very large data on very old computers) you should invest time to adapt your grammar for Yacc. You may also consider advanced LL tools such as ANTLR or PRECC.
Accent may be the choice if you want to create a language processor
for a specific problem in short time.
|