Ejemplo n.º 1
0
Archivo: r1r2.go Proyecto: mm0205/gcasl
// NewR1R2 returns a r1r2.
func NewR1R2() *R1R2 {
	return &R1R2{
		Label:    token.NewLabel(),
		Opcode:   token.NewOpcode(),
		Operand1: token.NewRegister(),
		Operand2: token.NewRegister(),
		Comment:  token.NewComment(),
	}
}
Ejemplo n.º 2
0
// NewRAdrX returns a radrx.
func NewRAdrX() *RAdrX {
	return &RAdrX{
		Label:    token.NewLabel(),
		Opcode:   token.NewOpcode(),
		Operand1: token.NewRegister(),
		Operand2: token.NewAddress(),
		Operand3: token.NewRegister(),
		Comment:  token.NewComment(),
	}
}
Ejemplo n.º 3
0
func TestRegisterParse(t *testing.T) {
	testCaseList := []testCaseForTestRegisterParse{
		{data: `							LD      GR0, DATA1`},
		{data: `							LD      GR0, 65535`},
		{data: `							LD      GR0, #ABCD`},
		{data: `							LD      GR0, =12345`},
		{data: `							LD      GR0, =#1FE0`},
		{data: `							LD      GR0, ='string'`},
		{data: `							LD      GR0, ='''is esacped quote'`},
	}
	for _, testCase := range testCaseList {
		testData := testCase.data

		source := token.NewSource(testData)
		opcode := token.NewOpcode()
		err := opcode.Parse(source)
		if err != nil {
			t.Error(err)
		}

		register := token.NewRegister()
		err = register.Parse(source)
		if err != nil {
			t.Error(err)
		}

		comma := token.NewComma()
		err = comma.Parse(source)
		if err != nil {
			t.Error(err)
		}
		address := token.NewAddress()
		err = address.Parse(source)
		if err != nil {
			t.Error(err)
		}
	}
}