Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/musgravejw/compiler

Single pass LL(1) recursive descent compiler written in Ruby.
https://github.com/musgravejw/compiler

compiler ruby

Last synced: 24 days ago
JSON representation

Single pass LL(1) recursive descent compiler written in Ruby.

Awesome Lists containing this project

README

        

Compiler ![Build Status](https://travis-ci.org/musgravejw/compiler.svg?branch=master)
========
This is a project written in Ruby to demonstrate compiler theory concepts.
The compiler is a single pass LL(1) recursive descent compiler built from a custom grammar.

## Usage
`rake` will build everything in the 'tests' dir.

`rake clean` to clear 'target' dir.

```
compiler
├── README.md
├── compiler.rb
├── rakefile
├── src
│   ├── code_gen.rb
│   ├── parser.rb
│   ├── runtime.rb
│   ├── scanner.rb
│   └── semantic.rb
└── tests
└── correct
├── fromJake.src
├── test_heap.src
├── test_program.src
├── test_program_array.src
├── test_program_minimal.src
└── test_program_with_errors.src

3 directories, 14 files
```

## Language
```
::=

::=
program is

::=
( ; )*
begin
( ; )*
end program

::=
[ global ]
[ global ]

::=
[ [ ] ]

::=
integer |
float |
bool |
string

::=

::=
procedure ( [ ] )

::=
( ; )*
begin
( ::=
, |

::=
( in | out )

::=
|
|
|
|

::=
:=

::=
if ( ) then ( ; )+
[ else ( ; )+ ]
end if

::=
for ( ; )
( ; )*
end for

::=
( [ ] )

::=
, |

::=
[ [ ] ]

::=
& |
| |
[ not ]

::=
+ |
- |

::=
< |
> |
>= |
<= |
== |
!= |

::=
* |
/ |

::=
( ) |
[ - ] |
[ - ] |
|
true |
false |

::=
[ [ ] ]

::=
[a-zA-Z][a-zA-Z0-9_]*

::=
[0-9][0-9_]*[.[0-9_]*]?

::=
"[a-zA-Z0-9 _,;:.]*"
```

## Author
Written by [John Musgrave](http://johnmusgrave.com).

## License
Licensed under the [MIT License](https://github.com/musgravejw/compiler/blob/master/LICENSE)