-
Notifications
You must be signed in to change notification settings - Fork 2
/
phps-mode-syntax-table.el
119 lines (72 loc) · 3.66 KB
/
phps-mode-syntax-table.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
;;; phps-mode-syntax-table.el --- Syntax table for PHPs -*- lexical-binding: t -*-
;; Copyright (C) 2018-2024 Free Software Foundation, Inc.
;; This file is not part of GNU Emacs.
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 2, or (at
;; your option) any later version.
;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; Please see README.md from the same repository for extended documentation.
;;; Code:
(defvar phps-mode-syntax-table
(let ((phps-mode-syntax-table (make-syntax-table)))
;; This is added so entity names with underscores can be more easily parsed as one word
;; WHITE-SPACE
;; Treat spaces as white-space
(modify-syntax-entry ?\s " " phps-mode-syntax-table)
;; Treat line-feed as white-space
(modify-syntax-entry ?\f " " phps-mode-syntax-table)
;; Treat spce as white-space
(modify-syntax-entry ?\s " " phps-mode-syntax-table)
;; Treat tabs as white-space
(modify-syntax-entry ?\t " " phps-mode-syntax-table)
;; Treat newline as white-space
(modify-syntax-entry ?\n " " phps-mode-syntax-table)
;; Treat carriage-return as white-space
(modify-syntax-entry ?\r " " phps-mode-syntax-table)
;; PUNCTUATIONS
;; Treat underscore, dollar-sign, question-mark as punctuations
(modify-syntax-entry ?_ "." phps-mode-syntax-table)
;; Treat dollar-sign as a punctuation
(modify-syntax-entry ?\$ "." phps-mode-syntax-table)
;; Treat question-mark as a punctuation
(modify-syntax-entry ?\? "." phps-mode-syntax-table)
;; Treat backslash as a punctuation
(modify-syntax-entry ?\\ "." phps-mode-syntax-table)
;; PARENTHESIS
;; Treat opening round bracket as open-parenthesis closed by )
(modify-syntax-entry ?\( "()" phps-mode-syntax-table)
;; Treat closing round bracket as close-parenthesis opened by (
(modify-syntax-entry ?\) ")(" phps-mode-syntax-table)
;; Treat opening square bracket as open-parenthesis closed by ]
(modify-syntax-entry ?\[ "(]" phps-mode-syntax-table)
;; Treat closing square bracket as close-parenthesis opened by [
(modify-syntax-entry ?\] ")[" phps-mode-syntax-table)
;; Treat opening curly bracket as open-parenthesis closed by }
(modify-syntax-entry ?\{ "(}" phps-mode-syntax-table)
;; Treat closing curly bracket as close-parenthesis opened by {
(modify-syntax-entry ?\} "){" phps-mode-syntax-table)
;; STRING QUOTE
;; Treat double quoted string as string quote
(modify-syntax-entry ?\" "\"" phps-mode-syntax-table)
;; Treat single quoted string as string quote
(modify-syntax-entry ?' "\"" phps-mode-syntax-table)
;; Treat back-quoted string as string quote
(modify-syntax-entry ?` "\"" phps-mode-syntax-table)
;; GENERIC COMMENT FENCE
;; Double slash starts comment type b
(modify-syntax-entry ?/ ". 124b" phps-mode-syntax-table)
(modify-syntax-entry ?* ". 23" phps-mode-syntax-table)
;; Newline end comment type b
(modify-syntax-entry ?\n "> b" phps-mode-syntax-table)
(modify-syntax-entry ?\r "> b" phps-mode-syntax-table)
phps-mode-syntax-table)
"Syntax table for phps-mode.")
(provide 'phps-mode-syntax-table)
;;; phps-mode-syntax-table.el ends here