in reply to Re: Parsing arguments
in thread Parsing arguments
Thanks, that's an interesting approach. I find the logic still rather complex, though, and I think if I were going in this direction I'd separate it out a bit differently:
Hugowhile (pos($tag) < length($tag)) { if (m{ \G (\w+) \s* = }gcx) { push @args [ $1 ]; } elsif (m{ \G (\w+) (?= \s* | \z ) \s* }gcx) { push @args, $1; } elsif (m{ \G (['"]) ( \\. | [^\\] )*? \1 \s* }gcx) { (my $quoted = $2) =~ s/\\(.)/$1/g; push @args, $quoted; } else { die "parsing error\n"; } } for (my $i = 0; $i < @args; ++$i) { $args[$i][1] = splice(@args, $i + 1, 1) if ref $args[$_]; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Parsing arguments
by xmath (Hermit) on Feb 20, 2003 at 19:32 UTC | |
by hv (Prior) on Feb 20, 2003 at 19:55 UTC |