annotate code/lmc.tp @ 3:a9a2ad99adfb

Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
author Michael Pavone <pavone@retrodev.com>
date Fri, 25 Jul 2014 10:52:17 -0700
parents 71e8d638da5c
children eaf0a014d18b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
1 {
3
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
2 inst <- :_name _args {
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
3 #{
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
4 name <- _name
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
5 args <- _args
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
6 translateLabels <- :labelDict {
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
7 missing <- #[]
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
8 foreach: args :idx arg {
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
9 if: (object does: arg understand?: "isString?") && (arg isString?) {
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
10 labelDict ifget: arg :translated {
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
11 args set: idx translated
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
12 } else: {
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
13 missing append: arg
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
14 }
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
15 }
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
16 }
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
17 missing
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
18 }
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
19 label <- ""
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
20 string <- {
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
21 (if: label != "" { ";" . label . "\n " } else: { " " }
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
22 ) . name . " " . (args join: " ")
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
23 }
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
24 }
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
25 }
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
26 _nextLabel <- 0
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
27 _setLabel <- :inst {
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
28 inst
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
29 }
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
30 prog <- #{
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
31 instructions <- #[]
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
32 add <- :inst {
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
33 instructions append: (_setLabel: inst)
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
34 }
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
35 makeLabel <- :suffix {
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
36 num <- _nextLabel
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
37 _nextLabel <- _nextLabel + 1
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
38 "" . num . "_" . suffix
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
39 }
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
40 labels <- dict hash
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
41 setLabel <- :name {
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
42 labels set: name pc
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
43 _setLabel <- :inst {
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
44 _setLabel <- :i { i }
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
45 inst label!: name
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
46 }
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
47 }
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
48 pc <- { instructions length }
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
49 print <- {
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
50 foreach: instructions :idx i {
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
51 missing <- i translateLabels: labels
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
52 if: (missing length) > 0 {
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
53 error: "Undefined labels " . (missing join: ", ") . " at address " . idx
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
54 }
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
55 print: (string: i) . "\n"
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
56 }
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
57
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
58 }
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
59 }
2
71e8d638da5c Add operator support to lmc
Michael Pavone <pavone@retrodev.com>
parents: 1
diff changeset
60 error <- :msg {
71e8d638da5c Add operator support to lmc
Michael Pavone <pavone@retrodev.com>
parents: 1
diff changeset
61 (file stderr) write: "Error - " . msg . "\n"
71e8d638da5c Add operator support to lmc
Michael Pavone <pavone@retrodev.com>
parents: 1
diff changeset
62 }
71e8d638da5c Add operator support to lmc
Michael Pavone <pavone@retrodev.com>
parents: 1
diff changeset
63
1
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
64 _exprHandlers <- dict hash
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
65
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
66 compileExpr <- :expr {
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
67 _exprHandlers ifget: (expr nodeType) :handler {
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
68 handler: expr
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
69 } else: {
2
71e8d638da5c Add operator support to lmc
Michael Pavone <pavone@retrodev.com>
parents: 1
diff changeset
70 error: "Unhandled node type " . (expr nodeType)
1
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
71 }
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
72 }
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
73
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
74 _exprHandlers set: (ast intlit) :expr {
3
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
75 prog add: (inst: "LDC" #[(expr val)])
1
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
76 }
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
77
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
78 _exprHandlers set: (ast sequence) :expr {
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
79 count <- 0
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
80 foreach: (expr els) :idx el {
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
81 compileExpr: el
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
82 count <- count + 1
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
83 }
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
84 if: (expr array?) {
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
85 count <- count - 1
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
86 } else: {
3
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
87 prog add: (inst: "LDC" #[0])
1
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
88 }
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
89 while: { count > 0} do: {
3
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
90 prog add: (inst: "CONS" #[])
1
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
91 count <- count - 1
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
92 }
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
93 }
2
71e8d638da5c Add operator support to lmc
Michael Pavone <pavone@retrodev.com>
parents: 1
diff changeset
94
71e8d638da5c Add operator support to lmc
Michael Pavone <pavone@retrodev.com>
parents: 1
diff changeset
95 _opNames <- dict hash
71e8d638da5c Add operator support to lmc
Michael Pavone <pavone@retrodev.com>
parents: 1
diff changeset
96 _opNames set: "+" "ADD"
71e8d638da5c Add operator support to lmc
Michael Pavone <pavone@retrodev.com>
parents: 1
diff changeset
97 _opNames set: "-" "SUB"
71e8d638da5c Add operator support to lmc
Michael Pavone <pavone@retrodev.com>
parents: 1
diff changeset
98 _opNames set: "*" "MUL"
71e8d638da5c Add operator support to lmc
Michael Pavone <pavone@retrodev.com>
parents: 1
diff changeset
99 _opNames set: "/" "DIV"
71e8d638da5c Add operator support to lmc
Michael Pavone <pavone@retrodev.com>
parents: 1
diff changeset
100 _opNames set: "|" "CONS"
71e8d638da5c Add operator support to lmc
Michael Pavone <pavone@retrodev.com>
parents: 1
diff changeset
101 _opNames set: "=" "CEQ"
71e8d638da5c Add operator support to lmc
Michael Pavone <pavone@retrodev.com>
parents: 1
diff changeset
102 _opNames set: ">" "CGT"
71e8d638da5c Add operator support to lmc
Michael Pavone <pavone@retrodev.com>
parents: 1
diff changeset
103 _opNames set: ">=" "CGTE"
71e8d638da5c Add operator support to lmc
Michael Pavone <pavone@retrodev.com>
parents: 1
diff changeset
104
71e8d638da5c Add operator support to lmc
Michael Pavone <pavone@retrodev.com>
parents: 1
diff changeset
105 _exprHandlers set: (ast binary) :expr {
71e8d638da5c Add operator support to lmc
Michael Pavone <pavone@retrodev.com>
parents: 1
diff changeset
106 if: (expr op) = "|" {
71e8d638da5c Add operator support to lmc
Michael Pavone <pavone@retrodev.com>
parents: 1
diff changeset
107 compileExpr: (expr left)
71e8d638da5c Add operator support to lmc
Michael Pavone <pavone@retrodev.com>
parents: 1
diff changeset
108 compileExpr: (expr right)
71e8d638da5c Add operator support to lmc
Michael Pavone <pavone@retrodev.com>
parents: 1
diff changeset
109 } else: {
71e8d638da5c Add operator support to lmc
Michael Pavone <pavone@retrodev.com>
parents: 1
diff changeset
110 compileExpr: (expr right)
71e8d638da5c Add operator support to lmc
Michael Pavone <pavone@retrodev.com>
parents: 1
diff changeset
111 compileExpr: (expr left)
71e8d638da5c Add operator support to lmc
Michael Pavone <pavone@retrodev.com>
parents: 1
diff changeset
112 }
3
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
113 _opNames ifget: (expr op) :i {
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
114 prog add: (inst: i #[])
2
71e8d638da5c Add operator support to lmc
Michael Pavone <pavone@retrodev.com>
parents: 1
diff changeset
115 } else: {
71e8d638da5c Add operator support to lmc
Michael Pavone <pavone@retrodev.com>
parents: 1
diff changeset
116 error: "operator " . (expr op) . " is not supported"
71e8d638da5c Add operator support to lmc
Michael Pavone <pavone@retrodev.com>
parents: 1
diff changeset
117 }
71e8d638da5c Add operator support to lmc
Michael Pavone <pavone@retrodev.com>
parents: 1
diff changeset
118 }
3
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
119
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
120 _funHandlers <- dict hash
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
121 _funHandlers set: "if:else" :args {
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
122 compileExpr: (args value)
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
123 args <- args tail
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
124 tlabel <- prog makeLabel: "true"
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
125 flabel <- prog makeLabel: "false"
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
126 prog add: (inst: "SEL" #[
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
127 tlabel
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
128 flabel
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
129 ])
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
130 prog setLabel: tlabel
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
131 foreach: ((args value) expressions) :idx expr {
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
132 compileExpr: expr
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
133 }
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
134 args <- args tail
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
135 prog setLabel: flabel
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
136 foreach: ((args value) expressions) :idx expr {
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
137 compileExpr: expr
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
138 }
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
139 }
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
140 _funHandlers set: "isInteger?" :args {
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
141 compileExpr: (args value)
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
142 prog add: (inst: "ATOM" #[])
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
143 }
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
144 _funHandlers set: "value" :args {
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
145 compileExpr: (args value)
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
146 prog add: (inst: "CAR" #[])
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
147 }
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
148 _funHandlers set: "tail" :args {
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
149 compileExpr: (args value)
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
150 prog add: (inst: "CDR" #[])
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
151 }
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
152
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
153 _exprHandlers set: (ast call) :expr {
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
154 tc <- (expr tocall)
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
155 if: (tc nodeType) = (ast sym) {
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
156 _funHandlers ifget: (tc name) :handler {
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
157 handler: (expr args)
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
158 } else: {
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
159 error: "function calls not implemented yet"
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
160 }
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
161 } else: {
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
162 error: "call expression to value not implemented yet - " . tc
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
163 }
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
164 }
1
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
165 #{
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
166 compile <- :code {
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
167 res <- parser top: code
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
168 if: res {
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
169 outer <- res yield
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
170 main_fun <- false
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
171 others <- dict hash
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
172 foreach: (outer messages) :idx msg {
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
173 if: ((msg to) name) = "main" {
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
174 main_fun <- msg assign
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
175 } else: {
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
176 others set: ((msg to) name) (msg assign)
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
177 }
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
178 }
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
179 foreach: (main_fun expressions) :idx expr {
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
180 compileExpr: expr
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
181 }
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
182 foreach: others :name fun {
3
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
183 prog setLabel: name
1
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
184 foreach: (fun expressions) :idx expr {
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
185 compileExpr: expr
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
186 }
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
187 }
3
a9a2ad99adfb Rework lmc a bit to support labels in generated code. Add support for certain special funcall expressions, namely: if:else, isInteger? value and tail which translate to SEL ATOM CAR and CDR respectively
Michael Pavone <pavone@retrodev.com>
parents: 2
diff changeset
188 print: prog
1
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
189 } else: {
2
71e8d638da5c Add operator support to lmc
Michael Pavone <pavone@retrodev.com>
parents: 1
diff changeset
190 error: "Parse failed!"
1
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
191 }
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
192 }
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
193
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
194 compileFile <- :filename {
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
195 f <- file open: filename
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
196 compile: (f readAll)
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
197 }
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
198
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
199 main <- :args {
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
200 if: (args length) > 1 {
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
201 compileFile: (args get: 1)
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
202 } else: {
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
203 print: "Usage lmc FILE\n"
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
204 }
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
205 }
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
206 }
68d1447bfdbe Support for compiling lists, tuples and integer literals in lmc. Added small test lm program for exercising compiler.
Michael Pavone <pavone@retrodev.com>
parents: 0
diff changeset
207 }