@@ -985,18 +985,43 @@ this ^ lineup"
985
985
(string-match " \\ _<.+?\\ _>" heredoc-start)
986
986
(concat " ^\\ s-*\\ (" (match-string 0 heredoc-start) " \\ )\\ W" ))
987
987
988
+ (defvar php-syntax-propertize-functions
989
+ '(php-syntax-propertize-heredoc
990
+ php-syntax-propertize-quotes-in-comment
991
+ php-syntax-propertize-hash-line-comment)
992
+ " Syntax propertize functions for PHP script." )
993
+
988
994
(defun php-syntax-propertize-function (start end )
989
995
" Apply propertize rules from START to END."
990
- (goto-char start)
996
+ (dolist (propertizer php-syntax-propertize-functions)
997
+ (goto-char start)
998
+ (funcall propertizer start end)))
999
+
1000
+ (defun php-syntax-propertize-heredoc (_start end )
1001
+ " Apply propertize Heredoc and Nowdoc from START to END."
991
1002
(while (and (< (point ) end)
992
1003
(re-search-forward php-heredoc-start-re end t ))
993
- (php-heredoc-syntax))
994
- (goto-char start)
1004
+ (php-heredoc-syntax)))
1005
+
1006
+ (defun php-syntax-propertize-quotes-in-comment (_start end )
1007
+ " Apply propertize quotes (' and \" ) from START to END."
995
1008
(while (re-search-forward " ['\" ]" end t )
996
1009
(when (php-in-comment-p)
997
1010
(c-put-char-property (match-beginning 0 )
998
1011
'syntax-table (string-to-syntax " _" )))))
999
1012
1013
+ (defun php-syntax-propertize-hash-line-comment (_start end )
1014
+ " Apply propertize # comment (without PHP8 Attributes) from START to END."
1015
+ (unless php-mode-use-php7-syntax-table
1016
+ (while (< (point ) (min end (point-max )))
1017
+ (let ((line-end (line-end-position )))
1018
+ (when (and (search-forward " #" line-end t )
1019
+ (not (php-in-string-or-comment-p))
1020
+ (not (looking-at " [[]" )))
1021
+ (c-put-char-property (1- (point )) 'syntax-table (string-to-syntax " <" ))
1022
+ (c-put-char-property line-end 'syntax-table (string-to-syntax " >" )))
1023
+ (move-beginning-of-line 2 )))))
1024
+
1000
1025
(defun php-heredoc-syntax ()
1001
1026
" Mark the boundaries of searched heredoc."
1002
1027
(goto-char (match-beginning 0 ))
0 commit comments