xref: /OpenGrok/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/javascript/Consts.java (revision 0e4c55544f8ea0a68e8bae37b0e502097e008ec1)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * See LICENSE.txt included in this distribution for the specific
9  * language governing permissions and limitations under the License.
10  *
11  * When distributing Covered Code, include this CDDL HEADER in each
12  * file and include the License file at LICENSE.txt.
13  * If applicable, add the following below this CDDL HEADER, with the
14  * fields enclosed by brackets "[]" replaced with your own identifying
15  * information: Portions Copyright [yyyy] [name of copyright owner]
16  *
17  * CDDL HEADER END
18  */
19 
20 /*
21  * Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
22  * Portions Copyright (c) 2019, Chris Fraire <cfraire@me.com>.
23  */
24 package org.opengrok.indexer.analysis.javascript;
25 
26 import java.util.Collections;
27 import java.util.HashSet;
28 import java.util.Set;
29 
30 /**
31  * Holds JavaScript keywords from ECMA-262 10th Edition, June 2019.
32  */
33 public class Consts {
34 
35     private static final Set<String> kwd = new HashSet<>();
36 
37     public static final Set<String> KEYWORDS = Collections.unmodifiableSet(kwd);
38 
39     static {
40         // literals
41         kwd.add("true");
42         kwd.add("false");
43         kwd.add("null");
44         //builtins
45         kwd.add("Array");
46         kwd.add("Boolean");
47         kwd.add("Date");
48         kwd.add("Function");
49         kwd.add("Infinity"); // ECMA-262, 10th edition, June 2019
50         kwd.add("Math");
51         kwd.add("Number");
52         kwd.add("Object");
53         kwd.add("RegExp");
54         kwd.add("String");
55         //keywords
56         kwd.add("await"); // ECMA-262, 10th edition, June 2019
57         kwd.add("break");
58         kwd.add("case");
59         kwd.add("catch");
60         kwd.add("class");
61         kwd.add("const");
62         kwd.add("continue");
63         kwd.add("debugger");
64         kwd.add("default");
65         kwd.add("delete");
66         kwd.add("do");
67         kwd.add("else");
68         kwd.add("export");
69         kwd.add("extends");
70         kwd.add("finally");
71         kwd.add("for");
72         kwd.add("function");
73         kwd.add("if");
74         kwd.add("in");
75         kwd.add("instanceof");
76         kwd.add("import");
77         kwd.add("new");
78         kwd.add("return");
79         kwd.add("super");
80         kwd.add("switch");
81         kwd.add("this");
82         kwd.add("throw");
83         kwd.add("try");
84         kwd.add("typeof");
85         kwd.add("var");
86         kwd.add("void");
87         kwd.add("while");
88         kwd.add("with");
89         kwd.add("yield");
90         //future reserved
91         kwd.add("enum");
92         //strict future reserved
93         kwd.add("implements");
94         kwd.add("interface");
95         kwd.add("let");
96         kwd.add("package");
97         kwd.add("private");
98         kwd.add("protected");
99         kwd.add("public");
100         kwd.add("static");
101     }
102 
Consts()103     protected Consts() {
104     }
105 }
106