experiments
authorBen Pfaff <blp@cs.stanford.edu>
Tue, 30 Nov 2021 14:49:03 +0000 (06:49 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Tue, 30 Nov 2021 14:55:06 +0000 (06:55 -0800)
src/language/lexer/lexer.c

index 3c46fa70ebb787689a81244559ec2477f874eec4..d501cf8993ca8a2d1ac77e175c9f0483608950df 100644 (file)
@@ -69,7 +69,6 @@ struct lex_token
        call. */
     size_t token_pos;           /* Offset into src->buffer of token start. */
     size_t token_len;           /* Length of source for token in bytes. */
-    int first_line;             /* Line number at token_pos. */
 
     /* For a token obtained through macro expansion, this is just this token.
 
@@ -221,7 +220,10 @@ struct lex_source
     size_t journal_pos;         /* First byte not yet output to journal. */
     size_t seg_pos;             /* First byte not yet scanned as token. */
 
-    int n_newlines;             /* Number of new-lines up to seg_pos. */
+    /* Offset into 'buffer' of starts of lines. */
+    size_t *lines;
+    size_t n_lines, allocated_lines;
+
     bool suppress_next_newline;
 
     /* Tokens.
@@ -1241,6 +1243,8 @@ static int
 lex_token_get_last_line_number (const struct lex_source *src,
                                 const struct lex_token *token)
 {
+  size_t end = token->token_pos + token->token_len
+  return lex_source_ofs_to_line_number (src, 
   if (token->first_line == 0)
     return 0;
   else