The Compiler Generator Coco/R
Hanspeter Mössenböck,
Markus Löberbauer,
Albrecht Wöß, University of Linz
Last update: December 3, 2018
Documentation |
Coco/R for C#,
Java,
C++,
F#,
VB.Net,
Delphi,
Swift,
Oberon,
other languages |
projects using Coco/R |
Contributions |
Cookbook |
Tools |
Mailing list
Coco/R is a compiler generator, which takes an attributed grammar
of a source language and generates a scanner and a parser for this
language. The scanner works as a deterministic finite automaton.
The parser uses recursive descent. LL(1) conflicts can be resolved
by a multi-symbol lookahead or by semantic checks. Thus the class
of accepted grammars is LL(k) for an arbitrary k.
There are versions of Coco/R for different languages (see below).
The latest versions from the University of Linz are those for C#,
Java and C++, which can be downloaded from this site.
An older (non-reentrant) version of Coco/R for C# and Java can be obtained from
here.
Coco/R is distributed under the terms of the
GNU General Public License
(slightly extended).
New:
If you used Coco/R for a project that might also be of interest to others,
please send us a link to a Web page describing the project. We will put those
references online here.
license.txt
|
GNU General Public License (slightly extended)
|
UserManual.pdf
|
Language specification and user guide
|
DataStructures.pdf
|
Description of the data structures in Coco/R (for those who want to
understand the implementation of Coco/R)
|
TestSuite.zip
|
A test suite for Coco/R (see readme.pdf)
|
JMLC'03 paper
|
LL(1) Conflict Resolution in a Recursive Descent Compiler Generator
|
Tutorial
|
Powerpoint slides of a Coco/R tutorial given at JMLC'06 (by Hanspeter Mössenböck)
|
another Tutorial
|
about using Coco/R (by Henrik Teinelund)
|
AST.pdf, AST.zip
|
Tutorial showing how to build abstract syntax trees with Coco/R
|
Coco.exe
|
the executable
|
Scanner.frame
|
the frame file from which the scanner is generated
|
Parser.frame
|
the frame file from which the parser is generated
|
CocoSourcesCS.zip
|
the sources (put them in a subdirectory and run build.bat)
|
log.html
|
change log
|
Samples |
|
Taste.zip
|
the sources of the sample compiler (Taste) described in the user manual.
|
CSharp.ATG
|
a sample ATG for C# (a template) that produces a complete scanner and parser for C# source code.
Add your own semantic actions to customize your parser. (last update 2005-06-29)
|
CSParser.cs
|
the source code for the main class of a simple sample C# parser
that uses the scanner and parser generated from the above CSharp.ATG.
It only reports the number of syntax errors found in any parsed C# source.
|
CSharp2.ATG
|
a sample ATG for C# 2.0 (C# Language Specification Working Draft 2.7, Jun, 2004)
that produces a complete scanner and parser for C# 2.0 source code.
Add your own semantic actions to customize your parser. (last update 2007-03-20)
|
CS2Parser.cs
|
the source code for the main class of a simple sample C# parser
that uses the scanner and parser generated from the above CSharp2.ATG.
It only reports the number of syntax errors found in any parsed C# 2.0 source.
|
CSharp3.atg
|
a sample ATG for C# 3.0 (C# Language Specification Version 3.0, 2007)
that produces a complete scanner and parser for C# 3.0 source code.
Add your own semantic actions to customize your parser. Attention, to
use this grammar the default Scanner.frame and Parser.frame must be updated as described
in the top of the grammar. (last update 2010-10-01)
|
C.atg
|
a sample ATG for ANSI C 89 as specified in
flash-gordon.me.uk/ansi.c.txt.
In order to resolve LL(1) conflicts you need a symbol table. A very simple example
for such a symbol table (just giving you an idea) can be downloaded from
here.
|
The C# version of Coco/R is also available from https://www.nuget.org/packages/CocoR/
Coco.jar
|
an archive containing all classes of Coco/R
|
Scanner.frame
|
the frame file from which the scanner is generated
|
Parser.frame
|
the frame file from which the parser is generated
|
CocoSourcesJava.zip
|
the sources (put them in a subdirectory and run build.bat)
|
log.html
|
change log
|
Eclipse Plug-in
|
Integration into the development environment Eclipse
|
IntelliJ Plug-in
|
Integration into the development environment IntelliJ IDEA (Thomas Scheinecker)
|
Samples |
|
Java.ATG
|
a sample ATG for Java 1.4 (a template) that produces a complete scanner and parser
for Java source code.
Add your own semantic actions to customize your parser.
|
JavaParser.java
|
the source code for the main class of a simple sample Java parser
that uses the scanner and parser generated from the above Java.ATG.
It only reports the number of syntax errors found in any parsed Java source.
|
JavaGrammar.html
|
HTML documentation of the Java grammar used in Java.ATG.
|
ported and maintained by Markus Löberbauer and Csaba Balazs
Coco.exe
|
the executable
|
Scanner.frame
|
the frame file from which the scanner is generated
|
Parser.frame
|
the frame file from which the parser is generated
|
CocoSourcesCPP.zip
|
the sources (put them in a subdirectory and run build.bat)
|
log.html
|
change log
|
Samples |
|
Taste.zip
|
the sources of the sample compiler (Taste) described in the user manual.
|
ported and maintained by Alexandre Pereira
ported and maintained by Adrian Devries
Coco.exe
|
the executable
|
Scanner.frame
|
the frame file from which the scanner is generated
|
Parser.frame
|
the frame file from which the parser is generated
|
CocoSourcesVB.zip
|
the sources (put them in a subdirectory and run build.cmd)
|
log.html
|
change log
|
Samples |
|
Taste.zip
|
the sources of the sample compiler (Taste) described in the user manual.
|
There are several versions of Coco under Delphi, ported and maintained by different people:
ported and maintained by Michael Griebling
Coco.Cod
|
Oberon archive with the sources of Coco/R; this version is not further developed and
differs from the C# and Java versions. It is also non-reentrant.
|
These versions were ported from the original version of Coco/R
and have a slightly different input language and functionality.
Many projects use Coco/R to parse data e.g. logs, configurations, and user input. Here
we list some great projects doing so. If you used Coco/R for a project that might also
be of interest to others, please send us a link to a Web page describing the project.
Books
Hanspeter Mössenböck has written a book Compilerbau
that includes a chapter on Coco/R
and its use in various scenarios. Throughout the book, attributed grammars are used for describing
translation processes. The book is in German, but an English version is in preparation.
There are also other excellent books about using Coco/R for compiler construction:
Pat Terry:
- Compiling with C# and Java
- Compilers and Compiler Generators - An Introduction with C++
|