Permalink
Browse files

fixed whitespacing handling around quantifiers

  • Loading branch information...
dwarring committed Jan 18, 2017
1 parent 9d9b6e9 commit 48b79a329ed631b3205c61f4f6491f73aec714c4
Showing with 18 additions and 17 deletions.
  1. +1 −0 Changes
  2. +1 −1 META.info
  3. +1 −1 lib/CSS/Specification.pm
  4. +5 −5 lib/CSS/Specification/Actions.pm
  5. +4 −4 lib/CSS/Specification/Build.pm
  6. +4 −4 lib/t/CSS/Aural/Spec/Grammar.pm
  7. +2 −2 t/00basic.t
View
@@ -1,3 +1,4 @@
0.4.4 Fixed whitespace handling on quantifiers
0.4.3 Move test classes into lib path; t::CSS::Aural::Grammar, etc.
0.4.2 Bugfix a length can be a percentage quantity
- Also reinstate t/terms.t, lost around 538f043
View
@@ -1,6 +1,6 @@
{ "perl" : "6.c",
"name" : "CSS::Specification",
"version" : "0.4.3",
"version" : "0.4.4",
"description" : "CSS Property definition grammar and generation tools",
"depends" : [ "CSS::Grammar" ],
"source-url" : "git://github.com/p6-css/perl6-CSS-Specification.git",
View
@@ -39,7 +39,7 @@ grammar CSS::Specification:ver<000.04> {
token id-quoted { <.quote> <id> <.quote> }
rule keyw { <id> }
rule digits { \d+ }
rule rule { '<'~'>' <id> }
rule rule { '<'~'>' <id> }
rule terms { <term=.term-options>+ }
rule term-options { <term=.term-combo> +% '|' }
@@ -79,7 +79,7 @@ class CSS::Specification::Actions {
!! @choices[0];
}
method _choose(@choices) {
method !choose(@choices) {
my $choices := @choices.map({[~] ($_, ' <!seen(', $*CHOICE++, ')>')}).join(' | ');
return [~] '[ ', $choices, ' ]';
}
@@ -88,15 +88,15 @@ class CSS::Specification::Actions {
my @choices = @<term>>>.ast;
make @choices > 1
?? $._choose( @choices ) ~ '+'
?? self!choose( @choices ) ~ '+'
!! @choices[0];
}
method term-required($/) {
my @choices = $<term>>>.ast;
make @choices > 1
?? [~] $._choose( @choices ), '**', @choices.Int
?? [~] self!choose( @choices ), '**', @choices.Int
!! @choices[0];
}
@@ -117,11 +117,11 @@ class CSS::Specification::Actions {
method occurs:sym<zero-plus>($/) { make '*' }
method occurs:sym<list>($/) {
my $quant = $<range> ?? $<range>.ast !! '+';
make " {$quant}% <op(',')>"
make "{$quant}% <op(',')>"
}
method occurs:sym<range>($/) { make $<range>.ast }
method range($/) {
my $range = '**' ~ $<min>.ast;
my $range = ' ** ' ~ $<min>.ast;
$range ~= '..' ~ $<max>.ast
if $<max>;
@@ -130,7 +130,7 @@ module CSS::Specification::Build {
with $def<props> -> @props {
my $perl6 = $def<perl6>;
my $synopsis = $def<synopsis>;
my $box = $perl6 ~~ / '**1..4' $/;
my $box = $perl6 ~~ /:s '**' '1..4' $/;
for @props -> $name {
my %details = :$name, :$synopsis;
@@ -184,13 +184,13 @@ module CSS::Specification::Build {
my $synopsis = $def<synopsis>;
# boxed repeating property. repeat the expr
my $box = $perl6 ~~ / '**1..4' $/
my $box = $perl6 ~~ /:s '**' '1..4' $/
?? ', :box'
!! '';
my $repeats = '';
if $box {
$perl6 ~~ s/ '**1..4' $//;
$repeats = '**1..4';
$perl6 ~~ s/:s '**' '1..4' $//;
$repeats = ' ** 1..4';
}
for @props -> $prop {
@@ -26,7 +26,7 @@ grammar t::CSS::Aural::Spec::Grammar {
#| pause: [ [<time> | <percentage>]{1,2} ]
rule decl:sym<pause> {:i (pause) ':' <val( rx{ <expr=.expr-pause> }, &?ROUTINE.WHY)> }
rule expr-pause {:i [ [ [ <time> || <percentage> ] ]**1..2 ] }
rule expr-pause {:i [ [ [ <time> || <percentage> ] ] ** 1..2 ] }
#| pause-after: <time> | <percentage>
rule decl:sym<pause-after> {:i (pause\-after) ':' <val( rx{ <expr=.expr-pause-after> }, &?ROUTINE.WHY)> }
@@ -78,7 +78,7 @@ grammar t::CSS::Aural::Spec::Grammar {
#| voice-family: [<generic-voice> | <specific-voice> ]#
rule decl:sym<voice-family> {:i (voice\-family) ':' <val( rx{ <expr=.expr-voice-family> }, &?ROUTINE.WHY)> }
rule expr-voice-family {:i [ [ <generic-voice> || <specific-voice> ] ] +% <op(',')> }
rule expr-voice-family {:i [ [ <generic-voice> || <specific-voice> ] ]+% <op(',')> }
#| generic-voice: male | female | child
rule generic-voice {:i [ male | female | child ] & <keyw> }
@@ -91,8 +91,8 @@ grammar t::CSS::Aural::Spec::Grammar {
rule expr-volume {:i [ <number> || <percentage> || [ silent | x\-soft | soft | medium | loud | x\-loud ] & <keyw> ] }
#| border-color: [ <color> | transparent ]{1,4}
rule decl:sym<border-color> {:i (border\-color) ':' <val( rx{ <expr=.expr-border-color>**1..4 }, &?ROUTINE.WHY)> }
rule expr-border-color {:i [ [ <color> || transparent & <keyw> ] ] }
rule decl:sym<border-color> {:i (border\-color) ':' <val( rx{ <expr=.expr-border-color> ** 1..4 }, &?ROUTINE.WHY)> }
rule expr-border-color {:i [ [ <color> || transparent & <keyw> ] ] }
#| border-top-color: <color> | transparent
rule decl:sym<border-top-color> {:i (border\-top\-color) ':' <val( rx{ <expr=.expr-border-top-color> }, &?ROUTINE.WHY)> }
View
@@ -20,10 +20,10 @@ for (
ast => "<rule-ref> [ <op(',')> [ [ <expr-css21-prop-ref> || <expr-css3-prop-ref> ] ] ]*",
},
'spec' => {input => '<length>{4}',
ast => '<length>**4',
ast => '<length> ** 4',
},
'spec' => {input => '<length>#{1,4}',
ast => "<length> **1..4% <op(',')>",
ast => "<length> ** 1..4% <op(',')>",
},
# precedence tests taken from: https://developer.mozilla.org/en-US/docs/CSS/Value_definition_syntax
'spec' => {input => 'bold thin && <length>',

0 comments on commit 48b79a3

Please sign in to comment.