settings: Add support for multi-line strings

Unterminated strings are now an error.
This commit is contained in:
Tobias Brunner
2015-07-28 13:27:32 +02:00
parent d918410add
commit 764960e8b9
3 changed files with 20 additions and 16 deletions
+2 -7
View File
@@ -119,16 +119,11 @@ static void include_files(parser_helper_t *ctx);
<str>{
"\"" |
<<EOF>> |
\n |
\\ {
if (!streq(yytext, "\""))
{
if (streq(yytext, "\n"))
{ /* put the newline back to fix the line numbers */
unput('\n');
yy_set_bol(0);
}
PARSER_DBG1(yyextra, "unterminated string detected");
return STRING_ERROR;
}
if (yy_top_state(yyscanner) == inc)
{ /* string include */
@@ -148,7 +143,7 @@ static void include_files(parser_helper_t *ctx);
\\t yyextra->string_add(yyextra, "\t");
\\\r?\n /* merge lines that end with EOL characters */
\\. yyextra->string_add(yyextra, yytext+1);
[^\\\n"]+ {
[^\\"]+ {
yyextra->string_add(yyextra, yytext);
}
}
+1 -1
View File
@@ -79,7 +79,7 @@ static int yylex(YYSTYPE *lvalp, parser_helper_t *ctx)
struct kv_t *kv;
}
%token <s> NAME STRING
%token NEWLINE
%token NEWLINE STRING_ERROR
/* ...and other symbols */
%type <s> value valuepart