当前位置: 首页>>代码示例>>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;未经允许,请勿转载。