Parses a non-negative integer without leading zeros. Returns the end position, or npos on failure.
| 165 | // Parses a non-negative integer without leading zeros. |
| 166 | // Returns the end position, or npos on failure. |
| 167 | size_t parseNumeric(std::string_view V) { |
| 168 | if (V.empty()) |
| 169 | return std::string_view::npos; |
| 170 | if (V[0] == '0') { |
| 171 | return 1; |
| 172 | } |
| 173 | if (V[0] >= '1' && V[0] <= '9') { |
| 174 | size_t Pos = 1; |
| 175 | while (Pos < V.size() && isdigit(V[Pos])) |
| 176 | Pos++; |
| 177 | return Pos; |
| 178 | } |
| 179 | return std::string_view::npos; |
| 180 | } |
| 181 | |
| 182 | // canonversion ::= [1-9] [0-9]* |
| 183 | // | '0.' [1-9] [0-9]* |
no test coverage detected