Changeset 13560 in webkit


Ignore:
Timestamp:
Mar 29, 2006 9:37:43 AM (18 years ago)
Author:
ap
Message:

Reviewed by Darin.

Gets the number of shift/reduce and reduce/reduce conflicts down from 37+4 to 7+0.

I have fixed the reduce/reduce conflicts, then noticed that two of the fixes
were already made in KDE tree (the other two are different because declaration
blocks are described in quite different ways). Shift/reduce fixes are just
merged from KDE, r332845 by Michael Matz.

  • css/CSSGrammar.y:
Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r13559 r13560  
     12006-03-29  Alexey Proskuryakov  <ap@nypop.com>
     2
     3        Reviewed by Darin.
     4
     5        - http://bugzilla.opendarwin.org/show_bug.cgi?id=8055
     6          Fix most CSS grammar conflicts.
     7
     8        Gets the number of shift/reduce and reduce/reduce conflicts down from 37+4 to 7+0.
     9
     10        I have fixed the reduce/reduce conflicts, then noticed that two of the fixes
     11        were already made in KDE tree (the other two are different because declaration
     12        blocks are described in quite different ways). Shift/reduce fixes are just
     13        merged from KDE, r332845 by Michael Matz.
     14
     15        * css/CSSGrammar.y:
     16
    1172006-03-29  Alexey Proskuryakov  <ap@nypop.com>
    218
  • trunk/WebCore/css/CSSGrammar.y

    r13559 r13560  
    145145//%expect 37
    146146
     147%left UNIMPORTANT_TOK
     148
    147149%token WHITESPACE SGML_CD
    148150
     
    155157%token <string> STRING
    156158
    157 %token <string> IDENT
    158 
    159 %token <string> HASH
    160 %token ':'
    161 %token '.'
    162 %token '['
    163 
    164 %token <string> '*'
     159%right <string> IDENT
     160
     161%nonassoc <string> HASH
     162%nonassoc ':'
     163%nonassoc '.'
     164%nonassoc '['
     165%nonassoc <string> '*'
     166%nonassoc error
     167%left '|'
    165168
    166169%token IMPORT_SYM
     
    290293
    291294maybe_space:
    292     /* empty */
     295    /* empty */ %prec UNIMPORTANT_TOK
    293296  | maybe_space WHITESPACE
    294297  ;
     
    381384
    382385media_list:
    383     /* empty */ {
    384         $$ = 0;
    385     }
    386     | medium {
     386    medium {
    387387        $$ = static_cast<CSSParser*>(parser)->createMediaList();
    388388        $$->appendMedium( domString($1).lower() );
     
    401401    MEDIA_SYM maybe_space media_list '{' maybe_space ruleset_list '}' {
    402402        $$ = static_cast<CSSParser*>(parser)->createMediaRule($3, $6);
     403    }
     404    | MEDIA_SYM maybe_space '{' maybe_space ruleset_list '}' {
     405        $$ = static_cast<CSSParser*>(parser)->createMediaRule(0, $5);
    403406    }
    404407    ;
     
    475478
    476479selector_list:
    477     selector {
    478         $$ = $1;
    479     }
    480     | selector_list ',' maybe_space selector {
     480    selector %prec UNIMPORTANT_TOK {
     481        $$ = $1;
     482    }
     483    | selector_list ',' maybe_space selector %prec UNIMPORTANT_TOK {
    481484        if ($1 && $4) {
    482485            CSSParser* p = static_cast<CSSParser*>(parser);
     
    523526
    524527namespace_selector:
    525     /* empty */ { $$.string = 0; $$.length = 0; }
    526     | '*' { static unsigned short star = '*'; $$.string = &star; $$.length = 1; }
    527     | IDENT { $$ = $1; }
     528    /* empty */ '|' { $$.string = 0; $$.length = 0; }
     529    | '*' '|' { static unsigned short star = '*'; $$.string = &star; $$.length = 1; }
     530    | IDENT '|' { $$ = $1; }
    528531;
    529532
     
    547550            $$->tag = QualifiedName(nullAtom, starAtom, p->defaultNamespace);
    548551    }
    549     | namespace_selector '|' element_name maybe_space {
     552    | namespace_selector element_name maybe_space {
    550553        AtomicString namespacePrefix = atomicString($1);
    551554        CSSParser *p = static_cast<CSSParser *>(parser);
     
    553556        if (p->styleElement && p->styleElement->isCSSStyleSheet())
    554557            $$->tag = QualifiedName(namespacePrefix,
    555                                     atomicString($3),
     558                                    atomicString($2),
    556559                                    static_cast<CSSStyleSheet*>(p->styleElement)->determineNamespace(namespacePrefix));
    557560        else // FIXME: Shouldn't this case be an error?
    558             $$->tag = QualifiedName(nullAtom, atomicString($3), p->defaultNamespace);
    559     }
    560     | namespace_selector '|' element_name specifier_list maybe_space {
    561         $$ = $4;
     561            $$->tag = QualifiedName(nullAtom, atomicString($2), p->defaultNamespace);
     562    }
     563    | namespace_selector element_name specifier_list maybe_space {
     564        $$ = $3;
    562565        if ($$) {
    563566            AtomicString namespacePrefix = atomicString($1);
     
    565568            if (p->styleElement && p->styleElement->isCSSStyleSheet())
    566569                $$->tag = QualifiedName(namespacePrefix,
    567                                         atomicString($3),
     570                                        atomicString($2),
    568571                                        static_cast<CSSStyleSheet*>(p->styleElement)->determineNamespace(namespacePrefix));
    569572            else // FIXME: Shouldn't this case be an error?
    570                 $$->tag = QualifiedName(nullAtom, atomicString($3), p->defaultNamespace);
    571         }
    572     }
    573     | namespace_selector '|' specifier_list maybe_space {
    574         $$ = $3;
     573                $$->tag = QualifiedName(nullAtom, atomicString($2), p->defaultNamespace);
     574        }
     575    }
     576    | namespace_selector specifier_list maybe_space {
     577        $$ = $2;
    575578        if ($$) {
    576579            AtomicString namespacePrefix = atomicString($1);
     
    670673        $$->value = atomicString($6);
    671674    }
    672     | '[' maybe_space namespace_selector '|' attr_name ']' {
     675    | '[' maybe_space namespace_selector attr_name ']' {
    673676        AtomicString namespacePrefix = atomicString($3);
    674677        CSSParser *p = static_cast<CSSParser *>(parser);
    675678        $$ = p->createFloatingSelector();
    676679        $$->attr = QualifiedName(namespacePrefix,
    677                                  atomicString($5),
     680                                 atomicString($4),
    678681                                 static_cast<CSSStyleSheet*>(p->styleElement)->determineNamespace(namespacePrefix));
    679682        $$->match = CSSSelector::Set;
    680683    }
    681     | '[' maybe_space namespace_selector '|' attr_name match maybe_space ident_or_string maybe_space ']' {
     684    | '[' maybe_space namespace_selector attr_name match maybe_space ident_or_string maybe_space ']' {
    682685        AtomicString namespacePrefix = atomicString($3);
    683686        CSSParser *p = static_cast<CSSParser *>(parser);
    684687        $$ = p->createFloatingSelector();
    685688        $$->attr = QualifiedName(namespacePrefix,
    686                                  atomicString($5),
     689                                 atomicString($4),
    687690                                 static_cast<CSSStyleSheet*>(p->styleElement)->determineNamespace(namespacePrefix));
    688         $$->match = (CSSSelector::Match)$6;
    689         $$->value = atomicString($8);
     691        $$->match = (CSSSelector::Match)$5;
     692        $$->value = atomicString($7);
    690693    }
    691694  ;
     
    819822    }
    820823    |
    821     prio {
     824    IMPORTANT_SYM maybe_space {
    822825        /* Handle this case: div { text-align: center; !important } Just reduce away the stray !important. */
    823826        $$ = false;
Note: See TracChangeset for help on using the changeset viewer.