aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2016-08-14 17:24:52 +0200
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2016-08-14 17:24:52 +0200
commita06167b963f39019112d7aa68dedcf2a1f30aed8 (patch)
treea4fde245847734e07f4db88125c68f108c70e6a0
parent0bb2b6cf6d68458eebea70e22785c10af5353395 (diff)
downloadCompiler-a06167b963f39019112d7aa68dedcf2a1f30aed8.zip
Compiler-a06167b963f39019112d7aa68dedcf2a1f30aed8.tar.gz
Compiler-a06167b963f39019112d7aa68dedcf2a1f30aed8.tar.bz2
Llk: Correctly order and merge skip tokens.
First, skip tokens were not correctly merge. For instance: %skip a b %skip c d %skip e f would have produced the following skip token: %token skip (?:f)|(?:d)|b which is correct but not fantastics. Now, the following skip token is produced: %token skip (?:f|(?:d|b)) Second, since the user declares `a` before `c`, this order must be preserved. Thus, the final following skip token is produced: %token skip (?:(?:b|d)|f)
-rw-r--r--Llk/Llk.php6
1 files changed, 4 insertions, 2 deletions
diff --git a/Llk/Llk.php b/Llk/Llk.php
index 2fdfc85..97d3318 100644
--- a/Llk/Llk.php
+++ b/Llk/Llk.php
@@ -365,8 +365,10 @@ abstract class Llk
$tokens[$matches[1]]['skip'] = $matches[3];
} else {
$tokens[$matches[1]]['skip'] =
- '(?:' . $matches[3] . ')|' .
- $tokens[$matches[1]]['skip'];
+ '(?:' .
+ $tokens[$matches[1]]['skip'] . '|' .
+ $matches[3] .
+ ')';
}
} elseif (0 !== preg_match('#^%token\s+(?:([^:]+):)?([^\s]+)\s+(.*?)(?:\s+->\s+(.*))?$#u', $line, $matches)) {
if (empty($matches[1])) {