File: php

package info (click to toggle)
dte 1.10-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 2,152 kB
  • sloc: ansic: 28,421; sh: 94; awk: 56; makefile: 13; sed: 1
file content (295 lines) | stat: -rw-r--r-- 5,325 bytes parent folder | download | duplicates (2)
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# "simple" variable inside string
syntax .php-strvar

state start
    char a-zA-Z_ strvar
    noeat END

state strvar
    char a-zA-Z_0-9 this
    noeat END

# Curly braces inside string
syntax .php-strcurly

state strvar
    char } END strvar
    eat this

# Common escapes inside double quotes and heredocs
syntax .php-esc

state special
    char x hex
    # 1-3 octal digits, \777 (0x1ff) overflows to 0xff
    char 0-7 oct1
    recolor string 1
    eat END

state hex special
    char 0-9a-fA-F hex2
    # "\xq" is not an error, it's literal
    recolor string 2
    noeat END

state hex2 special
    char 0-9a-fA-F END special
    # Single hex digit is ok
    noeat END

state oct1 special
    char 0-7 oct2
    noeat END

state oct2 special
    char 0-7 END special
    noeat END

# Common to <<<END and <<<"END"
syntax .php-heredoc-common

state bol string
    heredocend match
    noeat string

state string
    char "\n" bol
    char \\ esc
    char \$ .php-strvar:this strvar
    str '{$' .php-strcurly:this strvar
    eat this

state esc special
    # NOTE: \" is not special unlike in double quotes
    char 'nrtvf\$' string special
    noeat .php-esc:string

state match special
    char "\n" END
    str ";\n" END
    # Length clamped to bol
    recolor string 1000
    noeat string

# heredoc: <<<END
syntax .php-heredoc

state start special
    char "\n" .php-heredoc-common:END
    noeat END

# heredoc: <<<"END"
syntax .php-heredoc-dq

state start special
    str "\"\n" .php-heredoc-common:END
    noeat END

# nowdoc: <<<'END'
syntax .php-nowdoc

state start special
    str "'\n" bol
    noeat END

state bol string
    heredocend match
    noeat string

state string
    char "\n" bol
    eat this

state match special
    char "\n" END
    str ";\n" END
    # Length clamped to bol
    recolor string 1000
    noeat string

# Inside <? and ?>
syntax .php

state code
    char -b a-zA-Z_ word
    char \$ variable
    char \" dq
    char \' sq
    char 0 zero
    char 1-9 dec
    char . dot
    char ? qm
    str "//" cpp-comment
    str "/*" c-comment
    char # sh-comment
    str <<< heredoc
    eat this

state word code
    char -b a-zA-Z_0-9 this
    inlist keyword code
    inlist constant code
    inlist lang code
    noeat code

state variable
    char -b a-zA-Z_ variable2
    noeat code

state variable2 variable
    char -b a-zA-Z_0-9 this
    bufis this this-keyword
    noeat code

state this-keyword
    recolor this 5
    noeat code

state dq string
    char \" code string
    char \\ dqesc
    char \$ .php-strvar:this strvar
    str '{$' .php-strcurly:this strvar
    eat this

state dqesc special
    char 'nrtvf\$"' dq special
    noeat .php-esc:dq

state sq string
    char \' code string
    char \\ sqesc
    eat this

state sqesc string
    # Not \ or '
    char -n "\\'" sq
    recolor special 1
    eat sq special

state zero numeric
    char xX hex
    char 0-7 oct
    char . float
    noeat check-suffix

state oct numeric
    char 0-7 this
    noeat check-suffix

state dec numeric
    char 0-9 this
    char eE exp
    char . float
    noeat check-suffix

state hex numeric
    char 0-9a-fA-F this
    noeat check-suffix

state check-suffix error
    char a-zA-Z0-9_ this
    noeat code

state dot numeric
    char 0-9 float
    recolor code 1
    noeat code

state float numeric
    char 0-9 this
    char eE exp
    noeat check-suffix

state exp numeric
    char +- exp-digit
    char 0-9 exp-digit
    noeat check-suffix

state exp-digit numeric
    char 0-9 this
    noeat check-suffix

state qm tag
    char > END tag
    recolor code 1
    noeat code

state cpp-comment comment
    char "\n" code
    eat this

state c-comment comment
    str "*/" code comment
    eat this

state sh-comment comment
    char "\n" code
    eat this

state heredoc special
    char -b a-zA-Z_ heredoc-plain
    char \" heredoc-dq-start
    char \' nowdoc-start
    noeat code

state heredoc-plain special
    char -b a-zA-Z0-9_ this
    heredocbegin .php-heredoc code

state heredoc-dq-start special
    char -b a-zA-Z_ heredoc-dq
    noeat code

state heredoc-dq special
    char -b a-zA-Z0-9_ this
    heredocbegin .php-heredoc-dq code

state nowdoc-start special
    char -b a-zA-Z_ nowdoc
    noeat code

state nowdoc special
    char -b a-zA-Z0-9_ this
    heredocbegin .php-nowdoc code

list keyword \
    abstract and array as break case catch cfunction class clone \
    const continue declare default do else elseif enddeclare \
    endfor endforeach endif endswitch endwhile extends final for \
    foreach function global goto if implements interface \
    instanceof namespace new old_function or private protected \
    public static switch throw try use var while xor self parent

list -i constant \
    __CLASS__ __DIR__ __FILE__ __FUNCTION__ __METHOD__ __NAMESPACE__ \
    false null true

# Language constructs
list lang \
    die echo empty exit eval include include_once isset list require \
    require_once return print unset

syntax php

state code
    char < lab
    eat this

state lab tag
    char ? tag-php
    recolor code 1
    noeat code

state tag-php tag
    str "php" tag-ver
    noeat .php:code

state tag-ver tag
    char 3-5 .php:code tag
    noeat .php:code

default special tag
default keyword lang
default special strvar
default variable this