Skip to content

Commit 1c396bc

Browse files
committed
Creatio ex nihilo
0 parents  commit 1c396bc

File tree

4 files changed

+74
-0
lines changed

4 files changed

+74
-0
lines changed

.editorconfig

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
8+
9+
[*.md]
10+
indent_style = space
11+
indent_size = 2
12+
13+
[{Gemfile,*.gemspec,*.rb}]
14+
indent_style = space
15+
indent_size = 2
16+
17+
[*.toml]
18+
indent_style = space
19+
indent_size = 2

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Gemfile.lock
2+
samples/

.ruby-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.3.1

README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
## Rip Compiler
2+
3+
4+
### Assumptions
5+
6+
A project root is demarkated by a `package.toml` file. Source files are to be kept in `./source`. Dependencies are installed in flattened tree under `./vender`. Authors may configure source control to ignore `vendor`, but an exception should be made for the vendor cache (`./vendor/.cache`, see `.gitignore`). This allows for an virtual dependency lock "file". This also allows for offline compiles, as dependencies are committed into source control. The load path is managed at compile time and will only include direct dependencies (so *not* transitive dependencies).
7+
8+
9+
### Usage
10+
11+
`rip-compile` takes a Rip source file as a starting point and a name for the resulting binary. Output directories in the binary name will be created if they don't exist:
12+
13+
`$ rip compile source/main.rip build/rip-spec`
14+
15+
Then run with:
16+
17+
`$ ./build/rip-spec`
18+
19+
Specifying `--` as the output file sends the output to standard out. You probably want to redirect this to another process:
20+
21+
`$ rip compile source/main.rip --`
22+
23+
The output argument is not required if the `executables` table in `package.toml` specifies an output for the input file:
24+
25+
`$ rip compile source/main.rip`
26+
27+
If you simply wish to build everything listed in `executables`:
28+
29+
`$ rip compile`
30+
31+
32+
Compile and execute:
33+
34+
`$ rip execute source/main.rip`
35+
36+
Or just:
37+
38+
`$ rip source/main.rip`
39+
40+
41+
### Notes
42+
43+
compiler optimization passes on ast:
44+
45+
* transform interpolation into concatenation (followed by `.to_string()`)
46+
* lift import
47+
* lift literals, replace with references
48+
* insert return
49+
* expand overloads, replace `self` with generated name
50+
* lift closures, rewrite parameters to accept closed locals, rewrite call sites to propogate closed locals
51+
* flatten nested calls, insert local references (`a(b(c(42)))` => `r1 = c(42); r2 = b(r1); a(r2)`)
52+

0 commit comments

Comments
 (0)