annotate modules/ast.tp @ 252:004946743678

Added code for building a method symbol table
author Michael Pavone <pavone@retrodev.com>
date Sat, 10 May 2014 19:11:01 -0700
parents b76f683d076e
children be224817a14b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 }
252
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
39 fold:with <- :acc :fun {
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
40 acc <- fun: acc self
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
41 acc <- _left fold: acc with: fun
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
42 _right fold: acc with: fun
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
43 }
246
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
44 }
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
45 }
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
46
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
47 stringLit <- :_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 nodeType <- { _string }
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
50 val <- _val
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
51 stringIndent <- :indent {
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
52 "\"" . val . "\""
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 string <- {
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
55 stringIndent: ""
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
56 }
252
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
57 fold:with <- :acc :fun {
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
58 fun: acc self
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
59 }
246
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
60 }
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
61 }
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
62
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
63 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
64 #{
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
65 nodeType <- { _int }
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
66 val <- _val
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
67 base <- _base
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
68 bits <- _bits
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
69 signed? <- _signed?
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
70 stringIndent <- :indent {
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
71 suffix <- ""
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
72 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
73 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
74 }
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
75 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
76 "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
77 } else: {
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
78 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
79 str <- "0b"
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
80 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
81 printzero <- false
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
82 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
83 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
84 printzero <- true
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
85 "1"
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
86 } else: {
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
87 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
88 })
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
89 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
90 }
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
91 str . suffix
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
92 } else: {
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
93 (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
94 }
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
95 }
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
96 }
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
97 string <- {
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
98 stringIndent: ""
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
99 }
252
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
100 fold:with <- :acc :fun {
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
101 fun: acc self
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
102 }
246
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
103 }
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
104 }
247
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 symbol <- :_name {
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 nodeType <- { _symbol }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
109 name <- _name
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
110 stringIndent <- :indent {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
111 name
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
112 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
113 string <- {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
114 stringIndent: ""
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
115 }
252
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
116 fold:with <- :acc :fun {
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
117 fun: acc self
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
118 }
247
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 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
121
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
122 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
123 #{
252
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
124 nodeType <- { _call }
247
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
125 tocall <- _tocall
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
126 args <- _args
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
127 hasReceiver? <- _receiver?
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
128 stringIndent <- :indent {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
129 argparts <- []
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
130 if: (tocall nodeType) = _symbol {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
131 argparts <- (tocall name) splitOn: ":"
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
132 } else: {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
133 argparts <- [tocall stringIndent: indent]
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
134 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
135 curarg <- args
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
136 str <- ""
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
137 if: hasReceiver? {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
138 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
139 curarg <- curarg tail
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
140 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
141 foreach: argparts :idx part {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
142 str <- str . part . ":"
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
143 if: (not: (curarg empty?)) {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
144 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
145 curarg <- curarg tail
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 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
148 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
149 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
150 curarg <- curarg tail
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
151 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
152 str
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
153 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
154 string <- {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
155 stringIndent: ""
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
156 }
252
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
157 fold:with <- :acc :fun {
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
158 acc <- fun: acc self
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
159 _args fold: acc with: :acc el {
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
160 fun: acc el
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
161 }
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
162 }
247
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
163 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
164 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
165
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
166 object <- :_messages {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
167 #{
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
168 nodeType <- { _object }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
169 messages <- _messages
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
170 stringIndent <- :indent {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
171 nextindent <- "\t" . indent
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
172 (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
173 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
174 }) . "\n" . indent . "}"
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 string <- {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
177 stringIndent: ""
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
178 }
252
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
179 fold:with <- :acc :fun {
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
180 acc <- fun: acc self
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
181 messages fold: acc with: :acc el {
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
182 fun: acc el
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
183 }
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
184 }
247
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 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
187
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
188 seqLit:array? <- :_els :_array? {
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 nodeType <- { _sequence }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
191 els <- _els
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
192 array? <- _array?
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
193 stringIndent <- :indent {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
194 nextIndent <- "\t" . indent
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
195 (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
196 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
197 }) . "\n" . indent . "]"
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
198 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
199 string <- {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
200 stringIndent: ""
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
201 }
252
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
202 fold:with <- :acc :fun {
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
203 acc <- fun: acc self
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
204 els fold: acc with: :acc el {
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
205 fun: acc el
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
206 }
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
207 }
247
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
208 }
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 assign:to <- :_expr :_sym {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
212 #{
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
213 nodeType <- { _assignment }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
214 assign <- _expr
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
215 to <- _sym
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
216 stringIndent <- :indent {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
217 (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
218 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
219 string <- {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
220 stringIndent: ""
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
221 }
252
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
222 fold:with <- :acc :fun {
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
223 acc <- fun: acc self
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
224 acc <- fun: acc _sym
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
225 fun: acc _expr
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
226 }
247
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
227 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
228 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
229
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
230 lambda:withArgs <- :_exprs :_args {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
231 #{
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
232 nodeType <- { _lambda }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
233 args <- _args
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
234 expressions <- _exprs
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
235 stringIndent <- :indent {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
236 argStr <- args join: " "
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
237 if: (argStr length) > 0 {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
238 argStr <- argStr . " "
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
239 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
240 nextIndent <- "\t" . indent
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
241 (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
242 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
243 }) . "\n" . indent . "}"
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
244 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
245 string <- {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
246 stringIndent: ""
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
247 }
252
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
248 fold:with <- :acc :fun {
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
249 acc <- fun: acc self
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
250 expressions fold: acc with: :acc el {
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
251 fun: acc el
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
252 }
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
253 }
247
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
254 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
255 }
246
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
256 }
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
257 }