Last change
on this file since 636 was
49,
checked in by Sam Hocevar, 15 years ago
|
- Imported original public domain release, for future reference.
|
File size:
834 bytes
|
Line | |
---|
1 | (setq __gen 0) |
---|
2 | (setq indent 0) |
---|
3 | |
---|
4 | (defun gen_sym (base) |
---|
5 | (concatenate 'string (symbol-name base) (digstr (setq __gen (+ __gen 1)) 5))) |
---|
6 | |
---|
7 | (defun print_indent (level) |
---|
8 | (if (eq level 0) |
---|
9 | nil |
---|
10 | (progn |
---|
11 | (print " ") |
---|
12 | (print_indent (- level 1))))) |
---|
13 | |
---|
14 | (defun pi () |
---|
15 | (print_indent indent)) |
---|
16 | |
---|
17 | (defun i+ () (setq indent (+ indent 2))) |
---|
18 | (defun i- () (setq indent (- indent 2))) |
---|
19 | |
---|
20 | |
---|
21 | (defun compile-if (? x y) |
---|
22 | (compile ?) |
---|
23 | (pi) (print "if (pop())\n") |
---|
24 | (pi) (print "{\n") (i+) |
---|
25 | (compile x) (i-) |
---|
26 | (pi) (print "} else\n") |
---|
27 | (pi) (print "{\n") (i+) |
---|
28 | (compile y) (i-) |
---|
29 | (pi) (print "}\n") |
---|
30 | ) |
---|
31 | |
---|
32 | |
---|
33 | (defun |
---|
34 | |
---|
35 | |
---|
36 | (defun compile (val) |
---|
37 | (if (listp val |
---|
38 | (select (car list) |
---|
39 | ('if (compile-if |
---|
40 | |
---|
41 | |
---|
42 | |
---|
43 | |
---|
44 | |
---|
45 | |
---|
46 | |
---|
47 | |
---|
48 | |
---|
49 | (print (if a 1 2)) |
---|
50 | |
---|
51 | push(a) |
---|
52 | if (pop()) |
---|
53 | push(1) |
---|
54 | else push(2); |
---|
55 | |
---|
56 | print(pop()) |
---|
Note: See
TracBrowser
for help on using the repository browser.