# Coco/R

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Coco/R
> Markdown URL: https://mediated.wiki/source/Coco/R.md
> Source: https://en.wikipedia.org/wiki/Coco%2FR
> Source revision: 1276027269
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

**Coco/R** is a [compiler generator](/source/Compiler_generator) that takes [wirth syntax notation](/source/Wirth_syntax_notation): 6[note 1] grammars of a source language and generates a scanner and a parser for that language.[1]

The [scanner](/source/Lexical_analysis) works as a [deterministic finite automaton](/source/Deterministic_finite_automaton). It supports [Unicode](/source/Unicode) characters in [UTF-8](/source/UTF-8) encoding and can be made case-sensitive or case-insensitive. It can also recognize tokens based on their right-hand-side context. In addition to terminal symbols the scanner can also recognize [pragmas](/source/Compiler_directive), which are tokens that are not part of the syntax but can occur anywhere in the input stream (e.g. compiler directives or end-of-line characters).

The [parser](/source/Parser) uses [recursive descent](/source/Recursive_descent); [LL(1)](/source/LL_parser) conflicts can be resolved by either a multi-symbol lookahead or by semantic checks. Thus the class of accepted grammars is LL(k) for an arbitrary k. [Fuzzy parsing](/source/Fuzzy_string_searching) is supported by so-called ANY symbols that match complementary sets of tokens. Semantic actions are written in the same language as the generated scanner and parser. The parser's error handling can be tuned by specifying synchronization points and "weak symbols" in the grammar. Coco/R checks the grammar for completeness, consistency, non-redundancy as well as for LL(1) conflicts.

There are versions of Coco/R for [Java](/source/Java_(programming_language)), [C#](/source/C_Sharp_(programming_language)), [C++](/source/C%2B%2B), [Pascal](/source/Pascal_(programming_language)), [Modula-2](/source/Modula-2), [Modula-3](/source/Modula-3), [Delphi](/source/Delphi_(programming_language)), [VB.NET](/source/VB.NET), [Python](/source/Python_(programming_language)), [Ruby](/source/Ruby_(programming_language)) and other programming languages. The latest versions from the [University of Linz](/source/University_of_Linz) are those for C#, Java and C++. For the Java version, there is an [Eclipse](/source/Eclipse_(software)) plug-in and for C#, a Visual Studio plug-in. There are also sample grammars for Java and C#.

Coco/R was originally developed at the [ETHZ](/source/ETHZ) and moved with [Hanspeter Mössenböck](/source/Hanspeter_M%C3%B6ssenb%C3%B6ck) to [University of Linz](/source/Johannes_Kepler_University_of_Linz) when he got his appointment there. Coco/R is distributed under the terms of a slightly relaxed [GNU General Public License](/source/GNU_General_Public_License).

## See also

- [ANTLR](/source/ANTLR)
- [JavaCC](/source/JavaCC)
- [SableCC](/source/SableCC)

## References

1. Mössenböck, Hanspeter & Kepler, Johannes. ["The Compiler Generator Coco/R User Manual"](https://ssw.jku.at/Research/Projects/Coco/Doc/UserManual.pdf). [Johannes Kepler University Linz](/source/Johannes_Kepler_University_Linz), Institute of System Software. [Archived](https://web.archive.org/web/20120619124533/http://ssw.jku.at:80/Research/Projects/Coco/Doc/UserManual.pdf) 19 June 2012 at the Wayback Machine.

## Bibliography

- *Compiling with C# and Java*. [Addison Wesley](/source/Addison_Wesley). 2005. (A book about using Coco/R for compiler construction.)
- *Ein Compiler-Generator für Mikrocomputer - Grundlagen, Anwendungen, Programmierung in Modula-2* (in German). 1 ed. Munich, Germany: [Carl Hanser Verlag](/source/Carl_Hanser_Verlag). 1985. ISBN 3-446-14495-1. (NB. The book describes the construction of Coco in [Modula-2](/source/Modula-2).)

## External links

- [Coco/R homepage](http://www.ssw.uni-linz.ac.at/Research/Projects/Coco/)
- [Coco/R page of Pat Terry](https://web.archive.org/web/20150910072441/http://www.scifac.ru.ac.za/coco/)
- [Coco/R user manual](https://ssw.jku.at/Research/Projects/Coco/Doc/UserManual.pdf)
- [Coco/R tutorial slides (by Hanspeter Mössenböck)](https://ssw.jku.at/Research/Projects/Coco/Tutorial/)
- [Coco/R Addin for Visual Studio (by Prabir Shrestha)](http://cocor.codeplex.com/)
- [Coco/R Plugin for Visual Studio 2015, 2017](https://github.com/michaeldz/Coco.VSPlugin.VS2015)

1. In the manual, however, it is referred as [L-attributed](/source/L-attributed_grammar) [Extended Backus–Naur Form](/source/Extended_Backus%E2%80%93Naur_Form) syntax (EBNF).

---
Adapted from the Wikipedia article [Coco/R](https://en.wikipedia.org/wiki/Coco%2FR) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Coco%2FR?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
