Page Speed Optimization Libraries  1.3.25.1
net/instaweb/js/public/js_keywords.h
Go to the documentation of this file.
00001 // Copyright 2011 Google Inc. All Rights Reserved.
00019 
00020 #ifndef NET_INSTAWEB_JS_PUBLIC_JS_KEYWORDS_H_
00021 #define NET_INSTAWEB_JS_PUBLIC_JS_KEYWORDS_H_
00022 
00023 #include "net/instaweb/util/public/string_util.h"
00024 
00025 namespace net_instaweb {
00026 
00027 class JsKeywords {
00028  public:
00029   enum Type {
00031     kNull,
00032     kTrue,
00033     kFalse,
00034 
00036     kBreak,
00037     kCase,
00038     kCatch,
00039     kConst,
00040     kDefault,
00041     kFinally,
00042     kFor,
00043     kInstanceof,
00044     kNew,
00045     kVar,
00046     kContinue,
00047     kFunction,
00048     kReturn,
00049     kVoid,
00050     kDelete,
00051     kIf,
00052     kThis,
00053     kDo,
00054     kWhile,
00055     kElse,
00056     kIn,
00057     kSwitch,
00058     kThrow,
00059     kTry,
00060     kTypeof,
00061     kWith,
00062     kDebugger,
00063 
00065     kClass,
00066     kEnum,
00067     kExport,
00068     kExtends,
00069     kImport,
00070     kSuper,
00071 
00073     kImplements,
00074     kInterface,
00075     kLet,
00076     kPackage,
00077     kPrivate,
00078     kProtected,
00079     kPublic,
00080     kStatic,
00081     kYield,
00082 
00084     kNotAKeyword,
00085 
00087     kComment,
00088     kWhitespace,
00089     kLineSeparator,
00090     kRegex,
00091     kStringLiteral,
00092     kNumber,
00093     kOperator,
00094     kIdentifier,
00095     kEndOfInput
00096   };
00097 
00098   static bool IsAKeyword(Type type) { return type < kNotAKeyword; }
00099 
00100   enum Flag {
00101     kNone,
00102     kIsValue,
00103     kIsReservedNonStrict,
00104     kIsReservedStrict
00105   };
00106 
00110   static Type Lookup(const StringPiece& name, Flag* flag);
00111 
00112  private:
00113   friend class JsLexer;
00114 
00119   class Iterator {
00120    public:
00121     Iterator() : index_(-1) { Next(); }
00122     bool AtEnd() const;
00123     void Next();
00124     Type keyword() const;
00125     const char* name() const;
00126 
00127    private:
00128     int index_;
00129 
00131   };
00132 
00136   static int num_keywords();
00137 };
00138 
00139 }  
00140 
00141 #endif  ///< NET_INSTAWEB_JS_PUBLIC_JS_KEYWORDS_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines