MCPcopy Create free account
hub / github.com/djhworld/simple-computer / parseDefSymbol

Function parseDefSymbol

asm/parser.go:69–89  ·  view source on GitHub ↗
(line string)

Source from the content-addressed store, hash-verified

67}
68
69func parseDefSymbol(line string) (Instruction, error) {
70 tokens := IS_DEFSYMBOL.FindStringSubmatch(line)
71 if len(tokens) != 4 {
72 return nil, fmt.Errorf("could not parse the arguments correctly out of DEFSYMBOL %s", line)
73 }
74
75 var value uint64
76 var err error
77 // parse in base 16 or 10
78 if tokens[3] == "0x" {
79 value, err = strconv.ParseUint(strings.Replace(tokens[2], "0x", "", -1), 16, 16)
80 } else {
81 value, err = strconv.ParseUint(tokens[2], 10, 16)
82 }
83
84 if err != nil {
85 return nil, err
86 }
87
88 return DEFSYMBOL{tokens[1], uint16(value)}, nil
89}
90
91func processLabel(line string) DEFLABEL {
92 line = strings.Replace(line, ":", "", -1)

Callers 1

ParseMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected