本文整理汇总了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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}