Skip to content

A tool and package to parse TIS100 assembly programs.

License

Notifications You must be signed in to change notification settings

oguzhand95/tis100

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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