Mercurial > repos > tabletprog
annotate modules/ast.tp @ 247:b76f683d076e
Finish moving ast object definitions to a separate ast module
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 08 Jan 2014 19:27:19 -0800 |
parents | 8c81afd6d2d3 |
children | 004946743678 |
rev | line source |
---|---|
246
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1 { |
247
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
2 _binary <- 0 |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
3 _string <- 1 |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
4 _int <- 2 |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
5 _symbol <- 3 |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
6 _call <- 4 |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
7 _object <- 5 |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
8 _sequence <- 6 |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
9 _assignment <- 7 |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
10 _lambda <- 8 |
246
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
11 |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 #{ |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 binary <- { _binary } |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 stringlit <- { _string } |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 intlit <- { _int } |
247
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
16 sym <- { _symbol } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
17 call <- { _call } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
18 obj <- { _object } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
19 sequence <- { _sequence } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
20 assignment <- { _assignment } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
21 lambda <- { _lambda } |
246
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
22 |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
23 binaryOp:withArgs <- :opname :_left _right { |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
24 #{ |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
25 nodeType <- { _binary } |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
26 left <- _left |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
27 op <- opname |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
28 right <- _right |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
29 |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
30 leftAssociative? <- { |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
31 op != "|" |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
32 } |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
33 stringIndent <- :indent { |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
34 (left stringIndent: indent) . " " . op . (right stringIndent: indent) |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
35 } |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
36 string <- { |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
37 stringIndent: "" |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
38 } |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
39 } |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
40 } |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
41 |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
42 stringLit <- :_val { |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
43 #{ |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
44 nodeType <- { _string } |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
45 val <- _val |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
46 stringIndent <- :indent { |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
47 "\"" . val . "\"" |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
48 } |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
49 string <- { |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
50 stringIndent: "" |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
51 } |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
52 } |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
53 } |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
54 |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
55 intLit:withBits:andBase:signed? <- :_val :_bits :_base :_signed? { |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
56 #{ |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
57 nodeType <- { _int } |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
58 val <- _val |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
59 base <- _base |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
60 bits <- _bits |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
61 signed? <- _signed? |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
62 stringIndent <- :indent { |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
63 suffix <- "" |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
64 if: bits != 32 || (not: signed?) { |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
65 suffix <- (if: signed? {"i"} else: {"u"}) . bits |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
66 } |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
67 if: base = 16 { |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
68 "0x" . (hex: val) . suffix |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
69 } else: { |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
70 if: base = 2 { |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
71 str <- "0b" |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
72 i <- bits - 1 |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
73 printzero <- false |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
74 while: { i >= 0 } do: { |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
75 str <- str . (if: (lshift: 1 by: i) and val > 0 { |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
76 printzero <- true |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
77 "1" |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
78 } else: { |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
79 if: printzero {"0"} else: {""} |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
80 }) |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
81 i <- i - 1 |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
82 } |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
83 str . suffix |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
84 } else: { |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
85 (string: val) . suffix |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
86 } |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
87 } |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
88 } |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
89 string <- { |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
90 stringIndent: "" |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
91 } |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
92 } |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
93 } |
247
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
94 |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
95 symbol <- :_name { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
96 #{ |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
97 nodeType <- { _symbol } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
98 name <- _name |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
99 stringIndent <- :indent { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
100 name |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
101 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
102 string <- { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
103 stringIndent: "" |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
104 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
105 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
106 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
107 |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
108 funcall:withArgs:hasReceiver? <- :_tocall :_args :_receiver? { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
109 #{ |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
110 tocall <- _tocall |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
111 args <- _args |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
112 hasReceiver? <- _receiver? |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
113 stringIndent <- :indent { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
114 argparts <- [] |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
115 if: (tocall nodeType) = _symbol { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
116 argparts <- (tocall name) splitOn: ":" |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
117 } else: { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
118 argparts <- [tocall stringIndent: indent] |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
119 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
120 curarg <- args |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
121 str <- "" |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
122 if: hasReceiver? { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
123 str <- ((curarg value) stringIndent: indent) . " " |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
124 curarg <- curarg tail |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
125 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
126 foreach: argparts :idx part { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
127 str <- str . part . ":" |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
128 if: (not: (curarg empty?)) { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
129 str <- str . " " . ((curarg value) stringIndent: indent) |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
130 curarg <- curarg tail |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
131 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
132 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
133 while: { not: (curarg empty?) } do: { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
134 str <- str . " " . ((curarg value) stringIndent: indent) |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
135 curarg <- curarg tail |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
136 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
137 str |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
138 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
139 string <- { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
140 stringIndent: "" |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
141 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
142 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
143 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
144 |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
145 object <- :_messages { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
146 #{ |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
147 nodeType <- { _object } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
148 messages <- _messages |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
149 stringIndent <- :indent { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
150 nextindent <- "\t" . indent |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
151 (messages fold: "#{" with: :acc el { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
152 acc . "\n" . nextindent . (el stringIndent: nextindent) |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
153 }) . "\n" . indent . "}" |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
154 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
155 string <- { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
156 stringIndent: "" |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
157 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
158 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
159 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
160 |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
161 seqLit:array? <- :_els :_array? { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
162 #{ |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
163 nodeType <- { _sequence } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
164 els <- _els |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
165 array? <- _array? |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
166 stringIndent <- :indent { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
167 nextIndent <- "\t" . indent |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
168 (els fold: (if: array? {"#["} else: {"["}) with: :acc el { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
169 acc . "\n" . nextIndent . (el stringIndent: nextIndent) |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
170 }) . "\n" . indent . "]" |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
171 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
172 string <- { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
173 stringIndent: "" |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
174 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
175 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
176 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
177 |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
178 assign:to <- :_expr :_sym { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
179 #{ |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
180 nodeType <- { _assignment } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
181 assign <- _expr |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
182 to <- _sym |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
183 stringIndent <- :indent { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
184 (to stringIndent: indent) . " <- " . (assign stringIndent: indent) |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
185 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
186 string <- { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
187 stringIndent: "" |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
188 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
189 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
190 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
191 |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
192 lambda:withArgs <- :_exprs :_args { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
193 #{ |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
194 nodeType <- { _lambda } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
195 args <- _args |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
196 expressions <- _exprs |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
197 stringIndent <- :indent { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
198 argStr <- args join: " " |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
199 if: (argStr length) > 0 { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
200 argStr <- argStr . " " |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
201 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
202 nextIndent <- "\t" . indent |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
203 (expressions fold: argStr . "{" with: :acc el { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
204 acc . "\n" . nextIndent . (el stringIndent: nextIndent) |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
205 }) . "\n" . indent . "}" |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
206 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
207 string <- { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
208 stringIndent: "" |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
209 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
210 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
211 } |
246
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
212 } |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
213 } |