# HG changeset patch # User Danielle Hutzley # Date 1653258722 25200 # Sun May 22 15:32:02 2022 -0700 # Node ID 58af657f2ee35325c1bead864e60c7bf26559b5b # Parent 26397b125c3b69384b3645592919f29b6b944c08 Actually fix single number parsing, should probably test before tagging diff --git a/src/laal_lexer.c b/src/laal_lexer.c --- a/src/laal_lexer.c +++ b/src/laal_lexer.c @@ -44,13 +44,16 @@ static bool is_number (const char *begin, uintptr_t len) { - const char *cur = begin; - if (*cur == '-') + uintptr_t cur = 0; + if (begin[cur] == '-') cur++; - while (++cur < begin + len) - if (!(isdigit (*cur) || *cur == '.')) - return false; + while (cur < len) + { + if (!(isdigit (begin[cur]) || begin[cur] == '.')) + return false; + cur++; + } return true; } diff --git a/test/lexer.c b/test/lexer.c --- a/test/lexer.c +++ b/test/lexer.c @@ -47,8 +47,8 @@ } if (expected_tokens[i].type != tok->type) { - fprintf (stderr, "Expected: %d, Actual: %d", expected_tokens[i].type, - tok->type); + fprintf (stderr, "\nExpected: %d, Actual: %d", + expected_tokens[i].type, tok->type); TEST_FAIL ( "Mismatched token types, see laal_lexer.h for variant names") }