line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CSS::Parse::PRDGrammar; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$VERSION = 1.01; |
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
74
|
|
6
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
234
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
$CSS::Parse::PRDGrammar::GRAMMAR = q! |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
## |
11
|
|
|
|
|
|
|
## RULES |
12
|
|
|
|
|
|
|
## |
13
|
|
|
|
|
|
|
stylesheet: ( |
14
|
|
|
|
|
|
|
WS {2;} |
15
|
|
|
|
|
|
|
| statement {3;} |
16
|
|
|
|
|
|
|
)(s) {$return = $all_rulesets;} |
17
|
|
|
|
|
|
|
stylesheet: <rulevar: local $all_rulesets> |
18
|
|
|
|
|
|
|
statement: ruleset {4;} |
19
|
|
|
|
|
|
|
| atrule {5;} |
20
|
|
|
|
|
|
|
atrule: ATKEYWORD WS(s?) any(s?) ( block | ';' WS(s?) ) {print "at-rule\\n"} |
21
|
|
|
|
|
|
|
block: '{' WS(s?) ( any | block | ATKEYWORD WS(s?) | ';' )(s?) '}' WS(s?) {print "block\\n"} |
22
|
|
|
|
|
|
|
ruleset: selector(?) '{' WS(s?) declaration(?) ( |
23
|
|
|
|
|
|
|
';' WS(s?) declaration(?) {6;} |
24
|
|
|
|
|
|
|
)(s?) '}' WS(s?) {push @{$all_rulesets}, $ruleset; 1;} |
25
|
|
|
|
|
|
|
ruleset: <rulevar: local $ruleset = new CSS::Style();> |
26
|
|
|
|
|
|
|
selector: any(s) |
27
|
|
|
|
|
|
|
{ |
28
|
|
|
|
|
|
|
$ruleset->add_selector(new CSS::Selector({'name' => $_})) |
29
|
|
|
|
|
|
|
for(map{s/^\s*(.*?)\s*$/$1/;$_}split /\\s*,\\s*/, join('',@{$item[1]})); |
30
|
|
|
|
|
|
|
1; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
declaration: property ':' WS(s?) value |
33
|
|
|
|
|
|
|
{ |
34
|
|
|
|
|
|
|
$ruleset->add_property(new CSS::Property({ |
35
|
|
|
|
|
|
|
'property' => $item[1], |
36
|
|
|
|
|
|
|
'value' => $item[4], |
37
|
|
|
|
|
|
|
})); |
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
declaration: <rulevar: local $value> |
41
|
|
|
|
|
|
|
property: IDENT OWS {$return = $item[1]} |
42
|
|
|
|
|
|
|
value: ( |
43
|
|
|
|
|
|
|
any {$return = $item[1]} |
44
|
|
|
|
|
|
|
| block {$return = $item[1]} |
45
|
|
|
|
|
|
|
| ATKEYWORD OWS {$return = $item[1].$item[2]} |
46
|
|
|
|
|
|
|
)(s) {$return = join('',@{$item[1]})} |
47
|
|
|
|
|
|
|
any: any_item OWS {$return = $item[1].$item[2]} |
48
|
|
|
|
|
|
|
any_item: URI {$return = $item[1];} |
49
|
|
|
|
|
|
|
| IDENT {$return = $item[1];} |
50
|
|
|
|
|
|
|
| NUMBER {$return = $item[1];} |
51
|
|
|
|
|
|
|
| PERCENTAGE {$return = $item[1];} |
52
|
|
|
|
|
|
|
| DIMENSION {$return = $item[1];} |
53
|
|
|
|
|
|
|
| STRING {$return = $item[1];} |
54
|
|
|
|
|
|
|
| HASH {$return = $item[1];} |
55
|
|
|
|
|
|
|
| UNICODERANGE {$return = $item[1];} |
56
|
|
|
|
|
|
|
| INCLUDES {$return = $item[1];} |
57
|
|
|
|
|
|
|
| FUNCTION {$return = $item[1];} |
58
|
|
|
|
|
|
|
| DASHMATCH {$return = $item[1];} |
59
|
|
|
|
|
|
|
| '(' any(s?) ')' {$return = '('.join('',@{$item[2]}).')';} |
60
|
|
|
|
|
|
|
| '[' any(s?) ']' {$return = '['.join('',@{$item[2]}).']';} |
61
|
|
|
|
|
|
|
| DELIM {$return = $item[1];} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
## |
64
|
|
|
|
|
|
|
## TOKENS |
65
|
|
|
|
|
|
|
## |
66
|
|
|
|
|
|
|
IDENT: macro_ident {$return = $item[1]} |
67
|
|
|
|
|
|
|
ATKEYWORD: '@' macro_ident {$return = '@'.$item[2]} |
68
|
|
|
|
|
|
|
STRING: macro_string {$return = $item[1]} |
69
|
|
|
|
|
|
|
HASH: '#' macro_name {$return = '#'.$item[2]} |
70
|
|
|
|
|
|
|
NUMBER: macro_num {$return = $item[1]} |
71
|
|
|
|
|
|
|
PERCENTAGE: macro_num '%' {$return = $item[1].'&'} |
72
|
|
|
|
|
|
|
DIMENSION: macro_num macro_ident {$return = $item[1].$item[2]} |
73
|
|
|
|
|
|
|
URI: 'url(' macro_w macro_string macro_w ')' {$return = "url(".$item[3].")"} |
74
|
|
|
|
|
|
|
| 'url(' macro_w ( |
75
|
|
|
|
|
|
|
/[\!#$%&*-~]/ {$return = $item[1]} |
76
|
|
|
|
|
|
|
| macro_nonascii {$return = $item[1]} |
77
|
|
|
|
|
|
|
| macro_escape {$return = $item[1]} |
78
|
|
|
|
|
|
|
)(s?) macro_w ')' {$return = "url(".join('',@{$item[3]}).")"} |
79
|
|
|
|
|
|
|
UNICODERANGE: /U\\+[0-9A-F?]{1,6}(-[0-9A-F]{1,6})?/ {$return = $item[1]} |
80
|
|
|
|
|
|
|
WS: /[ \\t\\r\\n\\f]+/ {$return = ' ';} |
81
|
|
|
|
|
|
|
OWS: WS(s?) {$return = ''; if (scalar(@{$item[1]}) > 0){$return = ' ';} 1;} |
82
|
|
|
|
|
|
|
FUNCTION: macro_ident '(' {$return = $item[1].'('} |
83
|
|
|
|
|
|
|
INCLUDES: '~=' {$return = $item[1]} |
84
|
|
|
|
|
|
|
DASHMATCH: '|=' {$return = $item[1]} |
85
|
|
|
|
|
|
|
DELIM: /[^0-9a-zA-Z\\{\\}\\(\\)\\[\\];]/ {$return = $item[1]} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
## |
88
|
|
|
|
|
|
|
## MACROS |
89
|
|
|
|
|
|
|
## |
90
|
|
|
|
|
|
|
macro_ident: macro_nmstart macro_nmchar(s?) {$return = $item[1]; if (scalar(@{$item[2]}) > 0){$return .= join('',@{$item[2]});} 1;} |
91
|
|
|
|
|
|
|
macro_name: macro_nmchar(s) {$return = join('',@{$item[1]})} |
92
|
|
|
|
|
|
|
macro_nmstart: /[a-zA-Z]/ {$return = $item[1]} |
93
|
|
|
|
|
|
|
| macro_nonascii {$return = $item[1]} |
94
|
|
|
|
|
|
|
| macro_escape {$return = $item[1]} |
95
|
|
|
|
|
|
|
macro_nonascii: /[^\\0-\\177]/ {$return = $item[1]} |
96
|
|
|
|
|
|
|
macro_unicode: /\\[0-9a-f]{1,6}[ \\n\\r\\t\\f]?/ {$return = $item[1]} |
97
|
|
|
|
|
|
|
macro_escape: macro_unicode {$return = $item[1]} |
98
|
|
|
|
|
|
|
| /\\\\[ -~\\200-\\4177777]/ {$return = $item[1]} |
99
|
|
|
|
|
|
|
macro_nmchar: /[a-z0-9-]/ {$return = $item[1]} |
100
|
|
|
|
|
|
|
| macro_nonascii {$return = $item[1]} |
101
|
|
|
|
|
|
|
| macro_escape {$return = $item[1]} |
102
|
|
|
|
|
|
|
macro_num: /[0-9]+|[0-9]*\\.[0-9]+/ {$return = $item[1]} |
103
|
|
|
|
|
|
|
macro_string: macro_string1 {$return = $item[1]} |
104
|
|
|
|
|
|
|
| macro_string2 {$return = $item[1]} |
105
|
|
|
|
|
|
|
macro_string1: '"' ( |
106
|
|
|
|
|
|
|
/[\\t \!#$%&(-~]/ {$return = $item[1]} |
107
|
|
|
|
|
|
|
| '\\\\' macro_nl {$return = ''} |
108
|
|
|
|
|
|
|
| "'" {$return = $item[1]} |
109
|
|
|
|
|
|
|
| macro_nonascii {$return = $item[1]} |
110
|
|
|
|
|
|
|
| macro_escape {$return = $item[1]} |
111
|
|
|
|
|
|
|
)(s?) '"' {$return = '"'.join('', @{$item[2]}).'"'} |
112
|
|
|
|
|
|
|
macro_string2: "'" ( |
113
|
|
|
|
|
|
|
/[\\t \!#$%&(-~]/ {$return = $item[1]} |
114
|
|
|
|
|
|
|
| '\\\\' macro_nl {$return = ''} |
115
|
|
|
|
|
|
|
| '"' {$return = $item[1]} |
116
|
|
|
|
|
|
|
| macro_nonascii {$return = $item[1]} |
117
|
|
|
|
|
|
|
| macro_escape {$return = $item[1]} |
118
|
|
|
|
|
|
|
)(s?) "'" {return "'".join('', @{$item[2]})."'"} |
119
|
|
|
|
|
|
|
macro_nl: /\\n|\\r\\n|\\r|\\f/ {$return = $item[1]} |
120
|
|
|
|
|
|
|
macro_w: /[ \\t\\r\\n\\f]*/ {$return = $item[1]} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
!; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
1; |
125
|
|
|
|
|
|
|
__END__ |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 NAME |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
CSS::Parse::PRDGrammar - A CSS grammar for Parse::RecDescent |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 SYNOPSIS |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
use CSS; |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 DESCRIPTION |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
This module is used by CSS::Parse::Heavy and used to build CSS::Parse::Compiled |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 AUTHOR |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Copyright (C) 2003-2004, Cal Henderson <cal@iamcal.com> |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 SEE ALSO |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
L<CSS>, L<CSS::Parse::Heavy>, L<CSS::Parse::Compiled>, http://www.w3.org/TR/REC-CSS1 |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=cut |
148
|
|
|
|
|
|
|
|