How to Run with Go:
go run compiler.go optimizer.go tac.go mips.go -file input.josh
How to Build:
go build compiler.go optimizer.go tac.go mips.go
How to Run Binary:
./compiler -file input.josh
Make sure to pass in the file with the -file flag
The compiler supports the following types:
stringboolintfloatcharglobal- used to allow access from all subscopes
Syntax
[type] [name]
[type] [name] = [value]
global [type] [name]
Syntax
func [name]([type] [param],...) [return type, omit if void] {
[body]
[return, omit if void] [returned value, omit if void]
}
Syntax
if ([value] [operator] [value]) {
[body]
} else {
[body]
}
Supported Operators
+-/*%Syntax
[value] [operator] [value]
For loops are the only type of loop supported. Syntax
for (int i = 0; i < [value]; i = i + [increment]) {
[body]
}
The built-in function used for printing is write(x)
The write method takes any type as an arg and will cause a MIPS syscall to print