about summary refs log tree commit diff
path: root/boot/lex.c
diff options
context:
space:
mode:
Diffstat (limited to 'boot/lex.c')
-rw-r--r--boot/lex.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/boot/lex.c b/boot/lex.c
index 30f4071..6b6badc 100644
--- a/boot/lex.c
+++ b/boot/lex.c
@@ -111,6 +111,7 @@ enum Token_Kind
     TOKEN_COMMA,
     TOKEN_AMPERSAND,
     TOKEN_DOT,
+    TOKEN_DOT_DOT,
     TOKEN_BANG,
     TOKEN_PERCENT,
     TOKEN_PIPE,
@@ -223,6 +224,8 @@ token_kind_to_string(enum Token_Kind kind)
         return "AMPERSAND";
     case TOKEN_DOT:
         return "DOT";
+    case TOKEN_DOT_DOT:
+        return "DOT_DOT";
     case TOKEN_BANG:
         return "BANG";
     case TOKEN_PERCENT:
@@ -551,7 +554,6 @@ lexer_symbol_token(struct Lexer* l, struct Lexer_Char current)
     case ']':
         RET{ TOKEN_SQUARE_CLOSE, 1 };
 
-
     case ',':
         RET{ TOKEN_COMMA, 1 };
     case '&': {
@@ -565,6 +567,8 @@ lexer_symbol_token(struct Lexer* l, struct Lexer_Char current)
         RET{ TOKEN_AMPERSAND, 1 };
     }
     case '.':
+        a = lexer_match_char(l, '.');
+        if (a.got_match) RET{ TOKEN_DOT_DOT, 2 };
         RET{ TOKEN_DOT, 1 };
     case '!': {
         a = lexer_match_char(l, '=');
@@ -691,8 +695,14 @@ lexer_number_token(struct Lexer* l)
     uint buffer_size = 0;
     for (;;) {
         struct Lexer_Char c = lexer_peek_char(l);
-        bool is_number_char = ascii_is_number(c.character) || c.character == '.';
+        bool is_dot = c.character == '.';
+        bool is_number_char = ascii_is_number(c.character) || is_dot;
         if (c.eof || !is_number_char) break;
+        if (is_dot) {
+            struct Lexer_Char next = lexer_peek_char_further(l);
+            // two dots in a row means a range, not a number.
+            if (next.character == '.') break;
+        }
 
         check(buffer_size < MAX_CHAR_BUFFER_SIZE, "number too long to lex");
         buffer[buffer_size++] = c.character;