()
| 114 | } |
| 115 | |
| 116 | func (p *Parser) ReadNumber() int { |
| 117 | ind := len(p.b) - p.i |
| 118 | for i, c := range p.b[p.i:] { |
| 119 | if !isNum(c) { |
| 120 | ind = i |
| 121 | break |
| 122 | } |
| 123 | } |
| 124 | if ind == 0 { |
| 125 | return 0 |
| 126 | } |
| 127 | n, err := strconv.Atoi(string(p.b[p.i : p.i+ind])) |
| 128 | if err != nil { |
| 129 | panic(err) |
| 130 | } |
| 131 | p.i += ind |
| 132 | return n |
| 133 | } |
| 134 | |
| 135 | func isNum(c byte) bool { |
| 136 | return c >= '0' && c <= '9' |