https://github.com/drakmord2/rec-compiler
A compiler for the REC language implemented in Java.
https://github.com/drakmord2/rec-compiler
ada compiler java
Last synced: 2 months ago
JSON representation
A compiler for the REC language implemented in Java.
- Host: GitHub
- URL: https://github.com/drakmord2/rec-compiler
- Owner: Drakmord2
- License: gpl-3.0
- Created: 2017-06-18T06:12:50.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-06-30T23:31:13.000Z (almost 8 years ago)
- Last Synced: 2025-01-01T21:44:30.795Z (4 months ago)
- Topics: ada, compiler, java
- Language: Java
- Homepage:
- Size: 179 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# REC Compiler
A compiler for the REC language implemented in Java.
## REC programming language overview
REC is based on the ADA language.```ada
global num : Integer := 8;function fibonacci(pos : Integer) return Integer is
begin
if pos <= 0 then
return 0;
end if;
if pos < 3 then
return 1;
end if;
return fibonacci(pos-1) + fibonacci(pos-2);
end fibonacci;procedure Main () is
begin
show fibonacci(num);
return;
end Main;
```
You can find REC's context-free grammars written in an EBNF variant on [/docs](https://github.com/Drakmord2/rec-compiler/tree/develop/docs)## The Compiler
Right now lexical, syntatic, and semantic analysis are performed. Code generation will be added on the next release.* **Implementation**
* The Scanner simulates a Deterministic Finite Automaton (DFA) to create Tokens
* The Parser builds an Abstract Syntax Tree (AST) using the Recursive-descent parsing algorithm
* The Checker decorates the AST with information from indentification and type checking using the Visitor pattern
## How to useWhile an executable is not available, build the project
```bash
$> cd /Path/To/Project/root/$> javac -d Compilador/bin -cp Compilador/src Compilador/src/compiler/Compiler.java
```Then create an alias for the compiler with
```bash
$> alias compile="java -cp Compilador/bin compiler.Compiler"
```Now you can compile your REC programs from the command line using
```bash
$> compile /some/path/program.rec
```