Skip to content

Latest commit

 

History

History
62 lines (46 loc) · 1.17 KB

README.md

File metadata and controls

62 lines (46 loc) · 1.17 KB

TIS100

A tool and package to parse TIS100 assembly programs.

CLI Usage

Command tis100 parse <path>

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

Package Usage

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