Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
js_keywords.h
Go to the documentation of this file.
1 // Copyright 2011 Google Inc. All Rights Reserved.
19 
20 #ifndef PAGESPEED_KERNEL_JS_JS_KEYWORDS_H_
21 #define PAGESPEED_KERNEL_JS_JS_KEYWORDS_H_
22 
24 
25 namespace net_instaweb {
26  class JsLexer;
27 }
28 
29 namespace pagespeed {
30 
31 class JsKeywords {
32  public:
33  enum Type {
36  kTrue,
37  kFalse,
38 
41  kCase,
42  kCatch,
43  kConst,
44  kDefault,
45  kFinally,
46  kFor,
47  kInstanceof,
48  kNew,
49  kVar,
50  kContinue,
51  kFunction,
52  kReturn,
53  kVoid,
54  kDelete,
55  kIf,
56  kThis,
57  kDo,
58  kWhile,
59  kElse,
60  kIn,
61  kSwitch,
62  kThrow,
63  kTry,
64  kTypeof,
65  kWith,
66  kDebugger,
67 
70  kEnum,
71  kExport,
72  kExtends,
73  kImport,
74  kSuper,
75 
78  kInterface,
79  kLet,
80  kPackage,
81  kPrivate,
82  kProtected,
83  kPublic,
84  kStatic,
85  kYield,
86 
89 
102  };
103 
104  static bool IsAKeyword(Type type) { return type < kNotAKeyword; }
105 
109  static bool CanKeywordPrecedeRegEx(const StringPiece& name);
110 
111  enum Flag {
112  kNone,
113  kIsValue,
114  kIsReservedNonStrict,
115  kIsReservedStrict,
117  };
118 
122  static Type Lookup(const StringPiece& name, Flag* flag);
123 
128  class Iterator {
129  public:
130  Iterator() : index_(-1) { Next(); }
131  bool AtEnd() const;
132  void Next();
133  Type keyword() const;
134  const char* name() const;
135 
136  private:
137  int index_;
138 
140  };
141 
142  private:
145  friend class net_instaweb::JsLexer;
146 
150  static int num_keywords();
151 };
152 
153 }
154 
155 #endif
friend class net_instaweb::JsLexer
Definition: js_keywords.h:145
A regex literal, such as /foo/i or /a+b*/.
Definition: js_keywords.h:95
keywords that can be placed directly before a regex
Definition: js_keywords.h:116
Whitespace that triggers semicolon insertion.
Definition: js_keywords.h:94
keywords
Definition: js_keywords.h:40
An identifier (variable name, label, etc).
Definition: js_keywords.h:99
Flag
Definition: js_keywords.h:111
Type
Definition: js_keywords.h:33
Other types of lexical tokens; returned by lexer, but not gperf.
Definition: js_keywords.h:91
Sentinel value for gperf.
Definition: js_keywords.h:88
literals
Definition: js_keywords.h:35
reserved for future use
Definition: js_keywords.h:69
An operator or symbol, such as && or <<= or (.
Definition: js_keywords.h:98
static Type Lookup(const StringPiece &name, Flag *flag)
A string literal, such as 'foo' or "bar".
Definition: js_keywords.h:96
A numeric literal, such as 3.5 or 017 or .2e+10.
Definition: js_keywords.h:97
Definition: js_keywords.h:128
Definition: js_keywords.h:31
Whitespace with linebreaks, but no semicolon insertion.
Definition: js_keywords.h:93
static bool CanKeywordPrecedeRegEx(const StringPiece &name)
Whitespace not containing any linebreaks.
Definition: js_keywords.h:92
End of input was reached without errors.
Definition: js_keywords.h:100
A syntax error occurred.
Definition: js_keywords.h:101
reserved for future use in strict code
Definition: js_keywords.h:77