aboutsummaryrefslogtreecommitdiff
path: root/src/lexer.l
diff options
context:
space:
mode:
Diffstat (limited to 'src/lexer.l')
-rw-r--r--src/lexer.l13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/lexer.l b/src/lexer.l
index 5242af0..8715932 100644
--- a/src/lexer.l
+++ b/src/lexer.l
@@ -5,7 +5,18 @@
#include "parser.h"
#include "pinocchio.h"
-#define YY_USER_ACTION yylloc.first_line = yylloc.last_line = yylineno;
+#define YY_USER_ACTION \
+ do { \
+ yylloc.first_column = yylloc.last_column; \
+ yylloc.first_line = yylloc.last_line; \
+ for (int i = 0; i < yyleng; i++) { \
+ if (yytext[i] == '\n') { \
+ yylloc.last_column = 1; \
+ yylloc.last_line++; \
+ } else \
+ yylloc.last_column++; \
+ } \
+ } while (0);
extern const char *current_file;
%}