OLD | NEW |
---|---|
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 Loading... | |
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 38 | 90 %expect 35 |
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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
307 %type <valueList> calc_func_expr | 307 %type <valueList> calc_func_expr |
308 %type <valueList> calc_func_expr_list | 308 %type <valueList> calc_func_expr_list |
309 %type <valueList> calc_func_paren_expr | 309 %type <valueList> calc_func_paren_expr |
310 %type <value> calc_function | 310 %type <value> calc_function |
311 %type <string> min_or_max | 311 %type <string> min_or_max |
312 %type <value> min_or_max_function | 312 %type <value> min_or_max_function |
313 | 313 |
314 %type <string> element_name | 314 %type <string> element_name |
315 %type <string> attr_name | 315 %type <string> attr_name |
316 | 316 |
317 %type <location> errors | |
318 %type <location> error_location | 317 %type <location> error_location |
319 | 318 |
320 %% | 319 %% |
321 | 320 |
322 stylesheet: | 321 stylesheet: |
323 maybe_space maybe_charset maybe_sgml rule_list | 322 maybe_space maybe_charset maybe_sgml rule_list |
324 | internal_decls maybe_space | 323 | internal_decls maybe_space |
325 | internal_rule maybe_space | 324 | internal_rule maybe_space |
326 | internal_selector maybe_space | 325 | internal_selector maybe_space |
327 | internal_value maybe_space | 326 | internal_value maybe_space |
(...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1519 | decl_list decl_list_recovery { | 1518 | decl_list decl_list_recovery { |
1520 $$ = $1; | 1519 $$ = $1; |
1521 } | 1520 } |
1522 ; | 1521 ; |
1523 | 1522 |
1524 decl_list: | 1523 decl_list: |
1525 declaration ';' maybe_space { | 1524 declaration ';' maybe_space { |
1526 parser->startProperty(); | 1525 parser->startProperty(); |
1527 $$ = $1; | 1526 $$ = $1; |
1528 } | 1527 } |
1529 | declaration error_location invalid_block_list maybe_space { | |
SeRya
2013/04/29 18:01:26
What's wrong with this rule?
1. It covers "body {
| |
1530 parser->syntaxError($2); | |
1531 parser->startProperty(); | |
1532 $$ = false; | |
1533 } | |
1534 | declaration error_location invalid_block_list ';' maybe_space { | |
SeRya
2013/04/29 18:01:26
Same as above. Just add that #inv1 guarantees this
| |
1535 parser->syntaxError($2); | |
1536 parser->startProperty(); | |
1537 $$ = false; | |
1538 } | |
1539 | decl_list_recovery ';' maybe_space { | 1528 | decl_list_recovery ';' maybe_space { |
1540 parser->startProperty(); | 1529 parser->startProperty(); |
1541 $$ = false; | 1530 $$ = false; |
1542 } | 1531 } |
1543 | decl_list declaration ';' maybe_space { | 1532 | decl_list declaration ';' maybe_space { |
1544 parser->startProperty(); | 1533 parser->startProperty(); |
1545 $$ = $1; | 1534 $$ = $1; |
1546 if ($2) | 1535 if ($2) |
1547 $$ = $2; | 1536 $$ = $2; |
1548 } | 1537 } |
(...skipping 27 matching lines...) Expand all Loading... | |
1576 $$ = parser->parseValue(static_cast<CSSPropertyID>($1), $5); | 1565 $$ = parser->parseValue(static_cast<CSSPropertyID>($1), $5); |
1577 if (!$$) | 1566 if (!$$) |
1578 parser->rollbackLastProperties(parser->m_parsedProperties.size() - oldParsedProperties); | 1567 parser->rollbackLastProperties(parser->m_parsedProperties.size() - oldParsedProperties); |
1579 else | 1568 else |
1580 isPropertyParsed = true; | 1569 isPropertyParsed = true; |
1581 parser->m_valueList = nullptr; | 1570 parser->m_valueList = nullptr; |
1582 } | 1571 } |
1583 parser->endProperty($5, isPropertyParsed); | 1572 parser->endProperty($5, isPropertyParsed); |
1584 } | 1573 } |
1585 | | 1574 | |
1586 property errors { | 1575 property declaration_recovery { |
SeRya
2013/04/29 18:01:26
Why this change? To inforce #inv1.
"error" is cove
| |
1587 parser->syntaxError($2); | |
1588 parser->endProperty(false, false, CSSParser::GeneralSyntaxError); | 1576 parser->endProperty(false, false, CSSParser::GeneralSyntaxError); |
1589 $$ = false; | 1577 $$ = false; |
1590 } | 1578 } |
1591 | | 1579 | |
1592 property ':' maybe_space errors expr prio { | 1580 property ':' maybe_space expr prio declaration_recovery { |
SeRya
2013/04/29 18:01:26
What's wrong with this rule?
1. It covers exactly
| |
1593 /* The default movable type template has letter-spacing: .none; Handle this by looking for | |
1594 error tokens at the start of an expr, recover the expr and then treat as an error, cleaning | |
1595 up and deleting the shifted expr. */ | |
1596 parser->syntaxError($4); | |
1597 parser->endProperty(false, false); | |
1598 $$ = false; | |
1599 } | |
1600 | | |
1601 property ':' maybe_space expr prio error { | |
1602 /* When we encounter something like p {color: red !important fail;} we s hould drop the declaration */ | 1581 /* When we encounter something like p {color: red !important fail;} we s hould drop the declaration */ |
1603 parser->endProperty(false, false); | 1582 parser->endProperty(false, false); |
1604 $$ = false; | 1583 $$ = false; |
1605 } | 1584 } |
1606 | | 1585 | |
1607 IMPORTANT_SYM maybe_space error_location { | 1586 IMPORTANT_SYM maybe_space declaration_recovery { |
SeRya
2013/04/29 18:01:26
What's wrong?
Violate #inv1.
"body { !important ;
| |
1608 /* Handle this case: div { text-align: center; !important } Just reduce away the stray !important. */ | 1587 /* Handle this case: div { text-align: center; !important } Just reduce away the stray !important. */ |
1609 parser->syntaxError($3); | |
1610 parser->endProperty(false, false, CSSParser::GeneralSyntaxError); | 1588 parser->endProperty(false, false, CSSParser::GeneralSyntaxError); |
1611 $$ = false; | 1589 $$ = false; |
1612 } | 1590 } |
1613 | | 1591 | |
1614 property ':' maybe_space error_location { | 1592 property ':' maybe_space declaration_recovery { |
SeRya
2013/04/29 18:01:26
What's wrong with this rule:
1. It's redundant. "p
SeRya
2013/04/29 18:01:26
What's wrong with this rule?
It's redundant. "div
| |
1615 /* div { font-family: } Just reduce away this property with no value. */ | 1593 /* if we come across rules with invalid values like this case: p { weigh t: *; }, just discard the rule */ |
1616 parser->syntaxError($4); | |
1617 parser->endProperty(false, false); | 1594 parser->endProperty(false, false); |
1618 $$ = false; | 1595 $$ = false; |
1619 } | 1596 } |
1620 | | |
1621 property ':' maybe_space errors { | |
SeRya
2013/04/29 18:01:26
Tranformed to "property ':' maybe_space declaratio
SeRya
2013/04/29 18:01:26
Transformed to "property ':' maybe_space declarati
| |
1622 /* if we come across rules with invalid values like this case: p { weigh t: *; }, just discard the rule */ | |
1623 parser->syntaxError($4); | |
1624 parser->endProperty(false, false); | |
1625 $$ = false; | |
1626 } | |
1627 | | |
1628 property error_location invalid_block { | |
SeRya
2013/04/29 18:01:26
It perfectly covered by "property declaration_reco
| |
1629 /* if we come across: div { color{;color:maroon} }, ignore everything wi thin curly brackets */ | |
1630 parser->syntaxError($2); | |
1631 parser->endProperty(false, false, CSSParser::GeneralSyntaxError); | |
1632 $$ = false; | |
1633 } | |
1634 ; | 1597 ; |
1635 | 1598 |
1599 declaration_recovery: | |
1600 error error_location { | |
1601 parser->syntaxError($2); | |
1602 } | |
1603 | declaration_recovery invalid_block | |
1604 | declaration_recovery error | |
1605 ; | |
1606 | |
1636 property: | 1607 property: |
1637 IDENT maybe_space { | 1608 IDENT maybe_space { |
1638 $$ = cssPropertyID($1); | 1609 $$ = cssPropertyID($1); |
1639 } | 1610 } |
1640 ; | 1611 ; |
1641 | 1612 |
1642 prio: | 1613 prio: |
1643 IMPORTANT_SYM maybe_space { $$ = true; } | 1614 IMPORTANT_SYM maybe_space { $$ = true; } |
1644 | /* empty */ { $$ = false; } | 1615 | /* empty */ { $$ = false; } |
1645 ; | 1616 ; |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1997 | '{' error closing_brace { | 1968 | '{' error closing_brace { |
1998 parser->invalidBlockHit(); | 1969 parser->invalidBlockHit(); |
1999 } | 1970 } |
2000 ; | 1971 ; |
2001 | 1972 |
2002 invalid_block_list: | 1973 invalid_block_list: |
2003 invalid_block | 1974 invalid_block |
2004 | invalid_block_list error invalid_block | 1975 | invalid_block_list error invalid_block |
2005 ; | 1976 ; |
2006 | 1977 |
2007 errors: | |
2008 error error_location { | |
2009 $$ = $2; | |
2010 } | |
2011 ; | |
2012 | |
2013 error_location: { | 1978 error_location: { |
2014 $$ = parser->currentLocation(); | 1979 $$ = parser->currentLocation(); |
2015 } | 1980 } |
2016 ; | 1981 ; |
2017 | 1982 |
2018 %% | 1983 %% |
2019 | 1984 |
OLD | NEW |