-
Notifications
You must be signed in to change notification settings - Fork 3
/
method.red
64 lines (52 loc) · 1.24 KB
/
method.red
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
Red [
Title: "The Remix Interpreter Runner"
Needs: view
]
do %remix-grammar-AST.red
filename: trim system/options/args/1
rem-file: to-file filename
print ["input file:" rem-file]
; print "SOURCE CODE"
; print read rem-file
; N.B. remember to include the standard-lib
source: rejoin ["^/" read %standard-lib.rem "^/"]
append append source read rem-file "^/"
first-pass: parse source split-words
clean-lex: tidy-up first-pass
lex-symbols: spit-out-symbols clean-lex
call-back: function [
event [word!]
match? [logic!]
rule [block!]
input [series!]
stack [block!]
/extern successful-parse
][
if all [event = 'end match?][
successful-parse: true
]
if all [event = 'end not match?][
probe input
]
true
]
successful-parse: false
ast: parse/trace lex-symbols [collect program] :call-back
if not successful-parse [
print "Error: parsing failed."
quit
]
; probe ast
; print "^/FUNCTIONS"
; probe function-map
probe object-list
; do %transpiler.red
; ; print "^/TRANSPILED OUTPUT"
; transpile-functions function-map
; ; probe function-map
; red-code: transpile-main ast
; ; print []
; ; probe red-code
; print "^/PROGRAM OUTPUT"
; recycle/off ; turn garbage collector off - this is not good but stops crashes in the short term
; do red-code