https://github.com/gapotchenko/turbo-cocor
Turbo Coco/R is a compile-time compiler generator which takes an attributed grammar of a source language and generates a scanner and a parser for this language.
https://github.com/gapotchenko/turbo-cocor
coco-r compiler-generator csharp grammar parse parser-generator parsing scanner-generator
Last synced: 5 months ago
JSON representation
Turbo Coco/R is a compile-time compiler generator which takes an attributed grammar of a source language and generates a scanner and a parser for this language.
- Host: GitHub
- URL: https://github.com/gapotchenko/turbo-cocor
- Owner: gapotchenko
- License: other
- Created: 2022-11-14T13:50:20.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-05-12T23:22:48.000Z (over 2 years ago)
- Last Synced: 2025-04-05T21:04:59.276Z (7 months ago)
- Topics: coco-r, compiler-generator, csharp, grammar, parse, parser-generator, parsing, scanner-generator
- Language: C#
- Homepage:
- Size: 453 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Turbo Coco/R
Turbo Coco/R is a compile-time compiler generator which takes an attributed grammar of a source language and generates a scanner and a parser for this language. It is based on the de-facto Coco/R standard and extends it to be more useful in commercial settings.
## Basics
Turbo Coco/R is very similar to once popular `lex` and `yacc` tools and their open-source `flex` and `bison` counterparts.
The main distinction of Turbo Coco/R is that it provides the support for multiple programming languages and generates both a scanner and a parser from a provided grammar file.
The produced scanners and parsers are tiny, do not have external dependendencies and thus can be embedded into any project at the source level.
The scanner works as a deterministic finite automaton.
The parser uses recursive descent.
A multi-symbol lookahead or semantic checks can resolve LL(1) conflicts. Thus the class of accepted grammars is LL(k) for an arbitrary k.
Turbo Coco/R rigorously follows the baseline [Coco/R standard](https://ssw.jku.at/Research/Projects/Coco/) while providing a plethora of improvements, extensions, and integrations.
## Getting Started
1. Install Turbo Coco/R tool using .NET package manager:
``` sh
> dotnet tool install --global Gapotchenko.Turbo.CocoR
```
2. Create your first attributed grammar file:
``` sh
> turbo-coco new grammar MyLang.atg
```
3. Create the customizable frame files* for a scanner and parser:
``` sh
> turbo-coco new frame scanner parser
```
\* A frame file defines the basic code structure of a source file generated from the grammar.
Now you can generate the actual scanner and parser source files for your grammar:
``` sh
> turbo-coco MyLang.atg
```
Once generated, the files are ready to be compiled as parts of your project.
For further guidance, see the [examples](https://github.com/gapotchenko/Turbo-CocoR/tree/main/Examples).
## Build Integration
In addition to the traditional command line approach, Turbo Coco/R offers automatic [build integration](https://github.com/gapotchenko/Turbo-CocoR/tree/main/Source/Integration/MSBuild) to streamline the development process.
## Requirements
- Turbo Coco/R tool requires .NET 7.0+ to run
Please note that:
- The produced source files are not subject to the requirements and can work under any .NET target framework
## Licensing
Turbo Coco/R is licensed under GNU General Public License v2.0.
If not otherwise stated, any source code generated by Turbo Coco/R
(other than Turbo Coco/R itself) does not fall under the GNU General
Public License.