|
16 | 16 | class ContextGenerator |
17 | 17 | { |
18 | 18 |
|
| 19 | + /** |
| 20 | + * Labels and flags that may be used when defining keywords. |
| 21 | + * |
| 22 | + * @var array |
| 23 | + */ |
| 24 | + public static $LABELS_FLAGS = array( |
| 25 | + '(R)' => 2, |
| 26 | + '(D)' => 8, |
| 27 | + '(K)' => 16, |
| 28 | + '(F)' => 32, |
| 29 | + ); |
| 30 | + |
19 | 31 | /** |
20 | 32 | * Documentation links for each context. |
21 | 33 | * |
@@ -123,28 +135,12 @@ public static function readWords(array $files) |
123 | 135 | $type = 1; |
124 | 136 | $value = trim($words[$i]); |
125 | 137 |
|
126 | | - // Reserved keyword. |
127 | | - if (strstr($value, '(R)') !== false) { |
128 | | - $type |= 2; |
129 | | - $value = trim(str_replace('(R)', '', $value)); |
130 | | - } |
131 | | - |
132 | | - // Data type keyword. |
133 | | - if (strstr($value, '(D)') !== false) { |
134 | | - $type |= 8; |
135 | | - $value = trim(str_replace('(D)', '', $value)); |
136 | | - } |
137 | | - |
138 | | - // Key keyword. |
139 | | - if (strstr($value, '(K)') !== false) { |
140 | | - $type |= 16; |
141 | | - $value = trim(str_replace('(K)', '', $value)); |
142 | | - } |
143 | | - |
144 | | - // Function keyword. |
145 | | - if (strstr($value, '(F)') !== false) { |
146 | | - $type |= 32; |
147 | | - $value = trim(str_replace('(F)', '', $value)); |
| 138 | + // Reserved, data types, keys, functions, etc. keywords. |
| 139 | + foreach (static::$LABELS_FLAGS as $label => $flags) { |
| 140 | + if (strstr($value, $label) !== false) { |
| 141 | + $type |= $flags; |
| 142 | + $value = trim(str_replace($label, '', $value)); |
| 143 | + } |
148 | 144 | } |
149 | 145 |
|
150 | 146 | // Composed keyword. |
@@ -338,7 +334,7 @@ public static function buildAll($input, $output) |
338 | 334 | } |
339 | 335 |
|
340 | 336 | // Building the context. |
341 | | - print("Building context for {$file}...\n"); |
| 337 | + sprintf("Building context for %s...\n", $file); |
342 | 338 | static::build($input . '/' . $file, $output); |
343 | 339 | } |
344 | 340 | } |
|
0 commit comments