當前位置: 首頁>>代碼示例>>Golang>>正文


Golang token.Source類代碼示例

本文整理匯總了Golang中mm0205/gcasl/token.Source的典型用法代碼示例。如果您正苦於以下問題:Golang Source類的具體用法?Golang Source怎麽用?Golang Source使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Source類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Parse

// Parse parses a line.
func (radr *RAdr) Parse(source *token.Source) error {
	radr.Label.Parse(source)

	err := radr.Opcode.Parse(source)
	if err != nil {
		return err
	}
	err = radr.Operand1.Parse(source)
	if err != nil {
		return err
	}
	err = token.NewComma().Parse(source)
	if err != nil {
		return err
	}
	err = radr.Operand2.Parse(source)
	if err != nil {
		return err
	}

	radr.Comment.Parse(source)
	if !IsRAdrOpcode(radr.Opcode.TextValue()) {
		return fmt.Errorf("This line can't accept R, adr %#v", source)
	}
	if !source.IsEmpty() {
		return fmt.Errorf("This line doesn't end. %#v", source)
	}
	return nil
}
開發者ID:mm0205,項目名稱:gcasl,代碼行數:30,代碼來源:radr.go

示例2: Parse

// Parse parses a line.
func (adrx *AdrX) Parse(source *token.Source) error {
	adrx.Label.Parse(source)

	err := adrx.Opcode.Parse(source)
	if err != nil {
		return err
	}
	err = adrx.Operand1.Parse(source)
	if err != nil {
		return err
	}
	err = token.NewComma().Parse(source)
	if err != nil {
		return err
	}
	err = adrx.Operand2.Parse(source)
	if err != nil {
		return err
	}

	adrx.Comment.Parse(source)
	if !IsAdrXOpcode(adrx.Opcode.TextValue()) {
		return fmt.Errorf("This line can't accept adr, x %#v", source)
	}
	if !source.IsEmpty() {
		return fmt.Errorf("This line doesn't end. %#v", source)
	}

	return nil
}
開發者ID:mm0205,項目名稱:gcasl,代碼行數:31,代碼來源:adrx.go

示例3: Parse

// Parse parses a line.
func (r1r2 *R1R2) Parse(source *token.Source) error {
	r1r2.Label.Parse(source)

	err := r1r2.Opcode.Parse(source)
	if err != nil {
		return err
	}
	err = r1r2.Operand1.Parse(source)
	if err != nil {
		return err
	}
	err = token.NewComma().Parse(source)
	if err != nil {
		return err
	}
	err = r1r2.Operand2.Parse(source)
	if err != nil {
		return err
	}
	r1r2.Comment.Parse(source)
	if !IsR1R2Opcode(r1r2.Opcode.TextValue()) {
		return fmt.Errorf("This line can't accept R1, R2, %#v", source)
	}
	if !source.IsEmpty() {
		return fmt.Errorf("This line doesn't end. %#v", source)
	}
	return nil
}
開發者ID:mm0205,項目名稱:gcasl,代碼行數:29,代碼來源:r1r2.go

示例4: Parse

// Parse parses a line.
func (inout *InOut) Parse(source *token.Source) error {
	inout.Label.Parse(source)

	err := inout.Opcode.Parse(source)
	if err != nil {
		return err
	}
	err = inout.Operand1.Parse(source)
	if err != nil {
		return err
	}
	err = token.NewComma().Parse(source)
	if err != nil {
		return err
	}
	err = inout.Operand2.Parse(source)
	if err != nil {
		return err
	}

	inout.Comment.Parse(source)
	if !IsInOutOpcode(inout.Opcode.TextValue()) {
		return fmt.Errorf("This line can't accept label, label %#v", source)
	}
	if !source.IsEmpty() {
		return fmt.Errorf("This line doesn't end. %#v", source)
	}

	return nil
}
開發者ID:mm0205,項目名稱:gcasl,代碼行數:31,代碼來源:inout.go

示例5: Parse

// Parse parses a line.
func (dc *DC) Parse(source *token.Source) error {
	dc.Label.Parse(source)

	err := dc.Opcode.Parse(source)
	if err != nil {
		return err
	}
	for {
		constant := token.NewConstant()
		err = constant.Parse(source)
		if err != nil {
			if 0 < len(dc.Operands) {
				break
			}
			return fmt.Errorf("This line is invalid DC, %#v", source)
		}
		dc.Operands = append(dc.Operands, constant)
		err = token.NewComma().Parse(source)
		if err == nil {
			continue
		}
		break
	}

	dc.Comment.Parse(source)
	if !IsDCOpcode(dc.Opcode.TextValue()) {
		return fmt.Errorf("This line can't accept dc %#v", source)
	}
	if !source.IsEmpty() {
		return fmt.Errorf("This line doesn't end. %#v", source)
	}
	return nil
}
開發者ID:mm0205,項目名稱:gcasl,代碼行數:34,代碼來源:dc.go

示例6: Parse

// Parse parses a line.
func (end *End) Parse(source *token.Source) error {
	err := end.Opcode.Parse(source)
	if err != nil {
		return err
	}
	end.Comment.Parse(source)
	if end.Opcode.TextValue() != "END" {
		return fmt.Errorf("This line is not end. %s", source)
	}
	if !source.IsEmpty() {
		return fmt.Errorf("This line doesn't end. %#v", source)
	}
	return nil
}
開發者ID:mm0205,項目名稱:gcasl,代碼行數:15,代碼來源:end.go

示例7: Parse

// Parse parses a line.
func (none *None) Parse(source *token.Source) error {
	none.Label.Parse(source)

	err := none.Opcode.Parse(source)
	if err != nil {
		return err
	}

	none.Comment.Parse(source)
	if !IsNoneOpcode(none.Opcode.TextValue()) {
		return fmt.Errorf("This line can't accept none %#v", source)
	}
	if !source.IsEmpty() {
		return fmt.Errorf("This line doesn't end. %#v", source)
	}
	return nil
}
開發者ID:mm0205,項目名稱:gcasl,代碼行數:18,代碼來源:none.go

示例8: Parse

// Parse parses a line.
func (start *Start) Parse(source *token.Source) error {
	err := start.Label.Parse(source)
	// START line must have label.
	if err != nil {
		return err
	}
	err = start.Opcode.Parse(source)
	if err != nil {
		return err
	}
	start.Operand1.Parse(source)
	start.Comment.Parse(source)
	if start.Opcode.TextValue() != "START" {
		return fmt.Errorf("This line is not START. %s", source)
	}
	if !source.IsEmpty() {
		return fmt.Errorf("This line doesn't end. %#v", source)
	}
	return nil
}
開發者ID:mm0205,項目名稱:gcasl,代碼行數:21,代碼來源:start.go

示例9: Parse

// Parse parses a line.
func (ds *DS) Parse(source *token.Source) error {
	ds.Label.Parse(source)

	err := ds.Opcode.Parse(source)
	if err != nil {
		return err
	}
	err = ds.Operand1.Parse(source)
	if err != nil {
		return err
	}

	ds.Comment.Parse(source)
	if !IsDSOpcode(ds.Opcode.TextValue()) {
		return fmt.Errorf("This line can't accept ds %#v", source)
	}
	if !source.IsEmpty() {
		return fmt.Errorf("This line doesn't end. %#v", source)
	}
	return nil
}
開發者ID:mm0205,項目名稱:gcasl,代碼行數:22,代碼來源:ds.go

示例10: Parse

// Parse parses a line.
func (r *R) Parse(source *token.Source) error {
	r.Label.Parse(source)

	err := r.Opcode.Parse(source)
	if err != nil {
		return err
	}
	err = r.Operand1.Parse(source)
	if err != nil {
		return err
	}

	r.Comment.Parse(source)
	if !IsROpcode(r.Opcode.TextValue()) {
		return fmt.Errorf("This line can't accept r %#v", source)
	}
	if !source.IsEmpty() {
		return fmt.Errorf("This line doesn't end. %#v", source)
	}
	return nil
}
開發者ID:mm0205,項目名稱:gcasl,代碼行數:22,代碼來源:r.go


注:本文中的mm0205/gcasl/token.Source類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。