summaryrefslogtreecommitdiff
path: root/lex.l
diff options
context:
space:
mode:
Diffstat (limited to 'lex.l')
-rw-r--r--lex.l27
1 files changed, 23 insertions, 4 deletions
diff --git a/lex.l b/lex.l
index ce84278..5319430 100644
--- a/lex.l
+++ b/lex.l
@@ -1,18 +1,35 @@
+%option noinput nounput
%option noyywrap
%option nodefault
-%option yylineno
-%option noinput nounput
+/* %option reentrant bison-bridge bison-locations */
%{
#include <string.h>
-#include "basic.h"
+#include "sexpr.h"
+#include "sinter.h"
#include "parse.h"
void yyerror(const char *s, ...);
char *str_value(char *s);
+void update_yylloc() {
+ yylloc.first_line = yylloc.last_line;
+ yylloc.first_column = yylloc.last_column;
+
+ for (int i = 0; yytext[i]; i++) {
+ if (yytext[i] == '\n') {
+ yylloc.last_line++;
+ yylloc.last_column = 0;
+ } else {
+ yylloc.last_column++;
+ }
+ }
+}
+
+#define YY_USER_ACTION update_yylloc();
+
char *str_value(char *s) {
s++;
/* FIXME: strdup allocates memory! */
@@ -24,7 +41,9 @@ char *str_value(char *s) {
%}
-ID [-A-Za-z_+*!/.=<>][-A-Za-z0-9_+*!.=<>]*
+%option yylineno
+
+ID [-A-Za-z_+*^!:/%.=<>][-A-Za-z0-9_+*^!:/%.=<>]*
STRING ["][^"]*["]|['][^']*[']
FLOAT [+-]?([0-9]+[.][0-9]*([Ee][+-]?[0-9]+)?|[.][0-9]+([Ee][+-]?[0-9]+)?)
INT [+-]?[0-9]+