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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « LayoutTests/fast/css/parsing-error-recovery.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2002-2003 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2002-2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 App le Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 App le Inc. All rights reserved.
4 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) 4 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com)
5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> 5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
6 * Copyright (C) 2012 Intel Corporation. All rights reserved. 6 * Copyright (C) 2012 Intel Corporation. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public 9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 case VAR_DEFINITION: 80 case VAR_DEFINITION:
81 case UNICODERANGE: 81 case UNICODERANGE:
82 return true; 82 return true;
83 default: 83 default:
84 return false; 84 return false;
85 } 85 }
86 } 86 }
87 87
88 %} 88 %}
89 89
90 %expect 35 90 %expect 34
91 91
92 %nonassoc LOWEST_PREC 92 %nonassoc LOWEST_PREC
93 93
94 %left UNIMPORTANT_TOK 94 %left UNIMPORTANT_TOK
95 95
96 %token WHITESPACE SGML_CD 96 %token WHITESPACE SGML_CD
97 %token TOKEN_EOF 0 97 %token TOKEN_EOF 0
98 98
99 %token INCLUDES 99 %token INCLUDES
100 %token DASHMATCH 100 %token DASHMATCH
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 /* empty */ 396 /* empty */
397 | charset { 397 | charset {
398 } 398 }
399 ; 399 ;
400 400
401 closing_brace: 401 closing_brace:
402 '}' 402 '}'
403 | %prec LOWEST_PREC TOKEN_EOF 403 | %prec LOWEST_PREC TOKEN_EOF
404 ; 404 ;
405 405
406 closing_parenthesis:
407 ')'
408 | %prec LOWEST_PREC TOKEN_EOF
409 ;
410
406 charset: 411 charset:
407 CHARSET_SYM maybe_space STRING maybe_space ';' { 412 CHARSET_SYM maybe_space STRING maybe_space ';' {
408 if (parser->m_styleSheet) 413 if (parser->m_styleSheet)
409 parser->m_styleSheet->parserSetEncodingFromCharsetRule($3); 414 parser->m_styleSheet->parserSetEncodingFromCharsetRule($3);
410 parser->startEndUnknownRule(); 415 parser->startEndUnknownRule();
411 $$ = 0; 416 $$ = 0;
412 } 417 }
413 | CHARSET_SYM error invalid_block { 418 | CHARSET_SYM error invalid_block {
414 } 419 }
415 | CHARSET_SYM error ';' { 420 | CHARSET_SYM error ';' {
(...skipping 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1536 if ($2) 1541 if ($2)
1537 $$ = $2; 1542 $$ = $2;
1538 } 1543 }
1539 | decl_list decl_list_recovery ';' maybe_space { 1544 | decl_list decl_list_recovery ';' maybe_space {
1540 parser->startProperty(); 1545 parser->startProperty();
1541 $$ = $1; 1546 $$ = $1;
1542 } 1547 }
1543 ; 1548 ;
1544 1549
1545 decl_list_recovery: 1550 decl_list_recovery:
1546 error error_location { 1551 error error_location error_recovery {
1547 parser->syntaxError($2, CSSParser::PropertyDeclarationError); 1552 parser->syntaxError($2, CSSParser::PropertyDeclarationError);
1548 } 1553 }
1549 | decl_list_recovery invalid_block
1550 | decl_list_recovery error
1551 ; 1554 ;
1552 1555
1553 declaration: 1556 declaration:
1554 VAR_DEFINITION ':' maybe_space expr prio { 1557 VAR_DEFINITION ':' maybe_space expr prio {
1555 parser->storeVariableDeclaration($1, parser->sinkFloatingValueList($4), $5); 1558 parser->storeVariableDeclaration($1, parser->sinkFloatingValueList($4), $5);
1556 $$ = true; 1559 $$ = true;
1557 parser->endProperty($5, true); 1560 parser->endProperty($5, true);
1558 } 1561 }
1559 | 1562 |
1560 property ':' maybe_space expr prio { 1563 property ':' maybe_space expr prio {
(...skipping 30 matching lines...) Expand all
1591 } 1594 }
1592 | 1595 |
1593 property ':' maybe_space declaration_recovery { 1596 property ':' maybe_space declaration_recovery {
1594 /* if we come across rules with invalid values like this case: p { weigh t: *; }, just discard the rule */ 1597 /* if we come across rules with invalid values like this case: p { weigh t: *; }, just discard the rule */
1595 parser->endProperty(false, false); 1598 parser->endProperty(false, false);
1596 $$ = false; 1599 $$ = false;
1597 } 1600 }
1598 ; 1601 ;
1599 1602
1600 declaration_recovery: 1603 declaration_recovery:
1601 error error_location { 1604 error error_location error_recovery {
1602 parser->syntaxError($2); 1605 parser->syntaxError($2);
1603 } 1606 }
1604 | declaration_recovery invalid_block
1605 | declaration_recovery error
1606 ; 1607 ;
1607 1608
1608 property: 1609 property:
1609 IDENT maybe_space { 1610 IDENT maybe_space {
1610 $$ = cssPropertyID($1); 1611 $$ = cssPropertyID($1);
1611 } 1612 }
1612 ; 1613 ;
1613 1614
1614 prio: 1615 prio:
1615 IMPORTANT_SYM maybe_space { $$ = true; } 1616 IMPORTANT_SYM maybe_space { $$ = true; }
(...skipping 11 matching lines...) Expand all
1627 if ($2) { 1628 if ($2) {
1628 CSSParserValue v; 1629 CSSParserValue v;
1629 v.id = 0; 1630 v.id = 0;
1630 v.unit = CSSParserValue::Operator; 1631 v.unit = CSSParserValue::Operator;
1631 v.iValue = $2; 1632 v.iValue = $2;
1632 $$->addValue(v); 1633 $$->addValue(v);
1633 } 1634 }
1634 $$->addValue(parser->sinkFloatingValue($3)); 1635 $$->addValue(parser->sinkFloatingValue($3));
1635 } 1636 }
1636 } 1637 }
1637 | expr invalid_block_list { 1638 | expr expr_recovery {
1638 $$ = 0; 1639 $$ = 0;
1639 } 1640 }
1640 | expr invalid_block_list error { 1641 ;
1641 $$ = 0; 1642
1642 } 1643 expr_recovery:
1643 | expr error { 1644 error error_location error_recovery
1644 $$ = 0;
1645 }
1646 ; 1645 ;
1647 1646
1648 operator: 1647 operator:
1649 '/' maybe_space { 1648 '/' maybe_space {
1650 $$ = '/'; 1649 $$ = '/';
1651 } 1650 }
1652 | ',' maybe_space { 1651 | ',' maybe_space {
1653 $$ = ','; 1652 $$ = ',';
1654 } 1653 }
1655 | /* empty */ { 1654 | /* empty */ {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1726 | VH { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_VH; } 1725 | VH { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_VH; }
1727 | VMIN { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_VMIN; } 1726 | VMIN { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_VMIN; }
1728 | VMAX { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_VMAX; } 1727 | VMAX { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_VMAX; }
1729 | DPPX { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_DPPX; } 1728 | DPPX { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_DPPX; }
1730 | DPI { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_DPI; } 1729 | DPI { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_DPI; }
1731 | DPCM { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_DPCM; } 1730 | DPCM { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_DPCM; }
1732 | FR { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_FR; } 1731 | FR { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_FR; }
1733 ; 1732 ;
1734 1733
1735 function: 1734 function:
1736 FUNCTION maybe_space expr ')' maybe_space { 1735 FUNCTION maybe_space expr closing_parenthesis maybe_space {
1737 CSSParserFunction* f = parser->createFloatingFunction(); 1736 CSSParserFunction* f = parser->createFloatingFunction();
1738 f->name = $1; 1737 f->name = $1;
1739 f->args = parser->sinkFloatingValueList($3); 1738 f->args = parser->sinkFloatingValueList($3);
1740 $$.id = 0; 1739 $$.id = 0;
1741 $$.unit = CSSParserValue::Function; 1740 $$.unit = CSSParserValue::Function;
1742 $$.function = f; 1741 $$.function = f;
1743 } | 1742 } |
1744 FUNCTION maybe_space expr TOKEN_EOF { 1743 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
1745 CSSParserFunction* f = parser->createFloatingFunction();
1746 f->name = $1;
1747 f->args = parser->sinkFloatingValueList($3);
1748 $$.id = 0;
1749 $$.unit = CSSParserValue::Function;
1750 $$.function = f;
1751 } |
1752 FUNCTION maybe_space ')' maybe_space {
1753 CSSParserFunction* f = parser->createFloatingFunction(); 1744 CSSParserFunction* f = parser->createFloatingFunction();
1754 f->name = $1; 1745 f->name = $1;
1755 CSSParserValueList* valueList = parser->createFloatingValueList(); 1746 CSSParserValueList* valueList = parser->createFloatingValueList();
1756 f->args = parser->sinkFloatingValueList(valueList); 1747 f->args = parser->sinkFloatingValueList(valueList);
1757 $$.id = 0; 1748 $$.id = 0;
1758 $$.unit = CSSParserValue::Function; 1749 $$.unit = CSSParserValue::Function;
1759 $$.function = f; 1750 $$.function = f;
1760 } | 1751 } |
1761 FUNCTION maybe_space error { 1752 FUNCTION maybe_space expr_recovery closing_parenthesis maybe_space {
SeRya 2013/05/08 06:24:07 Functional change is here. I extracted nonfunction
1762 CSSParserFunction* f = parser->createFloatingFunction(); 1753 CSSParserFunction* f = parser->createFloatingFunction();
1763 f->name = $1; 1754 f->name = $1;
1764 f->args = nullptr; 1755 f->args = nullptr;
1765 $$.id = 0; 1756 $$.id = 0;
1766 $$.unit = CSSParserValue::Function; 1757 $$.unit = CSSParserValue::Function;
1767 $$.function = f; 1758 $$.function = f;
1768 } 1759 }
1769 ; 1760 ;
1770 1761
1771 calc_func_term: 1762 calc_func_term:
1772 unary_term { $$ = $1; } 1763 unary_term { $$ = $1; }
1773 | VARFUNCTION maybe_space IDENT ')' { 1764 | VARFUNCTION maybe_space IDENT ')' {
1774 $$.id = 0; 1765 $$.id = 0;
1775 $$.string = $3; 1766 $$.string = $3;
1776 $$.unit = CSSPrimitiveValue::CSS_VARIABLE_NAME; 1767 $$.unit = CSSPrimitiveValue::CSS_VARIABLE_NAME;
1777 } 1768 }
1778 | unary_operator unary_term { $$ = $2; $$.fValue *= $1; } 1769 | unary_operator unary_term { $$ = $2; $$.fValue *= $1; }
1779 ; 1770 ;
1780 1771
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1975 invalid_block_list: 1966 invalid_block_list:
1976 invalid_block 1967 invalid_block
1977 | invalid_block_list error invalid_block 1968 | invalid_block_list error invalid_block
1978 ; 1969 ;
1979 1970
1980 error_location: { 1971 error_location: {
1981 $$ = parser->currentLocation(); 1972 $$ = parser->currentLocation();
1982 } 1973 }
1983 ; 1974 ;
1984 1975
1976 error_recovery:
1977 /* empty */
1978 | error_recovery invalid_block
1979 | error_recovery error
1980
1985 %% 1981 %%
1986 1982
OLDNEW
« 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