diff --git a/src/compiler.c b/src/compiler.c index 214d799..db3fc6a 100644 --- a/src/compiler.c +++ b/src/compiler.c @@ -800,7 +800,8 @@ static void number(struct GlobalState * state, int exprType, RewindState *rewind invalidTarget(state, exprType, "literal"); for (size_t j = 0; j < state->parser.previous.length; ++j) { - if (state->parser.previous.start[j] == '.') { + if (start[j] == 'x' || start[j] == 'X') break; + if (start[j] == '.' || start[j] == 'e' || start[j] == 'E') { #ifndef KRK_NO_FLOAT emitConstant(krk_parse_float(start, state->parser.previous.length)); #else diff --git a/src/scanner.c b/src/scanner.c index 75e2909..c228bc9 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -180,6 +180,12 @@ static KrkToken number(KrkScanner * scanner, char c) { while (isDigit(peek(scanner))) advance(scanner); } + if (peek(scanner) == 'e' || peek(scanner) == 'E') { + advance(scanner); + if (peek(scanner) == '+' || peek(scanner) == '-') advance(scanner); + while (isDigit(peek(scanner))) advance(scanner); + } + return makeToken(scanner, TOKEN_NUMBER); } diff --git a/src/vendor/rline.c b/src/vendor/rline.c index f0a369a..9d2de42 100644 --- a/src/vendor/rline.c +++ b/src/vendor/rline.c @@ -672,6 +672,11 @@ static int paint_krk_numeral(struct syntax_state * state) { paint(1, FLAG_NUMERAL); while (isdigit(charat())) paint(1, FLAG_NUMERAL); } + if (charat() == 'e' || charat() == 'E') { + paint(1, FLAG_NUMERAL); + if (charat() == '-' || charat() == '+') paint(1, FLAG_NUMERAL); + while (isdigit(charat())) paint(1, FLAG_NUMERAL); + } } return 0; }