aboutsummaryrefslogtreecommitdiffstats
path: root/libalee/parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libalee/parser.cpp')
-rw-r--r--libalee/parser.cpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/libalee/parser.cpp b/libalee/parser.cpp
index cdec1a5..2b1d8e1 100644
--- a/libalee/parser.cpp
+++ b/libalee/parser.cpp
@@ -85,15 +85,16 @@ Error Parser::parseNumber(State& state, Word word)
{
const auto base = state.dict.read(Dictionary::Base);
DoubleCell result = 0;
- auto i = word.start;
- bool inv;
- char c;
+ auto it = word.begin(&state.dict);
- c = state.dict.readbyte(i);
- if (inv = c == '-'; inv)
- c = state.dict.readbyte(++i);
+ bool inv = *it == '-';
+ if (inv)
+ ++it;
+
+ const auto end = word.end(&state.dict);
+ for (char c; it != end; ++it) {
+ c = *it;
- do {
if (isdigit(c)) {
result *= base;
result += c - '0';
@@ -103,10 +104,7 @@ Error Parser::parseNumber(State& state, Word word)
} else {
return Error::noword;
}
-
- if (++i < word.wend)
- c = state.dict.readbyte(i);
- } while (i < word.wend);
+ }
if (inv)
result *= -1;