1/*============================================================================= 2 Boost.Wave: A Standard compliant C++ preprocessor library 3 4 Copyright (c) 2001 Daniel C. Nuffer 5 Copyright (c) 2001-2013 Hartmut Kaiser. 6 Distributed under the Boost Software License, Version 1.0. (See accompanying 7 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 9 This is a lexer conforming to the Standard with a few exceptions. 10 So it does allow the '$' to be part of identifiers. If you need strict 11 Standards conforming behaviour, please include the lexer definition 12 provided in the file strict_cpp.re. 13 14 TODO: 15 handle errors better. 16=============================================================================*/ 17 18/*!re2c 19re2c:indent:string = " "; 20any = [\t\v\f\r\n\040-\377]; 21anyctrl = [\001-\037]; 22OctalDigit = [0-7]; 23Digit = [0-9]; 24HexDigit = [a-fA-F0-9]; 25Integer = (("0" [xX] HexDigit+) | ("0" OctalDigit*) | ([1-9] Digit*)); 26ExponentStart = [Ee] [+-]; 27ExponentPart = [Ee] [+-]? Digit+; 28FractionalConstant = (Digit* "." Digit+) | (Digit+ "."); 29FloatingSuffix = [fF] [lL]? | [lL] [fF]?; 30IntegerSuffix = [uU] [lL]? | [lL] [uU]?; 31LongIntegerSuffix = [uU] ("ll" | "LL") | ("ll" | "LL") [uU]?; 32MSLongIntegerSuffix = "u"? "i64"; 33Backslash = [\\] | "??/"; 34EscapeSequence = Backslash ([abfnrtv?'"] | Backslash | "x" HexDigit+ | OctalDigit OctalDigit? OctalDigit?); 35HexQuad = HexDigit HexDigit HexDigit HexDigit; 36UniversalChar = Backslash ("u" HexQuad | "U" HexQuad HexQuad); 37Newline = "\r\n" | "\n" | "\r"; 38PPSpace = ([ \t\f\v]|("/*"(any\[*]|Newline|("*"+(any\[*/]|Newline)))*"*"+"/"))*; 39Pound = "#" | "??=" | "%:"; 40NonDigit = [a-zA-Z_$] | UniversalChar; 41*/ 42 43/*!re2c 44 "/*" { goto ccomment; } 45 "//" { goto cppcomment; } 46 "."? Digit { goto pp_number; } 47 48 "alignas" { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_ALIGNAS : T_IDENTIFIER); } 49 "alignof" { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_ALIGNOF : T_IDENTIFIER); } 50 "asm" { BOOST_WAVE_RET(T_ASM); } 51 "auto" { BOOST_WAVE_RET(T_AUTO); } 52 "bool" { BOOST_WAVE_RET(T_BOOL); } 53 "break" { BOOST_WAVE_RET(T_BREAK); } 54 "case" { BOOST_WAVE_RET(T_CASE); } 55 "catch" { BOOST_WAVE_RET(T_CATCH); } 56 "char" { BOOST_WAVE_RET(T_CHAR); } 57 "char16_t" { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_CHAR16_T : T_IDENTIFIER); } 58 "char32_t" { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_CHAR32_T : T_IDENTIFIER); } 59 "class" { BOOST_WAVE_RET(T_CLASS); } 60 "const" { BOOST_WAVE_RET(T_CONST); } 61 "constexpr" { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_CONSTEXPR : T_IDENTIFIER); } 62 "const_cast" { BOOST_WAVE_RET(T_CONSTCAST); } 63 "continue" { BOOST_WAVE_RET(T_CONTINUE); } 64 "decltype" { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_DECLTYPE : T_IDENTIFIER); } 65 "default" { BOOST_WAVE_RET(T_DEFAULT); } 66 "delete" { BOOST_WAVE_RET(T_DELETE); } 67 "do" { BOOST_WAVE_RET(T_DO); } 68 "double" { BOOST_WAVE_RET(T_DOUBLE); } 69 "dynamic_cast" { BOOST_WAVE_RET(T_DYNAMICCAST); } 70 "else" { BOOST_WAVE_RET(T_ELSE); } 71 "enum" { BOOST_WAVE_RET(T_ENUM); } 72 "explicit" { BOOST_WAVE_RET(T_EXPLICIT); } 73 "export" { BOOST_WAVE_RET(T_EXPORT); } 74 "extern" { BOOST_WAVE_RET(T_EXTERN); } 75 "false" { BOOST_WAVE_RET(T_FALSE); } 76 "float" { BOOST_WAVE_RET(T_FLOAT); } 77 "for" { BOOST_WAVE_RET(T_FOR); } 78 "friend" { BOOST_WAVE_RET(T_FRIEND); } 79 "goto" { BOOST_WAVE_RET(T_GOTO); } 80 "if" { BOOST_WAVE_RET(T_IF); } 81 "import" { BOOST_WAVE_RET(s->enable_import_keyword ? T_IMPORT : T_IDENTIFIER); } 82 "inline" { BOOST_WAVE_RET(T_INLINE); } 83 "int" { BOOST_WAVE_RET(T_INT); } 84 "long" { BOOST_WAVE_RET(T_LONG); } 85 "mutable" { BOOST_WAVE_RET(T_MUTABLE); } 86 "namespace" { BOOST_WAVE_RET(T_NAMESPACE); } 87 "new" { BOOST_WAVE_RET(T_NEW); } 88 "noexcept" { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_NOEXCEPT : T_IDENTIFIER); } 89 "nullptr" { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_NULLPTR : T_IDENTIFIER); } 90 "operator" { BOOST_WAVE_RET(T_OPERATOR); } 91 "private" { BOOST_WAVE_RET(T_PRIVATE); } 92 "protected" { BOOST_WAVE_RET(T_PROTECTED); } 93 "public" { BOOST_WAVE_RET(T_PUBLIC); } 94 "register" { BOOST_WAVE_RET(T_REGISTER); } 95 "reinterpret_cast" { BOOST_WAVE_RET(T_REINTERPRETCAST); } 96 "return" { BOOST_WAVE_RET(T_RETURN); } 97 "short" { BOOST_WAVE_RET(T_SHORT); } 98 "signed" { BOOST_WAVE_RET(T_SIGNED); } 99 "sizeof" { BOOST_WAVE_RET(T_SIZEOF); } 100 "static" { BOOST_WAVE_RET(T_STATIC); } 101 "static_cast" { BOOST_WAVE_RET(T_STATICCAST); } 102 "static_assert" { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_STATICASSERT : T_IDENTIFIER); } 103 "struct" { BOOST_WAVE_RET(T_STRUCT); } 104 "switch" { BOOST_WAVE_RET(T_SWITCH); } 105 "template" { BOOST_WAVE_RET(T_TEMPLATE); } 106 "this" { BOOST_WAVE_RET(T_THIS); } 107 "thread_local" { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_THREADLOCAL : T_IDENTIFIER); } 108 "throw" { BOOST_WAVE_RET(T_THROW); } 109 "true" { BOOST_WAVE_RET(T_TRUE); } 110 "try" { BOOST_WAVE_RET(T_TRY); } 111 "typedef" { BOOST_WAVE_RET(T_TYPEDEF); } 112 "typeid" { BOOST_WAVE_RET(T_TYPEID); } 113 "typename" { BOOST_WAVE_RET(T_TYPENAME); } 114 "union" { BOOST_WAVE_RET(T_UNION); } 115 "unsigned" { BOOST_WAVE_RET(T_UNSIGNED); } 116 "using" { BOOST_WAVE_RET(T_USING); } 117 "virtual" { BOOST_WAVE_RET(T_VIRTUAL); } 118 "void" { BOOST_WAVE_RET(T_VOID); } 119 "volatile" { BOOST_WAVE_RET(T_VOLATILE); } 120 "wchar_t" { BOOST_WAVE_RET(T_WCHART); } 121 "while" { BOOST_WAVE_RET(T_WHILE); } 122 123 "__int8" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_INT8 : T_IDENTIFIER); } 124 "__int16" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_INT16 : T_IDENTIFIER); } 125 "__int32" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_INT32 : T_IDENTIFIER); } 126 "__int64" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_INT64 : T_IDENTIFIER); } 127 "_"? "_based" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_BASED : T_IDENTIFIER); } 128 "_"? "_declspec" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_DECLSPEC : T_IDENTIFIER); } 129 "_"? "_cdecl" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_CDECL : T_IDENTIFIER); } 130 "_"? "_fastcall" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_FASTCALL : T_IDENTIFIER); } 131 "_"? "_stdcall" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_STDCALL : T_IDENTIFIER); } 132 "__try" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_TRY : T_IDENTIFIER); } 133 "__except" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_EXCEPT : T_IDENTIFIER); } 134 "__finally" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_FINALLY : T_IDENTIFIER); } 135 "__leave" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_LEAVE : T_IDENTIFIER); } 136 "_"? "_inline" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_INLINE : T_IDENTIFIER); } 137 "_"? "_asm" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_ASM : T_IDENTIFIER); } 138 139 "{" { BOOST_WAVE_RET(T_LEFTBRACE); } 140 "??<" { BOOST_WAVE_RET(T_LEFTBRACE_TRIGRAPH); } 141 "<%" { BOOST_WAVE_RET(T_LEFTBRACE_ALT); } 142 "}" { BOOST_WAVE_RET(T_RIGHTBRACE); } 143 "??>" { BOOST_WAVE_RET(T_RIGHTBRACE_TRIGRAPH); } 144 "%>" { BOOST_WAVE_RET(T_RIGHTBRACE_ALT); } 145 "[" { BOOST_WAVE_RET(T_LEFTBRACKET); } 146 "??(" { BOOST_WAVE_RET(T_LEFTBRACKET_TRIGRAPH); } 147 "<:" { BOOST_WAVE_RET(T_LEFTBRACKET_ALT); } 148 "]" { BOOST_WAVE_RET(T_RIGHTBRACKET); } 149 "??)" { BOOST_WAVE_RET(T_RIGHTBRACKET_TRIGRAPH); } 150 ":>" { BOOST_WAVE_RET(T_RIGHTBRACKET_ALT); } 151 "#" { BOOST_WAVE_RET(T_POUND); } 152 "%:" { BOOST_WAVE_RET(T_POUND_ALT); } 153 "??=" { BOOST_WAVE_RET(T_POUND_TRIGRAPH); } 154 "##" { BOOST_WAVE_RET(T_POUND_POUND); } 155 "#??=" { BOOST_WAVE_RET(T_POUND_POUND_TRIGRAPH); } 156 "??=#" { BOOST_WAVE_RET(T_POUND_POUND_TRIGRAPH); } 157 "??=??=" { BOOST_WAVE_RET(T_POUND_POUND_TRIGRAPH); } 158 "%:%:" { BOOST_WAVE_RET(T_POUND_POUND_ALT); } 159 "(" { BOOST_WAVE_RET(T_LEFTPAREN); } 160 ")" { BOOST_WAVE_RET(T_RIGHTPAREN); } 161 ";" { BOOST_WAVE_RET(T_SEMICOLON); } 162 ":" { BOOST_WAVE_RET(T_COLON); } 163 "..." { BOOST_WAVE_RET(T_ELLIPSIS); } 164 "?" { BOOST_WAVE_RET(T_QUESTION_MARK); } 165 "::" 166 { 167 if (s->act_in_c99_mode) { 168 --YYCURSOR; 169 BOOST_WAVE_RET(T_COLON); 170 } 171 else { 172 BOOST_WAVE_RET(T_COLON_COLON); 173 } 174 } 175 "." { BOOST_WAVE_RET(T_DOT); } 176 ".*" 177 { 178 if (s->act_in_c99_mode) { 179 --YYCURSOR; 180 BOOST_WAVE_RET(T_DOT); 181 } 182 else { 183 BOOST_WAVE_RET(T_DOTSTAR); 184 } 185 } 186 "+" { BOOST_WAVE_RET(T_PLUS); } 187 "-" { BOOST_WAVE_RET(T_MINUS); } 188 "*" { BOOST_WAVE_RET(T_STAR); } 189 "/" { BOOST_WAVE_RET(T_DIVIDE); } 190 "%" { BOOST_WAVE_RET(T_PERCENT); } 191 "^" { BOOST_WAVE_RET(T_XOR); } 192 "??'" { BOOST_WAVE_RET(T_XOR_TRIGRAPH); } 193 "xor" { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_XOR_ALT); } 194 "&" { BOOST_WAVE_RET(T_AND); } 195 "bitand" { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_AND_ALT); } 196 "|" { BOOST_WAVE_RET(T_OR); } 197 "bitor" { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_OR_ALT); } 198 "??!" { BOOST_WAVE_RET(T_OR_TRIGRAPH); } 199 "~" { BOOST_WAVE_RET(T_COMPL); } 200 "??-" { BOOST_WAVE_RET(T_COMPL_TRIGRAPH); } 201 "compl" { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_COMPL_ALT); } 202 "!" { BOOST_WAVE_RET(T_NOT); } 203 "not" { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_NOT_ALT); } 204 "=" { BOOST_WAVE_RET(T_ASSIGN); } 205 "<" { BOOST_WAVE_RET(T_LESS); } 206 ">" { BOOST_WAVE_RET(T_GREATER); } 207 "+=" { BOOST_WAVE_RET(T_PLUSASSIGN); } 208 "-=" { BOOST_WAVE_RET(T_MINUSASSIGN); } 209 "*=" { BOOST_WAVE_RET(T_STARASSIGN); } 210 "/=" { BOOST_WAVE_RET(T_DIVIDEASSIGN); } 211 "%=" { BOOST_WAVE_RET(T_PERCENTASSIGN); } 212 "^=" { BOOST_WAVE_RET(T_XORASSIGN); } 213 "xor_eq" { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_XORASSIGN_ALT); } 214 "??'=" { BOOST_WAVE_RET(T_XORASSIGN_TRIGRAPH); } 215 "&=" { BOOST_WAVE_RET(T_ANDASSIGN); } 216 "and_eq" { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_ANDASSIGN_ALT); } 217 "|=" { BOOST_WAVE_RET(T_ORASSIGN); } 218 "or_eq" { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_ORASSIGN_ALT); } 219 "??!=" { BOOST_WAVE_RET(T_ORASSIGN_TRIGRAPH); } 220 "<<" { BOOST_WAVE_RET(T_SHIFTLEFT); } 221 ">>" { BOOST_WAVE_RET(T_SHIFTRIGHT); } 222 ">>=" { BOOST_WAVE_RET(T_SHIFTRIGHTASSIGN); } 223 "<<=" { BOOST_WAVE_RET(T_SHIFTLEFTASSIGN); } 224 "==" { BOOST_WAVE_RET(T_EQUAL); } 225 "!=" { BOOST_WAVE_RET(T_NOTEQUAL); } 226 "not_eq" { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_NOTEQUAL_ALT); } 227 "<=" { BOOST_WAVE_RET(T_LESSEQUAL); } 228 ">=" { BOOST_WAVE_RET(T_GREATEREQUAL); } 229 "&&" { BOOST_WAVE_RET(T_ANDAND); } 230 "and" { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_ANDAND_ALT); } 231 "||" { BOOST_WAVE_RET(T_OROR); } 232 "??!|" { BOOST_WAVE_RET(T_OROR_TRIGRAPH); } 233 "|??!" { BOOST_WAVE_RET(T_OROR_TRIGRAPH); } 234 "or" { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_OROR_ALT); } 235 "??!??!" { BOOST_WAVE_RET(T_OROR_TRIGRAPH); } 236 "++" { BOOST_WAVE_RET(T_PLUSPLUS); } 237 "--" { BOOST_WAVE_RET(T_MINUSMINUS); } 238 "," { BOOST_WAVE_RET(T_COMMA); } 239 "->*" 240 { 241 if (s->act_in_c99_mode) { 242 --YYCURSOR; 243 BOOST_WAVE_RET(T_ARROW); 244 } 245 else { 246 BOOST_WAVE_RET(T_ARROWSTAR); 247 } 248 } 249 "->" { BOOST_WAVE_RET(T_ARROW); } 250 "??/" { BOOST_WAVE_RET(T_ANY_TRIGRAPH); } 251 252 "L"? (['] (EscapeSequence | UniversalChar | any\[\n\r\\'])+ [']) 253 { BOOST_WAVE_RET(T_CHARLIT); } 254 255 "L"? (["] (EscapeSequence | UniversalChar | any\[\n\r\\"])* ["]) 256 { BOOST_WAVE_RET(T_STRINGLIT); } 257 258 "L"? "R" ["] 259 { 260 if (s->act_in_cpp0x_mode) 261 { 262 rawstringdelim = ""; 263 goto extrawstringlit; 264 } 265 --YYCURSOR; 266 BOOST_WAVE_RET(T_IDENTIFIER); 267 } 268 269 [uU] ['] 270 { 271 if (s->act_in_cpp0x_mode) 272 goto extcharlit; 273 --YYCURSOR; 274 BOOST_WAVE_RET(T_IDENTIFIER); 275 } 276 277 ([uU] | "u8") ["] 278 { 279 if (s->act_in_cpp0x_mode) 280 goto extstringlit; 281 --YYCURSOR; 282 BOOST_WAVE_RET(T_IDENTIFIER); 283 } 284 285 ([uU] | "u8") "R" ["] 286 { 287 if (s->act_in_cpp0x_mode) 288 { 289 rawstringdelim = ""; 290 goto extrawstringlit; 291 } 292 --YYCURSOR; 293 BOOST_WAVE_RET(T_IDENTIFIER); 294 } 295 296 ([a-zA-Z_$] | UniversalChar) ([a-zA-Z_0-9$] | UniversalChar)* 297 { BOOST_WAVE_RET(T_IDENTIFIER); } 298 299 Pound PPSpace ( "include" | "include_next") PPSpace "<" (any\[\n\r>])+ ">" 300 { BOOST_WAVE_RET(T_PP_HHEADER); } 301 302 Pound PPSpace ( "include" | "include_next") PPSpace "\"" (any\[\n\r"])+ "\"" 303 { BOOST_WAVE_RET(T_PP_QHEADER); } 304 305 Pound PPSpace ( "include" | "include_next") PPSpace 306 { BOOST_WAVE_RET(T_PP_INCLUDE); } 307 308 Pound PPSpace "if" { BOOST_WAVE_RET(T_PP_IF); } 309 Pound PPSpace "ifdef" { BOOST_WAVE_RET(T_PP_IFDEF); } 310 Pound PPSpace "ifndef" { BOOST_WAVE_RET(T_PP_IFNDEF); } 311 Pound PPSpace "else" { BOOST_WAVE_RET(T_PP_ELSE); } 312 Pound PPSpace "elif" { BOOST_WAVE_RET(T_PP_ELIF); } 313 Pound PPSpace "endif" { BOOST_WAVE_RET(T_PP_ENDIF); } 314 Pound PPSpace "define" { BOOST_WAVE_RET(T_PP_DEFINE); } 315 Pound PPSpace "undef" { BOOST_WAVE_RET(T_PP_UNDEF); } 316 Pound PPSpace "line" { BOOST_WAVE_RET(T_PP_LINE); } 317 Pound PPSpace "error" { BOOST_WAVE_RET(T_PP_ERROR); } 318 Pound PPSpace "pragma" { BOOST_WAVE_RET(T_PP_PRAGMA); } 319 320 Pound PPSpace "warning" { BOOST_WAVE_RET(T_PP_WARNING); } 321 322 Pound PPSpace "region" { BOOST_WAVE_RET(T_MSEXT_PP_REGION); } 323 Pound PPSpace "endregion" { BOOST_WAVE_RET(T_MSEXT_PP_ENDREGION); } 324 325 [ \t\v\f]+ 326 { BOOST_WAVE_RET(T_SPACE); } 327 328 Newline 329 { 330 s->line++; 331 cursor.column = 1; 332 BOOST_WAVE_RET(T_NEWLINE); 333 } 334 335 "\000" 336 { 337 if (s->eof && cursor != s->eof) 338 { 339 BOOST_WAVE_UPDATE_CURSOR(); // adjust the input cursor 340 (*s->error_proc)(s, lexing_exception::generic_lexing_error, 341 "invalid character '\\000' in input stream"); 342 } 343 BOOST_WAVE_RET(T_EOF); 344 } 345 346 any { BOOST_WAVE_RET(TOKEN_FROM_ID(*s->tok, UnknownTokenType)); } 347 348 anyctrl 349 { 350 // flag the error 351 BOOST_WAVE_UPDATE_CURSOR(); // adjust the input cursor 352 (*s->error_proc)(s, lexing_exception::generic_lexing_error, 353 "invalid character '\\%03o' in input stream", *--YYCURSOR); 354 } 355*/ 356 357ccomment: 358/*!re2c 359 "*/" { BOOST_WAVE_RET(T_CCOMMENT); } 360 361 Newline 362 { 363 /*if(cursor == s->eof) BOOST_WAVE_RET(T_EOF);*/ 364 /*s->tok = cursor; */ 365 s->line += count_backslash_newlines(s, cursor) +1; 366 cursor.column = 1; 367 goto ccomment; 368 } 369 370 any { goto ccomment; } 371 372 "\000" 373 { 374 if(cursor == s->eof) 375 { 376 BOOST_WAVE_UPDATE_CURSOR(); // adjust the input cursor 377 (*s->error_proc)(s, lexing_exception::generic_lexing_warning, 378 "Unterminated 'C' style comment"); 379 } 380 else 381 { 382 --YYCURSOR; // next call returns T_EOF 383 BOOST_WAVE_UPDATE_CURSOR(); // adjust the input cursor 384 (*s->error_proc)(s, lexing_exception::generic_lexing_error, 385 "invalid character: '\\000' in input stream"); 386 } 387 } 388 389 anyctrl 390 { 391 // flag the error 392 BOOST_WAVE_UPDATE_CURSOR(); // adjust the input cursor 393 (*s->error_proc)(s, lexing_exception::generic_lexing_error, 394 "invalid character '\\%03o' in input stream", *--YYCURSOR); 395 } 396*/ 397 398cppcomment: 399/*!re2c 400 Newline 401 { 402 /*if(cursor == s->eof) BOOST_WAVE_RET(T_EOF); */ 403 /*s->tok = cursor; */ 404 s->line++; 405 cursor.column = 1; 406 BOOST_WAVE_RET(T_CPPCOMMENT); 407 } 408 409 any { goto cppcomment; } 410 411 "\000" 412 { 413 if (s->eof && cursor != s->eof) 414 { 415 --YYCURSOR; // next call returns T_EOF 416 BOOST_WAVE_UPDATE_CURSOR(); // adjust the input cursor 417 (*s->error_proc)(s, lexing_exception::generic_lexing_error, 418 "invalid character '\\000' in input stream"); 419 } 420 421 --YYCURSOR; // next call returns T_EOF 422 if (!s->single_line_only) 423 { 424 BOOST_WAVE_UPDATE_CURSOR(); // adjust the input cursor 425 (*s->error_proc)(s, lexing_exception::generic_lexing_warning, 426 "Unterminated 'C++' style comment"); 427 } 428 BOOST_WAVE_RET(T_CPPCOMMENT); 429 } 430 431 anyctrl 432 { 433 // flag the error 434 BOOST_WAVE_UPDATE_CURSOR(); // adjust the input cursor 435 (*s->error_proc)(s, lexing_exception::generic_lexing_error, 436 "invalid character '\\%03o' in input stream", *--YYCURSOR); 437 } 438*/ 439 440/* this subscanner is called whenever a pp_number has been started */ 441pp_number: 442{ 443 cursor = uchar_wrapper(s->tok = s->cur, s->column = s->curr_column); 444 marker = uchar_wrapper(s->ptr); 445 limit = uchar_wrapper(s->lim); 446 447 if (s->detect_pp_numbers) { 448 /*!re2c 449 "."? Digit (Digit | NonDigit | ExponentStart | ".")* 450 { BOOST_WAVE_RET(T_PP_NUMBER); } 451 452 // because we reached this point, then reset the cursor, 453 // the pattern above should always match 454 * { BOOST_ASSERT(false); } 455 */ 456 } 457 else { 458 /*!re2c 459 ((FractionalConstant ExponentPart?) | (Digit+ ExponentPart)) FloatingSuffix? 460 { BOOST_WAVE_RET(T_FLOATLIT); } 461 462 Integer { goto integer_suffix; } 463 464 // one of the above patterns should always match 465 * { BOOST_ASSERT(false); } 466 */ 467 } 468} 469 470/* this subscanner is called, whenever an Integer was recognized */ 471integer_suffix: 472{ 473 if (s->enable_ms_extensions) { 474 /*!re2c 475 LongIntegerSuffix | MSLongIntegerSuffix 476 { BOOST_WAVE_RET(T_LONGINTLIT); } 477 478 IntegerSuffix? 479 { BOOST_WAVE_RET(T_INTLIT); } 480 */ 481 } 482 else { 483 /*!re2c 484 LongIntegerSuffix 485 { BOOST_WAVE_RET(T_LONGINTLIT); } 486 487 IntegerSuffix? 488 { BOOST_WAVE_RET(T_INTLIT); } 489 */ 490 } 491 492 // re2c will complain about -Wmatch-empty-string above 493 // it's OK because we've already matched an integer 494 // and will return T_INTLIT 495} 496 497/* this subscanner is invoked for C++0x extended character literals */ 498extcharlit: 499{ 500 /*!re2c 501 * { 502 (*s->error_proc)(s, lexing_exception::generic_lexing_error, 503 "Invalid character in raw string delimiter ('%c')", yych); 504 } 505 506 ((EscapeSequence | UniversalChar | any\[\n\r\\']) [']) 507 { BOOST_WAVE_RET(T_CHARLIT); } 508 509 any 510 { BOOST_WAVE_RET(TOKEN_FROM_ID(*s->tok, UnknownTokenType)); } 511 */ 512} 513 514/* this subscanner is invoked for C++0x extended character string literals */ 515extstringlit: 516{ 517 /*!re2c 518 * { 519 (*s->error_proc)(s, lexing_exception::generic_lexing_error, 520 "Invalid character in raw string delimiter ('%c')", yych); 521 } 522 523 ((EscapeSequence | UniversalChar | any\[\n\r\\"])* ["]) 524 { BOOST_WAVE_RET(T_STRINGLIT); } 525 526 any 527 { BOOST_WAVE_RET(TOKEN_FROM_ID(*s->tok, UnknownTokenType)); } 528 */ 529} 530 531extrawstringlit: 532{ 533 // we have consumed the double quote but not the lparen 534 // at this point we may see a delimiter 535 536 /*!re2c 537 * { 538 (*s->error_proc)(s, lexing_exception::generic_lexing_error, 539 "Invalid character in raw string delimiter ('%c')", yych); 540 } 541 542 // delimiters are any character but parentheses, backslash, and whitespace 543 any\[()\\\t\v\f\r\n] 544 { 545 rawstringdelim += yych; 546 if (rawstringdelim.size() > 16) 547 { 548 (*s->error_proc)(s, lexing_exception::generic_lexing_error, 549 "Raw string delimiter of excessive length (\"%s\") in input stream", 550 rawstringdelim.c_str()); 551 } 552 goto extrawstringlit; 553 } 554 555 "(" 556 { 557 rawstringdelim = ")" + rawstringdelim; 558 goto extrawstringbody; 559 } 560 561 */ 562} 563 564extrawstringbody: 565{ 566 /*!re2c 567 568 * { 569 (*s->error_proc)(s, lexing_exception::generic_lexing_error, 570 "Invalid character in raw string body ('%c')", yych); 571 } 572 573 Newline 574 { 575 s->line += count_backslash_newlines(s, cursor) +1; 576 cursor.column = 1; 577 goto extrawstringbody; 578 } 579 580 (EscapeSequence | UniversalChar | any\["]) 581 { 582 goto extrawstringbody; 583 } 584 585 ["] 586 { 587 // check to see if we have completed a delimiter 588 if (string_type((char *)(YYCURSOR - rawstringdelim.size() - 1), 589 (char *)(YYCURSOR - 1)) == rawstringdelim) 590 { 591 BOOST_WAVE_RET(T_RAWSTRINGLIT); 592 } else { 593 goto extrawstringbody; 594 } 595 } 596 */ 597} 598