various documentation and minor refactor
[hiphop-php.git] / hphp / hack / src / parser / full_fidelity_token_kind.ml
blob357964d8519cc86436319a2e2213481ca4152537
1 (*
2 * Copyright (c) 2016, Facebook, Inc.
3 * All rights reserved.
5 * This source code is licensed under the MIT license found in the
6 * LICENSE file in the "hack" directory of this source tree. An additional
7 * directory.
9 **
11 * THIS FILE IS @generated; DO NOT EDIT IT
12 * To regenerate this file, run
14 * buck run //hphp/hack/src:generate_full_fidelity
20 type t =
21 (* No text tokens *)
22 | EndOfFile
23 (* Given text tokens *)
24 | Abstract
25 | Arraykey
26 | As
27 | Async
28 | Attribute
29 | Await
30 | Backslash
31 | Binary
32 | Bool
33 | Boolean
34 | Break
35 | Case
36 | Catch
37 | Category
38 | Children
39 | Class
40 | Classname
41 | Clone
42 | Concurrent
43 | Const
44 | Construct
45 | Continue
46 | Ctx
47 | Darray
48 | Default
49 | Dict
50 | Do
51 | Double
52 | Echo
53 | Else
54 | Empty
55 | Endif
56 | Enum
57 | Eval
58 | Exports
59 | Extends
60 | Fallthrough
61 | Float
62 | File
63 | Final
64 | Finally
65 | For
66 | Foreach
67 | Function
68 | Global
69 | If
70 | Implements
71 | Imports
72 | Include
73 | Include_once
74 | Inout
75 | Instanceof
76 | Insteadof
77 | Int
78 | Integer
79 | Interface
80 | Is
81 | Isset
82 | Keyset
83 | Lateinit
84 | List
85 | Match
86 | Mixed
87 | Module
88 | Nameof
89 | Namespace
90 | New
91 | Newctx
92 | Newtype
93 | Noreturn
94 | Num
95 | Parent
96 | Print
97 | Private
98 | Protected
99 | Public
100 | Real
101 | Reify
102 | Require
103 | Require_once
104 | Required
105 | Resource
106 | Return
107 | Self
108 | Shape
109 | Static
110 | String
111 | Super
112 | Switch
113 | This
114 | Throw
115 | Trait
116 | Try
117 | Tuple
118 | Type
119 | Unset
120 | Upcast
121 | Use
122 | Using
123 | Var
124 | Varray
125 | Vec
126 | Void
127 | With
128 | Where
129 | While
130 | Yield
131 | NullLiteral
132 | LeftBracket
133 | RightBracket
134 | LeftParen
135 | RightParen
136 | LeftBrace
137 | RightBrace
138 | Dot
139 | MinusGreaterThan
140 | PlusPlus
141 | MinusMinus
142 | StarStar
143 | Star
144 | Plus
145 | Minus
146 | Tilde
147 | Exclamation
148 | Dollar
149 | Slash
150 | Percent
151 | LessThanEqualGreaterThan
152 | LessThanLessThan
153 | GreaterThanGreaterThan
154 | LessThan
155 | GreaterThan
156 | LessThanEqual
157 | GreaterThanEqual
158 | EqualEqual
159 | EqualEqualEqual
160 | ExclamationEqual
161 | ExclamationEqualEqual
162 | Carat
163 | Bar
164 | Ampersand
165 | AmpersandAmpersand
166 | BarBar
167 | Question
168 | QuestionAs
169 | QuestionColon
170 | QuestionQuestion
171 | QuestionQuestionEqual
172 | Colon
173 | Semicolon
174 | Equal
175 | StarStarEqual
176 | StarEqual
177 | SlashEqual
178 | PercentEqual
179 | PlusEqual
180 | MinusEqual
181 | DotEqual
182 | LessThanLessThanEqual
183 | GreaterThanGreaterThanEqual
184 | AmpersandEqual
185 | CaratEqual
186 | BarEqual
187 | Comma
188 | At
189 | ColonColon
190 | EqualGreaterThan
191 | EqualEqualGreaterThan
192 | QuestionMinusGreaterThan
193 | DotDotDot
194 | DollarDollar
195 | BarGreaterThan
196 | SlashGreaterThan
197 | LessThanSlash
198 | LessThanQuestion
199 | Backtick
200 | XHP
201 | Hash
202 | Readonly
203 | Internal
204 | Package
205 | Let
206 | Optional
207 (* Variable text tokens *)
208 | ErrorToken
209 | Name
210 | Variable
211 | DecimalLiteral
212 | OctalLiteral
213 | HexadecimalLiteral
214 | BinaryLiteral
215 | FloatingLiteral
216 | SingleQuotedStringLiteral
217 | DoubleQuotedStringLiteral
218 | DoubleQuotedStringLiteralHead
219 | StringLiteralBody
220 | DoubleQuotedStringLiteralTail
221 | HeredocStringLiteral
222 | HeredocStringLiteralHead
223 | HeredocStringLiteralTail
224 | NowdocStringLiteral
225 | BooleanLiteral
226 | XHPCategoryName
227 | XHPElementName
228 | XHPClassName
229 | XHPStringLiteral
230 | XHPBody
231 | XHPComment
232 | Hashbang
233 [@@deriving show, eq, sexp_of]
235 let from_string keyword ~only_reserved =
236 match keyword with
237 | "true" when not only_reserved -> Some BooleanLiteral
238 | "false" when not only_reserved -> Some BooleanLiteral
239 | "abstract" -> Some Abstract
240 | "arraykey" when not only_reserved -> Some Arraykey
241 | "as" -> Some As
242 | "async" -> Some Async
243 | "attribute" when not only_reserved -> Some Attribute
244 | "await" -> Some Await
245 | "\\" -> Some Backslash
246 | "binary" when not only_reserved -> Some Binary
247 | "bool" when not only_reserved -> Some Bool
248 | "boolean" when not only_reserved -> Some Boolean
249 | "break" -> Some Break
250 | "case" -> Some Case
251 | "catch" -> Some Catch
252 | "category" when not only_reserved -> Some Category
253 | "children" when not only_reserved -> Some Children
254 | "class" -> Some Class
255 | "classname" when not only_reserved -> Some Classname
256 | "clone" -> Some Clone
257 | "concurrent" -> Some Concurrent
258 | "const" -> Some Const
259 | "__construct" -> Some Construct
260 | "continue" -> Some Continue
261 | "ctx" -> Some Ctx
262 | "darray" when not only_reserved -> Some Darray
263 | "default" -> Some Default
264 | "dict" when not only_reserved -> Some Dict
265 | "do" -> Some Do
266 | "double" when not only_reserved -> Some Double
267 | "echo" -> Some Echo
268 | "else" -> Some Else
269 | "empty" -> Some Empty
270 | "endif" -> Some Endif
271 | "enum" when not only_reserved -> Some Enum
272 | "eval" -> Some Eval
273 | "exports" when not only_reserved -> Some Exports
274 | "extends" -> Some Extends
275 | "fallthrough" when not only_reserved -> Some Fallthrough
276 | "float" when not only_reserved -> Some Float
277 | "file" when not only_reserved -> Some File
278 | "final" -> Some Final
279 | "finally" -> Some Finally
280 | "for" -> Some For
281 | "foreach" -> Some Foreach
282 | "function" -> Some Function
283 | "global" -> Some Global
284 | "if" -> Some If
285 | "implements" -> Some Implements
286 | "imports" when not only_reserved -> Some Imports
287 | "include" -> Some Include
288 | "include_once" -> Some Include_once
289 | "inout" -> Some Inout
290 | "instanceof" -> Some Instanceof
291 | "insteadof" -> Some Insteadof
292 | "int" when not only_reserved -> Some Int
293 | "integer" when not only_reserved -> Some Integer
294 | "interface" -> Some Interface
295 | "is" when not only_reserved -> Some Is
296 | "isset" -> Some Isset
297 | "keyset" when not only_reserved -> Some Keyset
298 | "lateinit" -> Some Lateinit
299 | "list" -> Some List
300 | "match" when not only_reserved -> Some Match
301 | "mixed" when not only_reserved -> Some Mixed
302 | "module" -> Some Module
303 | "nameof" -> Some Nameof
304 | "namespace" -> Some Namespace
305 | "new" -> Some New
306 | "newctx" when not only_reserved -> Some Newctx
307 | "newtype" when not only_reserved -> Some Newtype
308 | "noreturn" when not only_reserved -> Some Noreturn
309 | "num" when not only_reserved -> Some Num
310 | "parent" when not only_reserved -> Some Parent
311 | "print" -> Some Print
312 | "private" -> Some Private
313 | "protected" -> Some Protected
314 | "public" -> Some Public
315 | "real" when not only_reserved -> Some Real
316 | "reify" when not only_reserved -> Some Reify
317 | "require" -> Some Require
318 | "require_once" -> Some Require_once
319 | "required" -> Some Required
320 | "resource" when not only_reserved -> Some Resource
321 | "return" -> Some Return
322 | "self" when not only_reserved -> Some Self
323 | "shape" -> Some Shape
324 | "static" -> Some Static
325 | "string" when not only_reserved -> Some String
326 | "super" when not only_reserved -> Some Super
327 | "switch" -> Some Switch
328 | "this" when not only_reserved -> Some This
329 | "throw" -> Some Throw
330 | "trait" -> Some Trait
331 | "try" -> Some Try
332 | "tuple" -> Some Tuple
333 | "type" when not only_reserved -> Some Type
334 | "unset" -> Some Unset
335 | "upcast" when not only_reserved -> Some Upcast
336 | "use" -> Some Use
337 | "using" -> Some Using
338 | "var" -> Some Var
339 | "varray" when not only_reserved -> Some Varray
340 | "vec" when not only_reserved -> Some Vec
341 | "void" when not only_reserved -> Some Void
342 | "with" when not only_reserved -> Some With
343 | "where" when not only_reserved -> Some Where
344 | "while" -> Some While
345 | "yield" -> Some Yield
346 | "null" when not only_reserved -> Some NullLiteral
347 | "[" -> Some LeftBracket
348 | "]" -> Some RightBracket
349 | "(" -> Some LeftParen
350 | ")" -> Some RightParen
351 | "{" -> Some LeftBrace
352 | "}" -> Some RightBrace
353 | "." -> Some Dot
354 | "->" -> Some MinusGreaterThan
355 | "++" -> Some PlusPlus
356 | "--" -> Some MinusMinus
357 | "**" -> Some StarStar
358 | "*" -> Some Star
359 | "+" -> Some Plus
360 | "-" -> Some Minus
361 | "~" -> Some Tilde
362 | "!" -> Some Exclamation
363 | "$" -> Some Dollar
364 | "/" -> Some Slash
365 | "%" -> Some Percent
366 | "<=>" -> Some LessThanEqualGreaterThan
367 | "<<" -> Some LessThanLessThan
368 | ">>" -> Some GreaterThanGreaterThan
369 | "<" -> Some LessThan
370 | ">" -> Some GreaterThan
371 | "<=" -> Some LessThanEqual
372 | ">=" -> Some GreaterThanEqual
373 | "==" -> Some EqualEqual
374 | "===" -> Some EqualEqualEqual
375 | "!=" -> Some ExclamationEqual
376 | "!==" -> Some ExclamationEqualEqual
377 | "^" -> Some Carat
378 | "|" -> Some Bar
379 | "&" -> Some Ampersand
380 | "&&" -> Some AmpersandAmpersand
381 | "||" -> Some BarBar
382 | "?" -> Some Question
383 | "?as" -> Some QuestionAs
384 | "?:" -> Some QuestionColon
385 | "??" -> Some QuestionQuestion
386 | "??=" -> Some QuestionQuestionEqual
387 | ":" -> Some Colon
388 | ";" -> Some Semicolon
389 | "=" -> Some Equal
390 | "**=" -> Some StarStarEqual
391 | "*=" -> Some StarEqual
392 | "/=" -> Some SlashEqual
393 | "%=" -> Some PercentEqual
394 | "+=" -> Some PlusEqual
395 | "-=" -> Some MinusEqual
396 | ".=" -> Some DotEqual
397 | "<<=" -> Some LessThanLessThanEqual
398 | ">>=" -> Some GreaterThanGreaterThanEqual
399 | "&=" -> Some AmpersandEqual
400 | "^=" -> Some CaratEqual
401 | "|=" -> Some BarEqual
402 | "," -> Some Comma
403 | "@" -> Some At
404 | "::" -> Some ColonColon
405 | "=>" -> Some EqualGreaterThan
406 | "==>" -> Some EqualEqualGreaterThan
407 | "?->" -> Some QuestionMinusGreaterThan
408 | "..." -> Some DotDotDot
409 | "$$" -> Some DollarDollar
410 | "|>" -> Some BarGreaterThan
411 | "/>" -> Some SlashGreaterThan
412 | "</" -> Some LessThanSlash
413 | "<?" -> Some LessThanQuestion
414 | "`" -> Some Backtick
415 | "xhp" when not only_reserved -> Some XHP
416 | "#" -> Some Hash
417 | "readonly" -> Some Readonly
418 | "internal" when not only_reserved -> Some Internal
419 | "package" -> Some Package
420 | "let" when not only_reserved -> Some Let
421 | "optional" when not only_reserved -> Some Optional
422 | _ -> None
424 let to_string kind =
425 match kind with
426 (* No text tokens *)
427 | EndOfFile -> "end_of_file"
428 (* Given text tokens *)
429 | Abstract -> "abstract"
430 | Arraykey -> "arraykey"
431 | As -> "as"
432 | Async -> "async"
433 | Attribute -> "attribute"
434 | Await -> "await"
435 | Backslash -> "\\"
436 | Binary -> "binary"
437 | Bool -> "bool"
438 | Boolean -> "boolean"
439 | Break -> "break"
440 | Case -> "case"
441 | Catch -> "catch"
442 | Category -> "category"
443 | Children -> "children"
444 | Class -> "class"
445 | Classname -> "classname"
446 | Clone -> "clone"
447 | Concurrent -> "concurrent"
448 | Const -> "const"
449 | Construct -> "__construct"
450 | Continue -> "continue"
451 | Ctx -> "ctx"
452 | Darray -> "darray"
453 | Default -> "default"
454 | Dict -> "dict"
455 | Do -> "do"
456 | Double -> "double"
457 | Echo -> "echo"
458 | Else -> "else"
459 | Empty -> "empty"
460 | Endif -> "endif"
461 | Enum -> "enum"
462 | Eval -> "eval"
463 | Exports -> "exports"
464 | Extends -> "extends"
465 | Fallthrough -> "fallthrough"
466 | Float -> "float"
467 | File -> "file"
468 | Final -> "final"
469 | Finally -> "finally"
470 | For -> "for"
471 | Foreach -> "foreach"
472 | Function -> "function"
473 | Global -> "global"
474 | If -> "if"
475 | Implements -> "implements"
476 | Imports -> "imports"
477 | Include -> "include"
478 | Include_once -> "include_once"
479 | Inout -> "inout"
480 | Instanceof -> "instanceof"
481 | Insteadof -> "insteadof"
482 | Int -> "int"
483 | Integer -> "integer"
484 | Interface -> "interface"
485 | Is -> "is"
486 | Isset -> "isset"
487 | Keyset -> "keyset"
488 | Lateinit -> "lateinit"
489 | List -> "list"
490 | Match -> "match"
491 | Mixed -> "mixed"
492 | Module -> "module"
493 | Nameof -> "nameof"
494 | Namespace -> "namespace"
495 | New -> "new"
496 | Newctx -> "newctx"
497 | Newtype -> "newtype"
498 | Noreturn -> "noreturn"
499 | Num -> "num"
500 | Parent -> "parent"
501 | Print -> "print"
502 | Private -> "private"
503 | Protected -> "protected"
504 | Public -> "public"
505 | Real -> "real"
506 | Reify -> "reify"
507 | Require -> "require"
508 | Require_once -> "require_once"
509 | Required -> "required"
510 | Resource -> "resource"
511 | Return -> "return"
512 | Self -> "self"
513 | Shape -> "shape"
514 | Static -> "static"
515 | String -> "string"
516 | Super -> "super"
517 | Switch -> "switch"
518 | This -> "this"
519 | Throw -> "throw"
520 | Trait -> "trait"
521 | Try -> "try"
522 | Tuple -> "tuple"
523 | Type -> "type"
524 | Unset -> "unset"
525 | Upcast -> "upcast"
526 | Use -> "use"
527 | Using -> "using"
528 | Var -> "var"
529 | Varray -> "varray"
530 | Vec -> "vec"
531 | Void -> "void"
532 | With -> "with"
533 | Where -> "where"
534 | While -> "while"
535 | Yield -> "yield"
536 | NullLiteral -> "null"
537 | LeftBracket -> "["
538 | RightBracket -> "]"
539 | LeftParen -> "("
540 | RightParen -> ")"
541 | LeftBrace -> "{"
542 | RightBrace -> "}"
543 | Dot -> "."
544 | MinusGreaterThan -> "->"
545 | PlusPlus -> "++"
546 | MinusMinus -> "--"
547 | StarStar -> "**"
548 | Star -> "*"
549 | Plus -> "+"
550 | Minus -> "-"
551 | Tilde -> "~"
552 | Exclamation -> "!"
553 | Dollar -> "$"
554 | Slash -> "/"
555 | Percent -> "%"
556 | LessThanEqualGreaterThan -> "<=>"
557 | LessThanLessThan -> "<<"
558 | GreaterThanGreaterThan -> ">>"
559 | LessThan -> "<"
560 | GreaterThan -> ">"
561 | LessThanEqual -> "<="
562 | GreaterThanEqual -> ">="
563 | EqualEqual -> "=="
564 | EqualEqualEqual -> "==="
565 | ExclamationEqual -> "!="
566 | ExclamationEqualEqual -> "!=="
567 | Carat -> "^"
568 | Bar -> "|"
569 | Ampersand -> "&"
570 | AmpersandAmpersand -> "&&"
571 | BarBar -> "||"
572 | Question -> "?"
573 | QuestionAs -> "?as"
574 | QuestionColon -> "?:"
575 | QuestionQuestion -> "??"
576 | QuestionQuestionEqual -> "??="
577 | Colon -> ":"
578 | Semicolon -> ";"
579 | Equal -> "="
580 | StarStarEqual -> "**="
581 | StarEqual -> "*="
582 | SlashEqual -> "/="
583 | PercentEqual -> "%="
584 | PlusEqual -> "+="
585 | MinusEqual -> "-="
586 | DotEqual -> ".="
587 | LessThanLessThanEqual -> "<<="
588 | GreaterThanGreaterThanEqual -> ">>="
589 | AmpersandEqual -> "&="
590 | CaratEqual -> "^="
591 | BarEqual -> "|="
592 | Comma -> ","
593 | At -> "@"
594 | ColonColon -> "::"
595 | EqualGreaterThan -> "=>"
596 | EqualEqualGreaterThan -> "==>"
597 | QuestionMinusGreaterThan -> "?->"
598 | DotDotDot -> "..."
599 | DollarDollar -> "$$"
600 | BarGreaterThan -> "|>"
601 | SlashGreaterThan -> "/>"
602 | LessThanSlash -> "</"
603 | LessThanQuestion -> "<?"
604 | Backtick -> "`"
605 | XHP -> "xhp"
606 | Hash -> "#"
607 | Readonly -> "readonly"
608 | Internal -> "internal"
609 | Package -> "package"
610 | Let -> "let"
611 | Optional -> "optional"
612 (* Variable text tokens *)
613 | ErrorToken -> "error_token"
614 | Name -> "name"
615 | Variable -> "variable"
616 | DecimalLiteral -> "decimal_literal"
617 | OctalLiteral -> "octal_literal"
618 | HexadecimalLiteral -> "hexadecimal_literal"
619 | BinaryLiteral -> "binary_literal"
620 | FloatingLiteral -> "floating_literal"
621 | SingleQuotedStringLiteral -> "single_quoted_string_literal"
622 | DoubleQuotedStringLiteral -> "double_quoted_string_literal"
623 | DoubleQuotedStringLiteralHead -> "double_quoted_string_literal_head"
624 | StringLiteralBody -> "string_literal_body"
625 | DoubleQuotedStringLiteralTail -> "double_quoted_string_literal_tail"
626 | HeredocStringLiteral -> "heredoc_string_literal"
627 | HeredocStringLiteralHead -> "heredoc_string_literal_head"
628 | HeredocStringLiteralTail -> "heredoc_string_literal_tail"
629 | NowdocStringLiteral -> "nowdoc_string_literal"
630 | BooleanLiteral -> "boolean_literal"
631 | XHPCategoryName -> "XHP_category_name"
632 | XHPElementName -> "XHP_element_name"
633 | XHPClassName -> "XHP_class_name"
634 | XHPStringLiteral -> "XHP_string_literal"
635 | XHPBody -> "XHP_body"
636 | XHPComment -> "XHP_comment"
637 | Hashbang -> "hashbang"
639 let is_variable_text kind =
640 match kind with
641 | ErrorToken -> true
642 | Name -> true
643 | Variable -> true
644 | DecimalLiteral -> true
645 | OctalLiteral -> true
646 | HexadecimalLiteral -> true
647 | BinaryLiteral -> true
648 | FloatingLiteral -> true
649 | SingleQuotedStringLiteral -> true
650 | DoubleQuotedStringLiteral -> true
651 | DoubleQuotedStringLiteralHead -> true
652 | StringLiteralBody -> true
653 | DoubleQuotedStringLiteralTail -> true
654 | HeredocStringLiteral -> true
655 | HeredocStringLiteralHead -> true
656 | HeredocStringLiteralTail -> true
657 | NowdocStringLiteral -> true
658 | BooleanLiteral -> true
659 | XHPCategoryName -> true
660 | XHPElementName -> true
661 | XHPClassName -> true
662 | XHPStringLiteral -> true
663 | XHPBody -> true
664 | XHPComment -> true
665 | Hashbang -> true
666 | _ -> false