Skip to content

Commit 7b23c3c

Browse files
author
ojd2
committed
Update to program names
1 parent 4e393d8 commit 7b23c3c

34 files changed

+30
-50
lines changed
163 KB
Binary file not shown.

compiler

0 Bytes
Binary file not shown.

compiler.hs

+17-34
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
type Id = String
22
--type Env = [(Id,Expr)]
33

4-
5-
6-
-- Remember that "|" = Alternative options
7-
-- The expression in Haskell "deriving Show" = Print to console
8-
-- Right is name of type being defined, left is what is in that type.
9-
10-
11-
124
-- <program> ::=
135
-- "program" <id> ":" <pars> "." (Skel program)
146
-- Program type is defined = takes the following expressions of "Id" or "Pars"
@@ -108,48 +100,39 @@ data Op = OpAdd
108100

109101

110102

111-
-- Abstract syntax tree expressions:
103+
-- Abstract syntax expression tests:
112104

113105
-- program printInt : string "int" and ExprInt of '42' int
114-
-- test = Program "printInt" ( Par ( ParId "Int" ( Struct ( StructExp ( Expression ( ExprInt 42 ) ) ) ) ) )
106+
-- printInt = Program "printInt" ( Par ( ParId "Int" ( Struct ( StructExp ( Expression ( ExprInt 42 ) ) ) ) ) )
115107

116108
-- program printString : func String "Hello World!".
117-
-- test2 = Program "printString" ( Par ( ParId "String" ( Struct ( StructExp ( Expression ( ExprString "Hello World!" ) ) ) ) ) )
109+
-- printString = Program "printString" ( Par ( ParId "String" ( Struct ( StructExp ( Expression ( ExprString "Hello World!" ) ) ) ) ) )
118110

119-
-- program assignBoolTrue : func Bool True.
120-
-- test3 = Program "assignBoolTrue" ( Par ( ParId "Bool" ( Struct ( StructExp ( Expression ( ExprBool True ) ) ) ) ) )
111+
-- program returnBoolTrue : func Bool True.
112+
-- returnBoolTrue = Program "returnBoolTrue" ( Par ( ParId "Bool" ( Struct ( StructExp ( Expression ( ExprBool True ) ) ) ) ) )
121113

122-
-- program assignBoolTrue : func Bool True.
123-
-- test4 = Program "assignBoolFalse" ( Par ( ParId "Bool" ( Struct ( StructExp ( Expression ( ExprBool False ) ) ) ) ) )
114+
-- program returnBoolFalse : func Bool True.
115+
-- returnBoolFalse = Program "returnBoolFalse" ( Par ( ParId "Bool" ( Struct ( StructExp ( Expression ( ExprBool False ) ) ) ) ) )
124116

125117
-- program opAddInts : func OpAdd ExprInt 10, OpAdd ExprInt 10
126-
--test5 = Program "opAddInts" ( Par ( ParId "OpAdd" ( Struct ( StructExp ( Expression ( ExprOp (Expression (ExprInt 10) ) (OpAdd) (Expression (ExprInt 5) ) ) ) ) ) ) )
118+
-- opAddInts = Program "opAddInts" ( Par ( ParId "OpAdd" ( Struct ( StructExp ( Expression ( ExprOp (Expression (ExprInt 10) ) (OpAdd) (Expression (ExprInt 5) ) ) ) ) ) ) )
127119

128120
-- program opMinusInts : func OpMinus ExprInt 100, OpMinus ExprInt 35
129-
-- test6 = Program "opMinusInts" ( Par ( ParId "OpMinus" ( Struct ( StructExp ( Expression ( ExprOp (Expression (ExprInt 100) ) (OpMinus) (Expression (ExprInt 35) ) ) ) ) ) ) )
121+
-- opMinusInts = Program "opMinusInts" ( Par ( ParId "OpMinus" ( Struct ( StructExp ( Expression ( ExprOp (Expression (ExprInt 100) ) (OpMinus) (Expression (ExprInt 35) ) ) ) ) ) ) )
130122

131123
-- program opDivideInts : func OpMinus ExprInt 100, OpDivide ExprInt 35
132-
-- test7 = Program "opDivideInts" ( Par ( ParId "OpDivide" ( Struct ( StructExp ( Expression ( ExprOp (Expression (ExprInt 100) ) (OpDivide) (Expression (ExprInt 35) ) ) ) ) ) ) )
124+
opDivideInts = Program "opDivideInts" ( Par ( ParId "OpDivide" ( Struct ( StructExp ( Expression ( ExprOp (Expression (ExprInt 100) ) (OpDivide) (Expression (ExprInt 35) ) ) ) ) ) ) )
133125

134-
-- program printStringInts : func String "Hello World!" func Int 42. return
135-
-- test8 = Program "printStringInts" ( Par ( ParId "ExprSeperator" ( Struct ( StructExp ( ExprSeperator ( ( ExprString "Hello World!" ) ) ( Expression ( ExprInt 42 ) ) ) ) ) ) )
126+
-- program opMultiplyInts : func String "Hello World!" func Int 42. return
127+
-- opMultiplyInts = Program "opMultiplyInts" ( Par ( ParId "OpMultiply" ( Struct ( StructExp ( Expression ( ExprOp (Expression (ExprInt 235) ) (OpMultiply) (Expression (ExprInt 19) ) ) ) ) ) ) )
136128

137-
-- program printStringBool : func String "Hello World!" func Int 42. return
138-
-- test9 = Program "printStringBool" ( Par ( ParId "ExprSeperator" ( Struct ( StructExp ( ExprSeperator ( ( ExprString "Hello World!" ) ) ( Expression ( ExprBool True ) ) ) ) ) ) )
129+
-- program printStringInts : func String "Hello World!" func Int 42. return
130+
-- printStringInts = Program "printStringInts" ( Par ( ParId "ExprSeperator" ( Struct ( StructExp ( ExprSeperator ( ( ExprString "Hello World!" ) ) ( Expression ( ExprInt 42 ) ) ) ) ) ) )
139131

140132
-- program printStringBool : func String "Hello World!" func Int 42. return
141-
test10 = Program "opMultiplyInts" ( Par ( ParId "OpMultiply" ( Struct ( StructExp ( Expression ( ExprOp (Expression (ExprInt 235) ) (OpMultiply) (Expression (ExprInt 19) ) ) ) ) ) ) )
142-
143-
144-
145-
146-
147-
148-
149-
150-
133+
-- printStringBool = Program "printStringBool" ( Par ( ParId "ExprSeperator" ( Struct ( StructExp ( ExprSeperator ( ( ExprString "Hello World!" ) ) ( Expression ( ExprBool True ) ) ) ) ) ) )
151134

152135

153-
-- Print out test program above using AST declarations
154-
main = print test10
136+
-- Print out programs above using AST declarations
137+
main = print opDivideInts
155138

compiler.o

0 Bytes
Binary file not shown.

opAddInts.class

356 Bytes
Binary file not shown.

test5.j renamed to opAddInts.j

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.class public test5
1+
.class public opAddInts
22
.super java/lang/Object
33

44
; standard initializer

opDivideInts.class

362 Bytes
Binary file not shown.

test7.j renamed to opDivideInts.j

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.class public test7
1+
.class public opDivideInts
22
.super java/lang/Object
33

44
; standard initializer
@@ -20,8 +20,8 @@
2020
getstatic java/lang/System/out Ljava/io/PrintStream;
2121
; push ints to be printed
2222

23-
ldc 100 ; load int
24-
ldc 35 ; load int
23+
ldc 345 ; load int
24+
ldc 15 ; load int
2525
idiv ; divide int
2626
istore_0 ; store result in variable
2727
iload 0 ; load variable, push to top of stack

opMinusInts.class

360 Bytes
Binary file not shown.

test6.j renamed to opMinusInts.j

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.class public test6
1+
.class public opMinusInts
22
.super java/lang/Object
33

44
; standard initializer

opMultiplyInts.class

366 Bytes
Binary file not shown.

test10.j renamed to opMultiplyInts.j

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.class public test10
1+
.class public opMultiplyInts
22
.super java/lang/Object
33

44
; standard initializer

printInt.class

343 Bytes
Binary file not shown.

test.j renamed to printInt.j

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.class public test
1+
.class public printInt
22
.super java/lang/Object
33

44
; standard initializer

printString.class

379 Bytes
Binary file not shown.

test2.j renamed to printString.j

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.class public test2
1+
.class public printString
22
.super java/lang/Object
33

44
; standard initializer

printStringBool.class

417 Bytes
Binary file not shown.

test9.j renamed to printStringBool.j

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.class public test9
1+
.class public printStringBool
22
.super java/lang/Object
33

44
; standard initializer

printStringInts.class

425 Bytes
Binary file not shown.

test8.j renamed to printStringInts.j

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.class public test8
1+
.class public printStringInts
22
.super java/lang/Object
33

44
; standard initializer
@@ -32,17 +32,14 @@
3232
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V ; string print
3333

3434
; push java.lang.System.out (type PrintStream)
35-
getstatic modifies the stack. Be aware.
35+
; getstatic modifies the stack. Be aware.
3636
getstatic java/lang/System/out Ljava/io/PrintStream;
3737

3838
iload 1 ; 1 bottom of stack but at top after print
3939

4040
; invoke println
4141
invokevirtual java/io/PrintStream/println(I)V ; int print
4242

43-
44-
45-
4643
; terminate main
4744
return
4845

returnBoolFalse.class

357 Bytes
Binary file not shown.

test4.j renamed to returnBoolFalse.j

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.class public test4
1+
.class public returnBoolFalse
22
.super java/lang/Object
33

44
; standard initializer

returnBoolTrue.class

355 Bytes
Binary file not shown.

test3.j renamed to returnBoolTrue.j

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.class public test3
1+
.class public returnBoolTrue
22
.super java/lang/Object
33

44
; standard initializer

test.class

-335 Bytes
Binary file not shown.

test10.class

-350 Bytes
Binary file not shown.

test2.class

-367 Bytes
Binary file not shown.

test3.class

-337 Bytes
Binary file not shown.

test4.class

-337 Bytes
Binary file not shown.

test5.class

-348 Bytes
Binary file not shown.

test6.class

-349 Bytes
Binary file not shown.

test7.class

-348 Bytes
Binary file not shown.

test8.class

-405 Bytes
Binary file not shown.

test9.class

-397 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)