aboutsummaryrefslogtreecommitdiff
path: root/libstorycode
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
parente2523695223db657fb2c348a47b318b5c2d998ce (diff)
Give line number in error message
Diffstat (limited to 'libstorycode')
-rw-r--r--libstorycode/storycode.l14
-rw-r--r--libstorycode/storycode.y3
2 files changed, 13 insertions, 4 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; }
diff --git a/libstorycode/storycode.y b/libstorycode/storycode.y
index 1062794..b2b2afa 100644
--- a/libstorycode/storycode.y
+++ b/libstorycode/storycode.y
@@ -53,6 +53,7 @@
extern int sclex();
extern int scparse();
void scerror(struct scpctx *ctx, const char *s);
+ extern int lineno;
%}
%token STYLES SLIDE
@@ -306,5 +307,5 @@ styledef:
%%
void scerror(struct scpctx *ctx, const char *s) {
- printf("Storycode parse error at %i-%i\n", yylloc.first_line, yylloc.first_column);
+ printf("Storycode parse error at line %i\n", lineno);
}