CSS2.1 Grammar

Author: wayland76, David Warring

This should be doing CSS2.1; hopefully CSS3 when that's ready (but that may be a while).

Source code: CSSGrammar.pm

use v6;

grammar CSSGrammar {
        # builtin: ident (we use cssident), alpha

        token TOP         { ^ * * $ || <.panic: "CSS parsing failed"> }
        token css         {  |  |  }
        rule ruleset      {  +% ',' '{' ~ '}'  }
        rule declarations {  +%% ';' }
        rule selector     {  +% ? }
        rule simple_selector   {  [  ]* | + }
        token hcap        { '#' |  | '[' ~ ']'  |  }
        token class       { '.'  }
        token element_name {  | '*' }
        token attrib      {  [ [ '=' |  |  ] [  |  ] ]? }
        token pseudo      { ':' [  ~ ')' ? |  ] }
        token combinator  { '+' | '>' }

        rule declaration  {  ':'  ? }
        token property    {  }
        token prio        {  }
        token expr        {  +% ? }
        token cssident    { '-'?* }
        rule term         { ?
                [  |  |  |  |  |