summaryrefslogtreecommitdiff
path: root/src/genjsbind-lexer.l
diff options
context:
space:
mode:
authorVincent Sanders <vincent.sanders@collabora.co.uk>2012-09-07 16:51:43 +0100
committerVincent Sanders <vincent.sanders@collabora.co.uk>2012-09-07 16:51:43 +0100
commit7ba968e4c33d3a05ff9b23b8e593b400e34a4cad (patch)
treeeb22fdebb318eaa1d0df25a5e2d7518d73aab1e8 /src/genjsbind-lexer.l
parentf60d94623e676bb80670b465b1bed7ad4559581d (diff)
downloadnsgenbind-7ba968e4c33d3a05ff9b23b8e593b400e34a4cad.tar.gz
nsgenbind-7ba968e4c33d3a05ff9b23b8e593b400e34a4cad.tar.bz2
fixup error reporting to give linenumber
Diffstat (limited to 'src/genjsbind-lexer.l')
-rw-r--r--src/genjsbind-lexer.l50
1 files changed, 35 insertions, 15 deletions
diff --git a/src/genjsbind-lexer.l b/src/genjsbind-lexer.l
index 8bfa391..1406872 100644
--- a/src/genjsbind-lexer.l
+++ b/src/genjsbind-lexer.l
@@ -1,33 +1,47 @@
+%{
+
/*
* binding generator lexer
*/
-/* lexer options */
-%option never-interactive
-%option bison-bridge
-%option nodefault
-%option warn
-%option prefix="genjsbind_"
-%option nounput
-
-/* header block */
-%{
-
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include "genjsbind-parser.h"
+#define YY_USER_ACTION yylloc->first_line = yylloc->last_line; \
+ yylloc->first_column = yylloc->last_column + 1; \
+ yylloc->last_column += yyleng;
+
%}
- /* other Unicode “space separator” */
+/* lexer options */
+%option never-interactive
+%option yylineno
+%option bison-bridge
+%option bison-locations
+%option nodefault
+%option warn
+%option prefix="genjsbind_"
+%option nounput
+%option noinput
+
+/* other Unicode “space separator” */
USP (\xe1\x9a\x80)|(\xe1\xa0\x8e)|(\xe2\x80[\x80-\x8a])|(\xe2\x80\xaf)|(\xe2\x81\x9f)|(\xe3\x80\x80)
/* non breaking space \u00A0 */
NBSP (\xc2\xa0)
-whitespace ([ \t\v\f\n]|{NBSP}|{USP})
+/* Line separator \u2028 */
+LS (\xe2\x80\xa8)
+
+/* paragraph separator \u2029 */
+PS (\xe2\x80\xa9)
+
+whitespace ([ \t\v\f]|{NBSP}|{USP})
+
+lineend ([\n\r]|{LS}|{PS})
multicomment \/\*(([^*])|(\*[^/]))*\*\/
@@ -45,7 +59,13 @@ cblockclose \]\]\]
%%
-{whitespace} /* nothing */
+{whitespace} ++yylloc->last_column;/* nothing */
+
+{lineend} if (yytext[0] != '\r') {
+ /* update position counts */
+ ++yylloc->last_line;
+ yylloc->last_column = 0;
+ }
/* terminals */
@@ -75,7 +95,7 @@ node return TOK_NODE;
return TOK_IDENTIFIER;
}
-\"{quotedstring}*\" yylval->text = strndup(yytext + 1,strlen(yytext+1) - 1 ); return TOK_STRING_LITERAL;
+\"{quotedstring}*\" yylval->text = strndup(yytext + 1, yyleng - 2 ); return TOK_STRING_LITERAL;
{multicomment} /* nothing */