about summary refs log tree commit diff
path: root/src/libexpr/lexer.l
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2010-05-06T16·46+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2010-05-06T16·46+0000
commit84ce7ac76feab6e9a5c074bd1b9550ae543d1db8 (patch)
tree6fe85234390d62dd3e712cf2169d0963e4e87af2 /src/libexpr/lexer.l
parentc82782f9a5190c7489fb8e9bd6876b247b0de0bf (diff)
* Store attribute positions in the AST and report duplicate attribute
  errors with position info.
* For all positions, use the position of the first character of the
  first token, rather than the last character of the first token plus
  one.

Diffstat (limited to 'src/libexpr/lexer.l')
-rw-r--r--src/libexpr/lexer.l13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/libexpr/lexer.l b/src/libexpr/lexer.l
index 00de57a7bac9..f29f9b684332 100644
--- a/src/libexpr/lexer.l
+++ b/src/libexpr/lexer.l
@@ -19,13 +19,16 @@ namespace nix {
     
 static void initLoc(YYLTYPE * loc)
 {
-    loc->first_line = 1;
-    loc->first_column = 1;
+    loc->first_line = loc->last_line = 1;
+    loc->first_column = loc->last_column = 1;
 }
 
     
 static void adjustLoc(YYLTYPE * loc, const char * s, size_t len)
 {
+    loc->first_line = loc->last_line;
+    loc->first_column = loc->last_column;
+
     while (len--) {
        switch (*s++) {
        case '\r':
@@ -33,11 +36,11 @@ static void adjustLoc(YYLTYPE * loc, const char * s, size_t len)
                s++;
            /* fall through */
        case '\n': 
-           ++loc->first_line;
-           loc->first_column = 1;
+           ++loc->last_line;
+           loc->last_column = 1;
            break;
        default:
-           ++loc->first_column;
+           ++loc->last_column;
        }
     }
 }