Skip to content

Commit

Permalink
[BUGFIX] Allow colons in PCRE part of default namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
ohader committed Oct 6, 2020
1 parent 90c9b80 commit 2242418
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Llk/Llk.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ public static function parsePP($pp, &$tokens, &$rules, &$pragmas, $streamName)
$matches[3] .
')';
}
} elseif (0 !== preg_match('#^%token\h+(?:([^:]+):)?([^\h]+)\h+(.*?)(?:\h+->\h+(.*))?$#u', $line, $matches)) {
} elseif (0 !== preg_match('#^%token\h+(?:([^:\h]+):)?([^\h]+)\h+(.*?)(?:\h+->\h+(.*))?$#u', $line, $matches)) {
if (empty($matches[1])) {
$matches[1] = 'default';
}
Expand Down
6 changes: 4 additions & 2 deletions Test/Unit/Llk/Llk.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ public function case_parse_tokens()
'%token foobar1 bazqux1' . "\n" .
'%token sourceNS1:foobar2 bazqux2' . "\n" .
'%token sourceNS2:foobar3 bazqux3 -> destinationNS' . "\n" .
'%token foobar4 barqux4 -> destinationNS'
'%token foobar4 barqux4 -> destinationNS' . "\n" .
'%token foobar5 ns:bar -> destinationNS'
)
->when($result = SUT::parsePP($pp, $tokens, $rules, $pragmas, 'streamFoo'))
->then
Expand All @@ -224,7 +225,8 @@ public function case_parse_tokens()
->isEqualTo([
'default' => [
'foobar1' => 'bazqux1',
'foobar4:destinationNS' => 'barqux4'
'foobar4:destinationNS' => 'barqux4',
'foobar5:destinationNS' => 'ns:bar',
],
'sourceNS1' => [
'foobar2' => 'bazqux2'
Expand Down

0 comments on commit 2242418

Please sign in to comment.