-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompiler.qon
121 lines (113 loc) · 3.66 KB
/
compiler.qon
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
; compiler.qon - the compiler for quon
((includes q/base.qon q/compiler.qon q/macros.qon q/lists.qon q/newparser.qon q/perl.qon q/ansi3.qon q/tests.qon q/node2.qon q/boolean.qon)
(types)
(functions
(int start ()
(declare
(bool runTests false)
(list cmdLine nil)
(box filenameBox nil)
(string filename "")
(bool runPerl false)
(bool runJava false)
(bool runAst false)
(bool runNode false)
(bool runNode2 false)
(bool runIma false)
(bool runAnsi3 false)
(bool runBash false)
(bool runTree false))
(body
(set cmdLine (listReverse (argList globalArgsCount 0 globalArgs)))
;(printf "//") (display cmdLine)
(if (> (listLength cmdLine) 1)
(then (set filenameBox (second cmdLine)))
(else (set filenameBox (boxString "compiler.qon"))))
(set filename (unBoxString filenameBox))
;(printf "#Parsing file: ")(display filename)(newLine 0)
(set releaseMode (inList (boxString "--release") cmdLine))
(set runTests (inList (boxString "--test") cmdLine))
(set runJava (inList (boxString "--java") cmdLine))
(set runPerl (inList (boxString "--perl") cmdLine))
(set runAst (inList (boxString "--ast") cmdLine))
(set runTree (inList (boxString "--tree") cmdLine))
(set runNode (inList (boxString "--node") cmdLine))
(set runNode2 (inList (boxString "--node2") cmdLine))
(set runIma (inList (boxString "--ima") cmdLine))
(set runAnsi3 (inList (boxString "--ansi3") cmdLine))
(set runBash (inList (boxString "--bash") cmdLine))
(set globalTrace (inList (boxString "--trace") cmdLine))
(set globalStepTrace (inList (boxString "--steptrace") cmdLine))
(if (inList (boxString "--help") cmdLine)
(then
(printf "Usage: quon file [options]\n\nNote the options go after the file name\n")
(printf "Options:\n")
(printf " --help Display this help\n")
(printf " --release Compile in release mode\n")
(printf " --test Run the test suite\n")
(printf " --java Compile to Java\n")
(printf " --perl Compile to Perl\n")
(printf " --ast Compile to the Abstract Syntax Tree\n")
(printf " --tree Compile to an s-expression tree\n")
(printf " --node Compile to Node.js\n")
(printf " --node2 Compile to Node.js, new outputter\n")
(printf " --ima Compile to Imaginary, the human-friendly language\n")
(printf " --ansi3 Compile to ANSI C (quon version 3)\n")
(printf " --bash Compile to Bash\n")
(printf " --trace Trace execution\n")
(printf " --steptrace Step trace execution\n")
(printf " --help Display this help\n")
(exit 0)
)
(else )
)
(if runTests
(then
(test0)
(test1)
(test2)
(test3)
(test4)
(test5)
(test6)
(test7)
(test8)
(test9)
(test10)
(test12)
(test13)
(test15)
(test16)
(test17)
(test18)
(test19)
(test20)
(test21)
(test22)
(test23)
(test24)
(test25)
(test27)
;(test22)
(printf "\n\nAfter all that hard work, I need a beer...\n")
(beers 9))
(else
(if runTree
(then (display (macrowalk (treeCompile filename))))
(else
(if runNode2
(then (node2Compile filename)(printf "\n"))
(else
(if runPerl
(then (perlCompile filename) (printf "\n"))
(else
(if runAnsi3
(then (ansi3Compile filename) (printf "\n"))
(else
(ansi3Compile filename) (printf "\n"))))))
))))
(return 0)
)
(return 0)
)
))