A tool and package to parse TIS100 assembly programs.
Parses the TIS100 assembly program in the given <path>
, and prints the AST result into standard output.
MOV 10, ACC
MOV ACC, DOWN
-> tis100 parse ~/program.asm
The result for the above execution looks like this;
instructions:
- mov:
source:
literal: 10
destination:
register: ACC
- mov:
source:
register: ACC
destination:
register: DOWN
go get github.com/oguzhand95/tis100
import "github.com/oguzhand95/tis100/parser"
func main() {
b, err := os.ReadFile(c.Path)
if err != nil {
return fmt.Errorf("failed to open the file in path %s: %w", c.Path, err)
}
ast, err := parser.Parse(bytes.NewReader(b), filepath.Base(c.Path))
if err != nil {
return fmt.Errorf("failed to parse the program: %w", err)
}
// Use ast struct to do some stuff
}
- Thanks Zachtronics for developing this awesome puzzle game!