The samples available for some of the compiler generators are based on the following grammar: Lavanda.
A small set of examples to use with each one of the compiler generated is available here.
An article comparing 3 of this compiler generators (Lex/Yacc, LISA and ANTLR-3) is avaliable here.
ANTLR
ANTLR, ANother Tool for Language Recognition, (formerly
PCCTS) is a language tool that provides a framework for constructing
recognizers, compilers, and translators from grammatical descriptions
containing Java, C#, C++, or Python actions. ANTLR provides support for
tree construction, tree walking, and translation.
Examples:
- version 2.0: (Lavanda.w
Lavanda.pdf)
Contribution by: Rodrigo Baptista, at January 2006
- version 3.0:
- Lavanda1.g --- An approach using global variables;
- Lavanda2.g --- An approach using attributes.
Contribution by: Rúben Fonseca, at January 2007
CoCo/R
Coco/R is a compiler generator, that takes an attribute grammar of a source language
and generates a scanner, parser and a semantic evaluator for this
language. The scanner works as a deterministic finite automaton. The parser is
recursive descent. LL(1) conflicts can be resolved by a multi-symbol lookahead
or by semantic checks.
Inherited and synthesized attributes are allowed; however evaluation is done in a
top-down, left to right, tree traversal, during parsing.
Thus the class of accepted grammars is LL(k) for an arbitrary k.
There are versions of Coco/R for Java, C#, C++, Delphi, Modula-2, Oberon and
other languages.
Manual
Examples: Lavanda.w , Lavanda.pdf
Original Page
JavaCC
Java Compiler Compiler (JavaCC) is the most popular parser generator for use with Java applications.
In addition to the parser generator itself, JavaCC provides other standard capabilities related to parser
generation such as tree building (via a tool called JJTree included with JavaCC), actions, debugging, etc.
Manual
Examples: Lavanda.w , Lavanda.pdf
Executable (jar): The Lavanda compiler to invoque in command line as "java -jar Lavanda.jar input.txt"
(Lavanda.jar).
Original Page
Contribution by: Nuno Oliveira, at August 2007
Lex/Yacc
Lex - A Lexical Analyzer Generator
Lex helps write programs whose control flow is directed by
instances of regular expressions in the input stream.
It is well suited for editor-script type transformations and for
segmenting input in preparation for a parsing routine. Lex source is a table of
regular expressions and corresponding program fragments. The table is
translated to a program which reads an input stream, copying it to an output
stream and partitioning the input into strings which match the given
expressions. As each such string is recognized the corresponding program
fragment is executed. The recognition of the expressions is performed by a
deterministic finite automaton generated by Lex. The program fragments written
by the user are executed in the order in which the corresponding regular
expressions occur in the input stream.
Manual
Original Page
Yacc: Yet Another Compiler-Compiler
Computer program input generally has some structure; in fact,
every computer program that does input can be thought of as defining an ``input
language'' which it accepts.
An input language may be as complex as a programming language,
or as simple as a sequence of numbers. Unfortunately, usual input facilities
are limited, difficult to use, and often are lax about checking their inputs
for validity.
Yacc provides a general tool for describing the input to a
computer program. The Yacc user specifies the structures of his input, together
with code to be invoked as each such structure is recognized. Yacc turns such a
specification into a subroutine that handles the input process; frequently,
it is convenient and appropriate to have most of the flow of control in the
user's application handled by this subroutine.
Manual
Original Page
Examples: Lavanda.w , Lavanda.pdf
Lisa
LISA is a set of related tools such
as scanner generator, parser generator, a semantic evaluator, graphic
tools, editor and conversion tools, which are integrated by well designed
interfaces.
Therefore, it has the advantages of a single system and
federated environment. LISA and the generated processors are written in Java
which enables high portability to different platforms.
User friendly multiwindow interface enable us to write
formal language description in a quick and simple manner.
Manual
Examples: Lavanda.w , Lavanda.pdf
Original Page
LRC
LRC is a generator for graphical, easy to use, language-oriented
tools. LRC accepts as input a Higher Order Attribute Grammar specifying a
particular language and generates incremental attribute evaluators. LRC
generates tools that have advanced interactive interfaces and these interfaces
are specified within the AG formalism.
Manual
Examples: Lavanda.w , Lavanda.pdf
Original Page
SableCC
SableCC is a parser generator which generates fully featured object-oriented frameworks for
building compilers, interpreters and other text parsers. In particular, generated frameworks include intuitive
strictly-typed abstract syntax trees and tree walkers. SableCC also keeps a clean separation between
machine-generated code and user-written code which leads to a shorter development cycle.
Manual
Examples: Lavanda.w , Lavanda.pdf
A tutorial explaining how to write a compiler with SableCC: Writing a compiler with SableCC
Original Page
Contribution by: Nuno Oliveira, at August 2007
Silver
Silver is an attribute grammar (AG) specification language and evaluator.
What makes Silver unique among attribute grammar tools is that it is designed to support the
specification of extensible language and is itself extensible.
Thus general purpose and domain specific features can be easily
added to it.
Thus, it supports a myriad of attribute grammar
features that are found separately in different AG systems.
These
features include higher-order attributes, reference attributes,
collection attributes, forwarding, aspect productions, and numerous
convenience features. Various general purpose language features can
also be added as extensions. These include pattern-matching and
parametric polymorphism which dramatically simplify the
specification of general purpose computations in Silver.
by Eric Van Wick
Manual
Examples: Lavanda.w , Lavanda.pdf
Original Page
Contribution by: Nuno Oliveira, at July 2007