Refactoring CSS grammar
Nonfunctional change.
Introduced closing_parenthesis and error_recovery to reduce code duplication.
Extracted from https://codereview.chromium.org/14969002/
BUG=140608
Review URL: https://chromiumcodereview.appspot.com/14917019
git-svn-id: svn://svn.chromium.org/blink/trunk@149948 bbb929c8-8fbe-4397-9dbb-9b2b20218538
diff --git a/Source/core/css/CSSGrammar.y.in b/Source/core/css/CSSGrammar.y.in
index 3be5c2c..f9cd738 100644
--- a/Source/core/css/CSSGrammar.y.in
+++ b/Source/core/css/CSSGrammar.y.in
@@ -87,7 +87,7 @@
%}
-%expect 35
+%expect 33
%nonassoc LOWEST_PREC
@@ -403,6 +403,11 @@
| %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_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_recovery:
- error error_location {
+ error error_location error_recovery {
parser->syntaxError($2);
}
- | declaration_recovery invalid_block
- | declaration_recovery error
;
property:
@@ -1634,15 +1635,13 @@
$$->addValue(parser->sinkFloatingValue($3));
}
}
- | expr invalid_block_list {
+ | expr expr_recovery {
$$ = 0;
}
- | expr invalid_block_list error {
- $$ = 0;
- }
- | expr error {
- $$ = 0;
- }
+ ;
+
+expr_recovery:
+ error error_location error_recovery
;
operator:
@@ -1733,7 +1732,7 @@
;
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 @@
$$.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 {
CSSParserFunction* f = parser->createFloatingFunction();
f->name = $1;
CSSParserValueList* valueList = parser->createFloatingValueList();
@@ -1767,7 +1758,7 @@
$$.function = f;
}
;
-
+
calc_func_term:
unary_term { $$ = $1; }
| VARFUNCTION maybe_space IDENT ')' {
@@ -1963,5 +1954,11 @@
}
;
+error_recovery:
+ /* empty */
+ | error_recovery invalid_block
+ | error_recovery error
+ ;
+
%%