Skip to content

Commit

Permalink
Revise whitespace and comment handling.
Browse files Browse the repository at this point in the history
This makes whitespace significant by default, requiring (?x) to make it
insignificant again, as is the Perl 5 default. Also implements the (?#xxx)
comment syntax.
  • Loading branch information
jnthn committed Oct 7, 2012
1 parent b8ad051 commit f982b88
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
10 changes: 1 addition & 9 deletions src/QRegex/P5Regex/Actions.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class QRegex::P5Regex::Actions is HLL::Actions {
make 0;
}
}

method p5mods($/) {
for nqp::split('', ~$<on>) {
%*RX{$_} := 1;
Expand Down Expand Up @@ -396,14 +396,6 @@ class QRegex::P5Regex::Actions is HLL::Actions {

# XXX Below here copied from p6regex; needs review

method metachar:sym<ws>($/) {
my $qast := %*RX<s>
?? QAST::Regex.new(:rxtype<ws>, :subtype<method>, :node($/),
QAST::Node.new( QAST::SVal.new( :value('ws') ) ))
!! 0;
make $qast;
}

method metachar:sym<'>($/) {
my $quote := $<quote_EXPR>.ast;
if QAST::SVal.ACCEPTS($quote) { $quote := $quote.value; }
Expand Down
8 changes: 6 additions & 2 deletions src/QRegex/P5Regex/Grammar.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,12 @@ grammar QRegex::P5Regex::Grammar is HLL::Grammar {

token quantmod { [ '?' | '+' ]? }

token ws { [ \s+ | '#' \N* ]* }
token ws {
[
| '(?#' ~ ')' <-[)]>*
| <?{ %*RX<x> }> [ \s+ | '#' \N* ]
]*
}


# XXX Below here is straight from P6Regex and unreviewed.
Expand All @@ -141,7 +146,6 @@ grammar QRegex::P5Regex::Grammar is HLL::Grammar {
rule arglist { <arg> [ ',' <arg>]* }

proto token metachar { <...> }
token metachar:sym<ws> { <.normspace> }
token metachar:sym<'> { <?[']> <quote_EXPR: ':q'> }
token metachar:sym<"> { <?["]> <quote_EXPR: ':qq'> }
token metachar:sym<lwb> { $<sym>=['<<'|'«'] }
Expand Down

0 comments on commit f982b88

Please sign in to comment.