示例#1
0
文件: start.go 项目: mm0205/gcasl
// NewStart returns a start.
func NewStart() *Start {
	return &Start{
		Label:    token.NewLabel(),
		Opcode:   token.NewOpcode(),
		Operand1: token.NewAddress(),
		Comment:  token.NewComment(),
	}
}
示例#2
0
文件: adr.go 项目: mm0205/gcasl
// NewAdr returns a adr.
func NewAdr() *Adr {
	return &Adr{
		Label:    token.NewLabel(),
		Opcode:   token.NewOpcode(),
		Operand1: token.NewAddress(),
		Comment:  token.NewComment(),
	}
}
示例#3
0
文件: radr.go 项目: mm0205/gcasl
// NewRAdr returns a radr.
func NewRAdr() *RAdr {
	return &RAdr{
		Label:    token.NewLabel(),
		Opcode:   token.NewOpcode(),
		Operand1: token.NewRegister(),
		Operand2: token.NewAddress(),
		Comment:  token.NewComment(),
	}
}
示例#4
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)
		}
	}
}