Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
allow smart quotes
  • Loading branch information
TimToady committed Feb 23, 2015
1 parent f9b7f55 commit efd2de0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion STD.pm6
Expand Up @@ -590,7 +590,9 @@ token quotepair {

token quote:sym<「 」> { :dba('perfect quotes') "「" ~ "」" <nibble($¢.cursor_fresh( %*LANG<Q> ).unbalanced(""))> }
token quote:sym<' '> { :dba('single quotes') "'" ~ "'" <nibble($¢.cursor_fresh( %*LANG<Q> ).tweak(:q).unbalanced("'"))> }
token quote:sym<‘ ’> { :dba('single quotes') "‘" ~ "’" <nibble($¢.cursor_fresh( %*LANG<Q> ).tweak(:q).unbalanced(""))> }
token quote:sym<" "> { :dba('double quotes') '"' ~ '"' <nibble($¢.cursor_fresh( %*LANG<Q> ).tweak(:qq).unbalanced('"'))> }
token quote:sym<“ ”> { :dba('double quotes') '“' ~ '”' <nibble($¢.cursor_fresh( %*LANG<Q> ).tweak(:qq).unbalanced(''))> }

token circumfix:sym<« »> { :dba('shell-quote words') '«' ~ '»' <nibble($¢.cursor_fresh( %*LANG<Q> ).tweak(:qq).tweak(:ww).balanced('«','»'))> }
token circumfix:sym«<< >>» { :dba('shell-quote words') '<<' ~ '>>' <nibble($¢.cursor_fresh( %*LANG<Q> ).tweak(:qq).tweak(:ww).balanced('<<','>>'))> }
Expand Down Expand Up @@ -4867,7 +4869,7 @@ grammar Regex is STD {
<?before \s | '#'> [ :lang(%*LANG<MAIN>) <.ws> ]
}

token unsp { '\\' <?before \s | '#'> <.panic: "No unspace allowed in regex; if you meant to match the literal character, please enclose in single quotes ('" ~ substr(self.orig,$¢.pos,1) ~ "') or use a backslashed form like \\x" ~ sprintf('%02x', ord(substr(self.orig,$¢.pos,1)))> } # no unspace in regexen
token unsp { '\\' <?before \s> <.panic: "No unspace allowed in regex; if you meant to match the literal character, please enclose in single quotes ('" ~ substr(self.orig,$¢.pos,1) ~ "') or use a backslashed form like \\x" ~ sprintf('%02x', ord(substr(self.orig,$¢.pos,1)))> } # no unspace in regexen

rule nibbler {
:temp %*RX;
Expand Down Expand Up @@ -5075,7 +5077,9 @@ grammar Regex is STD {

token metachar:sym<「 」> { <?before "「"> [:lang(%*LANG<MAIN>) <quote>] <.SIGOK> }
token metachar:sym<' '> { <?before "'"> [:lang(%*LANG<MAIN>) <quote>] <.SIGOK> }
token metachar:sym<‘ ’> { <?before "‘"> [:lang(%*LANG<MAIN>) <quote>] <.SIGOK> }
token metachar:sym<" "> { <?before '"'> [:lang(%*LANG<MAIN>) <quote>] <.SIGOK> }
token metachar:sym<“ ”> { <?before '“'> [:lang(%*LANG<MAIN>) <quote>] <.SIGOK> }

token metachar:var {
:my $*QSIGIL ::= substr(self.orig,self.pos,1);
Expand Down

0 comments on commit efd2de0

Please sign in to comment.