Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(319)

Unified Diff: Source/core/css/CSSGrammar.y.in

Issue 14969002: CSS parsing recovery in function. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/fast/css/parsing-error-recovery.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/CSSGrammar.y.in
diff --git a/Source/core/css/CSSGrammar.y.in b/Source/core/css/CSSGrammar.y.in
index 20860de7ce6e4c380e738dea75e7e8f86bd61db5..926dccfe88ef86d15238185a1b9a6c841c2d54f2 100644
--- a/Source/core/css/CSSGrammar.y.in
+++ b/Source/core/css/CSSGrammar.y.in
@@ -87,7 +87,7 @@ static inline bool isCSSTokenAString(int yytype)
%}
-%expect 35
+%expect 34
%nonassoc LOWEST_PREC
@@ -403,6 +403,11 @@ closing_brace:
| %prec LOWEST_PREC TOKEN_EOF
;
+closing_parenthesis:
+ ')'
+ | %prec LOWEST_PREC TOKEN_EOF
+ ;
+
charset:
CHARSET_SYM maybe_space STRING maybe_space ';' {
if (parser->m_styleSheet)
@@ -1543,11 +1548,9 @@ decl_list:
;
decl_list_recovery:
- error error_location {
+ error error_location error_recovery {
parser->syntaxError($2, CSSParser::PropertyDeclarationError);
}
- | decl_list_recovery invalid_block
- | decl_list_recovery error
;
declaration:
@@ -1598,11 +1601,9 @@ declaration:
;
declaration_recovery:
- error error_location {
+ error error_location error_recovery {
parser->syntaxError($2);
}
- | declaration_recovery invalid_block
- | declaration_recovery error
;
property:
@@ -1634,17 +1635,15 @@ expr:
$$->addValue(parser->sinkFloatingValue($3));
}
}
- | expr invalid_block_list {
- $$ = 0;
- }
- | expr invalid_block_list error {
- $$ = 0;
- }
- | expr error {
+ | expr expr_recovery {
$$ = 0;
}
;
+expr_recovery:
+ error error_location error_recovery
+ ;
+
operator:
'/' maybe_space {
$$ = '/';
@@ -1733,7 +1732,7 @@ unary_term:
;
function:
- FUNCTION maybe_space expr ')' maybe_space {
+ FUNCTION maybe_space expr closing_parenthesis maybe_space {
CSSParserFunction* f = parser->createFloatingFunction();
f->name = $1;
f->args = parser->sinkFloatingValueList($3);
@@ -1741,15 +1740,7 @@ function:
$$.unit = CSSParserValue::Function;
$$.function = f;
} |
- FUNCTION maybe_space expr TOKEN_EOF {
- CSSParserFunction* f = parser->createFloatingFunction();
- f->name = $1;
- f->args = parser->sinkFloatingValueList($3);
- $$.id = 0;
- $$.unit = CSSParserValue::Function;
- $$.function = f;
- } |
- FUNCTION maybe_space ')' maybe_space {
+ FUNCTION maybe_space closing_parenthesis maybe_space {
apavlov 2013/05/07 14:37:37 This is not quite equivalent (TOKEN_EOF is dropped
SeRya 2013/05/08 06:24:07 Actually "FUNCTION maybe_space expr TOKEN_EOF" is
CSSParserFunction* f = parser->createFloatingFunction();
f->name = $1;
CSSParserValueList* valueList = parser->createFloatingValueList();
@@ -1758,7 +1749,7 @@ function:
$$.unit = CSSParserValue::Function;
$$.function = f;
} |
- FUNCTION maybe_space error {
+ FUNCTION maybe_space expr_recovery closing_parenthesis maybe_space {
SeRya 2013/05/08 06:24:07 Functional change is here. I extracted nonfunction
CSSParserFunction* f = parser->createFloatingFunction();
f->name = $1;
f->args = nullptr;
@@ -1767,7 +1758,7 @@ function:
$$.function = f;
}
;
-
+
calc_func_term:
unary_term { $$ = $1; }
| VARFUNCTION maybe_space IDENT ')' {
@@ -1982,5 +1973,10 @@ error_location: {
}
;
+error_recovery:
+ /* empty */
+ | error_recovery invalid_block
+ | error_recovery error
+
%%
« no previous file with comments | « LayoutTests/fast/css/parsing-error-recovery.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698