17 |
%name parser |
%name parser |
18 |
%tokentype { TokenPosn } |
%tokentype { TokenPosn } |
19 |
%token |
%token |
20 |
|
S { (S , _) } |
21 |
INCLUDES { (INCLUDES , _) } |
INCLUDES { (INCLUDES , _) } |
22 |
DASHMATCH { (DASHMATCH , _) } |
DASHMATCH { (DASHMATCH , _) } |
23 |
LBRACE { (LBRACE , _) } |
LBRACE { (LBRACE , _) } |
59 |
%% |
%% |
60 |
|
|
61 |
stylesheet :: { Stylesheet } |
stylesheet :: { Stylesheet } |
62 |
: charset import_list statement_list { Stylesheet $1 $2 $3 } |
: charset s import_list s statement_list s |
63 |
|
{ Stylesheet $1 $3 $5 } |
64 |
|
|
65 |
charset :: { Maybe String } |
charset :: { Maybe String } |
66 |
: { Nothing } |
: { Nothing } |
67 |
| CHARSET_SYM STRING SEMI { Just $2 } |
| CHARSET_SYM s STRING s SEMI { Just $3 } |
68 |
|
|
69 |
import_list :: { [(String, [String])] } |
import_list :: { [(String, [String])] } |
70 |
: { [] } |
: { [] } |
71 |
| import_list import { $2 : $1 } |
| import_list s import { $3 : $1 } |
72 |
|
|
73 |
import :: { (String, [String]) } |
import :: { (String, [String]) } |
74 |
: IMPORT_SYM STRING medium_list SEMI { ($2, $3) } |
: IMPORT_SYM s STRING s medium_list SEMI s |
75 |
| IMPORT_SYM URI medium_list SEMI { ($2, $3) } |
{ ($3, $5) } |
76 |
|
| IMPORT_SYM s URI s medium_list SEMI s { ($3, $5) } |
77 |
|
|
78 |
statement_list :: { [Statement] } |
statement_list :: { [Statement] } |
79 |
: { [] } |
: { [] } |
80 |
| statement_list statement { $2 : $1 } |
| statement_list s statement { $3 : $1 } |
81 |
|
|
82 |
statement :: { Statement } |
statement :: { Statement } |
83 |
: ruleset { $1 } |
: ruleset { $1 } |
90 |
|
|
91 |
medium_list_1 :: { [String] } |
medium_list_1 :: { [String] } |
92 |
: medium { [$1] } |
: medium { [$1] } |
93 |
| medium_list_1 COMMA medium { $3 : $1 } |
| medium_list_1 s COMMA s medium { $5 : $1 } |
94 |
|
|
95 |
media :: { Statement } |
media :: { Statement } |
96 |
: MEDIA_SYM medium_list_1 LBRACE ruleset_list RBRACE |
: MEDIA_SYM s medium_list_1 s LBRACE s ruleset_list s RBRACE |
97 |
{ Media $2 $4 } |
{ Media $3 $7 } |
98 |
|
|
99 |
medium :: { String } |
medium :: { String } |
100 |
: IDENT { $1 } |
: IDENT { $1 } |
101 |
|
|
102 |
ruleset_list :: { [Statement] } |
ruleset_list :: { [Statement] } |
103 |
: { [] } |
: { [] } |
104 |
| ruleset_list ruleset { $2 : $1 } |
| ruleset_list s ruleset { $3 : $1 } |
105 |
|
|
106 |
page :: { Statement } |
page :: { Statement } |
107 |
: PAGE_SYM LBRACE declaration_list_1 RBRACE |
: PAGE_SYM s LBRACE s declaration_list_1 s RBRACE |
108 |
{ Page Nothing $3 } |
{ Page Nothing $5 } |
109 |
| PAGE_SYM pseudo_page LBRACE declaration_list_1 RBRACE |
| PAGE_SYM s pseudo_page s LBRACE s declaration_list_1 RBRACE |
110 |
{ Page (Just $2) $4 } |
{ Page (Just $3) $7 } |
111 |
|
|
112 |
declaration_list_1 :: { [Declaration] } |
declaration_list_1 :: { [Declaration] } |
113 |
: { [] } |
: { [] } |
114 |
| declaration { [$1] } |
| declaration s { [$1] } |
115 |
| declaration_list_1 SEMI { $1 } |
| declaration_list_1 s SEMI { $1 } |
116 |
| declaration_list_1 SEMI declaration { $3 : $1 } |
| declaration_list_1 s SEMI s declaration |
117 |
|
{ $5 : $1 } |
118 |
|
|
119 |
pseudo_page :: { String } |
pseudo_page :: { String } |
120 |
: COLON IDENT { $2 } |
: COLON IDENT { $2 } |
121 |
|
|
122 |
ruleset :: { Statement } |
ruleset :: { Statement } |
123 |
: selector_list_1 LBRACE declaration_list_1 RBRACE |
: selector_list_1 s LBRACE s declaration_list_1 s RBRACE |
124 |
{ Ruleset $1 $3 } |
{ Ruleset $1 $5 } |
125 |
|
|
126 |
selector_list_1 :: { [Selector] } |
selector_list_1 :: { [Selector] } |
127 |
: selector { [$1] } |
: selector { [$1] } |
128 |
| selector_list_1 COMMA selector { $3 : $1 } |
| selector_list_1 COMMA s selector { $4 : $1 } |
129 |
|
|
130 |
selector :: { Selector } |
selector :: { Selector } |
131 |
: simple_selector { [($1, NoMore)] } |
: simple_selector { [($1, NoMore)] } |
132 |
| simple_selector combinator selector { ($1, $2) : $3 } |
| simple_selector combinator selector |
133 |
|
{ ($1, $2) : $3 } |
134 |
|
|
135 |
combinator :: { Combinator } |
combinator :: { Combinator } |
136 |
: { Ancestor } |
: PLUS s { Preceded } |
137 |
| PLUS { Preceded } |
| GREATER s { Parent } |
138 |
| GREATER { Parent } |
| S { Ancestor } |
139 |
|
|
140 |
simple_selector :: { SimpleSelector } |
simple_selector :: { SimpleSelector } |
141 |
: element_name detail_list_1 { ($1, $2) } |
: element_name detail_list_1 { ($1, $2) } |
160 |
: DOT IDENT { Class $2 } |
: DOT IDENT { Class $2 } |
161 |
|
|
162 |
attrib :: { Detail } |
attrib :: { Detail } |
163 |
: LBRAC IDENT RBRAC { Attrib $2 } |
: LBRAC s IDENT s RBRAC { Attrib $3 } |
164 |
| LBRAC IDENT EQUALS IDENT RBRAC { AttribEq $2 $4 } |
| LBRAC s IDENT s EQUALS s IDENT s RBRAC |
165 |
| LBRAC IDENT EQUALS STRING RBRAC { AttribEq $2 $4 } |
{ AttribEq $3 $7 } |
166 |
| LBRAC IDENT INCLUDES IDENT RBRAC { AttribInc $2 $4 } |
| LBRAC s IDENT s EQUALS s STRING s RBRAC |
167 |
| LBRAC IDENT INCLUDES STRING RBRAC { AttribInc $2 $4 } |
{ AttribEq $3 $7 } |
168 |
| LBRAC IDENT DASHMATCH IDENT RBRAC { AttribDM $2 $4 } |
| LBRAC s IDENT s INCLUDES s IDENT s RBRAC |
169 |
| LBRAC IDENT DASHMATCH STRING RBRAC { AttribDM $2 $4 } |
{ AttribInc $3 $7 } |
170 |
|
| LBRAC s IDENT s INCLUDES s STRING s RBRAC |
171 |
|
{ AttribInc $3 $7 } |
172 |
|
| LBRAC s IDENT s DASHMATCH s IDENT s RBRAC |
173 |
|
{ AttribDM $3 $7 } |
174 |
|
| LBRAC s IDENT s DASHMATCH s STRING s RBRAC |
175 |
|
{ AttribDM $3 $7 } |
176 |
|
|
177 |
pseudo :: { Detail } |
pseudo :: { Detail } |
178 |
: COLON IDENT { Pseudo $2 } |
: COLON IDENT { Pseudo $2 } |
179 |
| COLON FUNCTION RPAREN { PseudoFunc $2 "" } |
| COLON FUNCTION s RPAREN { PseudoFunc $2 "" } |
180 |
| COLON FUNCTION IDENT RPAREN { PseudoFunc $2 $3 } |
| COLON FUNCTION s IDENT s RPAREN { PseudoFunc $2 $4 } |
181 |
|
|
182 |
declaration :: { Declaration } |
declaration :: { Declaration } |
183 |
: property COLON value_list_1 { ($1, $3, False) } |
: property COLON s value_list_1 { ($1, $4, False) } |
184 |
| property COLON value_list_1 prio { ($1, $3, True) } |
| property COLON s value_list_1 s prio { ($1, $4, True) } |
185 |
|
|
186 |
property :: { String } |
property :: { String } |
187 |
: IDENT { $1 } |
: IDENT { $1 } |
191 |
|
|
192 |
value_list :: { [Value] } |
value_list :: { [Value] } |
193 |
: { [] } |
: { [] } |
194 |
| value value_list { $1 : $2 } |
| value s value_list { $1 : $3 } |
195 |
|
|
196 |
value_list_1 :: { [Value] } |
value_list_1 :: { [Value] } |
197 |
: value { [$1] } |
: value { [$1] } |
198 |
| value value_list_1 { $1 : $2 } |
| value s value_list_1 { $1 : $3 } |
199 |
|
|
200 |
value :: { Value } |
value :: { Value } |
201 |
: NUMBER { Number $1 } |
: NUMBER { Number $1 } |
212 |
| HASH { HexColour $1 } |
| HASH { HexColour $1 } |
213 |
| SLASH { Slash } |
| SLASH { Slash } |
214 |
| COMMA { Comma } |
| COMMA { Comma } |
215 |
| FUNCTION value_list RPAREN { Function $1 $2 } |
| FUNCTION s value_list s RPAREN { Function $1 $3 } |
216 |
|
|
217 |
|
s :: {} |
218 |
|
: { } |
219 |
|
| S { } |
220 |
|
|
221 |
{ |
{ |
222 |
happyError :: [TokenPosn] -> a |
happyError :: [TokenPosn] -> a |