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