Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/musgravejw/compiler
- Owner: musgravejw
- License: bsd-3-clause
- Created: 2013-09-25T19:10:55.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2019-12-11T19:07:14.000Z (almost 5 years ago)
- Last Synced: 2023-08-04T05:54:16.905Z (over 1 year ago)
- Topics: compiler, ruby
- Language: Ruby
- Homepage: https://musgravejw.github.io/compiler
- Size: 87.9 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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.src3 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)