Skip to content

Commit 44d6bfa

Browse files
committed
revised expressions and func-specs
1 parent 9cfc421 commit 44d6bfa

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

lib/CSS/Specification/Actions.rakumod

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use Method::Also;
77
has %.rules is rw;
88
has %.rule-refs is rw;
99
has %.funcs is rw;
10+
has %.protos is rw;
1011
has %.func-refs is rw;
1112
has %.props is rw;
1213
has %.child-props is rw;
@@ -57,26 +58,27 @@ method func-spec($/) {
5758
my $func = $<func-ref>.ast,
5859
my $proto = $<func-proto>.ast<proto>;
5960
my $synopsis = ~$<func-proto>;
60-
my $spec = $proto<signature>;
61+
my $signature = $proto<signature>;
6162

62-
my %func-def = (
63-
:$func, :$synopsis, :$spec
63+
my %func-spec = (
64+
:$func, :$signature, :$synopsis,
6465
);
6566

66-
make %func-def;
67+
%!funcs{$func}++;
68+
make (:%func-spec);
6769
}
6870

6971
method func-proto($/) {
7072
my $synopsis = $/.trim;
7173
my $func = $<id>.ast;
7274
my %proto = :$func, :$synopsis;
7375
%proto<signature> = .ast with $<signature>;
74-
with %!funcs{$func} {
75-
warn "inconsistant function declaration: {$synopsis.raku} vs {.<proto><synopsis>.raku}"
76-
unless .<proto><signature> eqv %proto<signature>;
76+
with %!protos{$func} {
77+
warn "inconsistant function declaration: {$synopsis.raku} vs {.<synopsis>.raku}"
78+
unless .<signature> eqv %proto<signature>;
7779
}
7880
else {
79-
$_ = :%proto;
81+
$_ = %proto;
8082
}
8183

8284
make (:%proto);
@@ -202,7 +204,7 @@ method property-ref:sym<css3>($/) { make 'ref' => $<id>.ast }
202204
method value:sym<prop-ref>($/) {
203205
my Pair $prop-ref = $<property-ref>.ast;
204206
my $prop = $prop-ref.value;
205-
my $rule = 'val-' ~ $prop;;
207+
my $rule = 'prop-val-' ~ $prop;;
206208
%!rule-refs{ $rule }++;
207209
%!child-props{$_}.push: $prop for @*PROP-NAMES;
208210
make (:$rule);

t/00basic.t

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ for (
3737
ast => :rule<rule-ref>,
3838
},
3939
'values' => {
40-
input => "<rule-ref> [ 'css21-prop-ref' <'css3-prop-ref'> ]?",
40+
input => "<rule-ref> [ 'css21-prop' <'css3-prop'> ]?",
4141
ast => :seq[ :rule<rule-ref>,
42-
:occurs['?', :group(:seq[:rule<val-css21-prop-ref>, :rule<val-css3-prop-ref>]) ]
42+
:occurs['?', :group(:seq[:rule<prop-val-css21-prop>, :rule<prop-val-css3-prop>]) ]
4343
],
4444
},
4545
'values' => {
46-
input => "<rule-ref> [, [ 'css21-prop-ref' | <'css3-prop-ref'> ] ]*",
46+
input => "<rule-ref> [, [ 'css21-prop' | <'css3-prop'> ] ]*",
4747
ast => :seq[ :rule<rule-ref>,
4848
:occurs['*',
49-
:group(:seq[:op<,>, :group(:alt[:rule<val-css21-prop-ref>, :rule<val-css3-prop-ref>]) ])
49+
:group(:seq[:op<,>, :group(:alt[:rule<prop-val-css21-prop>, :rule<prop-val-css3-prop>]) ])
5050
],
5151
]
5252
},
@@ -86,7 +86,7 @@ for (
8686
},
8787
'func-spec' => {
8888
input => '<linear-gradient()> = linear-gradient( [ <linear-gradient-syntax> ] )',
89-
ast => {:func<linear-gradient>, :spec(:group(:rule<linear-gradient-syntax>)), :synopsis("linear-gradient( [ <linear-gradient-syntax> ] )")}
89+
ast => :func-spec{:func<linear-gradient>, :signature(:group(:rule<linear-gradient-syntax>)), :synopsis("linear-gradient( [ <linear-gradient-syntax> ] )")}
9090
},
9191
'values' => {
9292
input => '[ <length-percentage [0,∞]> | auto ]{1,2} | cover | contain',

0 commit comments

Comments
 (0)