|
28 | 28 | ;; 367-609 as of the `php-cc-mode' freeze) into plain, cc-mode independent |
29 | 29 | ;; `defconst' lists and pre-compiled `regexp-opt' regexps. |
30 | 30 | ;; |
31 | | -;; The purpose is to give the upcoming cc-free `php-mode' font-lock |
32 | | -;; implementation (see lisp/php-mode.el, not yet written) a single source |
33 | | -;; of truth for PHP keywords, without requiring `cc-mode', `cc-langs' or |
34 | | -;; `cc-fonts'. |
| 31 | +;; The purpose is to give the upcoming cc-mode independent `php-mode' |
| 32 | +;; font-lock implementation a single source of truth for PHP keywords, |
| 33 | +;; without requiring `cc-mode', `cc-langs' or `cc-fonts'. Nothing |
| 34 | +;; requires this file yet: the current `php-mode' still fontifies through |
| 35 | +;; CC Mode, so these tables have no effect until that work lands. |
35 | 36 | ;; |
36 | 37 | ;; Naming convention: for every category NAME there is |
37 | 38 | ;; - `php-keywords--NAME' a list of keyword strings (lower-case) |
|
48 | 49 | ;; `case-fold-search' to non-nil (or use `font-lock-defaults' with the |
49 | 50 | ;; KEYWORDS-CASE-FOLD slot set to t) while matching against them. |
50 | 51 | ;; |
51 | | -;; Magic constants (`__LINE__' etc.) are the sole exception: by PHP |
52 | | -;; convention they are always written in upper-case, and are therefore |
53 | | -;; stored upper-case and are not meant to be matched case-insensitively. |
54 | | -;; See `php-keywords--constants'. |
| 52 | +;; This file holds only the *syntactic* vocabulary of the language. Out |
| 53 | +;; of scope, and deliberately not duplicated here: |
55 | 54 | ;; |
56 | | -;; This file intentionally does NOT duplicate lisp/php-defs.el, which |
57 | | -;; holds the (large) table of built-in *function* names. Predefined |
58 | | -;; runtime constants other than `true'/`false'/`null' and the magic |
59 | | -;; constants (e.g. `PHP_INT_MAX') are likewise out of scope here; only |
60 | | -;; `PHP_EOL' is included below because it was explicitly called out in |
61 | | -;; the implementation blueprint as a commonly fontified constant. |
| 55 | +;; - built-in function names -- see lisp/php-defs.el; |
| 56 | +;; - the magic constants (`__LINE__' and friends), which are written |
| 57 | +;; upper-case and matched case-sensitively -- php.el owns that list |
| 58 | +;; as `php-magical-constants', and both major modes build their |
| 59 | +;; font-lock rule from it directly; |
| 60 | +;; - predefined runtime constants such as `PHP_EOL' or `PHP_INT_MAX', |
| 61 | +;; which are library symbols rather than language keywords. |
62 | 62 |
|
63 | 63 | ;;; Code: |
64 | 64 |
|
@@ -220,82 +220,27 @@ See the commentary in php-keywords.el for provenance.") |
220 | 220 | Match against buffer text with `case-fold-search' bound to non-nil.") |
221 | 221 |
|
222 | 222 |
|
223 | | -;;; 5. Language constants and magic constants |
| 223 | +;;; 5. Language constants |
224 | 224 | ;; |
225 | | -;; Source: |
226 | | -;; - `c-constant-kwds' -- "true" "false" "null" (case-insensitive |
227 | | -;; PHP language constants; stored lower-case here, same convention |
228 | | -;; as every other list in this file). |
229 | | -;; - php.el's existing `php-magical-constants' -- "__CLASS__" |
230 | | -;; "__DIR__" "__FILE__" "__FUNCTION__" "__LINE__" "__METHOD__" |
231 | | -;; "__NAMESPACE__" "__TRAIT__". These are NOT re-derived from |
232 | | -;; php-cc-mode.el (they are not part of the 367-609 c-lang-defconst |
233 | | -;; block; php-cc-mode.el fontifies them by referring directly to |
234 | | -;; `php-magical-constants' from php.el, see the |
235 | | -;; `php-magical-constant' font-lock rule). They are duplicated |
236 | | -;; into this file's `php-keywords--constants' so this module is |
237 | | -;; self-contained and does not need to `require' php.el; keep the |
238 | | -;; two lists in sync if `php-magical-constants' ever changes. |
239 | | -;; |
240 | | -;; Unlike every other category in this file, magic constants are |
241 | | -;; conventionally written in upper-case only and are matched |
242 | | -;; case-sensitively (that is how php-cc-mode.el's existing font-lock |
243 | | -;; rule for `php-magical-constants' behaves). "true"/"false"/"null" |
244 | | -;; remain lower-case/case-insensitive like the rest of the file. |
| 225 | +;; Source: `c-constant-kwds' -- "true" "false" "null" (case-insensitive |
| 226 | +;; PHP language constants; stored lower-case here, same convention as |
| 227 | +;; every other list in this file). |
245 | 228 | ;; |
246 | | -;; Supplemented: "PHP_EOL", a predefined runtime constant (not a |
247 | | -;; syntactic keyword) called out explicitly in the implementation |
248 | | -;; blueprint (§6) as worth fontifying alongside the magic constants. |
249 | | -;; It is the only predefined library constant included here -- the |
250 | | -;; rest of PHP's predefined constants (PHP_INT_MAX, PHP_VERSION, ...) |
251 | | -;; belong with built-in symbol tables such as lisp/php-defs.el, not in |
252 | | -;; this "language keyword" module. |
| 229 | +;; The magic constants (`__CLASS__', `__LINE__', ...) are intentionally |
| 230 | +;; NOT mirrored here. They are not part of php-cc-mode.el's 367-609 |
| 231 | +;; c-lang-defconst block either: both major modes fontify them straight |
| 232 | +;; from php.el's `php-magical-constants', which stays the single source |
| 233 | +;; of truth for that list. |
253 | 234 | (defconst php-keywords--constants |
254 | 235 | '("true" "false" "null") |
255 | 236 | "PHP literal keywords `true', `false' and `null' (case-insensitive). |
256 | | -See `php-keywords--magic-constants' for the separate, case-sensitive |
257 | | -upper-case magic constants (`__LINE__' and friends) and `PHP_EOL'.") |
| 237 | +The upper-case magic constants (`__LINE__' and friends) are matched |
| 238 | +case-sensitively and live in php.el's `php-magical-constants'.") |
258 | 239 |
|
259 | 240 | (defconst php-keywords--constants-re |
260 | 241 | (regexp-opt php-keywords--constants 'symbols) |
261 | 242 | "`regexp-opt' of `php-keywords--constants', symbol-bounded. |
262 | 243 | Match against buffer text with `case-fold-search' bound to non-nil.") |
263 | 244 |
|
264 | | -(defconst php-keywords--magic-constants |
265 | | - '("__CLASS__" "__DIR__" "__FILE__" "__FUNCTION__" "__LINE__" |
266 | | - "__METHOD__" "__NAMESPACE__" "__TRAIT__" "PHP_EOL") |
267 | | - "PHP magic constants and `PHP_EOL', kept upper-case and matched |
268 | | -case-sensitively (do NOT bind `case-fold-search' to non-nil when using |
269 | | -`php-keywords--magic-constants-re'). Mirrors php.el's |
270 | | -`php-magical-constants' plus \"PHP_EOL\"; see the commentary above.") |
271 | | - |
272 | | -(defconst php-keywords--magic-constants-re |
273 | | - (regexp-opt php-keywords--magic-constants 'symbols) |
274 | | - "`regexp-opt' of `php-keywords--magic-constants', symbol-bounded. |
275 | | -Match case-sensitively (do not fold case).") |
276 | | - |
277 | | - |
278 | | -;;; 6. Magic methods |
279 | | -;; |
280 | | -;; Source: none -- php-cc-mode.el's 367-609 `c-lang-defconst' block |
281 | | -;; does not enumerate magic method names anywhere (grepped for |
282 | | -;; "__construct", "__call", "__get", "__set", "magic" etc.: no hits). |
283 | | -;; This whole category is supplemented from the PHP manual's list of |
284 | | -;; magic methods (https://www.php.net/manual/language.oop5.magic.php), |
285 | | -;; current through PHP 8.4. |
286 | | -(defconst php-keywords--magic-methods |
287 | | - '("__call" "__callstatic" "__clone" "__construct" "__debuginfo" |
288 | | - "__destruct" "__get" "__invoke" "__isset" "__serialize" "__set" |
289 | | - "__set_state" "__sleep" "__tostring" "__unserialize" "__unset" |
290 | | - "__wakeup") |
291 | | - "PHP magic method names, stored lower-case (case-insensitive, like |
292 | | -ordinary PHP identifiers). Supplemented in full; not derived from |
293 | | -php-cc-mode.el, see the commentary above.") |
294 | | - |
295 | | -(defconst php-keywords--magic-methods-re |
296 | | - (regexp-opt php-keywords--magic-methods 'symbols) |
297 | | - "`regexp-opt' of `php-keywords--magic-methods', symbol-bounded. |
298 | | -Match against buffer text with `case-fold-search' bound to non-nil.") |
299 | | - |
300 | 245 | (provide 'php-keywords) |
301 | 246 | ;;; php-keywords.el ends here |
0 commit comments