bootstrap

view genesis/ometa/ometa-interpreter.church @ 750:526dd0f072f9

cleanup new interpreter
author John Leuner <jewel@subvert-the-dominant-paradigm.net>
date Sun Mar 27 13:51:45 2011 +0200 (13 months ago)
parents c76fc859ddae
children 96f6eb9a4278
line source
1 extern o-fail
3 class ometa-rule
4 with-slots
5 name
6 instructions
7 original-instructions
8 variables
9 action-closures
11 get-variable-position rule-variables var
12 position (intern var) (reverse rule-variables)
14 get-variable-position-new rule-variables sym
15 (position sym rule-variables)
17 global ometa-church-parser = nil
19 ometa-parse-array-with-interpreter array
20 if (null? ometa-church-parser)
21 ometa-church-parser = new 'new-church-parser :church-grammar-file-name "genesis/church/church.g"
22 parse-array ometa-church-parser array
24 replace-variables-with-positions variables form quoting
25 if (null? form)
26 form
27 else
28 typecase form
29 cons
30 cond
31 (and quoting (eq? (first form) 'unquote))
32 pos = position (second form) variables
33 `[_ometa_get_variable ,pos]
34 (and quoting (eq? (first form) 'unquote-splice))
35 pos = position (second form) variables
36 `[_ometa_get_variable_splice ,pos]
37 (eq? (first form) 'quote)
38 ,(replace-variables-with-positions variables (second form) true)
39 (eq? (first form) 'quasiquote)
40 loop
41 for f in (second form)
42 collect (replace-variables-with-positions variables f true)
43 true
44 loop
45 for f in form
46 collect (replace-variables-with-positions variables f quoting)
47 else
48 if (string? form)
49 form
50 else
51 if quoting
52 if (and (cons? form) (eq? (first form) 'quote))
53 form
54 else
55 `[quote ,form]
56 else
57 pos = get-variable-position-new variables form
58 if (null? pos)
59 error "var not found " (list form variables)
60 `[_ometa_get_variable ,pos]