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