1 /** 2 * @file token_enum.h 3 * List of the different tokens used in the program. 4 * 5 * @author Ben Gardner 6 * @author Guy Maurel since version 0.62 for uncrustify4Qt 7 * October 2015 8 * @license GPL v2+ 9 */ 10 11 #ifndef TOKEN_ENUM_H_INCLUDED 12 #define TOKEN_ENUM_H_INCLUDED 13 14 /** 15 * abbreviations used: 16 * CT = chunk type 17 */ 18 19 20 /** 21 * This is an enum of all the different chunks/tokens/elements that the 22 * program can work with. The parser and scanner assigns one of these to 23 * each chunk/token. 24 */ 25 enum c_token_t 26 { 27 CT_NONE, 28 CT_PARENT_NOT_SET, 29 CT_EOF, 30 CT_UNKNOWN, 31 32 CT_JUNK, // junk collected when parsing is disabled 33 34 CT_WHITESPACE, // whitespace without any newlines 35 CT_SPACE, // a fixed number of spaces to support weird spacing rules 36 CT_NEWLINE, // CRA, one or more newlines 37 CT_NL_CONT, // CRA, backslash-newline 38 CT_FORM_FEED, // character 12 39 CT_COMMENT_CPP, // C++ comment (always followed by CT_NEWLINE) 40 CT_COMMENT, // C-comment, single line 41 CT_COMMENT_MULTI, // Multi-lined comment 42 CT_COMMENT_EMBED, // comment parent_type: non-newline before and after 43 CT_COMMENT_START, // comment parent_type: newline before 44 CT_COMMENT_END, // comment parent_type: newline after 45 CT_COMMENT_WHOLE, // comment parent_type: newline before and after 46 CT_COMMENT_ENDIF, // C-comment, single line, after ENDIF 47 48 CT_IGNORED, // a chunk of ignored text 49 50 CT_WORD, // variable, type, function name, etc 51 CT_NUMBER, 52 CT_NUMBER_FP, 53 CT_STRING, // quoted string "hi" or 'a' or <in> for include 54 CT_STRING_MULTI, // quoted string with embedded newline 55 CT_IF, // built-in keywords 56 CT_ELSE, 57 CT_ELSEIF, 58 CT_CONSTEXPR, // only when preceded by 'if' (otherwise CT_QUALIFIER) 59 CT_FOR, 60 CT_WHILE, 61 CT_WHILE_OF_DO, 62 CT_SWITCH, 63 CT_CASE, 64 CT_DO, 65 CT_SYNCHRONIZED, 66 CT_VOLATILE, 67 CT_TYPEDEF, 68 CT_STRUCT, 69 CT_ENUM, 70 CT_ENUM_CLASS, 71 CT_SIZEOF, 72 CT_DECLTYPE, 73 CT_RETURN, 74 CT_BREAK, 75 CT_UNION, 76 CT_GOTO, 77 CT_CONTINUE, 78 CT_C_CAST, // C-style cast: "(int)5.6" 79 CT_CPP_CAST, // C++-style cast: "int(5.6)" 80 CT_D_CAST, // D-style cast: "cast(type)" and "const(type)" 81 CT_TYPE_CAST, // static_cast<type>(exp) 82 CT_TYPENAME, // typename type 83 CT_TEMPLATE, // template<...> 84 CT_PARAMETER_PACK, // template<typename ... ARGS> 85 CT_WHERE_SPEC, // 'where' : used in C# generic constraint 86 87 CT_ASSIGN, // =, +=, /=, etc 88 CT_ASSIGN_NL, // Assign followed by a newline - fake item for indenting 89 CT_SASSIGN, // 'and_eq' 90 91 CT_ASSIGN_DEFAULT_ARG, // Default argument such as 92 // Foo( int Foo = 5 ); 93 CT_ASSIGN_FUNC_PROTO, // function prototype modifier such as 94 // void* operator new(std::size_t) = delete; 95 // Foo( const Foo & ) = default; 96 // Foo( const Foo & ) = 0; 97 98 CT_COMPARE, // ==, !=, <=, >= 99 CT_SCOMPARE, // compare op that is a string 'is', 'neq' 100 CT_BOOL, // || or && 101 CT_SBOOL, // or, and 102 CT_ARITH, // +, -, /, etc 103 CT_SARITH, // 'not', 'xor' 104 CT_SHIFT, // <<, >> 105 CT_CARET, // ^ 106 CT_DEREF, // * dereference 107 CT_INCDEC_BEFORE, // ++a or --a 108 CT_INCDEC_AFTER, // a++ or a-- 109 CT_MEMBER, // . or -> 110 CT_DC_MEMBER, // :: 111 CT_C99_MEMBER, // . in structure stuff 112 CT_INV, // ~ 113 CT_DESTRUCTOR, // ~ 114 CT_NOT, // ! 115 CT_D_TEMPLATE, // ! as in Foo!(A) 116 CT_ADDR, // & 117 CT_NEG, // - as in -1 118 CT_POS, // + as in +1 119 CT_STAR, // * : raw char to be changed 120 CT_PLUS, // + : raw char to be changed 121 CT_MINUS, // - : raw char to be changed 122 CT_AMP, // & : raw char to be changed 123 CT_BYREF, // & in function def/proto params 124 125 // CT_BITWISE_AND, // & // is a CT_ARITH 126 // CT_BITWISE_OR, // | // is a CT_ARITH 127 // CT_BITWISE_EXCLUSIVE_OR,// ^ // is a CT_ARITH 128 // CT_BITWISE_NOT, // ~ // is a CT_ARITH 129 130 CT_POUND, // # 131 CT_PREPROC, // # at the start of a line 132 CT_PREPROC_INDENT, // # at the start of a line that gets indented: #region 133 CT_PREPROC_BODY, // body of every preproc EXCEPT #define 134 CT_PP, // ## 135 CT_ELLIPSIS, // ... 136 CT_RANGE, // .. 137 CT_NULLCOND, // ?. 138 139 CT_SEMICOLON, 140 CT_VSEMICOLON, // virtual semicolon for PAWN 141 CT_COLON, 142 CT_ASM_COLON, 143 CT_CASE_COLON, 144 CT_CASE_ELLIPSIS, // '...' in `case 1 ... 5`: 145 CT_CLASS_COLON, // colon after a class def 146 CT_CONSTR_COLON, // colon after a constructor 147 CT_D_ARRAY_COLON, // D named array initializer colon 148 CT_COND_COLON, // conditional colon in 'b ? t : f' 149 CT_WHERE_COLON, // C# where-constraint colon (after the type) 150 CT_QUESTION, 151 CT_COMMA, 152 153 CT_ASM, 154 CT_ATTRIBUTE, 155 CT_AUTORELEASEPOOL, // OC: Autorelease Pool Blocks, used by iOS 156 CT_OC_AVAILABLE, 157 CT_OC_AVAILABLE_VALUE, 158 CT_CATCH, 159 CT_WHEN, 160 CT_WHERE, // C# where clause 161 CT_CLASS, 162 CT_DELETE, 163 CT_EXPORT, 164 CT_FRIEND, 165 CT_NAMESPACE, 166 CT_PACKAGE, 167 CT_NEW, // may turn into CT_PBRACED if followed by a '(' 168 CT_OPERATOR, 169 CT_OPERATOR_VAL, 170 CT_ASSIGN_OPERATOR, // the value after 'operator' such as: 171 // Foo &operator= ( const Foo & ); 172 CT_ACCESS, 173 CT_ACCESS_COLON, 174 CT_THROW, 175 CT_NOEXCEPT, 176 CT_TRY, 177 CT_BRACED_INIT_LIST, 178 CT_USING, 179 CT_USING_STMT, // using (xxx) ... 180 CT_USING_ALIAS, // using identifier attr(optional) = type-id 181 CT_D_WITH, // D: parenthetis+braced 182 CT_D_MODULE, 183 CT_SUPER, 184 CT_DELEGATE, 185 CT_BODY, 186 CT_DEBUG, 187 CT_DEBUGGER, 188 CT_INVARIANT, 189 CT_UNITTEST, 190 CT_UNSAFE, 191 CT_FINALLY, 192 CT_FIXED, // C# fixed 193 CT_IMPORT, 194 CT_D_SCOPE, 195 CT_D_SCOPE_IF, 196 CT_LAZY, 197 CT_D_MACRO, 198 CT_D_VERSION, // turns into CT_D_VERSION_IF if not followed by '=' 199 CT_D_VERSION_IF, // version(x) { } 200 201 // note for parenthetis/brace/square pairs: close MUST be open + 1 202 CT_PAREN_OPEN, 203 CT_PAREN_CLOSE, 204 205 CT_ANGLE_OPEN, // template<T*> 206 CT_ANGLE_CLOSE, 207 208 CT_SPAREN_OPEN, // 'special' parenthetis after if/for/switch/while/synchronized/catch 209 CT_SPAREN_CLOSE, 210 211 CT_PPAREN_OPEN, // 'protect' parenthetis to protect a type such as (*int) 212 CT_PPAREN_CLOSE, // used at align_func_param 213 214 CT_FPAREN_OPEN, // 'function' parenthetis after fcn/macro fcn 215 CT_FPAREN_CLOSE, 216 217 CT_LPAREN_OPEN, // lambda-declarator parenthetis 218 CT_LPAREN_CLOSE, 219 220 CT_TPAREN_OPEN, // 'type' parenthetis used in function types 221 CT_TPAREN_CLOSE, 222 223 CT_BRACE_OPEN, // {...} 224 CT_BRACE_CLOSE, 225 226 CT_VBRACE_OPEN, // virtual brace, i.e. brace inserted by uncrustify 227 CT_VBRACE_CLOSE, 228 229 CT_SQUARE_OPEN, // [...] 230 CT_SQUARE_CLOSE, 231 232 CT_TSQUARE, // special case of [] 233 234 CT_MACRO_OPEN, // stuff specified via custom-pair 235 CT_MACRO_CLOSE, 236 CT_MACRO_ELSE, 237 238 // aggregate types 239 CT_LABEL, // a non-case label 240 CT_LABEL_COLON, // the colon for a label 241 CT_FUNCTION, // function - unspecified, call mark_function() 242 CT_FUNC_CALL, // function call 243 CT_FUNC_CALL_USER, // function call (special user) 244 CT_FUNC_DEF, // function definition/implementation 245 CT_FUNC_TYPE, // function type - foo in "typedef void (*foo)(void)" 246 CT_FUNC_VAR, // foo and parent type of first parens in "void (*foo)(void)" 247 CT_FUNC_PROTO, // function prototype 248 CT_FUNC_START, // global DC member for functions(void ::func()) 249 CT_FUNC_CLASS_DEF, // ctor or dtor for a class 250 CT_FUNC_CLASS_PROTO, // ctor or dtor for a class 251 CT_FUNC_CTOR_VAR, // variable or class initialization 252 CT_FUNC_WRAP, // macro that wraps the function name 253 CT_PROTO_WRAP, // macro: "RETVAL PROTO_WRAP( fcn_name, (PARAMS))". Parens for PARAMS are optional. 254 CT_MACRO_FUNC, // function-like macro 255 CT_MACRO_FUNC_CALL, // function-like macro call 256 CT_MACRO, // a macro def 257 CT_QUALIFIER, // static, const, etc 258 CT_EXTERN, // extern 259 CT_DECLSPEC, // __declspec 260 CT_ALIGN, // paren'd qualifier: align(4) struct a { } 261 CT_TYPE, 262 CT_PTR_TYPE, // a '*' as part of a type 263 CT_TYPE_WRAP, // macro that wraps a type name 264 CT_CPP_LAMBDA, // parent for '[=](...){...}' 265 CT_CPP_LAMBDA_RET, // '->' in '[=](...) -> type {...}' 266 CT_EXECUTION_CONTEXT, // Keyword for use in lambda statement: [] CT_EXECUTION_CONTEXT ()->{} 267 CT_TRAILING_RET, // '->' in 'auto fname(...) -> type;' 268 // '->' in 'auto fname(...) const -> type;' 269 CT_BIT_COLON, // a ':' in a variable declaration 270 271 CT_OC_DYNAMIC, 272 CT_OC_END, // ObjC: @end 273 CT_OC_IMPL, // ObjC: @implementation 274 CT_OC_INTF, // ObjC: @interface 275 CT_OC_PROTOCOL, // ObjC: @protocol or @protocol() 276 CT_OC_PROTO_LIST, // ObjC: protocol list < > (parent token only) 277 CT_OC_GENERIC_SPEC, // ObjC: specification of generic < > 278 CT_OC_PROPERTY, // ObjC: @property 279 CT_OC_CLASS, // ObjC: the name after @interface or @implementation 280 CT_OC_CLASS_EXT, // ObjC: a pair of empty parens after the class name in a @interface or @implementation 281 CT_OC_CATEGORY, // ObjC: the category name in parens after the class name in a @interface or @implementation 282 CT_OC_SCOPE, // ObjC: the '-' or '+' in '-(void) func: (int) i;' 283 CT_OC_MSG, // ObjC: parent type to '[', ']' and ';' in '[class func : param name: param];' 284 CT_OC_MSG_CLASS, // ObjC: 'class' in '[class func : param name: param];' (see also PCF_IN_OC_MSG) 285 CT_OC_MSG_FUNC, // ObjC: 'func' in '[class func : param name: param];' (see also PCF_IN_OC_MSG) 286 CT_OC_MSG_NAME, // ObjC: 'name' in '[class func : param name: param];' (see also PCF_IN_OC_MSG) 287 CT_OC_MSG_SPEC, // ObjC: msg spec '-(void) func: (int) i;' 288 CT_OC_MSG_DECL, // ObjC: msg decl '-(void) func: (int) i { }' 289 CT_OC_RTYPE, // ObjC: marks parens of the return type after scope 290 CT_OC_ATYPE, // ObjC: marks parens of the arg type after scope 291 CT_OC_COLON, // ObjC: the colon in a msg spec 292 CT_OC_DICT_COLON, // ObjC: colon in dictionary constant: "KEY: VALUE" 293 CT_OC_SEL, // ObjC: @selector 294 CT_OC_SEL_NAME, // ObjC: selector name 295 CT_OC_BLOCK, // ObjC: block parent type. 296 CT_OC_BLOCK_ARG, // ObjC: block arguments parent type. 297 CT_OC_BLOCK_TYPE, // ObjC: block declaration parent type, e.g. mainly the '(^block_t)' in 'void (^block_t)(int arg);' 298 CT_OC_BLOCK_EXPR, // ObjC: block expression with arg: '^(int arg) { arg++; };' and without (called a block literal): '^{ ... };' 299 CT_OC_BLOCK_CARET, // ObjC: block pointer caret: '^' 300 CT_OC_AT, // ObjC: boxed constants using '@' 301 CT_OC_PROPERTY_ATTR, // ObjC: property attribute (strong, weak, readonly, etc...) 302 303 // start PP types 304 CT_PP_DEFINE, // #define 305 CT_PP_DEFINED, // #if defined 306 CT_PP_INCLUDE, // #include 307 CT_PP_IF, // #if, #ifdef, or #ifndef 308 CT_PP_ELSE, // #else or #elif 309 CT_PP_ENDIF, // #endif 310 CT_PP_ASSERT, 311 CT_PP_EMIT, 312 CT_PP_ENDINPUT, 313 CT_PP_ERROR, 314 CT_PP_FILE, 315 CT_PP_LINE, 316 CT_PP_SECTION, 317 CT_PP_ASM, // start of assembly code section 318 CT_PP_UNDEF, 319 CT_PP_PROPERTY, 320 321 CT_PP_BODYCHUNK, // everything after this gets put in CT_PREPROC_BODY 322 323 CT_PP_PRAGMA, // pragma's should not be altered 324 CT_PP_REGION, // C# #region 325 CT_PP_ENDREGION, // C# #endregion 326 CT_PP_REGION_INDENT, // Dummy token for indenting a C# #region 327 CT_PP_IF_INDENT, // Dummy token for indenting a #if stuff 328 CT_PP_IGNORE, // Dummy token for ignoring a certain preprocessor directive (do not do any processing) 329 CT_PP_OTHER, // #line, #error, #pragma, etc 330 // end PP types 331 332 // PAWN stuff 333 CT_CHAR, 334 CT_DEFINED, 335 CT_FORWARD, 336 CT_NATIVE, 337 CT_STATE, 338 CT_STOCK, 339 CT_TAGOF, 340 CT_DOT, 341 CT_TAG, 342 CT_TAG_COLON, 343 344 // C-sharp 345 CT_LOCK, // lock/unlock 346 CT_AS, 347 CT_IN, // "foreach (T c in x)" or "foo(in char c)" or "in { ..." 348 CT_BRACED, // simple braced items: try {} 349 CT_THIS, // may turn into CT_PBRACED if followed by a '(' 350 CT_BASE, // C# thingy 351 CT_DEFAULT, // may be changed into CT_CASE 352 CT_GETSET, // must be followed by CT_BRACE_OPEN or reverts to CT_WORD 353 CT_GETSET_EMPTY, // get/set/add/remove followed by a semicolon 354 CT_CONCAT, // The '~' between strings 355 CT_CS_SQ_STMT, // '[assembly: xxx]' or '[Attribute()]' or '[Help()]', etc 356 CT_CS_SQ_COLON, // the colon in one of those [] thingys 357 CT_CS_PROPERTY, // word or ']' followed by '{' 358 359 // Embedded SQL - always terminated with a semicolon 360 CT_SQL_EXEC, // the 'EXEC' in 'EXEC SQL ...' 361 CT_SQL_BEGIN, // the 'BEGINN' in 'EXEC SQL BEGIN ...' 362 CT_SQL_END, // the 'END' in 'EXEC SQL END ...' 363 CT_SQL_WORD, // CT_WORDs in the 'EXEC SQL' statement 364 CT_SQL_ASSIGN, // := 365 366 // Vala stuff 367 CT_CONSTRUCT, // braced "construct { }" or qualifier "(construct int x)" 368 CT_LAMBDA, 369 370 // Java 371 CT_ASSERT, // assert EXP1 [ : EXP2 ] ; 372 CT_ANNOTATION, // @interface or @something(...) 373 CT_FOR_COLON, // colon in "for ( TYPE var: EXPR ) { ... }" 374 CT_DOUBLE_BRACE, // parent for double brace 375 376 /* Clang */ 377 CT_CNG_HASINC, // Clang: __has_include() 378 CT_CNG_HASINCN, // Clang: __has_include_next() 379 380 // extensions for Qt macros 381 CT_Q_EMIT, // guy 2015-10-16 382 CT_Q_FOREACH, // guy 2015-09-23 383 CT_Q_FOREVER, // guy 2015-10-18 384 CT_Q_GADGET, // guy 2016-05-04 385 CT_Q_OBJECT, // guy 2015-10-16 386 387 // Machine Modes 388 CT_MODE, // guy 2016-03-11 389 CT_DI, // guy 2016-03-11 390 CT_HI, // guy 2016-03-11 391 CT_QI, // guy 2016-03-11 392 CT_SI, // guy 2016-03-11 393 CT_NOTHROW, // guy 2016-03-11 394 CT_WORD_, // guy 2016-03-11 395 396 CT_TOKEN_COUNT_ // NOTE: Keep this the last entry because it's used as a counter. 397 }; 398 399 #endif /* TOKEN_ENUM_H_INCLUDED */ 400