Permalink
Browse files

Initial handling of double quotes.

  • Loading branch information...
1 parent c09a36b commit 1e2031c39e6093f60f82a35538653b145308c652 @bacek bacek committed Jan 30, 2011
Showing with 17 additions and 18 deletions.
  1. +17 −16 lib/YAML/Tiny.pm
  2. +0 −2 t/02_basic.t
View
@@ -155,24 +155,25 @@ method _read_scalar($string, $indent, @lines) {
return $string;
}
-### # Double quote.
-### # The commented out form is simpler, but overloaded the Perl regex
-### # engine due to recursion and backtracking problems on strings
-### # larger than 32,000ish characters. Keep it for reference purposes.
-### # if ( $string =~ /^\"((?:\\.|[^\"])*)\"\z/ ) {
+ # Double quote.
+ # The commented out form is simpler, but overloaded the Perl regex
+ # engine due to recursion and backtracking problems on strings
+ # larger than 32,000ish characters. Keep it for reference purposes.
+ if my $m := $string ~~ /^\" ([\\.|<-[\"]>]*) \" [\s+\#.*]?$/ {
### if ( $string =~ /^\"([^\\"]*(?:\\.[^\\"]*)*)\"(?:\s+\#.*)?\z/ ) {
-### # Reusing the variable is a little ugly,
-### # but avoids a new variable and a string copy.
-### $string = $1;
-### $string =~ s/\\"/"/g;
-### $string =~ s/\\([never\\fartz]|x([0-9a-fA-F]{2}))/(length($1)>1)?pack("H2",$2):$UNESCAPES{$1}/gex;
-### return $string;
-### }
-###
+ # Reusing the variable is a little ugly,
+ # but avoids a new variable and a string copy.
+ debug("Double match", $m);
+ $string := ~$m[0];
+ $string := subst($string, /\\\"/, '"', :global<1>);
+ #$string =~ s/\\([never\\fartz]|x([0-9a-fA-F]{2}))/(length($1)>1)?pack("H2",$2):$UNESCAPES{$1}/gex;
+ return $string;
+ }
+
# Special cases
-### if ( $string =~ /^[\'\"!&]/ ) {
-### pir::die \"YAML::Tiny does not support a feature in line '$string'";
-### }
+ if $string ~~ /^<[\'\"!&]>/ {
+ pir::die("YAML::Tiny does not support a feature in line '$string'");
+ }
return {} if $string ~~ /^{}[\s+\#.*]?$/;
return [] if $string ~~ /^\[\][\s+\#.*]?$/;
View
@@ -195,7 +195,6 @@ yaml_ok(
"only_spaces",
noyamlpm => 1,
noyamlperl => 1,
- todo => 1,
);
yaml_ok(
@@ -204,7 +203,6 @@ yaml_ok(
"leading_trailing_spaces",
noyamlpm => 1,
noyamlperl => 1,
- todo => 1,
);
# Implicit document start

0 comments on commit 1e2031c

Please sign in to comment.