X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FWeb-Simple.git;a=blobdiff_plain;f=lib%2FWeb%2FDispatch%2FParser.pm;h=cee4e1b5dbdf1c9536c4d3db3bafc0ced78c4b49;hp=c9a2657038d8dc1ed0f865bdd4f88241e5966a89;hb=63753442ca17095647197c331d544744ff8d39c7;hpb=965732b4ae93d6ba933d867d5329d7694ec91596 diff --git a/lib/Web/Dispatch/Parser.pm b/lib/Web/Dispatch/Parser.pm index c9a2657..cee4e1b 100644 --- a/lib/Web/Dispatch/Parser.pm +++ b/lib/Web/Dispatch/Parser.pm @@ -19,6 +19,14 @@ has _cache => ( sub diag { if (DEBUG) { warn $_[0] } } +sub _wtf { + my ($self, $error) = @_; + my $hat = (' ' x (pos||0)).'^'; + warn "Warning parsing dispatch specification: ${error}\n +${_} +${hat} here\n"; +} + sub _blam { my ($self, $error) = @_; my $hat = (' ' x (pos||0)).'^'; @@ -38,18 +46,20 @@ sub _parse_spec { return match_true() unless length($spec); for ($_[1]) { my @match; + my $close; PARSE: { do { push @match, $self->_parse_spec_section($_) or $self->_blam("Unable to work out what the next section is"); if (/\G\)/gc) { $self->_blam("Found closing ) with no opening (") unless $nested; + $close = 1; last PARSE; } last PARSE if (pos == length); $match[-1] = $self->_parse_spec_combinator($_, $match[-1]) or $self->_blam('No valid combinator - expected + or |'); } until (pos == length) }; # accept trailing whitespace - if ($nested and pos == length) { + if (!$close and $nested and pos == length) { pos = $nested - 1; $self->_blam("No closing ) found for opening ("); }