Skip to content

Commit f171650

Browse files
committed
Fix some CSS::Module regressions
1 parent f39eb89 commit f171650

File tree

7 files changed

+36
-141
lines changed

7 files changed

+36
-141
lines changed

lib/CSS/Specification/Compiler/Grammars.rakumod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ multi sub compile(Str :$rule!, :$spec!, Str :$synopsis!) {
100100
}
101101

102102
multi sub compile(:@occurs! ($quant!, *%term)) {
103-
my RakuAST::Regex $atom = (|%term).&compile.&group;
103+
my RakuAST::Regex $atom = (|%term).&compile.&group.&ws;
104104
my RakuAST::Regex $separator = compile(:op<,>)
105105
if $quant.tail ~~ ',';
106106

@@ -232,7 +232,7 @@ multi sub compile(Str:D :$rule!) {
232232
}
233233

234234
multi sub compile(:@keywords!) {
235-
_choice @keywords.map(&lit-ws), 'keyw'.&assertion;
235+
_choice @keywords.map(&lit-ws), 'keyw'.&assertion.&ws;
236236
}
237237

238238
multi sub compile(:@numbers!) {
@@ -242,7 +242,7 @@ multi sub compile(:@numbers!) {
242242
sub lit-ws(Str:D() $_) is export { .&lit.&ws }
243243

244244
multi sub compile(Str:D :$op!) {
245-
my RakuAST::ArgList $args = ','.&arg;
245+
my RakuAST::ArgList $args = $op.&arg;
246246
'op'.&assertion(:$args);
247247
}
248248

lib/CSS/Specification/Runtime/Grammar.rakumod

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ unit grammar CSS::Specification::Runtime::Grammar;
33
proto rule proforma {*}
44

55
token val( $*EXPR, $*USAGE='' ) {
6-
<proforma> || <rx={$*EXPR}> || <usage>
6+
<proforma> || <rx={$*EXPR}> || <usage($*USAGE)>
77
}
88

9-
token usage {
9+
token usage($*USAGE) {
1010
<any-args>
1111
}
1212

@@ -23,6 +23,7 @@ token frequency:sym<zero> {<number> <?{ +$<number> == 0 }> }
2323
token integer {$<sign>=< + - >?<uint>}
2424
token number {<num><!before ['%'|\w]>}
2525
token uri {<url>}
26-
token keyw {<id=.Ident>} # keyword (case insensitive)
26+
multi token keyw {<id=.Ident>} # keyword (case insensitive)
27+
multi token keyw($rx) {<id={$rx}>} # keyword (case insensitive)
2728
token identifier {<name>} # identifier (case sensitive)
2829
rule identifiers {[ <identifier> ]+} # E.g. font name: Times New Roman

t/00compile.t

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ for (
1616
'spec' => {
1717
input => 'thin',
1818
ast => :keywords['thin'],
19-
deparse => 'thin & <keyw>',
19+
deparse => 'thin & <keyw> ',
2020
},
2121
'spec' => {
2222
input => 'thin?',
@@ -26,7 +26,7 @@ for (
2626
'spec' => {
2727
input => 'thick | thin',
2828
ast => :keywords[ 'thick', 'thin' ],
29-
deparse => '[thick | thin ]& <keyw>',
29+
deparse => '[thick | thin ]& <keyw> ',
3030
},
3131
'spec' => {
3232
input => '35 | 7',
@@ -106,13 +106,13 @@ for (
106106
'spec' => {
107107
input => 'bold thin && <length>',
108108
ast => :required[:seq[:keywords["bold"], :keywords["thin"]], :rule("length")],
109-
deparse => "[:my \@S\n; bold \& <keyw> thin \& <keyw> <!\{\n \@S[0]++\n}>| <length><!\{\n \@S[1]++\n}>]** 2",
109+
deparse => "[:my \@S\n; bold \& <keyw> thin \& <keyw> <!\{\n \@S[0]++\n}>| <length><!\{\n \@S[1]++\n}>]** 2",
110110
rule-refs => ['length'],
111111
},
112112
'spec' => {
113113
input => 'bold || thin && <length>',
114114
ast => :combo[:keywords["bold"], :required[:keywords["thin"], :rule("length")]],
115-
deparse => "[:my \@S\n; bold \& <keyw><!\{\n \@S[0]++\n}>| [:my \@S\n; thin \& <keyw><!\{\n \@S[0]++\n}>| <length><!\{\n \@S[1]++\n}>]** 2<!\{\n \@S[1]++\n}>]+",
115+
deparse => "[:my \@S\n; bold \& <keyw> <!\{\n \@S[0]++\n}>| [:my \@S\n; thin \& <keyw> <!\{\n \@S[0]++\n}>| <length><!\{\n \@S[1]++\n}>]** 2<!\{\n \@S[1]++\n}>]+",
116116
rule-refs => ['length'],
117117
},
118118
'property-spec' => {
@@ -142,7 +142,7 @@ for (
142142
deparse => join("\n",
143143
'#| min-width: <length> | <percentage> | inherit',
144144
'rule decl:sym<min-width> { :i ("min-width") ":" <val(/<expr=.expr-min-width> /, &?ROUTINE.WHY)> }',
145-
'rule expr-min-width { :i <length> || <percentage> || inherit & <keyw> }',
145+
'rule expr-min-width { :i <length> || <percentage> || inherit & <keyw> }',
146146
''),
147147
},
148148
'property-spec' => {input => "'content'\tnormal | none | [ <string> | <uri> | <counter> | attr(<identifier>) | open-quote | close-quote | no-open-quote | no-close-quote ]+ | inherit\tnormal :before and :after pseudo-elements no",
@@ -167,7 +167,7 @@ for (
167167
deparse => join("\n",
168168
'#| content: normal | none | [ <string> | <uri> | <counter> | attr(<identifier>) | open-quote | close-quote | no-open-quote | no-close-quote ]+ | inherit',
169169
'rule decl:sym<content> { :i (content) ":" <val(/<expr=.expr-content> /, &?ROUTINE.WHY)> }',
170-
'rule expr-content { :i [normal | none ]& <keyw> || [<string> || <uri> || <counter> || <attr> || ["open-quote" | "close-quote" | "no-open-quote" | "no-close-quote" ]& <keyw> ]+ || inherit & <keyw> }',
170+
'rule expr-content { :i [normal | none ]& <keyw> || [<string> || <uri> || <counter> || <attr> || ["open-quote" | "close-quote" | "no-open-quote" | "no-close-quote" ]& <keyw> ]+ || inherit & <keyw> }',
171171
''
172172
),
173173

t/META6.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
"Test::CSS::Aural::Grammar": "lib/Test/CSS/Aural/Grammar.rakumod",
99
"Test::CSS::Aural::Spec::Actions": "lib/Test/CSS/Aural/Spec/Actions.rakumod",
1010
"Test::CSS::Aural::Spec::Interface": "lib/Test/CSS/Aural/Spec/Interface.rakumod",
11-
"Test::CSS::Aural::Spec::Grammar": "lib/Test/CSS/Aural/Spec/Grammar.rakumod",
12-
"Test::CSS::Aural::Spec::GrammarAST": "lib/Test/CSS/Aural/Spec/GrammarAST.rakumod"
11+
"Test::CSS::Aural::Spec::Grammar": "lib/Test/CSS/Aural/Spec/Grammar.rakumod"
1312
},
1413
"source-url": "git://github.com/p6-css/CSS-Specification-p6.git",
1514
"version": "0.0.1"

t/lib/Test/CSS/Aural/Spec/ActionsAST.rakumod

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
unit grammar Test::CSS::Aural::Spec::Grammar;
22
#| azimuth: <angle> | [[ left-side | far-left | left | center-left | center | center-right | right | far-right | right-side ] || behind ] | leftwards | rightwards
33
rule decl:sym<azimuth> { :i (azimuth) ":" <val(/<expr=.expr-azimuth> /, &?ROUTINE.WHY)> }
4-
rule expr-azimuth { :i <angle> || [[:my @S; [["left-side" | "far-left" | left | "center-left" | center | "center-right" | right | "far-right" | "right-side" ]& <keyw>]<!{
4+
rule expr-azimuth { :i <angle> || [[:my @S; [["left-side" | "far-left" | left | "center-left" | center | "center-right" | right | "far-right" | "right-side" ]& <keyw> ]<!{
55
@S[0]++
6-
}>| behind & <keyw><!{
6+
}>| behind & <keyw> <!{
77
@S[1]++
8-
}>]+] || [leftwards | rightwards ]& <keyw> }
8+
}>]+] || [leftwards | rightwards ]& <keyw> }
99
#| cue-after: <uri> | none
1010
rule decl:sym<cue-after> { :i ("cue-after") ":" <val(/<expr=.expr-cue-after> /, &?ROUTINE.WHY)> }
11-
rule expr-cue-after { :i <uri> || none & <keyw> }
11+
rule expr-cue-after { :i <uri> || none & <keyw> }
1212
#| cue-before: <uri> | none
1313
rule decl:sym<cue-before> { :i ("cue-before") ":" <val(/<expr=.expr-cue-before> /, &?ROUTINE.WHY)> }
14-
rule expr-cue-before { :i <uri> || none & <keyw> }
14+
rule expr-cue-before { :i <uri> || none & <keyw> }
1515
#| cue: [ 'cue-before' || 'cue-after' ]
1616
rule decl:sym<cue> { :i (cue) ":" <val(/<expr=.expr-cue> /, &?ROUTINE.WHY)> }
1717
rule expr-cue { :i [[:my @S; <expr-cue-before><!{
@@ -21,7 +21,7 @@ rule expr-cue { :i [[:my @S; <expr-cue-before><!{
2121
}>]+] }
2222
#| elevation: <angle> | below | level | above | higher | lower
2323
rule decl:sym<elevation> { :i (elevation) ":" <val(/<expr=.expr-elevation> /, &?ROUTINE.WHY)> }
24-
rule expr-elevation { :i <angle> || [below | level | above | higher | lower ]& <keyw> }
24+
rule expr-elevation { :i <angle> || [below | level | above | higher | lower ]& <keyw> }
2525
#| pause: [ [<time> | <percentage>]{1,2} ]
2626
rule decl:sym<pause> { :i (pause) ":" <val(/<expr=.expr-pause> /, &?ROUTINE.WHY)> }
2727
rule expr-pause { :i [[<time> || <percentage> ]** 1..2] }
@@ -36,57 +36,57 @@ rule decl:sym<pitch-range> { :i ("pitch-range") ":" <val(/<expr=.expr-pitch-rang
3636
rule expr-pitch-range { :i <number> }
3737
#| pitch: <frequency> | x-low | low | medium | high | x-high
3838
rule decl:sym<pitch> { :i (pitch) ":" <val(/<expr=.expr-pitch> /, &?ROUTINE.WHY)> }
39-
rule expr-pitch { :i <frequency> || ["x-low" | low | medium | high | "x-high" ]& <keyw> }
39+
rule expr-pitch { :i <frequency> || ["x-low" | low | medium | high | "x-high" ]& <keyw> }
4040
#| play-during: <uri> [ mix || repeat ]? | auto | none
4141
rule decl:sym<play-during> { :i ("play-during") ":" <val(/<expr=.expr-play-during> /, &?ROUTINE.WHY)> }
42-
rule expr-play-during { :i <uri> [[:my @S; mix & <keyw><!{
42+
rule expr-play-during { :i <uri> [[:my @S; mix & <keyw> <!{
4343
@S[0]++
44-
}>| repeat & <keyw><!{
44+
}>| repeat & <keyw> <!{
4545
@S[1]++
46-
}>]+]? || [auto | none ]& <keyw> }
46+
}>]+]? || [auto | none ]& <keyw> }
4747
#| richness: <number>
4848
rule decl:sym<richness> { :i (richness) ":" <val(/<expr=.expr-richness> /, &?ROUTINE.WHY)> }
4949
rule expr-richness { :i <number> }
5050
#| speak: normal | none | spell-out
5151
rule decl:sym<speak> { :i (speak) ":" <val(/<expr=.expr-speak> /, &?ROUTINE.WHY)> }
52-
rule expr-speak { :i [normal | none | "spell-out" ]& <keyw> }
52+
rule expr-speak { :i [normal | none | "spell-out" ]& <keyw> }
5353
#| speak-header: once | always
5454
rule decl:sym<speak-header> { :i ("speak-header") ":" <val(/<expr=.expr-speak-header> /, &?ROUTINE.WHY)> }
55-
rule expr-speak-header { :i [once | always ]& <keyw> }
55+
rule expr-speak-header { :i [once | always ]& <keyw> }
5656
#| speak-numeral: digits | continuous
5757
rule decl:sym<speak-numeral> { :i ("speak-numeral") ":" <val(/<expr=.expr-speak-numeral> /, &?ROUTINE.WHY)> }
58-
rule expr-speak-numeral { :i [digits | continuous ]& <keyw> }
58+
rule expr-speak-numeral { :i [digits | continuous ]& <keyw> }
5959
#| speak-punctuation: code | none
6060
rule decl:sym<speak-punctuation> { :i ("speak-punctuation") ":" <val(/<expr=.expr-speak-punctuation> /, &?ROUTINE.WHY)> }
61-
rule expr-speak-punctuation { :i [code | none ]& <keyw> }
61+
rule expr-speak-punctuation { :i [code | none ]& <keyw> }
6262
#| speech-rate: <number> | x-slow | slow | medium | fast | x-fast | faster | slower
6363
rule decl:sym<speech-rate> { :i ("speech-rate") ":" <val(/<expr=.expr-speech-rate> /, &?ROUTINE.WHY)> }
64-
rule expr-speech-rate { :i <number> || ["x-slow" | slow | medium | fast | "x-fast" | faster | slower ]& <keyw> }
64+
rule expr-speech-rate { :i <number> || ["x-slow" | slow | medium | fast | "x-fast" | faster | slower ]& <keyw> }
6565
#| stress: <number>
6666
rule decl:sym<stress> { :i (stress) ":" <val(/<expr=.expr-stress> /, &?ROUTINE.WHY)> }
6767
rule expr-stress { :i <number> }
6868
#| voice-family: [<generic-voice> | <specific-voice> ]#
6969
rule decl:sym<voice-family> { :i ("voice-family") ":" <val(/<expr=.expr-voice-family> /, &?ROUTINE.WHY)> }
7070
rule expr-voice-family { :i [<generic-voice> || <specific-voice> ]+% <op(",")> }
7171
#| male | female | child
72-
rule generic-voice { :i [male | female | child ]& <keyw> }
72+
rule generic-voice { :i [male | female | child ]& <keyw> }
7373
#| <identifier> | <string>
7474
rule specific-voice { :i <identifier> || <string> }
7575
#| volume: <number> | <percentage> | silent | x-soft | soft | medium | loud | x-loud
7676
rule decl:sym<volume> { :i (volume) ":" <val(/<expr=.expr-volume> /, &?ROUTINE.WHY)> }
77-
rule expr-volume { :i <number> || <percentage> || [silent | "x-soft" | soft | medium | loud | "x-loud" ]& <keyw> }
77+
rule expr-volume { :i <number> || <percentage> || [silent | "x-soft" | soft | medium | loud | "x-loud" ]& <keyw> }
7878
#| border-color: [ <color> | transparent ]{1,4}
7979
rule decl:sym<border-color> { :i ("border-color") ":" <val(/<expr=.expr-border-color>** 1..4 /, &?ROUTINE.WHY)> }
80-
rule expr-border-color { :i [<color> || transparent & <keyw> ] }
80+
rule expr-border-color { :i [<color> || transparent & <keyw> ] }
8181
#| border-top-color: <color> | transparent
8282
rule decl:sym<border-top-color> { :i ("border-top-color") ":" <val(/<expr=.expr-border-top-color> /, &?ROUTINE.WHY)> }
83-
rule expr-border-top-color { :i <color> || transparent & <keyw> }
83+
rule expr-border-top-color { :i <color> || transparent & <keyw> }
8484
#| border-top-color: <color> | transparent
8585
rule decl:sym<border-right-color> { :i ("border-right-color") ":" <val(/<expr=.expr-border-right-color> /, &?ROUTINE.WHY)> }
86-
rule expr-border-right-color { :i <color> || transparent & <keyw> }
86+
rule expr-border-right-color { :i <color> || transparent & <keyw> }
8787
#| border-top-color: <color> | transparent
8888
rule decl:sym<border-bottom-color> { :i ("border-bottom-color") ":" <val(/<expr=.expr-border-bottom-color> /, &?ROUTINE.WHY)> }
89-
rule expr-border-bottom-color { :i <color> || transparent & <keyw> }
89+
rule expr-border-bottom-color { :i <color> || transparent & <keyw> }
9090
#| border-top-color: <color> | transparent
9191
rule decl:sym<border-left-color> { :i ("border-left-color") ":" <val(/<expr=.expr-border-left-color> /, &?ROUTINE.WHY)> }
92-
rule expr-border-left-color { :i <color> || transparent & <keyw> }
92+
rule expr-border-left-color { :i <color> || transparent & <keyw> }

t/lib/Test/CSS/Aural/Spec/GrammarAST.rakumod

Lines changed: 0 additions & 92 deletions
This file was deleted.

0 commit comments

Comments
 (0)