diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-06-27 10:40:43 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-06-27 10:40:43 +0300 |
commit | 896d1c311129610bffbcc0c596926d8a1d6f1cc5 (patch) | |
tree | 9a80ddd805cd83978a7cd8e8136a5baf5c556bf4 | |
parent | 440771ca0056eb20396e24f03d349a75ee1c9d22 (diff) | |
download | grecs-896d1c311129610bffbcc0c596926d8a1d6f1cc5.tar.gz grecs-896d1c311129610bffbcc0c596926d8a1d6f1cc5.tar.bz2 |
Bugfixes.
* src/grecs-lex.l (qstring_locus_fixup): New function.
Call it before returning QSTRING to exclude quotes from the
reported string locations. FIXME: This should be user-configurable.
* src/grecs-locus.h (YY_LOCATION_PRINT): Add missing argument.
-rw-r--r-- | src/grecs-lex.l | 25 | ||||
-rw-r--r-- | src/grecs-locus.h | 3 |
2 files changed, 22 insertions, 6 deletions
diff --git a/src/grecs-lex.l b/src/grecs-lex.l index ba7a386..adff8a1 100644 --- a/src/grecs-lex.l +++ b/src/grecs-lex.l @@ -53,6 +53,7 @@ static void multiline_add(char *); static char *multiline_strip_tabs(char *text); static int ident(void); static int isemptystr(int off); +static void qstring_locus_fixup(void); #undef YY_INPUT #define YY_INPUT(buf,result,max_size) \ @@ -114,18 +115,25 @@ P [1-9][0-9]* \"[^\\"\n]*\" { grecs_line_begin(); grecs_line_add(yytext + 1, yyleng - 2); yylval.string = grecs_line_finish(); + qstring_locus_fixup(); return QSTRING; } -\"[^\\"\n]*\\. | \"[^\\"\n]*\\\n { BEGIN(STR); grecs_line_begin(); grecs_line_acc_grow_unescape_last(yytext + 1, + yyleng - 1); + grecs_locus_point_advance_line(grecs_current_locus_point); } +\"[^\\"\n]*\\. { BEGIN(STR); + grecs_line_begin(); + grecs_line_acc_grow_unescape_last(yytext + 1, yyleng - 1); } -<STR>[^\\"\n]*\\. | -<STR>\"[^\\"\n]*\\\n { grecs_line_acc_grow_unescape_last(yytext, yyleng); } +<STR>\"[^\\"\n]*\\\n { grecs_line_acc_grow_unescape_last(yytext, yyleng); + grecs_locus_point_advance_line(grecs_current_locus_point); } +<STR>[^\\"\n]*\\. { grecs_line_acc_grow_unescape_last(yytext, yyleng); } <STR>[^\\"\n]*\" { BEGIN(INITIAL); if (yyleng > 1) grecs_line_add(yytext, yyleng - 1); yylval.string = grecs_line_finish(); + qstring_locus_fixup(); return QSTRING; } /* Multiline strings */ "<<"(-" "?)?\\?{ID}[ \t]*#.*\n | @@ -169,8 +177,8 @@ P [1-9][0-9]* grecs_error(&yylloc, 0, _("stray character %c"), yytext[0]); else - grecs_error(&yylloc, 0, - _("stray character \\%03o"), + grecs_error(&yylloc, 0, + _("stray character \\%03o"), (unsigned char) yytext[0]); } %% @@ -331,6 +339,13 @@ ident() return IDENT; } +static void +qstring_locus_fixup() +{ + yylloc.beg.col++; + yylloc.end.col--; +} + grecs_value_t * grecs_value_ptr_from_static(grecs_value_t *input) { diff --git a/src/grecs-locus.h b/src/grecs-locus.h index e23add2..7de0fc9 100644 --- a/src/grecs-locus.h +++ b/src/grecs-locus.h @@ -51,6 +51,7 @@ else \ fprintf(File, "%s:%u.%u", \ (Loc).beg.file, \ - (Loc).beg.line); \ + (Loc).beg.line, \ + (Loc).beg.col); \ } while (0) |