-
Notifications
You must be signed in to change notification settings - Fork 0
/
lexer_hack.mll
717 lines (678 loc) · 24.2 KB
/
lexer_hack.mll
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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
{
(**
* Copyright (c) 2014, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the "hack" directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*)
open Utils
(*****************************************************************************)
(* Comments accumulator. *)
(*****************************************************************************)
let (comment_list: (Pos.t * string) list ref) = ref []
(*****************************************************************************)
(* Fixmes accumulators *)
(*****************************************************************************)
let (fixmes: Pos.t IMap.t IMap.t ref) = ref IMap.empty
let add_fixme err_nbr pos =
let line, _, _ = Pos.info_pos pos in
let line_value =
match IMap.get line !fixmes with
| None -> IMap.empty
| Some x -> x
in
fixmes := IMap.add line (IMap.add err_nbr pos line_value) !fixmes;
()
(*****************************************************************************)
(* The type for tokens. Some of them don't represent "real" tokens coming
* from the buffer. For example Terror can be used to tag an error, or Tyield
* doesn't really correspond to a string, it's just there to encode the
* priority.
*)
(*****************************************************************************)
type token =
| Tlvar
| Tint
| Tfloat
| Tat
| Tclose_php
| Tword
| Tbacktick
| Tphp
| Thh
| Tlp
| Trp
| Tsc
| Tcolon
| Tcolcol
| Tcomma
| Teq
| Tbareq
| Tpluseq
| Tstareq
| Tslasheq
| Tdoteq
| Tminuseq
| Tpercenteq
| Txoreq
| Tampeq
| Tlshifteq
| Trshifteq
| Teqeq
| Teqeqeq
| Tdiff
| Tdiff2
| Tbar
| Tbarbar
| Tampamp
| Tplus
| Tminus
| Tstar
| Tstarstar
| Tslash
| Tbslash
| Txor
| Tlcb
| Trcb
| Tlb
| Trb
| Tdot
| Tlte
| Tlt
| Tgt
| Tgte
| Tltlt
| Tgtgt
| Tsarrow
| Tnsarrow
| Tarrow
| Tlambda
| Tem
| Tqm
| Tamp
| Ttild
| Tincr
| Tdecr
| Tunderscore
| Trequired
| Tellipsis
| Tdollar
| Tpercent
| Teof
| Tquote
| Tdquote
| Tunsafe
| Tunsafeexpr
| Tfallthrough
| Theredoc
| Txhpname
| Tref
| Tspace
| Topen_comment
| Tclose_comment
| Tline_comment
| Topen_xhp_comment
| Tclose_xhp_comment
(* Fake tokens *)
| Tyield
| Tawait
| Timport
| Teval
| Tprint
| Tinstanceof
| Tnew
| Tclone
| Telseif
| Telse
| Tendif
| Tcast
| Terror
| Tnewline
| Tany
(*****************************************************************************)
(* Backtracking. *)
(*****************************************************************************)
let yyback n lexbuf =
Lexing.(
lexbuf.lex_curr_pos <- lexbuf.lex_curr_pos - n;
let currp = lexbuf.lex_curr_p in
lexbuf.lex_curr_p <-
{ currp with pos_cnum = currp.pos_cnum - n }
)
let back lb =
let n = Lexing.lexeme_end lb - Lexing.lexeme_start lb in
yyback n lb
(*****************************************************************************)
(* Pretty printer (pretty?) *)
(*****************************************************************************)
let token_to_string = function
| Tat -> "@"
| Tbacktick -> "`"
| Tlp -> "("
| Trp -> ")"
| Tsc -> ";"
| Tcolon -> ":"
| Tcolcol -> "::"
| Tcomma -> ","
| Teq -> "="
| Tbareq -> "|="
| Tpluseq -> "+="
| Tstareq -> "*="
| Tslasheq -> "/="
| Tdoteq -> ".="
| Tminuseq -> "-="
| Tpercenteq -> "%="
| Txoreq -> "^="
| Tampeq -> "&="
| Tlshifteq -> "<<="
| Trshifteq -> ">>="
| Teqeq -> "=="
| Teqeqeq -> "==="
| Tdiff -> "!="
| Tdiff2 -> "!=="
| Tbar -> "|"
| Tbarbar -> "||"
| Tampamp -> "&&"
| Tplus -> "+"
| Tminus -> "-"
| Tstar -> "*"
| Tstarstar -> "**"
| Tslash -> "/"
| Tbslash -> "\\"
| Txor -> "^"
| Tlcb -> "{"
| Trcb -> "}"
| Tlb -> "["
| Trb -> "]"
| Tdot -> "."
| Tlte -> "<="
| Tlt -> "<"
| Tgt -> ">"
| Tgte -> ">="
| Tltlt -> "<<"
| Tgtgt -> ">>"
| Tsarrow -> "=>"
| Tnsarrow -> "?->"
| Tarrow -> "->"
| Tlambda -> "==>"
| Tem -> "!"
| Tqm -> "?"
| Tamp -> "&"
| Ttild -> "~"
| Tincr -> "++"
| Tdecr -> "--"
| Tunderscore -> "_"
| Tellipsis -> "..."
| Tdollar -> "$"
| Tpercent -> "%"
| Tquote -> "'"
| Tdquote -> "\""
| Tclose_php -> "?>"
| Tlvar -> "lvar"
| Tint -> "int"
| Tfloat -> "float"
| Tword -> "word"
| Tphp -> "php"
| Thh -> "hh"
| Trequired -> "required"
| Teof -> "eof"
| Tyield -> "yield"
| Tawait -> "await"
| Timport -> "import"
| Teval -> "eval"
| Tprint -> "print"
| Tinstanceof -> "instanceof"
| Tnew -> "new"
| Tclone -> "clone"
| Telseif -> "elseif"
| Telse -> "else"
| Tendif -> "endif"
| Tcast -> "cast"
| Tref -> "ref"
| Theredoc -> "heredoc"
| Txhpname -> "xhpname"
| Terror -> "error"
| Tunsafe -> "unsafe"
| Tunsafeexpr -> "unsafeexpr"
| Tfallthrough -> "fallthrough"
| Tnewline -> "newline"
| Tany -> "any"
| Tspace -> "space"
| Topen_comment -> "open_comment"
| Tclose_comment -> "close_comment"
| Tline_comment -> "line_comment"
| Topen_xhp_comment -> "open_xhp_comment"
| Tclose_xhp_comment -> "close_xhp_comment"
}
let digit = ['0'-'9']
let letter = ['a'-'z''A'-'Z''_']
let alphanumeric = digit | letter
let varname = letter alphanumeric*
let word_part = (letter alphanumeric*) | (['a'-'z'] (alphanumeric | '-')* alphanumeric)
let word = ('\\' | word_part)+ (* Namespaces *)
let xhpname = ('%')? varname ([':' '-'] varname)*
let otag = '<' ['a'-'z''A'-'Z'] (alphanumeric | ':' | '-')*
let ctag = '<' '/' (alphanumeric | ':' | '-')+ '>'
let lvar = '$' varname
let ws = [' ' '\t' '\r' '\x0c']
let hex = digit | ['a'-'f''A'-'F']
let hex_number = '0' 'x' hex+
let bin_number = '0' 'b' ['0'-'1']+
let decimal_number = '0' | ['1'-'9'] digit*
let octal_number = '0' ['0'-'7']+
let int = decimal_number | hex_number | bin_number | octal_number
let float =
(digit* ('.' digit+) ((('e'|'E') ('+'?|'-') digit+))?) |
(digit+ ('.' digit*) ((('e'|'E') ('+'?|'-') digit+))?) |
(digit+ ('e'|'E') ('+'?|'-') digit+)
let unsafe = "//" ws* "UNSAFE" [^'\n']*
let unsafeexpr_start = "/*" ws* "UNSAFE_EXPR"
let fixme_start = "/*" ws* "HH_FIXME"
let fallthrough = "//" ws* "FALLTHROUGH" [^'\n']*
rule token file = parse
(* ignored *)
| ws+ { token file lexbuf }
| '\n' { Lexing.new_line lexbuf; token file lexbuf }
| unsafeexpr_start { let buf = Buffer.create 256 in
let start = lexbuf.Lexing.lex_start_p in
ignore (comment buf file lexbuf);
(* unsafeexpr is technically made up of multiple
* tokens, but we want to treat it as a single token
* as far as start / end positions are concerned *)
lexbuf.Lexing.lex_start_p <- start;
Tunsafeexpr
}
| fixme_start { let fixme = fixme_state0 file lexbuf in
let tok = token file lexbuf in
(match fixme with
| Some err_nbr -> add_fixme err_nbr (Pos.make file lexbuf)
| None -> ());
tok
}
| "/*" { let buf = Buffer.create 256 in
comment_list := comment buf file lexbuf :: !comment_list;
token file lexbuf
}
| "//" { line_comment lexbuf; token file lexbuf }
| "#" { line_comment lexbuf; token file lexbuf }
| '\"' { Tdquote }
| ''' { Tquote }
| "<<<" { Theredoc }
| int { Tint }
| float { Tfloat }
| '@' { Tat }
| "?>" { Tclose_php }
| word { Tword }
| lvar { Tlvar }
| '$' { Tdollar }
| '`' { Tbacktick }
| "<?php" { Tphp }
| "<?hh" { Thh }
| '(' { Tlp }
| ')' { Trp }
| ';' { Tsc }
| ':' { Tcolon }
| "::" { Tcolcol }
| ',' { Tcomma }
| '=' { Teq }
| "|=" { Tbareq }
| "+=" { Tpluseq }
| "*=" { Tstareq }
| "/=" { Tslasheq }
| ".=" { Tdoteq }
| "-=" { Tminuseq }
| "%=" { Tpercenteq }
| "^=" { Txoreq }
| "&=" { Tampeq }
| "<<=" { Tlshifteq }
| ">>=" { Trshifteq }
| "==" { Teqeq }
| "===" { Teqeqeq }
| "!=" { Tdiff }
| "!==" { Tdiff2 }
| '|' { Tbar }
| "||" { Tbarbar }
| "&&" { Tampamp }
| '+' { Tplus }
| '-' { Tminus }
| '*' { Tstar }
| "**" { Tstarstar }
| '/' { Tslash }
| '^' { Txor }
| '%' { Tpercent }
| '{' { Tlcb }
| '}' { Trcb }
| '[' { Tlb }
| ']' { Trb }
| '.' { Tdot }
| "<=" { Tlte }
| '<' { Tlt }
| '>' { Tgt }
| ">=" { Tgte }
| "<<" { Tltlt }
| ">>" { Tgtgt }
| "=>" { Tsarrow }
| "?->" { Tnsarrow }
| "->" { Tarrow }
| "==>" { Tlambda }
| '!' { Tem }
| '?' { Tqm }
| '&' { Tamp }
| '~' { Ttild }
| "++" { Tincr }
| "--" { Tdecr }
| "_" { Tunderscore }
| "@required" { Trequired }
| "..." { Tellipsis }
| unsafe { Tunsafe }
| fallthrough { Tfallthrough }
| eof { Teof }
| _ { Terror }
and xhpname file = parse
| eof { Terror }
| '\n' { Lexing.new_line lexbuf; xhpname file lexbuf }
| ws+ { xhpname file lexbuf }
| "/*" { ignore (comment (Buffer.create 256) file lexbuf);
xhpname file lexbuf
}
| "//" { line_comment lexbuf; xhpname file lexbuf }
| "#" { line_comment lexbuf; xhpname file lexbuf }
| word { Txhpname }
| xhpname { Txhpname }
| _ { Terror }
and xhptoken file = parse
| eof { Teof }
| '\n' { Lexing.new_line lexbuf; xhptoken file lexbuf }
| '<' { Tlt }
| '>' { Tgt }
| '{' { Tlcb }
| '}' { Trcb }
| '/' { Tslash }
| '\"' { Tdquote }
| word { Tword }
| "<!--" { xhp_comment file lexbuf; xhptoken file lexbuf }
| _ { xhptoken file lexbuf }
and xhpattr file = parse
| eof { Teof }
| ws+ { xhpattr file lexbuf }
| '\n' { Lexing.new_line lexbuf; xhpattr file lexbuf }
| fixme_start { let fixme = fixme_state0 file lexbuf in
let tok = xhpattr file lexbuf in
(match fixme with
| Some err_nbr -> add_fixme err_nbr (Pos.make file lexbuf)
| None -> ());
tok
}
| "/*" { ignore (comment (Buffer.create 256) file lexbuf);
xhpattr file lexbuf
}
| "//" { line_comment lexbuf; xhpattr file lexbuf }
| '\n' { Lexing.new_line lexbuf; xhpattr file lexbuf }
| '<' { Tlt }
| '>' { Tgt }
| '{' { Tlcb }
| '}' { Trcb }
| '/' { Tslash }
| '\"' { Tdquote }
| word { Tword }
| _ { Terror }
and heredoc_token = parse
| eof { Teof }
| '\n' { Lexing.new_line lexbuf; Tnewline }
| word { Tword }
| ';' { Tsc }
| _ { Tany }
and comment buf file = parse
| eof { let pos = Pos.make file lexbuf in
Errors.unterminated_comment pos;
pos, Buffer.contents buf
}
| '\n' { Lexing.new_line lexbuf;
Buffer.add_char buf '\n';
comment buf file lexbuf
}
| "*/" { Pos.make file lexbuf, Buffer.contents buf }
| _ { Buffer.add_string buf (Lexing.lexeme lexbuf);
comment buf file lexbuf
}
(* HH_FIXME... *)
and fixme_state0 file = parse
| eof { let pos = Pos.make file lexbuf in
Errors.unterminated_comment pos;
None
}
| ws+ { fixme_state0 file lexbuf
}
| '\n' { Lexing.new_line lexbuf;
fixme_state0 file lexbuf
}
| '[' { fixme_state1 file lexbuf }
| _ { Errors.fixme_format (Pos.make file lexbuf);
ignore (comment (Buffer.create 256) file lexbuf);
None
}
(* HH_FIXME[... *)
and fixme_state1 file = parse
| eof { let pos = Pos.make file lexbuf in
Errors.unterminated_comment pos;
None
}
| ws+ { fixme_state1 file lexbuf }
| '\n' { Lexing.new_line lexbuf;
fixme_state1 file lexbuf
}
| int { let err_nbr = Lexing.lexeme lexbuf in
let err_nbr = int_of_string err_nbr in
fixme_state2 err_nbr file lexbuf }
| _ { Errors.fixme_format (Pos.make file lexbuf);
ignore (comment (Buffer.create 256) file lexbuf);
None
}
(* HH_FIXME[NUMBER... *)
and fixme_state2 err_nbr file = parse
| eof { let pos = Pos.make file lexbuf in
Errors.unterminated_comment pos;
None
}
| "*/" ws* '\n' { Lexing.new_line lexbuf;
Some err_nbr
}
| "*/" { Some err_nbr }
| '\n' { Lexing.new_line lexbuf;
fixme_state2 err_nbr file lexbuf
}
| _ { fixme_state2 err_nbr file lexbuf }
and line_comment = parse
| eof { () }
| '\n' { Lexing.new_line lexbuf }
| _ { line_comment lexbuf }
and xhp_comment file = parse
| eof { let pos = Pos.make file lexbuf in
Errors.unterminated_xhp_comment pos;
()
}
| '\n' { Lexing.new_line lexbuf; xhp_comment file lexbuf }
| "-->" { () }
| _ { xhp_comment file lexbuf }
and gt_or_comma file = parse
| eof { Terror }
| ws+ { gt_or_comma file lexbuf }
| '\n' { Lexing.new_line lexbuf; gt_or_comma file lexbuf }
| "/*" { ignore (comment (Buffer.create 256) file lexbuf);
gt_or_comma file lexbuf
}
| "//" { line_comment lexbuf; gt_or_comma file lexbuf }
| '\n' { Lexing.new_line lexbuf; gt_or_comma file lexbuf }
| '>' { Tgt }
| ',' { Tcomma }
| _ { Terror }
and no_space_id = parse
| eof { Terror }
| word { Tword }
| _ { Terror }
and string file = parse
| eof { Teof }
| '\n' { Lexing.new_line lexbuf; string file lexbuf }
| '\\' { string_backslash file lexbuf; string file lexbuf }
| ''' { Tquote }
| _ { string file lexbuf }
and string_backslash file = parse
| eof { let pos = Pos.make file lexbuf in
Errors.unexpected_eof pos;
()
}
| '\n' { Lexing.new_line lexbuf }
| _ { () }
and string2 file = parse
| eof { Teof }
| '\n' { Lexing.new_line lexbuf; string2 file lexbuf }
| '\\' { string_backslash file lexbuf; string2 file lexbuf }
| '\"' { Tdquote }
| '{' { Tlcb }
| '}' { Trcb }
| '[' { Tlb }
| ']' { Trb }
| "->" { Tarrow }
| '$' { Tdollar }
| ''' { Tquote }
| int { Tint }
| word_part { Tword }
| lvar { Tlvar }
| _ { Tany }
and header file = parse
| eof { `error }
| ws+ { header file lexbuf }
| '\n' { Lexing.new_line lexbuf; header file lexbuf }
| "//" { line_comment lexbuf; header file lexbuf }
| "/*" { ignore (comment (Buffer.create 256) file lexbuf);
header file lexbuf
}
| "#" { line_comment lexbuf; header file lexbuf }
| "<?hh" { `default_mode }
| "<?hh" ws* "//" { `explicit_mode }
| "<?php" ws* "//" ws* "decl" { `php_decl_mode }
(*| "<?php" { `php_mode }*)
| "<?php" { `default_mode } (* We want to parse everything, always *)
| _ { `error }
and next_newline_or_close_cb = parse
| eof { () }
| '\n' { Lexing.new_line lexbuf }
| '}' { back lexbuf }
| _ { next_newline_or_close_cb lexbuf }
and look_for_open_cb = parse
| eof { () }
| '\n' { Lexing.new_line lexbuf; look_for_open_cb lexbuf }
| '{' { () }
| _ { look_for_open_cb lexbuf }
(* Normally you can just use "token" and get back Tlvar, but specifically for
* member variable accesses, the part to the right of the "->" isn't a word
* (cannot contain '-' for example) but doesn't start with '$' so isn't an lvar
* either. *)
and varname = parse
| varname { Tword }
| _ { Terror }
(****************************************************************************)
(* hh_format tokenizers. *)
(****************************************************************************)
and format_comment = parse
| [' ' '\t'] { Tspace }
| ws* '\n' { Tnewline } (* eat up trailing spaces *)
| eof { Teof }
| "*/" { Tclose_comment }
| _ { Tany }
and format_token = parse
| [' ' '\t'] { Tspace }
| ws* '\n' { Tnewline } (* eat up trailing spaces *)
| "/*" { Topen_comment }
| "//" { Tline_comment }
| "#" { Tline_comment }
| '\"' { Tdquote }
| ''' { Tquote }
| "<<<" { Theredoc }
| int { Tint }
| float { Tfloat }
| '@' { Tat }
| "?>" { Tclose_php }
| word_part { Tword }
| lvar { Tlvar }
| '$' { Tdollar }
| '`' { Tbacktick }
| "<?php" { Tphp }
| "<?hh" { Thh }
| '(' { Tlp }
| ')' { Trp }
| ';' { Tsc }
| ':' { Tcolon }
| "::" { Tcolcol }
| ',' { Tcomma }
| '=' { Teq }
| "|=" { Tbareq }
| "+=" { Tpluseq }
| "*=" { Tstareq }
| "/=" { Tslasheq }
| ".=" { Tdoteq }
| "-=" { Tminuseq }
| "%=" { Tpercenteq }
| "^=" { Txoreq }
| "&=" { Tampeq }
| "<<=" { Tlshifteq }
| ">>=" { Trshifteq }
| "==" { Teqeq }
| "===" { Teqeqeq }
| "!=" { Tdiff }
| "!==" { Tdiff2 }
| '|' { Tbar }
| "||" { Tbarbar }
| "&&" { Tampamp }
| '+' { Tplus }
| '-' { Tminus }
| '*' { Tstar }
| "**" { Tstarstar }
| '/' { Tslash }
| '\\' { Tbslash }
| '^' { Txor }
| '%' { Tpercent }
| '{' { Tlcb }
| '}' { Trcb }
| '[' { Tlb }
| ']' { Trb }
| '.' { Tdot }
| "<=" { Tlte }
| '<' { Tlt }
| '>' { Tgt }
| ">=" { Tgte }
| "<<" { Tltlt }
| "=>" { Tsarrow }
| "?->" { Tnsarrow }
| "->" { Tarrow }
| "==>" { Tlambda }
| '!' { Tem }
| '?' { Tqm }
| '&' { Tamp }
| '~' { Ttild }
| "++" { Tincr }
| "--" { Tdecr }
| "_" { Tunderscore }
| "..." { Tellipsis }
| eof { Teof }
| _ { Terror }
and format_xhptoken = parse
| eof { Teof }
| ws* '\n' { Tnewline } (* eat up trailing spaces *)
| ' ' { Tspace }
| '<' { Tlt }
| '>' { Tgt }
| '{' { Tlcb }
| '}' { Trcb }
| '/' { Tslash }
| '\"' { Tdquote }
| "/*" { Topen_comment }
| "*/" { Tclose_comment }
| "//" { Tline_comment }
| word { Tword }
| "<!--" { Topen_xhp_comment }
| "-->" { Tclose_xhp_comment }
| _ { Terror }