aboutsummaryrefslogtreecommitdiff
path: root/libstorycode/storycode.l
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.me.uk>2019-02-23 16:44:51 +0100
committerThomas White <taw@bitwiz.me.uk>2019-02-23 16:44:51 +0100
commit77ef611a5a6ee3bf7456d0fb5f26f708b8433971 (patch)
tree40c8823ef63a3ee116485d442c82a9902211006b /libstorycode/storycode.l
parente2523695223db657fb2c348a47b318b5c2d998ce (diff)
Give line number in error message
Diffstat (limited to 'libstorycode/storycode.l')
-rw-r--r--libstorycode/storycode.l14
1 files changed, 11 insertions, 3 deletions
diff --git a/libstorycode/storycode.l b/libstorycode/storycode.l
index 792637d..98f8f6a 100644
--- a/libstorycode/storycode.l
+++ b/libstorycode/storycode.l
@@ -29,6 +29,8 @@
#include "stylesheet.h"
#include "storycode_parse.h"
+
+ int lineno = 0;
%}
%option prefix="sc"
@@ -56,14 +58,20 @@ SIZE { return SC_SIZE; }
(?i:left) { return SC_LEFT; }
(?i:center) { return SC_CENTER; }
(?i:right) { return SC_RIGHT; }
-<string>.*\n { sclval.str = strdup(yytext); sclval.str[yyleng-1] = '\0'; BEGIN(0); return SC_STRING; }
+<string>.*\n { sclval.str = strdup(yytext);
+ sclval.str[yyleng-1] = '\0';
+ BEGIN(0);
+ lineno++;
+ return SC_STRING; }
"[" { return SC_SQOPEN; }
"]" { return SC_SQCLOSE; }
+":" { return SC_COLON; }
:[ ] { BEGIN(string); }
-:\n { sclval.str = strdup(""); return SC_STRING; }
+:\n { sclval.str = strdup(""); lineno++; ;return SC_STRING; }
[{] { return SC_OPENBRACE; }
[}] { return SC_CLOSEBRACE; }
-[.\n ] {}
+[. ] {}
+\n { lineno++; }
[0-9\.]+ { sclval.val = atof(yytext); return SC_VALUE; }
[uf] { sclval.character = yytext[0]; return SC_UNIT; }
[+] { return SC_PLUS; }