Skip to content

Commit 5c0a24b

Browse files
committed
Initial patches to ignore leading whitespace in rules.
1 parent ef3e3e4 commit 5c0a24b

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/NQP/Grammar.pm

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ grammar NQP::Grammar is HLL::Grammar {
118118
}
119119

120120
rule statementlist {
121-
| $
122-
| [<statement><.eat_terminator> ]*
121+
| <?> $
122+
| <?> [<statement><.eat_terminator> ]*
123123
}
124124

125125
token statement {
@@ -388,10 +388,13 @@ grammar NQP::Grammar is HLL::Grammar {
388388
token scope_declarator:sym<our> { <sym> <scoped('our')> }
389389
token scope_declarator:sym<has> { <sym> <scoped('has')> }
390390

391-
rule scoped($*SCOPE) {
391+
token scoped($*SCOPE) {
392+
<.ws>
393+
[
392394
| <declarator>
393395
| <multi_declarator>
394396
| <package_declarator>
397+
]
395398
}
396399

397400
token typename {
@@ -491,7 +494,7 @@ grammar NQP::Grammar is HLL::Grammar {
491494
':' <param_var>
492495
}
493496

494-
rule default_value { '=' <EXPR('i=')> }
497+
rule default_value { <?> '=' <EXPR('i=')> }
495498

496499
rule trait { <trait_mod> }
497500

@@ -613,7 +616,7 @@ grammar NQP::Grammar is HLL::Grammar {
613616
token circumfix:sym<{ }> { <?[{]> <pblock> }
614617
token circumfix:sym<sigil> { <sigil> '(' ~ ')' <semilist> }
615618

616-
rule semilist { <statement> }
619+
rule semilist { <?> <statement> }
617620

618621
## Operators
619622

src/QRegex/P6Regex/Grammar.nqp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,14 @@ grammar QRegex::P6Regex::Grammar is HLL::Grammar {
6363
}
6464

6565
token termish {
66+
<.ws>
67+
[
6668
|| <noun=.quantified_atom>+
6769
|| (\W) {
6870
my $char := ~$/[0];
6971
$/.CURSOR.panic("Unrecognized regex metacharacter $char (must be quoted to match literally)")
7072
}
73+
]
7174
}
7275

7376
token quantified_atom {

0 commit comments

Comments
 (0)