mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-08-03 14:07:48 +00:00
Added thirdparty: boost library
This commit is contained in:
+64
@@ -0,0 +1,64 @@
|
||||
/*=============================================================================
|
||||
Boost.Wave: A Standard compliant C++ preprocessor library
|
||||
|
||||
http://www.boost.org/
|
||||
|
||||
Copyright (c) 2001 Daniel C. Nuffer.
|
||||
Copyright (c) 2001-2012 Hartmut Kaiser.
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
=============================================================================*/
|
||||
|
||||
#if !defined(BOOST_AQ_HPP_A21D9145_B643_44C0_81E7_DB346DD67EE1_INCLUDED)
|
||||
#define BOOST_AQ_HPP_A21D9145_B643_44C0_81E7_DB346DD67EE1_INCLUDED
|
||||
|
||||
#include <boost/wave/wave_config.hpp>
|
||||
#include <cstdlib>
|
||||
|
||||
// this must occur after all of the includes and before any code appears
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
#include BOOST_ABI_PREFIX
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
namespace boost {
|
||||
namespace wave {
|
||||
namespace cpplexer {
|
||||
namespace re2clex {
|
||||
|
||||
typedef std::size_t aq_stdelement;
|
||||
|
||||
typedef struct tag_aq_queuetype
|
||||
{
|
||||
std::size_t head;
|
||||
std::size_t tail;
|
||||
std::size_t size;
|
||||
std::size_t max_size;
|
||||
aq_stdelement* queue;
|
||||
} aq_queuetype;
|
||||
|
||||
typedef aq_queuetype* aq_queue;
|
||||
|
||||
BOOST_WAVE_DECL int aq_enqueue(aq_queue q, aq_stdelement e);
|
||||
int aq_enqueue_front(aq_queue q, aq_stdelement e);
|
||||
int aq_serve(aq_queue q, aq_stdelement *e);
|
||||
BOOST_WAVE_DECL int aq_pop(aq_queue q);
|
||||
#define AQ_EMPTY(q) (q->size == 0)
|
||||
#define AQ_FULL(q) (q->size == q->max_size)
|
||||
int aq_grow(aq_queue q);
|
||||
|
||||
BOOST_WAVE_DECL aq_queue aq_create(void);
|
||||
BOOST_WAVE_DECL void aq_terminate(aq_queue q);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
} // namespace re2clex
|
||||
} // namespace cpplexer
|
||||
} // namespace wave
|
||||
} // namespace boost
|
||||
|
||||
// the suffix header occurs after all of the code
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
#include BOOST_ABI_SUFFIX
|
||||
#endif
|
||||
|
||||
#endif // !defined(BOOST_AQ_HPP_A21D9145_B643_44C0_81E7_DB346DD67EE1_INCLUDED)
|
||||
+615
@@ -0,0 +1,615 @@
|
||||
/*=============================================================================
|
||||
Boost.Wave: A Standard compliant C++ preprocessor library
|
||||
|
||||
Copyright (c) 2001 Daniel C. Nuffer
|
||||
Copyright (c) 2001-2013 Hartmut Kaiser.
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
This is a lexer conforming to the Standard with a few exceptions.
|
||||
So it does allow the '$' to be part of identifiers. If you need strict
|
||||
Standards conforming behaviour, please include the lexer definition
|
||||
provided in the file strict_cpp.re.
|
||||
|
||||
TODO:
|
||||
handle errors better.
|
||||
=============================================================================*/
|
||||
|
||||
/*!re2c
|
||||
re2c:indent:string = " ";
|
||||
any = [\t\v\f\r\n\040-\377];
|
||||
anyctrl = [\001-\037];
|
||||
OctalDigit = [0-7];
|
||||
Digit = [0-9];
|
||||
HexDigit = [a-fA-F0-9];
|
||||
Integer = (("0" [xX] HexDigit+) | ("0" OctalDigit*) | ([1-9] Digit*));
|
||||
ExponentStart = [Ee] [+-];
|
||||
ExponentPart = [Ee] [+-]? Digit+;
|
||||
FractionalConstant = (Digit* "." Digit+) | (Digit+ ".");
|
||||
FloatingSuffix = [fF] [lL]? | [lL] [fF]?;
|
||||
IntegerSuffix = [uU] [lL]? | [lL] [uU]?;
|
||||
LongIntegerSuffix = [uU] ("ll" | "LL") | ("ll" | "LL") [uU]?;
|
||||
MSLongIntegerSuffix = "u"? "i64";
|
||||
Backslash = [\\] | "??/";
|
||||
EscapeSequence = Backslash ([abeEfnrtv?'"] | Backslash | "x" HexDigit+ | OctalDigit OctalDigit? OctalDigit?);
|
||||
HexQuad = HexDigit HexDigit HexDigit HexDigit;
|
||||
UniversalChar = Backslash ("u" HexQuad | "U" HexQuad HexQuad);
|
||||
Newline = "\r\n" | "\n" | "\r";
|
||||
PPSpace = ([ \t\f\v]|("/*"(any\[*]|Newline|("*"+(any\[*/]|Newline)))*"*"+"/"))*;
|
||||
Pound = "#" | "??=" | "%:";
|
||||
NonDigit = [a-zA-Z_$] | UniversalChar;
|
||||
*/
|
||||
|
||||
/*!re2c
|
||||
"/*" { goto ccomment; }
|
||||
"//" { goto cppcomment; }
|
||||
"."? Digit { goto pp_number; }
|
||||
|
||||
"alignas" { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_ALIGNAS : T_IDENTIFIER); }
|
||||
"alignof" { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_ALIGNOF : T_IDENTIFIER); }
|
||||
"asm" { BOOST_WAVE_RET(T_ASM); }
|
||||
"auto" { BOOST_WAVE_RET(T_AUTO); }
|
||||
"bool" { BOOST_WAVE_RET(T_BOOL); }
|
||||
"break" { BOOST_WAVE_RET(T_BREAK); }
|
||||
"case" { BOOST_WAVE_RET(T_CASE); }
|
||||
"catch" { BOOST_WAVE_RET(T_CATCH); }
|
||||
"char" { BOOST_WAVE_RET(T_CHAR); }
|
||||
"char8_t" { BOOST_WAVE_RET(s->act_in_cpp2a_mode ? T_CHAR8_T : T_IDENTIFIER); }
|
||||
"char16_t" { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_CHAR16_T : T_IDENTIFIER); }
|
||||
"char32_t" { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_CHAR32_T : T_IDENTIFIER); }
|
||||
"class" { BOOST_WAVE_RET(T_CLASS); }
|
||||
"concept" { BOOST_WAVE_RET(s->act_in_cpp2a_mode ? T_CONCEPT : T_IDENTIFIER); }
|
||||
"const" { BOOST_WAVE_RET(T_CONST); }
|
||||
"consteval" { BOOST_WAVE_RET(s->act_in_cpp2a_mode ? T_CONSTEVAL : T_IDENTIFIER); }
|
||||
"constexpr" { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_CONSTEXPR : T_IDENTIFIER); }
|
||||
"constinit" { BOOST_WAVE_RET(s->act_in_cpp2a_mode ? T_CONSTINIT : T_IDENTIFIER); }
|
||||
"const_cast" { BOOST_WAVE_RET(T_CONSTCAST); }
|
||||
"continue" { BOOST_WAVE_RET(T_CONTINUE); }
|
||||
"co_await" { BOOST_WAVE_RET(s->act_in_cpp2a_mode ? T_CO_AWAIT : T_IDENTIFIER); }
|
||||
"co_return" { BOOST_WAVE_RET(s->act_in_cpp2a_mode ? T_CO_RETURN : T_IDENTIFIER); }
|
||||
"co_yield" { BOOST_WAVE_RET(s->act_in_cpp2a_mode ? T_CO_YIELD : T_IDENTIFIER); }
|
||||
"decltype" { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_DECLTYPE : T_IDENTIFIER); }
|
||||
"default" { BOOST_WAVE_RET(T_DEFAULT); }
|
||||
"delete" { BOOST_WAVE_RET(T_DELETE); }
|
||||
"do" { BOOST_WAVE_RET(T_DO); }
|
||||
"double" { BOOST_WAVE_RET(T_DOUBLE); }
|
||||
"dynamic_cast" { BOOST_WAVE_RET(T_DYNAMICCAST); }
|
||||
"else" { BOOST_WAVE_RET(T_ELSE); }
|
||||
"enum" { BOOST_WAVE_RET(T_ENUM); }
|
||||
"explicit" { BOOST_WAVE_RET(T_EXPLICIT); }
|
||||
"export" { BOOST_WAVE_RET(T_EXPORT); }
|
||||
"extern" { BOOST_WAVE_RET(T_EXTERN); }
|
||||
"false" { BOOST_WAVE_RET(T_FALSE); }
|
||||
"float" { BOOST_WAVE_RET(T_FLOAT); }
|
||||
"for" { BOOST_WAVE_RET(T_FOR); }
|
||||
"friend" { BOOST_WAVE_RET(T_FRIEND); }
|
||||
"goto" { BOOST_WAVE_RET(T_GOTO); }
|
||||
"if" { BOOST_WAVE_RET(T_IF); }
|
||||
"import" { BOOST_WAVE_RET(s->enable_import_keyword ? T_IMPORT : T_IDENTIFIER); }
|
||||
"inline" { BOOST_WAVE_RET(T_INLINE); }
|
||||
"int" { BOOST_WAVE_RET(T_INT); }
|
||||
"long" { BOOST_WAVE_RET(T_LONG); }
|
||||
"mutable" { BOOST_WAVE_RET(T_MUTABLE); }
|
||||
"namespace" { BOOST_WAVE_RET(T_NAMESPACE); }
|
||||
"new" { BOOST_WAVE_RET(T_NEW); }
|
||||
"noexcept" { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_NOEXCEPT : T_IDENTIFIER); }
|
||||
"nullptr" { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_NULLPTR : T_IDENTIFIER); }
|
||||
"operator" { BOOST_WAVE_RET(T_OPERATOR); }
|
||||
"private" { BOOST_WAVE_RET(T_PRIVATE); }
|
||||
"protected" { BOOST_WAVE_RET(T_PROTECTED); }
|
||||
"public" { BOOST_WAVE_RET(T_PUBLIC); }
|
||||
"register" { BOOST_WAVE_RET(T_REGISTER); }
|
||||
"reinterpret_cast" { BOOST_WAVE_RET(T_REINTERPRETCAST); }
|
||||
"requires" { BOOST_WAVE_RET(s->act_in_cpp2a_mode ? T_REQUIRES : T_IDENTIFIER); }
|
||||
"return" { BOOST_WAVE_RET(T_RETURN); }
|
||||
"short" { BOOST_WAVE_RET(T_SHORT); }
|
||||
"signed" { BOOST_WAVE_RET(T_SIGNED); }
|
||||
"sizeof" { BOOST_WAVE_RET(T_SIZEOF); }
|
||||
"static" { BOOST_WAVE_RET(T_STATIC); }
|
||||
"static_cast" { BOOST_WAVE_RET(T_STATICCAST); }
|
||||
"static_assert" { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_STATICASSERT : T_IDENTIFIER); }
|
||||
"struct" { BOOST_WAVE_RET(T_STRUCT); }
|
||||
"switch" { BOOST_WAVE_RET(T_SWITCH); }
|
||||
"template" { BOOST_WAVE_RET(T_TEMPLATE); }
|
||||
"this" { BOOST_WAVE_RET(T_THIS); }
|
||||
"thread_local" { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_THREADLOCAL : T_IDENTIFIER); }
|
||||
"throw" { BOOST_WAVE_RET(T_THROW); }
|
||||
"true" { BOOST_WAVE_RET(T_TRUE); }
|
||||
"try" { BOOST_WAVE_RET(T_TRY); }
|
||||
"typedef" { BOOST_WAVE_RET(T_TYPEDEF); }
|
||||
"typeid" { BOOST_WAVE_RET(T_TYPEID); }
|
||||
"typename" { BOOST_WAVE_RET(T_TYPENAME); }
|
||||
"union" { BOOST_WAVE_RET(T_UNION); }
|
||||
"unsigned" { BOOST_WAVE_RET(T_UNSIGNED); }
|
||||
"using" { BOOST_WAVE_RET(T_USING); }
|
||||
"virtual" { BOOST_WAVE_RET(T_VIRTUAL); }
|
||||
"void" { BOOST_WAVE_RET(T_VOID); }
|
||||
"volatile" { BOOST_WAVE_RET(T_VOLATILE); }
|
||||
"wchar_t" { BOOST_WAVE_RET(T_WCHART); }
|
||||
"while" { BOOST_WAVE_RET(T_WHILE); }
|
||||
|
||||
"__int8" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_INT8 : T_IDENTIFIER); }
|
||||
"__int16" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_INT16 : T_IDENTIFIER); }
|
||||
"__int32" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_INT32 : T_IDENTIFIER); }
|
||||
"__int64" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_INT64 : T_IDENTIFIER); }
|
||||
"_"? "_based" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_BASED : T_IDENTIFIER); }
|
||||
"_"? "_declspec" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_DECLSPEC : T_IDENTIFIER); }
|
||||
"_"? "_cdecl" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_CDECL : T_IDENTIFIER); }
|
||||
"_"? "_fastcall" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_FASTCALL : T_IDENTIFIER); }
|
||||
"_"? "_stdcall" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_STDCALL : T_IDENTIFIER); }
|
||||
"__try" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_TRY : T_IDENTIFIER); }
|
||||
"__except" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_EXCEPT : T_IDENTIFIER); }
|
||||
"__finally" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_FINALLY : T_IDENTIFIER); }
|
||||
"__leave" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_LEAVE : T_IDENTIFIER); }
|
||||
"_"? "_inline" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_INLINE : T_IDENTIFIER); }
|
||||
"_"? "_asm" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_ASM : T_IDENTIFIER); }
|
||||
|
||||
"{" { BOOST_WAVE_RET(T_LEFTBRACE); }
|
||||
"??<" { BOOST_WAVE_RET(T_LEFTBRACE_TRIGRAPH); }
|
||||
"<%" { BOOST_WAVE_RET(T_LEFTBRACE_ALT); }
|
||||
"}" { BOOST_WAVE_RET(T_RIGHTBRACE); }
|
||||
"??>" { BOOST_WAVE_RET(T_RIGHTBRACE_TRIGRAPH); }
|
||||
"%>" { BOOST_WAVE_RET(T_RIGHTBRACE_ALT); }
|
||||
"[" { BOOST_WAVE_RET(T_LEFTBRACKET); }
|
||||
"??(" { BOOST_WAVE_RET(T_LEFTBRACKET_TRIGRAPH); }
|
||||
"<:" { BOOST_WAVE_RET(T_LEFTBRACKET_ALT); }
|
||||
"]" { BOOST_WAVE_RET(T_RIGHTBRACKET); }
|
||||
"??)" { BOOST_WAVE_RET(T_RIGHTBRACKET_TRIGRAPH); }
|
||||
":>" { BOOST_WAVE_RET(T_RIGHTBRACKET_ALT); }
|
||||
"#" { BOOST_WAVE_RET(T_POUND); }
|
||||
"%:" { BOOST_WAVE_RET(T_POUND_ALT); }
|
||||
"??=" { BOOST_WAVE_RET(T_POUND_TRIGRAPH); }
|
||||
"##" { BOOST_WAVE_RET(T_POUND_POUND); }
|
||||
"#??=" { BOOST_WAVE_RET(T_POUND_POUND_TRIGRAPH); }
|
||||
"??=#" { BOOST_WAVE_RET(T_POUND_POUND_TRIGRAPH); }
|
||||
"??=??=" { BOOST_WAVE_RET(T_POUND_POUND_TRIGRAPH); }
|
||||
"%:%:" { BOOST_WAVE_RET(T_POUND_POUND_ALT); }
|
||||
"(" { BOOST_WAVE_RET(T_LEFTPAREN); }
|
||||
")" { BOOST_WAVE_RET(T_RIGHTPAREN); }
|
||||
";" { BOOST_WAVE_RET(T_SEMICOLON); }
|
||||
":" { BOOST_WAVE_RET(T_COLON); }
|
||||
"..." { BOOST_WAVE_RET(T_ELLIPSIS); }
|
||||
"?" { BOOST_WAVE_RET(T_QUESTION_MARK); }
|
||||
"::"
|
||||
{
|
||||
if (s->act_in_c99_mode) {
|
||||
--YYCURSOR;
|
||||
BOOST_WAVE_RET(T_COLON);
|
||||
}
|
||||
else {
|
||||
BOOST_WAVE_RET(T_COLON_COLON);
|
||||
}
|
||||
}
|
||||
"." { BOOST_WAVE_RET(T_DOT); }
|
||||
".*"
|
||||
{
|
||||
if (s->act_in_c99_mode) {
|
||||
--YYCURSOR;
|
||||
BOOST_WAVE_RET(T_DOT);
|
||||
}
|
||||
else {
|
||||
BOOST_WAVE_RET(T_DOTSTAR);
|
||||
}
|
||||
}
|
||||
"+" { BOOST_WAVE_RET(T_PLUS); }
|
||||
"-" { BOOST_WAVE_RET(T_MINUS); }
|
||||
"*" { BOOST_WAVE_RET(T_STAR); }
|
||||
"/" { BOOST_WAVE_RET(T_DIVIDE); }
|
||||
"%" { BOOST_WAVE_RET(T_PERCENT); }
|
||||
"^" { BOOST_WAVE_RET(T_XOR); }
|
||||
"??'" { BOOST_WAVE_RET(T_XOR_TRIGRAPH); }
|
||||
"xor" { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_XOR_ALT); }
|
||||
"&" { BOOST_WAVE_RET(T_AND); }
|
||||
"bitand" { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_AND_ALT); }
|
||||
"|" { BOOST_WAVE_RET(T_OR); }
|
||||
"bitor" { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_OR_ALT); }
|
||||
"??!" { BOOST_WAVE_RET(T_OR_TRIGRAPH); }
|
||||
"~" { BOOST_WAVE_RET(T_COMPL); }
|
||||
"??-" { BOOST_WAVE_RET(T_COMPL_TRIGRAPH); }
|
||||
"compl" { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_COMPL_ALT); }
|
||||
"!" { BOOST_WAVE_RET(T_NOT); }
|
||||
"not" { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_NOT_ALT); }
|
||||
"=" { BOOST_WAVE_RET(T_ASSIGN); }
|
||||
"<" { BOOST_WAVE_RET(T_LESS); }
|
||||
">" { BOOST_WAVE_RET(T_GREATER); }
|
||||
"+=" { BOOST_WAVE_RET(T_PLUSASSIGN); }
|
||||
"-=" { BOOST_WAVE_RET(T_MINUSASSIGN); }
|
||||
"*=" { BOOST_WAVE_RET(T_STARASSIGN); }
|
||||
"/=" { BOOST_WAVE_RET(T_DIVIDEASSIGN); }
|
||||
"%=" { BOOST_WAVE_RET(T_PERCENTASSIGN); }
|
||||
"^=" { BOOST_WAVE_RET(T_XORASSIGN); }
|
||||
"xor_eq" { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_XORASSIGN_ALT); }
|
||||
"??'=" { BOOST_WAVE_RET(T_XORASSIGN_TRIGRAPH); }
|
||||
"&=" { BOOST_WAVE_RET(T_ANDASSIGN); }
|
||||
"and_eq" { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_ANDASSIGN_ALT); }
|
||||
"|=" { BOOST_WAVE_RET(T_ORASSIGN); }
|
||||
"or_eq" { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_ORASSIGN_ALT); }
|
||||
"??!=" { BOOST_WAVE_RET(T_ORASSIGN_TRIGRAPH); }
|
||||
"<<" { BOOST_WAVE_RET(T_SHIFTLEFT); }
|
||||
">>" { BOOST_WAVE_RET(T_SHIFTRIGHT); }
|
||||
">>=" { BOOST_WAVE_RET(T_SHIFTRIGHTASSIGN); }
|
||||
"<<=" { BOOST_WAVE_RET(T_SHIFTLEFTASSIGN); }
|
||||
"==" { BOOST_WAVE_RET(T_EQUAL); }
|
||||
"!=" { BOOST_WAVE_RET(T_NOTEQUAL); }
|
||||
"not_eq" { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_NOTEQUAL_ALT); }
|
||||
"<=>"
|
||||
{
|
||||
if (s->act_in_cpp2a_mode) {
|
||||
BOOST_WAVE_RET(T_SPACESHIP);
|
||||
}
|
||||
else {
|
||||
--YYCURSOR;
|
||||
BOOST_WAVE_RET(T_LESSEQUAL);
|
||||
}
|
||||
}
|
||||
"<=" { BOOST_WAVE_RET(T_LESSEQUAL); }
|
||||
">=" { BOOST_WAVE_RET(T_GREATEREQUAL); }
|
||||
"&&" { BOOST_WAVE_RET(T_ANDAND); }
|
||||
"and" { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_ANDAND_ALT); }
|
||||
"||" { BOOST_WAVE_RET(T_OROR); }
|
||||
"??!|" { BOOST_WAVE_RET(T_OROR_TRIGRAPH); }
|
||||
"|??!" { BOOST_WAVE_RET(T_OROR_TRIGRAPH); }
|
||||
"or" { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_OROR_ALT); }
|
||||
"??!??!" { BOOST_WAVE_RET(T_OROR_TRIGRAPH); }
|
||||
"++" { BOOST_WAVE_RET(T_PLUSPLUS); }
|
||||
"--" { BOOST_WAVE_RET(T_MINUSMINUS); }
|
||||
"," { BOOST_WAVE_RET(T_COMMA); }
|
||||
"->*"
|
||||
{
|
||||
if (s->act_in_c99_mode) {
|
||||
--YYCURSOR;
|
||||
BOOST_WAVE_RET(T_ARROW);
|
||||
}
|
||||
else {
|
||||
BOOST_WAVE_RET(T_ARROWSTAR);
|
||||
}
|
||||
}
|
||||
"->" { BOOST_WAVE_RET(T_ARROW); }
|
||||
"??/" { BOOST_WAVE_RET(T_ANY_TRIGRAPH); }
|
||||
|
||||
"L"? (['] (EscapeSequence | UniversalChar | any\[\n\r\\'])+ ['])
|
||||
{ BOOST_WAVE_RET(T_CHARLIT); }
|
||||
|
||||
"L"? (["] (EscapeSequence | UniversalChar | any\[\n\r\\"])* ["])
|
||||
{ BOOST_WAVE_RET(T_STRINGLIT); }
|
||||
|
||||
"L"? "R" ["]
|
||||
{
|
||||
if (s->act_in_cpp0x_mode)
|
||||
{
|
||||
rawstringdelim = "";
|
||||
goto extrawstringlit;
|
||||
}
|
||||
--YYCURSOR;
|
||||
BOOST_WAVE_RET(T_IDENTIFIER);
|
||||
}
|
||||
|
||||
[uU] [']
|
||||
{
|
||||
if (s->act_in_cpp0x_mode)
|
||||
goto extcharlit;
|
||||
--YYCURSOR;
|
||||
BOOST_WAVE_RET(T_IDENTIFIER);
|
||||
}
|
||||
|
||||
([uU] | "u8") ["]
|
||||
{
|
||||
if (s->act_in_cpp0x_mode)
|
||||
goto extstringlit;
|
||||
--YYCURSOR;
|
||||
BOOST_WAVE_RET(T_IDENTIFIER);
|
||||
}
|
||||
|
||||
([uU] | "u8") "R" ["]
|
||||
{
|
||||
if (s->act_in_cpp0x_mode)
|
||||
{
|
||||
rawstringdelim = "";
|
||||
goto extrawstringlit;
|
||||
}
|
||||
--YYCURSOR;
|
||||
BOOST_WAVE_RET(T_IDENTIFIER);
|
||||
}
|
||||
|
||||
([a-zA-Z_$] | UniversalChar) ([a-zA-Z_0-9$] | UniversalChar)*
|
||||
{ BOOST_WAVE_RET(T_IDENTIFIER); }
|
||||
|
||||
Pound PPSpace ( "include" | "include_next") PPSpace "<" (any\[\n\r>])+ ">"
|
||||
{ BOOST_WAVE_RET(T_PP_HHEADER); }
|
||||
|
||||
Pound PPSpace ( "include" | "include_next") PPSpace "\"" (any\[\n\r"])+ "\""
|
||||
{ BOOST_WAVE_RET(T_PP_QHEADER); }
|
||||
|
||||
Pound PPSpace ( "include" | "include_next") PPSpace
|
||||
{ BOOST_WAVE_RET(T_PP_INCLUDE); }
|
||||
|
||||
Pound PPSpace "if" { BOOST_WAVE_RET(T_PP_IF); }
|
||||
Pound PPSpace "ifdef" { BOOST_WAVE_RET(T_PP_IFDEF); }
|
||||
Pound PPSpace "ifndef" { BOOST_WAVE_RET(T_PP_IFNDEF); }
|
||||
Pound PPSpace "else" { BOOST_WAVE_RET(T_PP_ELSE); }
|
||||
Pound PPSpace "elif" { BOOST_WAVE_RET(T_PP_ELIF); }
|
||||
Pound PPSpace "endif" { BOOST_WAVE_RET(T_PP_ENDIF); }
|
||||
Pound PPSpace "define" { BOOST_WAVE_RET(T_PP_DEFINE); }
|
||||
Pound PPSpace "undef" { BOOST_WAVE_RET(T_PP_UNDEF); }
|
||||
Pound PPSpace "line" { BOOST_WAVE_RET(T_PP_LINE); }
|
||||
Pound PPSpace "error" { BOOST_WAVE_RET(T_PP_ERROR); }
|
||||
Pound PPSpace "pragma" { BOOST_WAVE_RET(T_PP_PRAGMA); }
|
||||
|
||||
Pound PPSpace "warning" { BOOST_WAVE_RET(T_PP_WARNING); }
|
||||
|
||||
Pound PPSpace "region" { BOOST_WAVE_RET(T_MSEXT_PP_REGION); }
|
||||
Pound PPSpace "endregion" { BOOST_WAVE_RET(T_MSEXT_PP_ENDREGION); }
|
||||
|
||||
[ \t\v\f]+
|
||||
{ BOOST_WAVE_RET(T_SPACE); }
|
||||
|
||||
Newline
|
||||
{
|
||||
s->line++;
|
||||
cursor.column = 1;
|
||||
BOOST_WAVE_RET(T_NEWLINE);
|
||||
}
|
||||
|
||||
"\000"
|
||||
{
|
||||
if (s->eof && cursor != s->eof)
|
||||
{
|
||||
BOOST_WAVE_UPDATE_CURSOR(); // adjust the input cursor
|
||||
(*s->error_proc)(s, lexing_exception::generic_lexing_error,
|
||||
"invalid character '\\000' in input stream");
|
||||
}
|
||||
BOOST_WAVE_RET(T_EOF);
|
||||
}
|
||||
|
||||
any { BOOST_WAVE_RET(TOKEN_FROM_ID(*s->tok, UnknownTokenType)); }
|
||||
|
||||
anyctrl
|
||||
{
|
||||
// flag the error
|
||||
BOOST_WAVE_UPDATE_CURSOR(); // adjust the input cursor
|
||||
(*s->error_proc)(s, lexing_exception::generic_lexing_error,
|
||||
"invalid character '\\%03o' in input stream", *--YYCURSOR);
|
||||
}
|
||||
*/
|
||||
|
||||
ccomment:
|
||||
/*!re2c
|
||||
"*/" { BOOST_WAVE_RET(T_CCOMMENT); }
|
||||
|
||||
Newline
|
||||
{
|
||||
/*if(cursor == s->eof) BOOST_WAVE_RET(T_EOF);*/
|
||||
/*s->tok = cursor; */
|
||||
s->line += count_backslash_newlines(s, cursor) +1;
|
||||
cursor.column = 1;
|
||||
goto ccomment;
|
||||
}
|
||||
|
||||
any { goto ccomment; }
|
||||
|
||||
"\000"
|
||||
{
|
||||
if(cursor == s->eof)
|
||||
{
|
||||
BOOST_WAVE_UPDATE_CURSOR(); // adjust the input cursor
|
||||
(*s->error_proc)(s, lexing_exception::generic_lexing_warning,
|
||||
"Unterminated 'C' style comment");
|
||||
}
|
||||
else
|
||||
{
|
||||
--YYCURSOR; // next call returns T_EOF
|
||||
BOOST_WAVE_UPDATE_CURSOR(); // adjust the input cursor
|
||||
(*s->error_proc)(s, lexing_exception::generic_lexing_error,
|
||||
"invalid character: '\\000' in input stream");
|
||||
}
|
||||
}
|
||||
|
||||
anyctrl
|
||||
{
|
||||
// flag the error
|
||||
BOOST_WAVE_UPDATE_CURSOR(); // adjust the input cursor
|
||||
(*s->error_proc)(s, lexing_exception::generic_lexing_error,
|
||||
"invalid character '\\%03o' in input stream", *--YYCURSOR);
|
||||
}
|
||||
*/
|
||||
|
||||
cppcomment:
|
||||
/*!re2c
|
||||
Newline
|
||||
{
|
||||
/*if(cursor == s->eof) BOOST_WAVE_RET(T_EOF); */
|
||||
/*s->tok = cursor; */
|
||||
s->line++;
|
||||
cursor.column = 1;
|
||||
BOOST_WAVE_RET(T_CPPCOMMENT);
|
||||
}
|
||||
|
||||
any { goto cppcomment; }
|
||||
|
||||
"\000"
|
||||
{
|
||||
if (s->eof && cursor != s->eof)
|
||||
{
|
||||
--YYCURSOR; // next call returns T_EOF
|
||||
BOOST_WAVE_UPDATE_CURSOR(); // adjust the input cursor
|
||||
(*s->error_proc)(s, lexing_exception::generic_lexing_error,
|
||||
"invalid character '\\000' in input stream");
|
||||
}
|
||||
|
||||
--YYCURSOR; // next call returns T_EOF
|
||||
if (!s->single_line_only)
|
||||
{
|
||||
BOOST_WAVE_UPDATE_CURSOR(); // adjust the input cursor
|
||||
(*s->error_proc)(s, lexing_exception::generic_lexing_warning,
|
||||
"Unterminated 'C++' style comment");
|
||||
}
|
||||
BOOST_WAVE_RET(T_CPPCOMMENT);
|
||||
}
|
||||
|
||||
anyctrl
|
||||
{
|
||||
// flag the error
|
||||
BOOST_WAVE_UPDATE_CURSOR(); // adjust the input cursor
|
||||
(*s->error_proc)(s, lexing_exception::generic_lexing_error,
|
||||
"invalid character '\\%03o' in input stream", *--YYCURSOR);
|
||||
}
|
||||
*/
|
||||
|
||||
/* this subscanner is called whenever a pp_number has been started */
|
||||
pp_number:
|
||||
{
|
||||
cursor = uchar_wrapper(s->tok = s->cur, s->column = s->curr_column);
|
||||
marker = uchar_wrapper(s->ptr);
|
||||
limit = uchar_wrapper(s->lim);
|
||||
|
||||
if (s->detect_pp_numbers) {
|
||||
/*!re2c
|
||||
"."? Digit (Digit | NonDigit | ExponentStart | ".")*
|
||||
{ BOOST_WAVE_RET(T_PP_NUMBER); }
|
||||
|
||||
// because we reached this point, then reset the cursor,
|
||||
// the pattern above should always match
|
||||
* { BOOST_ASSERT(false); }
|
||||
*/
|
||||
}
|
||||
else {
|
||||
/*!re2c
|
||||
((FractionalConstant ExponentPart?) | (Digit+ ExponentPart)) FloatingSuffix?
|
||||
{ BOOST_WAVE_RET(T_FLOATLIT); }
|
||||
|
||||
Integer { goto integer_suffix; }
|
||||
|
||||
// one of the above patterns should always match
|
||||
* { BOOST_ASSERT(false); }
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
/* this subscanner is called, whenever an Integer was recognized */
|
||||
integer_suffix:
|
||||
{
|
||||
if (s->enable_ms_extensions) {
|
||||
/*!re2c
|
||||
LongIntegerSuffix | MSLongIntegerSuffix
|
||||
{ BOOST_WAVE_RET(T_LONGINTLIT); }
|
||||
|
||||
IntegerSuffix?
|
||||
{ BOOST_WAVE_RET(T_INTLIT); }
|
||||
*/
|
||||
}
|
||||
else {
|
||||
/*!re2c
|
||||
LongIntegerSuffix
|
||||
{ BOOST_WAVE_RET(T_LONGINTLIT); }
|
||||
|
||||
IntegerSuffix?
|
||||
{ BOOST_WAVE_RET(T_INTLIT); }
|
||||
*/
|
||||
}
|
||||
|
||||
// re2c will complain about -Wmatch-empty-string above
|
||||
// it's OK because we've already matched an integer
|
||||
// and will return T_INTLIT
|
||||
}
|
||||
|
||||
/* this subscanner is invoked for C++0x extended character literals */
|
||||
extcharlit:
|
||||
{
|
||||
/*!re2c
|
||||
* {
|
||||
(*s->error_proc)(s, lexing_exception::generic_lexing_error,
|
||||
"Invalid character in raw string delimiter ('%c')", yych);
|
||||
}
|
||||
|
||||
((EscapeSequence | UniversalChar | any\[\n\r\\']) ['])
|
||||
{ BOOST_WAVE_RET(T_CHARLIT); }
|
||||
|
||||
any
|
||||
{ BOOST_WAVE_RET(TOKEN_FROM_ID(*s->tok, UnknownTokenType)); }
|
||||
*/
|
||||
}
|
||||
|
||||
/* this subscanner is invoked for C++0x extended character string literals */
|
||||
extstringlit:
|
||||
{
|
||||
/*!re2c
|
||||
* {
|
||||
(*s->error_proc)(s, lexing_exception::generic_lexing_error,
|
||||
"Invalid character in raw string delimiter ('%c')", yych);
|
||||
}
|
||||
|
||||
((EscapeSequence | UniversalChar | any\[\n\r\\"])* ["])
|
||||
{ BOOST_WAVE_RET(T_STRINGLIT); }
|
||||
|
||||
any
|
||||
{ BOOST_WAVE_RET(TOKEN_FROM_ID(*s->tok, UnknownTokenType)); }
|
||||
*/
|
||||
}
|
||||
|
||||
extrawstringlit:
|
||||
{
|
||||
// we have consumed the double quote but not the lparen
|
||||
// at this point we may see a delimiter
|
||||
|
||||
/*!re2c
|
||||
* {
|
||||
(*s->error_proc)(s, lexing_exception::generic_lexing_error,
|
||||
"Invalid character in raw string delimiter ('%c')", yych);
|
||||
}
|
||||
|
||||
// delimiters are any character but parentheses, backslash, and whitespace
|
||||
any\[()\\\t\v\f\r\n]
|
||||
{
|
||||
rawstringdelim += yych;
|
||||
if (rawstringdelim.size() > 16)
|
||||
{
|
||||
(*s->error_proc)(s, lexing_exception::generic_lexing_error,
|
||||
"Raw string delimiter of excessive length (\"%s\") in input stream",
|
||||
rawstringdelim.c_str());
|
||||
}
|
||||
goto extrawstringlit;
|
||||
}
|
||||
|
||||
"("
|
||||
{
|
||||
rawstringdelim = ")" + rawstringdelim;
|
||||
goto extrawstringbody;
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
extrawstringbody:
|
||||
{
|
||||
/*!re2c
|
||||
|
||||
* {
|
||||
(*s->error_proc)(s, lexing_exception::generic_lexing_error,
|
||||
"Invalid character in raw string body ('%c')", yych);
|
||||
}
|
||||
|
||||
Newline
|
||||
{
|
||||
s->line += count_backslash_newlines(s, cursor) +1;
|
||||
cursor.column = 1;
|
||||
goto extrawstringbody;
|
||||
}
|
||||
|
||||
(EscapeSequence | UniversalChar | any\["])
|
||||
{
|
||||
goto extrawstringbody;
|
||||
}
|
||||
|
||||
["]
|
||||
{
|
||||
// check to see if we have completed a delimiter
|
||||
if (string_type((char *)(YYCURSOR - rawstringdelim.size() - 1),
|
||||
(char *)(YYCURSOR - 1)) == rawstringdelim)
|
||||
{
|
||||
BOOST_WAVE_RET(T_RAWSTRINGLIT);
|
||||
} else {
|
||||
goto extrawstringbody;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
+416
@@ -0,0 +1,416 @@
|
||||
/*=============================================================================
|
||||
Boost.Wave: A Standard compliant C++ preprocessor library
|
||||
|
||||
Re2C based C++ lexer
|
||||
|
||||
http://www.boost.org/
|
||||
|
||||
Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost
|
||||
Software License, Version 1.0. (See accompanying file
|
||||
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
=============================================================================*/
|
||||
|
||||
#if !defined(BOOST_CPP_RE_HPP_B76C4F5E_63E9_4B8A_9975_EC32FA6BF027_INCLUDED)
|
||||
#define BOOST_CPP_RE_HPP_B76C4F5E_63E9_4B8A_9975_EC32FA6BF027_INCLUDED
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include <boost/wave/wave_config.hpp>
|
||||
#include <boost/wave/token_ids.hpp>
|
||||
#include <boost/wave/cpplexer/cpplexer_exceptions.hpp>
|
||||
|
||||
// this must occur after all of the includes and before any code appears
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
#include BOOST_ABI_PREFIX
|
||||
#endif
|
||||
|
||||
// suppress warnings about dependent classes not being exported from the dll
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4251 4231 4660)
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define YYCTYPE uchar
|
||||
#define YYCURSOR cursor
|
||||
#define YYLIMIT limit
|
||||
#define YYMARKER marker
|
||||
#define YYFILL(n) \
|
||||
{ \
|
||||
cursor = uchar_wrapper(fill(s, cursor), cursor.column); \
|
||||
limit = uchar_wrapper (s->lim); \
|
||||
} \
|
||||
/**/
|
||||
|
||||
#include <iosfwd>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define BOOST_WAVE_UPDATE_CURSOR() \
|
||||
{ \
|
||||
s->line += count_backslash_newlines(s, cursor); \
|
||||
s->curr_column = cursor.column; \
|
||||
s->cur = cursor; \
|
||||
s->lim = limit; \
|
||||
s->ptr = marker; \
|
||||
} \
|
||||
/**/
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define BOOST_WAVE_RET(i) \
|
||||
{ \
|
||||
BOOST_WAVE_UPDATE_CURSOR() \
|
||||
if (s->cur > s->lim) \
|
||||
return T_EOF; /* may happen for empty files */ \
|
||||
return (i); \
|
||||
} \
|
||||
/**/
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace boost {
|
||||
namespace wave {
|
||||
namespace cpplexer {
|
||||
namespace re2clex {
|
||||
|
||||
template<typename Iterator>
|
||||
struct Scanner;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// The scanner function to call whenever a new token is requested
|
||||
template<typename Iterator>
|
||||
BOOST_WAVE_DECL boost::wave::token_id scan(Scanner<Iterator> *s);
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Utility functions
|
||||
|
||||
#define RE2C_ASSERT BOOST_ASSERT
|
||||
|
||||
template<typename Iterator>
|
||||
int get_one_char(Scanner<Iterator> *s)
|
||||
{
|
||||
RE2C_ASSERT(s->first <= s->act && s->act <= s->last);
|
||||
if (s->act < s->last)
|
||||
return *(s->act)++;
|
||||
return -1;
|
||||
}
|
||||
|
||||
template<typename Iterator>
|
||||
std::ptrdiff_t rewind_stream (Scanner<Iterator> *s, int cnt)
|
||||
{
|
||||
std::advance(s->act, cnt);
|
||||
RE2C_ASSERT(s->first <= s->act && s->act <= s->last);
|
||||
return std::distance(s->first, s->act);
|
||||
}
|
||||
|
||||
template<typename Iterator>
|
||||
std::size_t get_first_eol_offset(Scanner<Iterator>* s)
|
||||
{
|
||||
if (!AQ_EMPTY(s->eol_offsets))
|
||||
{
|
||||
return s->eol_offsets->queue[s->eol_offsets->head];
|
||||
}
|
||||
else
|
||||
{
|
||||
return (unsigned int)-1;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Iterator>
|
||||
void adjust_eol_offsets(Scanner<Iterator>* s, std::size_t adjustment)
|
||||
{
|
||||
aq_queue q;
|
||||
std::size_t i;
|
||||
|
||||
if (!s->eol_offsets)
|
||||
s->eol_offsets = aq_create();
|
||||
|
||||
q = s->eol_offsets;
|
||||
|
||||
if (AQ_EMPTY(q))
|
||||
return;
|
||||
|
||||
i = q->head;
|
||||
while (i != q->tail)
|
||||
{
|
||||
if (adjustment > q->queue[i])
|
||||
q->queue[i] = 0;
|
||||
else
|
||||
q->queue[i] -= adjustment;
|
||||
++i;
|
||||
if (i == q->max_size)
|
||||
i = 0;
|
||||
}
|
||||
if (adjustment > q->queue[i])
|
||||
q->queue[i] = 0;
|
||||
else
|
||||
q->queue[i] -= adjustment;
|
||||
}
|
||||
|
||||
template<typename Iterator>
|
||||
int count_backslash_newlines(Scanner<Iterator> *s, uchar *cursor)
|
||||
{
|
||||
std::size_t diff, offset;
|
||||
int skipped = 0;
|
||||
|
||||
/* figure out how many backslash-newlines skipped over unknowingly. */
|
||||
diff = cursor - s->bot;
|
||||
offset = get_first_eol_offset(s);
|
||||
while (offset <= diff && offset != (unsigned int)-1)
|
||||
{
|
||||
skipped++;
|
||||
aq_pop(s->eol_offsets);
|
||||
offset = get_first_eol_offset(s);
|
||||
}
|
||||
return skipped;
|
||||
}
|
||||
|
||||
BOOST_WAVE_DECL bool is_backslash(uchar *p, uchar *end, int &len);
|
||||
|
||||
#define BOOST_WAVE_BSIZE 196608
|
||||
template<typename Iterator>
|
||||
uchar *fill(Scanner<Iterator> *s, uchar *cursor)
|
||||
{
|
||||
using namespace std; // some systems have memcpy etc. in namespace std
|
||||
if(!s->eof)
|
||||
{
|
||||
uchar* p;
|
||||
std::ptrdiff_t cnt = s->tok - s->bot;
|
||||
if(cnt)
|
||||
{
|
||||
if (NULL == s->lim)
|
||||
s->lim = s->top;
|
||||
size_t length = s->lim - s->tok;
|
||||
if(length > 0){
|
||||
memmove(s->bot, s->tok, length);
|
||||
}
|
||||
s->tok = s->cur = s->bot;
|
||||
s->ptr -= cnt;
|
||||
cursor -= cnt;
|
||||
s->lim -= cnt;
|
||||
adjust_eol_offsets(s, cnt);
|
||||
}
|
||||
|
||||
if((s->top - s->lim) < BOOST_WAVE_BSIZE)
|
||||
{
|
||||
uchar *buf = (uchar*) malloc(((s->lim - s->bot) + BOOST_WAVE_BSIZE)*sizeof(uchar));
|
||||
if (buf == 0)
|
||||
{
|
||||
(*s->error_proc)(s, lexing_exception::unexpected_error,
|
||||
"Out of memory!");
|
||||
|
||||
/* get the scanner to stop */
|
||||
*cursor = 0;
|
||||
return cursor;
|
||||
}
|
||||
|
||||
size_t length = s->lim - s->tok;
|
||||
if(length > 0){
|
||||
memmove(buf, s->tok, length);
|
||||
}
|
||||
s->tok = s->cur = buf;
|
||||
s->ptr = &buf[s->ptr - s->bot];
|
||||
cursor = &buf[cursor - s->bot];
|
||||
s->lim = &buf[s->lim - s->bot];
|
||||
s->top = &s->lim[BOOST_WAVE_BSIZE];
|
||||
free(s->bot);
|
||||
s->bot = buf;
|
||||
}
|
||||
|
||||
cnt = std::distance(s->act, s->last);
|
||||
if (cnt > BOOST_WAVE_BSIZE)
|
||||
cnt = BOOST_WAVE_BSIZE;
|
||||
uchar * dst = s->lim;
|
||||
for (std::ptrdiff_t idx = 0; idx < cnt; ++idx)
|
||||
{
|
||||
*dst++ = *s->act++;
|
||||
}
|
||||
|
||||
if (cnt != BOOST_WAVE_BSIZE)
|
||||
{
|
||||
s->eof = &s->lim[cnt]; *(s->eof)++ = '\0';
|
||||
}
|
||||
|
||||
/* backslash-newline erasing time */
|
||||
|
||||
/* first scan for backslash-newline and erase them */
|
||||
for (p = s->lim; p < s->lim + cnt - 2; ++p)
|
||||
{
|
||||
int len = 0;
|
||||
if (is_backslash(p, s->lim + cnt, len))
|
||||
{
|
||||
if (*(p+len) == '\n')
|
||||
{
|
||||
int offset = len + 1;
|
||||
memmove(p, p + offset, s->lim + cnt - p - offset);
|
||||
cnt -= offset;
|
||||
--p;
|
||||
aq_enqueue(s->eol_offsets, p - s->bot + 1);
|
||||
}
|
||||
else if (*(p+len) == '\r')
|
||||
{
|
||||
if (*(p+len+1) == '\n')
|
||||
{
|
||||
int offset = len + 2;
|
||||
memmove(p, p + offset, s->lim + cnt - p - offset);
|
||||
cnt -= offset;
|
||||
--p;
|
||||
}
|
||||
else
|
||||
{
|
||||
int offset = len + 1;
|
||||
memmove(p, p + offset, s->lim + cnt - p - offset);
|
||||
cnt -= offset;
|
||||
--p;
|
||||
}
|
||||
aq_enqueue(s->eol_offsets, p - s->bot + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* FIXME: the following code should be fixed to recognize correctly the
|
||||
trigraph backslash token */
|
||||
|
||||
/* check to see if what we just read ends in a backslash */
|
||||
if (cnt >= 2)
|
||||
{
|
||||
uchar last = s->lim[cnt-1];
|
||||
uchar last2 = s->lim[cnt-2];
|
||||
/* check \ EOB */
|
||||
if (last == '\\')
|
||||
{
|
||||
int next = get_one_char(s);
|
||||
/* check for \ \n or \ \r or \ \r \n straddling the border */
|
||||
if (next == '\n')
|
||||
{
|
||||
--cnt; /* chop the final \, we've already read the \n. */
|
||||
aq_enqueue(s->eol_offsets, cnt + (s->lim - s->bot));
|
||||
}
|
||||
else if (next == '\r')
|
||||
{
|
||||
int next2 = get_one_char(s);
|
||||
if (next2 == '\n')
|
||||
{
|
||||
--cnt; /* skip the backslash */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* rewind one, and skip one char */
|
||||
rewind_stream(s, -1);
|
||||
--cnt;
|
||||
}
|
||||
aq_enqueue(s->eol_offsets, cnt + (s->lim - s->bot));
|
||||
}
|
||||
else if (next != -1) /* -1 means end of file */
|
||||
{
|
||||
/* next was something else, so rewind the stream */
|
||||
rewind_stream(s, -1);
|
||||
}
|
||||
}
|
||||
/* check \ \r EOB */
|
||||
else if (last == '\r' && last2 == '\\')
|
||||
{
|
||||
int next = get_one_char(s);
|
||||
if (next == '\n')
|
||||
{
|
||||
cnt -= 2; /* skip the \ \r */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* rewind one, and skip two chars */
|
||||
rewind_stream(s, -1);
|
||||
cnt -= 2;
|
||||
}
|
||||
aq_enqueue(s->eol_offsets, cnt + (s->lim - s->bot));
|
||||
}
|
||||
/* check \ \n EOB */
|
||||
else if (last == '\n' && last2 == '\\')
|
||||
{
|
||||
cnt -= 2;
|
||||
aq_enqueue(s->eol_offsets, cnt + (s->lim - s->bot));
|
||||
}
|
||||
}
|
||||
|
||||
s->lim += cnt;
|
||||
if (s->eof) /* eof needs adjusting if we erased backslash-newlines */
|
||||
{
|
||||
s->eof = s->lim;
|
||||
*(s->eof)++ = '\0';
|
||||
}
|
||||
}
|
||||
return cursor;
|
||||
}
|
||||
#undef BOOST_WAVE_BSIZE
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Special wrapper class holding the current cursor position
|
||||
struct BOOST_WAVE_DECL uchar_wrapper
|
||||
{
|
||||
uchar_wrapper (uchar *base_cursor, std::size_t column = 1);
|
||||
|
||||
uchar_wrapper& operator++();
|
||||
|
||||
uchar_wrapper& operator--();
|
||||
|
||||
uchar operator* () const;
|
||||
|
||||
operator uchar *() const;
|
||||
|
||||
friend BOOST_WAVE_DECL std::ptrdiff_t
|
||||
operator- (uchar_wrapper const& lhs, uchar_wrapper const& rhs);
|
||||
|
||||
uchar *base_cursor;
|
||||
std::size_t column;
|
||||
};
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template<typename Iterator>
|
||||
boost::wave::token_id scan(Scanner<Iterator> *s)
|
||||
{
|
||||
BOOST_ASSERT(0 != s->error_proc); // error handler must be given
|
||||
|
||||
uchar_wrapper cursor (s->tok = s->cur, s->column = s->curr_column);
|
||||
uchar_wrapper marker (s->ptr);
|
||||
uchar_wrapper limit (s->lim);
|
||||
|
||||
typedef BOOST_WAVE_STRINGTYPE string_type;
|
||||
string_type rawstringdelim; // for use with C++11 raw string literals
|
||||
|
||||
// include the correct Re2C token definition rules
|
||||
#if (defined (__FreeBSD__) || defined (__DragonFly__) || defined (__OpenBSD__)) && defined (T_DIVIDE)
|
||||
#undef T_DIVIDE
|
||||
#endif
|
||||
#if BOOST_WAVE_USE_STRICT_LEXER != 0
|
||||
#include "strict_cpp_re.inc"
|
||||
#else
|
||||
#include "cpp_re.inc"
|
||||
#endif
|
||||
|
||||
} /* end of scan */
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
} // namespace re2clex
|
||||
} // namespace cpplexer
|
||||
} // namespace wave
|
||||
} // namespace boost
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#undef BOOST_WAVE_RET
|
||||
#undef YYCTYPE
|
||||
#undef YYCURSOR
|
||||
#undef YYLIMIT
|
||||
#undef YYMARKER
|
||||
#undef YYFILL
|
||||
|
||||
// the suffix header occurs after all of the code
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
#include BOOST_ABI_SUFFIX
|
||||
#endif
|
||||
|
||||
#endif // !defined(BOOST_CPP_RE_HPP_B76C4F5E_63E9_4B8A_9975_EC32FA6BF027_INCLUDED)
|
||||
+8126
File diff suppressed because it is too large
Load Diff
+430
@@ -0,0 +1,430 @@
|
||||
/*=============================================================================
|
||||
Boost.Wave: A Standard compliant C++ preprocessor library
|
||||
|
||||
Re2C based C++ lexer
|
||||
|
||||
http://www.boost.org/
|
||||
|
||||
Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost
|
||||
Software License, Version 1.0. (See accompanying file
|
||||
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
=============================================================================*/
|
||||
|
||||
#if !defined(BOOST_CPP_RE2C_LEXER_HPP_B81A2629_D5B1_4944_A97D_60254182B9A8_INCLUDED)
|
||||
#define BOOST_CPP_RE2C_LEXER_HPP_B81A2629_D5B1_4944_A97D_60254182B9A8_INCLUDED
|
||||
|
||||
#include <string>
|
||||
#include <cstdio>
|
||||
#include <cstdarg>
|
||||
#if defined(BOOST_SPIRIT_DEBUG)
|
||||
#include <iostream>
|
||||
#endif // defined(BOOST_SPIRIT_DEBUG)
|
||||
|
||||
#include <boost/concept_check.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include <boost/wave/wave_config.hpp>
|
||||
#include <boost/wave/language_support.hpp>
|
||||
#include <boost/wave/token_ids.hpp>
|
||||
#include <boost/wave/util/file_position.hpp>
|
||||
#include <boost/wave/cpplexer/validate_universal_char.hpp>
|
||||
#include <boost/wave/cpplexer/cpplexer_exceptions.hpp>
|
||||
#include <boost/wave/cpplexer/token_cache.hpp>
|
||||
#include <boost/wave/cpplexer/convert_trigraphs.hpp>
|
||||
|
||||
#include <boost/wave/cpplexer/cpp_lex_interface.hpp>
|
||||
#include <boost/wave/cpplexer/re2clex/scanner.hpp>
|
||||
#include <boost/wave/cpplexer/re2clex/cpp_re.hpp>
|
||||
#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
|
||||
#include <boost/wave/cpplexer/detect_include_guards.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/wave/cpplexer/cpp_lex_interface_generator.hpp>
|
||||
|
||||
// this must occur after all of the includes and before any code appears
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
#include BOOST_ABI_PREFIX
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
namespace boost {
|
||||
namespace wave {
|
||||
namespace cpplexer {
|
||||
namespace re2clex {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// encapsulation of the re2c based cpp lexer
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <typename IteratorT,
|
||||
typename PositionT = boost::wave::util::file_position_type,
|
||||
typename TokenT = lex_token<PositionT> >
|
||||
class lexer
|
||||
{
|
||||
public:
|
||||
typedef TokenT token_type;
|
||||
typedef typename token_type::string_type string_type;
|
||||
|
||||
lexer(IteratorT const &first, IteratorT const &last,
|
||||
PositionT const &pos, boost::wave::language_support language_);
|
||||
~lexer();
|
||||
|
||||
token_type& get(token_type&);
|
||||
void set_position(PositionT const &pos)
|
||||
{
|
||||
// set position has to change the file name and line number only
|
||||
filename = pos.get_file();
|
||||
scanner.line = pos.get_line();
|
||||
// scanner.column = scanner.curr_column = pos.get_column();
|
||||
scanner.file_name = filename.c_str();
|
||||
}
|
||||
#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
|
||||
bool has_include_guards(std::string& guard_name) const
|
||||
{
|
||||
return guards.detected(guard_name);
|
||||
}
|
||||
#endif
|
||||
|
||||
// error reporting from the re2c generated lexer
|
||||
static int report_error(Scanner<IteratorT> const* s, int code, char const *, ...);
|
||||
|
||||
private:
|
||||
static char const *tok_names[];
|
||||
|
||||
Scanner<IteratorT> scanner;
|
||||
string_type filename;
|
||||
string_type value;
|
||||
bool at_eof;
|
||||
boost::wave::language_support language;
|
||||
#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
|
||||
include_guards<token_type> guards;
|
||||
#endif
|
||||
|
||||
#if BOOST_WAVE_SUPPORT_THREADING == 0
|
||||
static token_cache<string_type> const cache;
|
||||
#else
|
||||
token_cache<string_type> const cache;
|
||||
#endif
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// initialize cpp lexer
|
||||
template <typename IteratorT, typename PositionT, typename TokenT>
|
||||
inline
|
||||
lexer<IteratorT, PositionT, TokenT>::lexer(IteratorT const &first,
|
||||
IteratorT const &last, PositionT const &pos,
|
||||
boost::wave::language_support language_)
|
||||
: scanner(first, last),
|
||||
filename(pos.get_file()), at_eof(false), language(language_)
|
||||
#if BOOST_WAVE_SUPPORT_THREADING != 0
|
||||
, cache()
|
||||
#endif
|
||||
{
|
||||
using namespace std; // some systems have memset in std
|
||||
scanner.line = pos.get_line();
|
||||
scanner.column = scanner.curr_column = pos.get_column();
|
||||
scanner.error_proc = report_error;
|
||||
scanner.file_name = filename.c_str();
|
||||
|
||||
#if BOOST_WAVE_SUPPORT_MS_EXTENSIONS != 0
|
||||
scanner.enable_ms_extensions = true;
|
||||
#else
|
||||
scanner.enable_ms_extensions = false;
|
||||
#endif
|
||||
|
||||
#if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
|
||||
scanner.act_in_c99_mode = boost::wave::need_c99(language_);
|
||||
#endif
|
||||
|
||||
#if BOOST_WAVE_SUPPORT_IMPORT_KEYWORD != 0
|
||||
scanner.enable_import_keyword = !boost::wave::need_c99(language_);
|
||||
#else
|
||||
scanner.enable_import_keyword = false;
|
||||
#endif
|
||||
|
||||
scanner.detect_pp_numbers = boost::wave::need_prefer_pp_numbers(language_);
|
||||
scanner.single_line_only = boost::wave::need_single_line(language_);
|
||||
|
||||
#if BOOST_WAVE_SUPPORT_CPP0X != 0
|
||||
scanner.act_in_cpp0x_mode = boost::wave::need_cpp0x(language_);
|
||||
#else
|
||||
scanner.act_in_cpp0x_mode = false;
|
||||
#endif
|
||||
|
||||
#if BOOST_WAVE_SUPPORT_CPP2A != 0
|
||||
scanner.act_in_cpp2a_mode = boost::wave::need_cpp2a(language_);
|
||||
scanner.act_in_cpp0x_mode = boost::wave::need_cpp2a(language_)
|
||||
|| boost::wave::need_cpp0x(language_);
|
||||
#else
|
||||
scanner.act_in_cpp2a_mode = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename IteratorT, typename PositionT, typename TokenT>
|
||||
inline
|
||||
lexer<IteratorT, PositionT, TokenT>::~lexer()
|
||||
{
|
||||
using namespace std; // some systems have free in std
|
||||
free(scanner.bot);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// get the next token from the input stream
|
||||
template <typename IteratorT, typename PositionT, typename TokenT>
|
||||
inline TokenT&
|
||||
lexer<IteratorT, PositionT, TokenT>::get(TokenT& result)
|
||||
{
|
||||
if (at_eof)
|
||||
return result = token_type(); // return T_EOI
|
||||
|
||||
std::size_t actline = scanner.line;
|
||||
token_id id = token_id(scan(&scanner));
|
||||
|
||||
switch (id) {
|
||||
case T_IDENTIFIER:
|
||||
// test identifier characters for validity (throws if invalid chars found)
|
||||
value = string_type((char const *)scanner.tok,
|
||||
scanner.cur-scanner.tok);
|
||||
if (!boost::wave::need_no_character_validation(language))
|
||||
impl::validate_identifier_name(value, actline, scanner.column, filename);
|
||||
break;
|
||||
|
||||
case T_STRINGLIT:
|
||||
case T_CHARLIT:
|
||||
case T_RAWSTRINGLIT:
|
||||
// test literal characters for validity (throws if invalid chars found)
|
||||
value = string_type((char const *)scanner.tok,
|
||||
scanner.cur-scanner.tok);
|
||||
if (boost::wave::need_convert_trigraphs(language))
|
||||
value = impl::convert_trigraphs(value);
|
||||
if (!boost::wave::need_no_character_validation(language))
|
||||
impl::validate_literal(value, actline, scanner.column, filename);
|
||||
break;
|
||||
|
||||
case T_PP_HHEADER:
|
||||
case T_PP_QHEADER:
|
||||
case T_PP_INCLUDE:
|
||||
// convert to the corresponding ..._next token, if appropriate
|
||||
{
|
||||
value = string_type((char const *)scanner.tok,
|
||||
scanner.cur-scanner.tok);
|
||||
|
||||
#if BOOST_WAVE_SUPPORT_INCLUDE_NEXT != 0
|
||||
// Skip '#' and whitespace and see whether we find an 'include_next' here.
|
||||
typename string_type::size_type start = value.find("include");
|
||||
if (value.compare(start, 12, "include_next", 12) == 0)
|
||||
id = token_id(id | AltTokenType);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
case T_LONGINTLIT: // supported in C++11, C99 and long_long mode
|
||||
value = string_type((char const *)scanner.tok,
|
||||
scanner.cur-scanner.tok);
|
||||
if (!boost::wave::need_long_long(language)) {
|
||||
// syntax error: not allowed in C++ mode
|
||||
BOOST_WAVE_LEXER_THROW(lexing_exception, invalid_long_long_literal,
|
||||
value.c_str(), actline, scanner.column, filename.c_str());
|
||||
}
|
||||
break;
|
||||
|
||||
case T_OCTALINT:
|
||||
case T_DECIMALINT:
|
||||
case T_HEXAINT:
|
||||
case T_INTLIT:
|
||||
case T_FLOATLIT:
|
||||
case T_FIXEDPOINTLIT:
|
||||
case T_CCOMMENT:
|
||||
case T_CPPCOMMENT:
|
||||
case T_SPACE:
|
||||
case T_SPACE2:
|
||||
case T_ANY:
|
||||
case T_PP_NUMBER:
|
||||
value = string_type((char const *)scanner.tok,
|
||||
scanner.cur-scanner.tok);
|
||||
break;
|
||||
|
||||
case T_EOF:
|
||||
// T_EOF is returned as a valid token, the next call will return T_EOI,
|
||||
// i.e. the actual end of input
|
||||
at_eof = true;
|
||||
value.clear();
|
||||
break;
|
||||
|
||||
case T_OR_TRIGRAPH:
|
||||
case T_XOR_TRIGRAPH:
|
||||
case T_LEFTBRACE_TRIGRAPH:
|
||||
case T_RIGHTBRACE_TRIGRAPH:
|
||||
case T_LEFTBRACKET_TRIGRAPH:
|
||||
case T_RIGHTBRACKET_TRIGRAPH:
|
||||
case T_COMPL_TRIGRAPH:
|
||||
case T_POUND_TRIGRAPH:
|
||||
if (boost::wave::need_convert_trigraphs(language)) {
|
||||
value = cache.get_token_value(BASEID_FROM_TOKEN(id));
|
||||
}
|
||||
else {
|
||||
value = string_type((char const *)scanner.tok,
|
||||
scanner.cur-scanner.tok);
|
||||
}
|
||||
break;
|
||||
|
||||
case T_ANY_TRIGRAPH:
|
||||
if (boost::wave::need_convert_trigraphs(language)) {
|
||||
value = impl::convert_trigraph(
|
||||
string_type((char const *)scanner.tok));
|
||||
}
|
||||
else {
|
||||
value = string_type((char const *)scanner.tok,
|
||||
scanner.cur-scanner.tok);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (CATEGORY_FROM_TOKEN(id) != EXTCATEGORY_FROM_TOKEN(id) ||
|
||||
IS_CATEGORY(id, UnknownTokenType))
|
||||
{
|
||||
value = string_type((char const *)scanner.tok,
|
||||
scanner.cur-scanner.tok);
|
||||
}
|
||||
else {
|
||||
value = cache.get_token_value(id);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// std::cerr << boost::wave::get_token_name(id) << ": " << value << std::endl;
|
||||
|
||||
// the re2c lexer reports the new line number for newline tokens
|
||||
result = token_type(id, value, PositionT(filename, actline, scanner.column));
|
||||
|
||||
#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
|
||||
return guards.detect_guard(result);
|
||||
#else
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename IteratorT, typename PositionT, typename TokenT>
|
||||
inline int
|
||||
lexer<IteratorT, PositionT, TokenT>::report_error(Scanner<IteratorT> const *s, int errcode,
|
||||
char const *msg, ...)
|
||||
{
|
||||
BOOST_ASSERT(0 != s);
|
||||
BOOST_ASSERT(0 != msg);
|
||||
|
||||
using namespace std; // some system have vsprintf in namespace std
|
||||
|
||||
char buffer[200]; // should be large enough
|
||||
va_list params;
|
||||
va_start(params, msg);
|
||||
vsprintf(buffer, msg, params);
|
||||
va_end(params);
|
||||
|
||||
BOOST_WAVE_LEXER_THROW_VAR(lexing_exception, errcode, buffer, s->line,
|
||||
s->column, s->file_name);
|
||||
// BOOST_UNREACHABLE_RETURN(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// lex_functor
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <typename IteratorT,
|
||||
typename PositionT = boost::wave::util::file_position_type,
|
||||
typename TokenT = typename lexer<IteratorT, PositionT>::token_type>
|
||||
class lex_functor
|
||||
: public lex_input_interface_generator<TokenT>
|
||||
{
|
||||
public:
|
||||
typedef TokenT token_type;
|
||||
|
||||
lex_functor(IteratorT const &first, IteratorT const &last,
|
||||
PositionT const &pos, boost::wave::language_support language)
|
||||
: re2c_lexer(first, last, pos, language)
|
||||
{}
|
||||
virtual ~lex_functor() {}
|
||||
|
||||
// get the next token from the input stream
|
||||
token_type& get(token_type& result) BOOST_OVERRIDE { return re2c_lexer.get(result); }
|
||||
void set_position(PositionT const &pos) BOOST_OVERRIDE { re2c_lexer.set_position(pos); }
|
||||
#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
|
||||
bool has_include_guards(std::string& guard_name) const BOOST_OVERRIDE
|
||||
{ return re2c_lexer.has_include_guards(guard_name); }
|
||||
#endif
|
||||
|
||||
private:
|
||||
lexer<IteratorT, PositionT, TokenT> re2c_lexer;
|
||||
};
|
||||
|
||||
#if BOOST_WAVE_SUPPORT_THREADING == 0
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template <typename IteratorT, typename PositionT, typename TokenT>
|
||||
token_cache<typename lexer<IteratorT, PositionT, TokenT>::string_type> const
|
||||
lexer<IteratorT, PositionT, TokenT>::cache =
|
||||
token_cache<typename lexer<IteratorT, PositionT, TokenT>::string_type>();
|
||||
#endif
|
||||
|
||||
} // namespace re2clex
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// The new_lexer_gen<>::new_lexer function (declared in cpp_lex_interface.hpp)
|
||||
// should be defined inline, if the lex_functor shouldn't be instantiated
|
||||
// separately from the lex_iterator.
|
||||
//
|
||||
// Separate (explicit) instantiation helps to reduce compilation time.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if BOOST_WAVE_SEPARATE_LEXER_INSTANTIATION != 0
|
||||
#define BOOST_WAVE_RE2C_NEW_LEXER_INLINE
|
||||
#else
|
||||
#define BOOST_WAVE_RE2C_NEW_LEXER_INLINE inline
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// The 'new_lexer' function allows the opaque generation of a new lexer object.
|
||||
// It is coupled to the iterator type to allow to decouple the lexer/iterator
|
||||
// configurations at compile time.
|
||||
//
|
||||
// This function is declared inside the cpp_lex_token.hpp file, which is
|
||||
// referenced by the source file calling the lexer and the source file, which
|
||||
// instantiates the lex_functor. But it is defined here, so it will be
|
||||
// instantiated only while compiling the source file, which instantiates the
|
||||
// lex_functor. While the cpp_re2c_token.hpp file may be included everywhere,
|
||||
// this file (cpp_re2c_lexer.hpp) should be included only once. This allows
|
||||
// to decouple the lexer interface from the lexer implementation and reduces
|
||||
// compilation time.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <typename IteratorT, typename PositionT, typename TokenT>
|
||||
BOOST_WAVE_RE2C_NEW_LEXER_INLINE
|
||||
lex_input_interface<TokenT> *
|
||||
new_lexer_gen<IteratorT, PositionT, TokenT>::new_lexer(IteratorT const &first,
|
||||
IteratorT const &last, PositionT const &pos,
|
||||
boost::wave::language_support language)
|
||||
{
|
||||
using re2clex::lex_functor;
|
||||
return new lex_functor<IteratorT, PositionT, TokenT>(first, last, pos, language);
|
||||
}
|
||||
|
||||
#undef BOOST_WAVE_RE2C_NEW_LEXER_INLINE
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
} // namespace cpplexer
|
||||
} // namespace wave
|
||||
} // namespace boost
|
||||
|
||||
// the suffix header occurs after all of the code
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
#include BOOST_ABI_SUFFIX
|
||||
#endif
|
||||
|
||||
#endif // !defined(BOOST_CPP_RE2C_LEXER_HPP_B81A2629_D5B1_4944_A97D_60254182B9A8_INCLUDED)
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
/*=============================================================================
|
||||
Boost.Wave: A Standard compliant C++ preprocessor library
|
||||
|
||||
http://www.boost.org/
|
||||
|
||||
Copyright (c) 2001 Daniel C. Nuffer.
|
||||
Copyright (c) 2001-2012 Hartmut Kaiser.
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
=============================================================================*/
|
||||
|
||||
#if !defined(BOOST_SCANNER_HPP_F4FB01EB_E75C_4537_A146_D34B9895EF37_INCLUDED)
|
||||
#define BOOST_SCANNER_HPP_F4FB01EB_E75C_4537_A146_D34B9895EF37_INCLUDED
|
||||
|
||||
#include <boost/wave/wave_config.hpp>
|
||||
#include <boost/wave/cpplexer/re2clex/aq.hpp>
|
||||
|
||||
// this must occur after all of the includes and before any code appears
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
#include BOOST_ABI_PREFIX
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
namespace boost {
|
||||
namespace wave {
|
||||
namespace cpplexer {
|
||||
namespace re2clex {
|
||||
|
||||
template<typename Iterator>
|
||||
struct Scanner;
|
||||
typedef unsigned char uchar;
|
||||
|
||||
template<typename Iterator>
|
||||
struct Scanner {
|
||||
typedef int (* ReportErrorProc)(struct Scanner const *, int errorcode,
|
||||
char const *, ...);
|
||||
|
||||
|
||||
Scanner(Iterator const & f, Iterator const & l)
|
||||
: first(f), act(f), last(l),
|
||||
bot(0), top(0), eof(0), tok(0), ptr(0), cur(0), lim(0),
|
||||
eol_offsets(aq_create())
|
||||
// remaining data members externally initialized
|
||||
{}
|
||||
|
||||
~Scanner()
|
||||
{
|
||||
aq_terminate(eol_offsets);
|
||||
}
|
||||
|
||||
Iterator first; /* start of input buffer */
|
||||
Iterator act; /* act position of input buffer */
|
||||
Iterator last; /* end (one past last char) of input buffer */
|
||||
uchar* bot; /* beginning of the current buffer */
|
||||
uchar* top; /* top of the current buffer */
|
||||
uchar* eof; /* when we read in the last buffer, will point 1 past the
|
||||
end of the file, otherwise 0 */
|
||||
uchar* tok; /* points to the beginning of the current token */
|
||||
uchar* ptr; /* used for YYMARKER - saves backtracking info */
|
||||
uchar* cur; /* saves the cursor (maybe is redundant with tok?) */
|
||||
uchar* lim; /* used for YYLIMIT - points to the end of the buffer */
|
||||
/* (lim == top) except for the last buffer, it points to
|
||||
the end of the input (lim == eof - 1) */
|
||||
std::size_t line; /* current line being lex'ed */
|
||||
std::size_t column; /* current token start column position */
|
||||
std::size_t curr_column; /* current column position */
|
||||
ReportErrorProc error_proc; /* must be != 0, this function is called to
|
||||
report an error */
|
||||
char const *file_name; /* name of the lex'ed file */
|
||||
aq_queue eol_offsets;
|
||||
bool enable_ms_extensions; /* enable MS extensions */
|
||||
bool act_in_c99_mode; /* lexer works in C99 mode */
|
||||
bool detect_pp_numbers; /* lexer should prefer to detect pp-numbers */
|
||||
bool enable_import_keyword; /* recognize import as a keyword */
|
||||
bool single_line_only; /* don't report missing eol's in C++ comments */
|
||||
bool act_in_cpp0x_mode; /* lexer works in C++11 mode */
|
||||
bool act_in_cpp2a_mode; /* lexer works in C++20 mode */
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
} // namespace re2clex
|
||||
} // namespace cpplexer
|
||||
} // namespace wave
|
||||
} // namespace boost
|
||||
|
||||
// the suffix header occurs after all of the code
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
#include BOOST_ABI_SUFFIX
|
||||
#endif
|
||||
|
||||
#endif // !defined(BOOST_SCANNER_HPP_F4FB01EB_E75C_4537_A146_D34B9895EF37_INCLUDED)
|
||||
+611
@@ -0,0 +1,611 @@
|
||||
/*=============================================================================
|
||||
Boost.Wave: A Standard compliant C++ preprocessor library
|
||||
|
||||
Copyright (c) 2001 Daniel C. Nuffer
|
||||
Copyright (c) 2001-2011 Hartmut Kaiser.
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
This is a strict lexer conforming to the Standard as close as possible.
|
||||
It does not allow the '$' to be part of identifiers. If you need the '$'
|
||||
character in identifiers please include the lexer definition provided
|
||||
in the cpp.re file.
|
||||
|
||||
TODO:
|
||||
handle errors better.
|
||||
=============================================================================*/
|
||||
|
||||
/*!re2c
|
||||
re2c:indent:string = " ";
|
||||
any = [\t\v\f\r\n\040-\377];
|
||||
anyctrl = [\001-\037];
|
||||
OctalDigit = [0-7];
|
||||
Digit = [0-9];
|
||||
HexDigit = [a-fA-F0-9];
|
||||
Integer = (("0" [xX] HexDigit+) | ("0" OctalDigit*) | ([1-9] Digit*));
|
||||
ExponentStart = [Ee] [+-];
|
||||
ExponentPart = [Ee] [+-]? Digit+;
|
||||
FractionalConstant = (Digit* "." Digit+) | (Digit+ ".");
|
||||
FloatingSuffix = [fF] [lL]? | [lL] [fF]?;
|
||||
IntegerSuffix = [uU] [lL]? | [lL] [uU]?;
|
||||
LongIntegerSuffix = [uU] ("ll" | "LL") | ("ll" | "LL") [uU]?;
|
||||
Backslash = [\\] | "??/";
|
||||
EscapeSequence = Backslash ([abfnrtv?'"] | Backslash | "x" HexDigit+ | OctalDigit OctalDigit? OctalDigit?);
|
||||
HexQuad = HexDigit HexDigit HexDigit HexDigit;
|
||||
UniversalChar = Backslash ("u" HexQuad | "U" HexQuad HexQuad);
|
||||
Newline = "\r\n" | "\n" | "\r";
|
||||
PPSpace = ([ \t\f\v]|("/*"(any\[*]|Newline|("*"+(any\[*/]|Newline)))*"*"+"/"))*;
|
||||
Pound = "#" | "??=" | "%:";
|
||||
NonDigit = [a-zA-Z_] | UniversalChar;
|
||||
*/
|
||||
|
||||
/*!re2c
|
||||
"/*" { goto ccomment; }
|
||||
"//" { goto cppcomment; }
|
||||
"."? Digit { goto pp_number; }
|
||||
|
||||
"alignas" { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_ALIGNAS : T_IDENTIFIER); }
|
||||
"alignof" { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_ALIGNOF : T_IDENTIFIER); }
|
||||
"asm" { BOOST_WAVE_RET(T_ASM); }
|
||||
"auto" { BOOST_WAVE_RET(T_AUTO); }
|
||||
"bool" { BOOST_WAVE_RET(T_BOOL); }
|
||||
"break" { BOOST_WAVE_RET(T_BREAK); }
|
||||
"case" { BOOST_WAVE_RET(T_CASE); }
|
||||
"catch" { BOOST_WAVE_RET(T_CATCH); }
|
||||
"char" { BOOST_WAVE_RET(T_CHAR); }
|
||||
"char8_t" { BOOST_WAVE_RET(s->act_in_cpp2a_mode ? T_CHAR8_T : T_IDENTIFIER); }
|
||||
"char16_t" { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_CHAR16_T : T_IDENTIFIER); }
|
||||
"char32_t" { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_CHAR32_T : T_IDENTIFIER); }
|
||||
"class" { BOOST_WAVE_RET(T_CLASS); }
|
||||
"concept" { BOOST_WAVE_RET(s->act_in_cpp2a_mode ? T_CONCEPT : T_IDENTIFIER); }
|
||||
"const" { BOOST_WAVE_RET(T_CONST); }
|
||||
"consteval" { BOOST_WAVE_RET(s->act_in_cpp2a_mode ? T_CONSTEVAL : T_IDENTIFIER); }
|
||||
"constexpr" { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_CONSTEXPR : T_IDENTIFIER); }
|
||||
"constinit" { BOOST_WAVE_RET(s->act_in_cpp2a_mode ? T_CONSTINIT : T_IDENTIFIER); }
|
||||
"const_cast" { BOOST_WAVE_RET(T_CONSTCAST); }
|
||||
"continue" { BOOST_WAVE_RET(T_CONTINUE); }
|
||||
"co_await" { BOOST_WAVE_RET(s->act_in_cpp2a_mode ? T_CO_AWAIT : T_IDENTIFIER); }
|
||||
"co_return" { BOOST_WAVE_RET(s->act_in_cpp2a_mode ? T_CO_RETURN : T_IDENTIFIER); }
|
||||
"co_yield" { BOOST_WAVE_RET(s->act_in_cpp2a_mode ? T_CO_YIELD : T_IDENTIFIER); }
|
||||
"decltype" { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_DECLTYPE : T_IDENTIFIER); }
|
||||
"default" { BOOST_WAVE_RET(T_DEFAULT); }
|
||||
"delete" { BOOST_WAVE_RET(T_DELETE); }
|
||||
"do" { BOOST_WAVE_RET(T_DO); }
|
||||
"double" { BOOST_WAVE_RET(T_DOUBLE); }
|
||||
"dynamic_cast" { BOOST_WAVE_RET(T_DYNAMICCAST); }
|
||||
"else" { BOOST_WAVE_RET(T_ELSE); }
|
||||
"enum" { BOOST_WAVE_RET(T_ENUM); }
|
||||
"explicit" { BOOST_WAVE_RET(T_EXPLICIT); }
|
||||
"export" { BOOST_WAVE_RET(T_EXPORT); }
|
||||
"extern" { BOOST_WAVE_RET(T_EXTERN); }
|
||||
"false" { BOOST_WAVE_RET(T_FALSE); }
|
||||
"float" { BOOST_WAVE_RET(T_FLOAT); }
|
||||
"for" { BOOST_WAVE_RET(T_FOR); }
|
||||
"friend" { BOOST_WAVE_RET(T_FRIEND); }
|
||||
"goto" { BOOST_WAVE_RET(T_GOTO); }
|
||||
"if" { BOOST_WAVE_RET(T_IF); }
|
||||
"import" { BOOST_WAVE_RET(s->enable_import_keyword ? T_IMPORT : T_IDENTIFIER); }
|
||||
"inline" { BOOST_WAVE_RET(T_INLINE); }
|
||||
"int" { BOOST_WAVE_RET(T_INT); }
|
||||
"long" { BOOST_WAVE_RET(T_LONG); }
|
||||
"mutable" { BOOST_WAVE_RET(T_MUTABLE); }
|
||||
"namespace" { BOOST_WAVE_RET(T_NAMESPACE); }
|
||||
"new" { BOOST_WAVE_RET(T_NEW); }
|
||||
"noexcept" { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_NOEXCEPT : T_IDENTIFIER); }
|
||||
"nullptr" { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_NULLPTR : T_IDENTIFIER); }
|
||||
"operator" { BOOST_WAVE_RET(T_OPERATOR); }
|
||||
"private" { BOOST_WAVE_RET(T_PRIVATE); }
|
||||
"protected" { BOOST_WAVE_RET(T_PROTECTED); }
|
||||
"public" { BOOST_WAVE_RET(T_PUBLIC); }
|
||||
"register" { BOOST_WAVE_RET(T_REGISTER); }
|
||||
"reinterpret_cast" { BOOST_WAVE_RET(T_REINTERPRETCAST); }
|
||||
"requires" { BOOST_WAVE_RET(s->act_in_cpp2a_mode ? T_REQUIRES : T_IDENTIFIER); }
|
||||
"return" { BOOST_WAVE_RET(T_RETURN); }
|
||||
"short" { BOOST_WAVE_RET(T_SHORT); }
|
||||
"signed" { BOOST_WAVE_RET(T_SIGNED); }
|
||||
"sizeof" { BOOST_WAVE_RET(T_SIZEOF); }
|
||||
"static" { BOOST_WAVE_RET(T_STATIC); }
|
||||
"static_cast" { BOOST_WAVE_RET(T_STATICCAST); }
|
||||
"static_assert" { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_STATICASSERT : T_IDENTIFIER); }
|
||||
"struct" { BOOST_WAVE_RET(T_STRUCT); }
|
||||
"switch" { BOOST_WAVE_RET(T_SWITCH); }
|
||||
"template" { BOOST_WAVE_RET(T_TEMPLATE); }
|
||||
"this" { BOOST_WAVE_RET(T_THIS); }
|
||||
"thread_local" { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_THREADLOCAL : T_IDENTIFIER); }
|
||||
"throw" { BOOST_WAVE_RET(T_THROW); }
|
||||
"true" { BOOST_WAVE_RET(T_TRUE); }
|
||||
"try" { BOOST_WAVE_RET(T_TRY); }
|
||||
"typedef" { BOOST_WAVE_RET(T_TYPEDEF); }
|
||||
"typeid" { BOOST_WAVE_RET(T_TYPEID); }
|
||||
"typename" { BOOST_WAVE_RET(T_TYPENAME); }
|
||||
"union" { BOOST_WAVE_RET(T_UNION); }
|
||||
"unsigned" { BOOST_WAVE_RET(T_UNSIGNED); }
|
||||
"using" { BOOST_WAVE_RET(T_USING); }
|
||||
"virtual" { BOOST_WAVE_RET(T_VIRTUAL); }
|
||||
"void" { BOOST_WAVE_RET(T_VOID); }
|
||||
"volatile" { BOOST_WAVE_RET(T_VOLATILE); }
|
||||
"wchar_t" { BOOST_WAVE_RET(T_WCHART); }
|
||||
"while" { BOOST_WAVE_RET(T_WHILE); }
|
||||
|
||||
"__int8" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_INT8 : T_IDENTIFIER); }
|
||||
"__int16" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_INT16 : T_IDENTIFIER); }
|
||||
"__int32" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_INT32 : T_IDENTIFIER); }
|
||||
"__int64" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_INT64 : T_IDENTIFIER); }
|
||||
"_"? "_based" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_BASED : T_IDENTIFIER); }
|
||||
"_"? "_declspec" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_DECLSPEC : T_IDENTIFIER); }
|
||||
"_"? "_cdecl" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_CDECL : T_IDENTIFIER); }
|
||||
"_"? "_fastcall" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_FASTCALL : T_IDENTIFIER); }
|
||||
"_"? "_stdcall" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_STDCALL : T_IDENTIFIER); }
|
||||
"__try" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_TRY : T_IDENTIFIER); }
|
||||
"__except" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_EXCEPT : T_IDENTIFIER); }
|
||||
"__finally" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_FINALLY : T_IDENTIFIER); }
|
||||
"__leave" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_LEAVE : T_IDENTIFIER); }
|
||||
"_"? "_inline" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_INLINE : T_IDENTIFIER); }
|
||||
"_"? "_asm" { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_ASM : T_IDENTIFIER); }
|
||||
|
||||
"{" { BOOST_WAVE_RET(T_LEFTBRACE); }
|
||||
"??<" { BOOST_WAVE_RET(T_LEFTBRACE_TRIGRAPH); }
|
||||
"<%" { BOOST_WAVE_RET(T_LEFTBRACE_ALT); }
|
||||
"}" { BOOST_WAVE_RET(T_RIGHTBRACE); }
|
||||
"??>" { BOOST_WAVE_RET(T_RIGHTBRACE_TRIGRAPH); }
|
||||
"%>" { BOOST_WAVE_RET(T_RIGHTBRACE_ALT); }
|
||||
"[" { BOOST_WAVE_RET(T_LEFTBRACKET); }
|
||||
"??(" { BOOST_WAVE_RET(T_LEFTBRACKET_TRIGRAPH); }
|
||||
"<:" { BOOST_WAVE_RET(T_LEFTBRACKET_ALT); }
|
||||
"]" { BOOST_WAVE_RET(T_RIGHTBRACKET); }
|
||||
"??)" { BOOST_WAVE_RET(T_RIGHTBRACKET_TRIGRAPH); }
|
||||
":>" { BOOST_WAVE_RET(T_RIGHTBRACKET_ALT); }
|
||||
"#" { BOOST_WAVE_RET(T_POUND); }
|
||||
"%:" { BOOST_WAVE_RET(T_POUND_ALT); }
|
||||
"??=" { BOOST_WAVE_RET(T_POUND_TRIGRAPH); }
|
||||
"##" { BOOST_WAVE_RET(T_POUND_POUND); }
|
||||
"#??=" { BOOST_WAVE_RET(T_POUND_POUND_TRIGRAPH); }
|
||||
"??=#" { BOOST_WAVE_RET(T_POUND_POUND_TRIGRAPH); }
|
||||
"??=??=" { BOOST_WAVE_RET(T_POUND_POUND_TRIGRAPH); }
|
||||
"%:%:" { BOOST_WAVE_RET(T_POUND_POUND_ALT); }
|
||||
"(" { BOOST_WAVE_RET(T_LEFTPAREN); }
|
||||
")" { BOOST_WAVE_RET(T_RIGHTPAREN); }
|
||||
";" { BOOST_WAVE_RET(T_SEMICOLON); }
|
||||
":" { BOOST_WAVE_RET(T_COLON); }
|
||||
"..." { BOOST_WAVE_RET(T_ELLIPSIS); }
|
||||
"?" { BOOST_WAVE_RET(T_QUESTION_MARK); }
|
||||
"::"
|
||||
{
|
||||
if (s->act_in_c99_mode) {
|
||||
--YYCURSOR;
|
||||
BOOST_WAVE_RET(T_COLON);
|
||||
}
|
||||
else {
|
||||
BOOST_WAVE_RET(T_COLON_COLON);
|
||||
}
|
||||
}
|
||||
"." { BOOST_WAVE_RET(T_DOT); }
|
||||
".*"
|
||||
{
|
||||
if (s->act_in_c99_mode) {
|
||||
--YYCURSOR;
|
||||
BOOST_WAVE_RET(T_DOT);
|
||||
}
|
||||
else {
|
||||
BOOST_WAVE_RET(T_DOTSTAR);
|
||||
}
|
||||
}
|
||||
"+" { BOOST_WAVE_RET(T_PLUS); }
|
||||
"-" { BOOST_WAVE_RET(T_MINUS); }
|
||||
"*" { BOOST_WAVE_RET(T_STAR); }
|
||||
"/" { BOOST_WAVE_RET(T_DIVIDE); }
|
||||
"%" { BOOST_WAVE_RET(T_PERCENT); }
|
||||
"^" { BOOST_WAVE_RET(T_XOR); }
|
||||
"??'" { BOOST_WAVE_RET(T_XOR_TRIGRAPH); }
|
||||
"xor" { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_XOR_ALT); }
|
||||
"&" { BOOST_WAVE_RET(T_AND); }
|
||||
"bitand" { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_AND_ALT); }
|
||||
"|" { BOOST_WAVE_RET(T_OR); }
|
||||
"bitor" { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_OR_ALT); }
|
||||
"??!" { BOOST_WAVE_RET(T_OR_TRIGRAPH); }
|
||||
"~" { BOOST_WAVE_RET(T_COMPL); }
|
||||
"??-" { BOOST_WAVE_RET(T_COMPL_TRIGRAPH); }
|
||||
"compl" { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_COMPL_ALT); }
|
||||
"!" { BOOST_WAVE_RET(T_NOT); }
|
||||
"not" { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_NOT_ALT); }
|
||||
"=" { BOOST_WAVE_RET(T_ASSIGN); }
|
||||
"<" { BOOST_WAVE_RET(T_LESS); }
|
||||
">" { BOOST_WAVE_RET(T_GREATER); }
|
||||
"+=" { BOOST_WAVE_RET(T_PLUSASSIGN); }
|
||||
"-=" { BOOST_WAVE_RET(T_MINUSASSIGN); }
|
||||
"*=" { BOOST_WAVE_RET(T_STARASSIGN); }
|
||||
"/=" { BOOST_WAVE_RET(T_DIVIDEASSIGN); }
|
||||
"%=" { BOOST_WAVE_RET(T_PERCENTASSIGN); }
|
||||
"^=" { BOOST_WAVE_RET(T_XORASSIGN); }
|
||||
"xor_eq" { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_XORASSIGN_ALT); }
|
||||
"??'=" { BOOST_WAVE_RET(T_XORASSIGN_TRIGRAPH); }
|
||||
"&=" { BOOST_WAVE_RET(T_ANDASSIGN); }
|
||||
"and_eq" { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_ANDASSIGN_ALT); }
|
||||
"|=" { BOOST_WAVE_RET(T_ORASSIGN); }
|
||||
"or_eq" { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_ORASSIGN_ALT); }
|
||||
"??!=" { BOOST_WAVE_RET(T_ORASSIGN_TRIGRAPH); }
|
||||
"<<" { BOOST_WAVE_RET(T_SHIFTLEFT); }
|
||||
">>" { BOOST_WAVE_RET(T_SHIFTRIGHT); }
|
||||
">>=" { BOOST_WAVE_RET(T_SHIFTRIGHTASSIGN); }
|
||||
"<<=" { BOOST_WAVE_RET(T_SHIFTLEFTASSIGN); }
|
||||
"==" { BOOST_WAVE_RET(T_EQUAL); }
|
||||
"!=" { BOOST_WAVE_RET(T_NOTEQUAL); }
|
||||
"not_eq" { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_NOTEQUAL_ALT); }
|
||||
"<=>"
|
||||
{
|
||||
if (s->act_in_cpp2a_mode) {
|
||||
BOOST_WAVE_RET(T_SPACESHIP);
|
||||
}
|
||||
else {
|
||||
--YYCURSOR;
|
||||
BOOST_WAVE_RET(T_LESSEQUAL);
|
||||
}
|
||||
}
|
||||
"<=" { BOOST_WAVE_RET(T_LESSEQUAL); }
|
||||
">=" { BOOST_WAVE_RET(T_GREATEREQUAL); }
|
||||
"&&" { BOOST_WAVE_RET(T_ANDAND); }
|
||||
"and" { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_ANDAND_ALT); }
|
||||
"||" { BOOST_WAVE_RET(T_OROR); }
|
||||
"??!|" { BOOST_WAVE_RET(T_OROR_TRIGRAPH); }
|
||||
"|??!" { BOOST_WAVE_RET(T_OROR_TRIGRAPH); }
|
||||
"or" { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_OROR_ALT); }
|
||||
"??!??!" { BOOST_WAVE_RET(T_OROR_TRIGRAPH); }
|
||||
"++" { BOOST_WAVE_RET(T_PLUSPLUS); }
|
||||
"--" { BOOST_WAVE_RET(T_MINUSMINUS); }
|
||||
"," { BOOST_WAVE_RET(T_COMMA); }
|
||||
"->*"
|
||||
{
|
||||
if (s->act_in_c99_mode) {
|
||||
--YYCURSOR;
|
||||
BOOST_WAVE_RET(T_ARROW);
|
||||
}
|
||||
else {
|
||||
BOOST_WAVE_RET(T_ARROWSTAR);
|
||||
}
|
||||
}
|
||||
"->" { BOOST_WAVE_RET(T_ARROW); }
|
||||
"??/" { BOOST_WAVE_RET(T_ANY_TRIGRAPH); }
|
||||
|
||||
"L"? (['] (EscapeSequence | UniversalChar | any\[\n\r\\'])+ ['])
|
||||
{ BOOST_WAVE_RET(T_CHARLIT); }
|
||||
|
||||
"L"? (["] (EscapeSequence | UniversalChar | any\[\n\r\\"])* ["])
|
||||
{ BOOST_WAVE_RET(T_STRINGLIT); }
|
||||
|
||||
"L"? "R" ["]
|
||||
{
|
||||
if (s->act_in_cpp0x_mode)
|
||||
{
|
||||
rawstringdelim = "";
|
||||
goto extrawstringlit;
|
||||
}
|
||||
--YYCURSOR;
|
||||
BOOST_WAVE_RET(T_IDENTIFIER);
|
||||
}
|
||||
|
||||
[uU] [']
|
||||
{
|
||||
if (s->act_in_cpp0x_mode)
|
||||
goto extcharlit;
|
||||
--YYCURSOR;
|
||||
BOOST_WAVE_RET(T_IDENTIFIER);
|
||||
}
|
||||
|
||||
([uU] | "u8") ["]
|
||||
{
|
||||
if (s->act_in_cpp0x_mode)
|
||||
goto extstringlit;
|
||||
--YYCURSOR;
|
||||
BOOST_WAVE_RET(T_IDENTIFIER);
|
||||
}
|
||||
|
||||
([uU] | "u8") "R" ["]
|
||||
{
|
||||
if (s->act_in_cpp0x_mode)
|
||||
{
|
||||
rawstringdelim = "";
|
||||
goto extrawstringlit;
|
||||
}
|
||||
--YYCURSOR;
|
||||
BOOST_WAVE_RET(T_IDENTIFIER);
|
||||
}
|
||||
|
||||
([a-zA-Z_] | UniversalChar) ([a-zA-Z_0-9] | UniversalChar)*
|
||||
{ BOOST_WAVE_RET(T_IDENTIFIER); }
|
||||
|
||||
Pound PPSpace ( "include" | "include_next") PPSpace "<" (any\[\n\r>])+ ">"
|
||||
{ BOOST_WAVE_RET(T_PP_HHEADER); }
|
||||
|
||||
Pound PPSpace ( "include" | "include_next") PPSpace "\"" (any\[\n\r"])+ "\""
|
||||
{ BOOST_WAVE_RET(T_PP_QHEADER); }
|
||||
|
||||
Pound PPSpace ( "include" | "include_next") PPSpace
|
||||
{ BOOST_WAVE_RET(T_PP_INCLUDE); }
|
||||
|
||||
Pound PPSpace "if" { BOOST_WAVE_RET(T_PP_IF); }
|
||||
Pound PPSpace "ifdef" { BOOST_WAVE_RET(T_PP_IFDEF); }
|
||||
Pound PPSpace "ifndef" { BOOST_WAVE_RET(T_PP_IFNDEF); }
|
||||
Pound PPSpace "else" { BOOST_WAVE_RET(T_PP_ELSE); }
|
||||
Pound PPSpace "elif" { BOOST_WAVE_RET(T_PP_ELIF); }
|
||||
Pound PPSpace "endif" { BOOST_WAVE_RET(T_PP_ENDIF); }
|
||||
Pound PPSpace "define" { BOOST_WAVE_RET(T_PP_DEFINE); }
|
||||
Pound PPSpace "undef" { BOOST_WAVE_RET(T_PP_UNDEF); }
|
||||
Pound PPSpace "line" { BOOST_WAVE_RET(T_PP_LINE); }
|
||||
Pound PPSpace "error" { BOOST_WAVE_RET(T_PP_ERROR); }
|
||||
Pound PPSpace "pragma" { BOOST_WAVE_RET(T_PP_PRAGMA); }
|
||||
|
||||
Pound PPSpace "warning" { BOOST_WAVE_RET(T_PP_WARNING); }
|
||||
|
||||
Pound PPSpace "region" { BOOST_WAVE_RET(T_MSEXT_PP_REGION); }
|
||||
Pound PPSpace "endregion" { BOOST_WAVE_RET(T_MSEXT_PP_ENDREGION); }
|
||||
|
||||
[ \t\v\f]+
|
||||
{ BOOST_WAVE_RET(T_SPACE); }
|
||||
|
||||
Newline
|
||||
{
|
||||
s->line++;
|
||||
cursor.column = 1;
|
||||
BOOST_WAVE_RET(T_NEWLINE);
|
||||
}
|
||||
|
||||
"\000"
|
||||
{
|
||||
if (s->eof && cursor != s->eof)
|
||||
{
|
||||
BOOST_WAVE_UPDATE_CURSOR(); // adjust the input cursor
|
||||
(*s->error_proc)(s, lexing_exception::generic_lexing_error,
|
||||
"invalid character '\\000' in input stream");
|
||||
}
|
||||
BOOST_WAVE_RET(T_EOF);
|
||||
}
|
||||
|
||||
any { BOOST_WAVE_RET(TOKEN_FROM_ID(*s->tok, UnknownTokenType)); }
|
||||
|
||||
anyctrl
|
||||
{
|
||||
// flag the error
|
||||
BOOST_WAVE_UPDATE_CURSOR(); // adjust the input cursor
|
||||
(*s->error_proc)(s, lexing_exception::generic_lexing_error,
|
||||
"invalid character '\\%03o' in input stream", *--YYCURSOR);
|
||||
}
|
||||
*/
|
||||
|
||||
ccomment:
|
||||
/*!re2c
|
||||
"*/" { BOOST_WAVE_RET(T_CCOMMENT); }
|
||||
|
||||
Newline
|
||||
{
|
||||
/*if(cursor == s->eof) BOOST_WAVE_RET(T_EOF);*/
|
||||
/*s->tok = cursor; */
|
||||
s->line += count_backslash_newlines(s, cursor) +1;
|
||||
cursor.column = 1;
|
||||
goto ccomment;
|
||||
}
|
||||
|
||||
any { goto ccomment; }
|
||||
|
||||
"\000"
|
||||
{
|
||||
if(cursor == s->eof)
|
||||
{
|
||||
BOOST_WAVE_UPDATE_CURSOR(); // adjust the input cursor
|
||||
(*s->error_proc)(s, lexing_exception::generic_lexing_warning,
|
||||
"Unterminated 'C' style comment");
|
||||
}
|
||||
else
|
||||
{
|
||||
--YYCURSOR; // next call returns T_EOF
|
||||
BOOST_WAVE_UPDATE_CURSOR(); // adjust the input cursor
|
||||
(*s->error_proc)(s, lexing_exception::generic_lexing_error,
|
||||
"invalid character: '\\000' in input stream");
|
||||
}
|
||||
}
|
||||
|
||||
anyctrl
|
||||
{
|
||||
// flag the error
|
||||
BOOST_WAVE_UPDATE_CURSOR(); // adjust the input cursor
|
||||
(*s->error_proc)(s, lexing_exception::generic_lexing_error,
|
||||
"invalid character '\\%03o' in input stream", *--YYCURSOR);
|
||||
}
|
||||
*/
|
||||
|
||||
cppcomment:
|
||||
/*!re2c
|
||||
Newline
|
||||
{
|
||||
/*if(cursor == s->eof) BOOST_WAVE_RET(T_EOF); */
|
||||
/*s->tok = cursor; */
|
||||
s->line++;
|
||||
cursor.column = 1;
|
||||
BOOST_WAVE_RET(T_CPPCOMMENT);
|
||||
}
|
||||
|
||||
any { goto cppcomment; }
|
||||
|
||||
"\000"
|
||||
{
|
||||
if (s->eof && cursor != s->eof)
|
||||
{
|
||||
--YYCURSOR; // next call returns T_EOF
|
||||
BOOST_WAVE_UPDATE_CURSOR(); // adjust the input cursor
|
||||
(*s->error_proc)(s, lexing_exception::generic_lexing_error,
|
||||
"invalid character '\\000' in input stream");
|
||||
}
|
||||
|
||||
--YYCURSOR; // next call returns T_EOF
|
||||
if (!s->single_line_only)
|
||||
{
|
||||
BOOST_WAVE_UPDATE_CURSOR(); // adjust the input cursor
|
||||
(*s->error_proc)(s, lexing_exception::generic_lexing_warning,
|
||||
"Unterminated 'C++' style comment");
|
||||
}
|
||||
BOOST_WAVE_RET(T_CPPCOMMENT);
|
||||
}
|
||||
|
||||
anyctrl
|
||||
{
|
||||
// flag the error
|
||||
BOOST_WAVE_UPDATE_CURSOR(); // adjust the input cursor
|
||||
(*s->error_proc)(s, lexing_exception::generic_lexing_error,
|
||||
"invalid character '\\%03o' in input stream", *--YYCURSOR);
|
||||
}
|
||||
*/
|
||||
|
||||
/* this subscanner is called whenever a pp_number has been started */
|
||||
pp_number:
|
||||
{
|
||||
cursor = uchar_wrapper(s->tok = s->cur, s->column = s->curr_column);
|
||||
marker = uchar_wrapper(s->ptr);
|
||||
limit = uchar_wrapper(s->lim);
|
||||
|
||||
if (s->detect_pp_numbers) {
|
||||
/*!re2c
|
||||
"."? Digit (Digit | NonDigit | ExponentStart | ".")*
|
||||
{ BOOST_WAVE_RET(T_PP_NUMBER); }
|
||||
|
||||
* { BOOST_ASSERT(false); }
|
||||
*/
|
||||
}
|
||||
else {
|
||||
/*!re2c
|
||||
((FractionalConstant ExponentPart?) | (Digit+ ExponentPart)) FloatingSuffix?
|
||||
{ BOOST_WAVE_RET(T_FLOATLIT); }
|
||||
|
||||
Integer { goto integer_suffix; }
|
||||
|
||||
* { BOOST_ASSERT(false); }
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
/* this subscanner is called, whenever an Integer was recognized */
|
||||
integer_suffix:
|
||||
{
|
||||
if (s->enable_ms_extensions) {
|
||||
/*!re2c
|
||||
LongIntegerSuffix | "i64"
|
||||
{ BOOST_WAVE_RET(T_LONGINTLIT); }
|
||||
|
||||
IntegerSuffix?
|
||||
{ BOOST_WAVE_RET(T_INTLIT); }
|
||||
*/
|
||||
}
|
||||
else {
|
||||
/*!re2c
|
||||
LongIntegerSuffix
|
||||
{ BOOST_WAVE_RET(T_LONGINTLIT); }
|
||||
|
||||
IntegerSuffix?
|
||||
{ BOOST_WAVE_RET(T_INTLIT); }
|
||||
*/
|
||||
}
|
||||
|
||||
// re2c will complain about -Wmatch-empty-string above
|
||||
// it's OK because we've already matched an integer
|
||||
// and will return T_INTLIT
|
||||
}
|
||||
|
||||
/* this subscanner is invoked for C++0x extended character literals */
|
||||
extcharlit:
|
||||
{
|
||||
/*!re2c
|
||||
* {
|
||||
(*s->error_proc)(s, lexing_exception::generic_lexing_error,
|
||||
"Invalid character in raw string delimiter ('%c')", yych);
|
||||
}
|
||||
|
||||
((EscapeSequence | UniversalChar | any\[\n\r\\']) ['])
|
||||
{ BOOST_WAVE_RET(T_CHARLIT); }
|
||||
|
||||
any
|
||||
{ BOOST_WAVE_RET(TOKEN_FROM_ID(*s->tok, UnknownTokenType)); }
|
||||
*/
|
||||
}
|
||||
|
||||
/* this subscanner is invoked for C++0x extended character string literals */
|
||||
extstringlit:
|
||||
{
|
||||
/*!re2c
|
||||
* {
|
||||
(*s->error_proc)(s, lexing_exception::generic_lexing_error,
|
||||
"Invalid character in raw string delimiter ('%c')", yych);
|
||||
}
|
||||
|
||||
((EscapeSequence | UniversalChar | any\[\n\r\\"])* ["])
|
||||
{ BOOST_WAVE_RET(T_STRINGLIT); }
|
||||
|
||||
any
|
||||
{ BOOST_WAVE_RET(TOKEN_FROM_ID(*s->tok, UnknownTokenType)); }
|
||||
*/
|
||||
}
|
||||
|
||||
extrawstringlit:
|
||||
{
|
||||
// we have consumed the double quote but not the lparen
|
||||
// at this point we may see a delimiter
|
||||
|
||||
/*!re2c
|
||||
* {
|
||||
(*s->error_proc)(s, lexing_exception::generic_lexing_error,
|
||||
"Invalid character in raw string delimiter ('%c')", yych);
|
||||
}
|
||||
|
||||
// delimiters are any character but parentheses, backslash, and whitespace
|
||||
any\[()\\\t\v\f\r\n]
|
||||
{
|
||||
rawstringdelim += yych;
|
||||
if (rawstringdelim.size() > 16)
|
||||
{
|
||||
(*s->error_proc)(s, lexing_exception::generic_lexing_error,
|
||||
"Raw string delimiter of excessive length (\"%s\") in input stream",
|
||||
rawstringdelim.c_str());
|
||||
}
|
||||
goto extrawstringlit;
|
||||
}
|
||||
|
||||
"("
|
||||
{
|
||||
rawstringdelim = ")" + rawstringdelim;
|
||||
goto extrawstringbody;
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
extrawstringbody:
|
||||
{
|
||||
/*!re2c
|
||||
|
||||
* {
|
||||
(*s->error_proc)(s, lexing_exception::generic_lexing_error,
|
||||
"Invalid character in raw string body ('%c')", yych);
|
||||
}
|
||||
|
||||
Newline
|
||||
{
|
||||
s->line += count_backslash_newlines(s, cursor) +1;
|
||||
cursor.column = 1;
|
||||
goto extrawstringbody;
|
||||
}
|
||||
|
||||
(EscapeSequence | UniversalChar | any\["])
|
||||
{
|
||||
goto extrawstringbody;
|
||||
}
|
||||
|
||||
["]
|
||||
{
|
||||
// check to see if we have completed a delimiter
|
||||
if (string_type((char *)(YYCURSOR - rawstringdelim.size() - 1),
|
||||
(char *)(YYCURSOR - 1)) == rawstringdelim)
|
||||
{
|
||||
BOOST_WAVE_RET(T_RAWSTRINGLIT);
|
||||
} else {
|
||||
goto extrawstringbody;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
+8077
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user