{ use strict; use warnings; sub dequote_single { for (my $s = @_ ? $_[0] : $_) { s/^'//; s/'$//; s{\\([\\'])}{$1}gs; return STR_LIT => $_; } } sub dequote_double { for (my $s = @_ ? $_[0] : $_) { ... if (@pieces) { return $pieces[0]; } else { return CONCAT => \@pieces; } } } } STR_LIT: /'(?:\\.|[^\\'])*'/s { [ dequote_single($item[1]) ] } | /"(?:...)*'/s { [ dequote_double($item[1]) ] }
(assuming Perl-like literals)
In reply to Re: Parsing Statements with Quotes in Parse::RecDescent
by ikegami
in thread Parsing Statements with Quotes in Parse::RecDescent
by Starky
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |