|
| 1 | +m4_changequote() |
| 2 | + |
| 3 | +%{ |
| 4 | +#if defined __clang__ |
| 5 | +# define CLANG_VERSION (__clang_major__ * 100 + __clang_minor__) |
| 6 | +#endif |
| 7 | + |
| 8 | +// Clang and ICC like to pretend they are GCC. |
| 9 | +#if defined __GNUC__ && !defined __clang__ && !defined __ICC |
| 10 | +# define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__) |
| 11 | +#endif |
| 12 | + |
| 13 | +// Pacify warnings in yy_init_buffer (observed with Flex 2.6.4) |
| 14 | +// and GCC 6.4.0, 7.3.0 with -O3. |
| 15 | +#if defined GCC_VERSION && 600 <= GCC_VERSION |
| 16 | +# pragma GCC diagnostic ignored "-Wnull-dereference" |
| 17 | +#endif |
| 18 | + |
| 19 | +// This example uses Flex's C back end, yet compiles it as C++. |
| 20 | +// So expect warnings about C style casts and NULL. |
| 21 | +#if defined CLANG_VERSION && 500 <= CLANG_VERSION |
| 22 | +# pragma clang diagnostic ignored "-Wold-style-cast" |
| 23 | +# pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" |
| 24 | +#elif defined GCC_VERSION && 407 <= GCC_VERSION |
| 25 | +# pragma GCC diagnostic ignored "-Wold-style-cast" |
| 26 | +# pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" |
| 27 | +#endif |
| 28 | + |
| 29 | +#define FLEX_VERSION (YY_FLEX_MAJOR_VERSION * 100 + YY_FLEX_MINOR_VERSION) |
| 30 | + |
| 31 | +// Old versions of Flex (2.5.35) generate an incomplete documentation comment. |
| 32 | +// |
| 33 | +// In file included from src/scan-code-c.c:3: |
| 34 | +// src/scan-code.c:2198:21: error: empty paragraph passed to '@param' command |
| 35 | +// [-Werror,-Wdocumentation] |
| 36 | +// * @param line_number |
| 37 | +// ~~~~~~~~~~~~~~~~~^ |
| 38 | +// 1 error generated. |
| 39 | +#if FLEX_VERSION < 206 && defined CLANG_VERSION |
| 40 | +# pragma clang diagnostic ignored "-Wdocumentation" |
| 41 | +#endif |
| 42 | + |
| 43 | +// Old versions of Flex (2.5.35) use 'register'. Warnings introduced in |
| 44 | +// GCC 7 and Clang 6. |
| 45 | +#if FLEX_VERSION < 206 |
| 46 | +# if defined CLANG_VERSION && 600 <= CLANG_VERSION |
| 47 | +# pragma clang diagnostic ignored "-Wdeprecated-register" |
| 48 | +# elif defined GCC_VERSION && 700 <= GCC_VERSION |
| 49 | +# pragma GCC diagnostic ignored "-Wregister" |
| 50 | +# endif |
| 51 | +#endif |
| 52 | + |
| 53 | +#if FLEX_VERSION < 206 |
| 54 | +# if defined CLANG_VERSION |
| 55 | +# pragma clang diagnostic ignored "-Wconversion" |
| 56 | +# pragma clang diagnostic ignored "-Wdocumentation" |
| 57 | +# pragma clang diagnostic ignored "-Wshorten-64-to-32" |
| 58 | +# pragma clang diagnostic ignored "-Wsign-conversion" |
| 59 | +# elif defined GCC_VERSION |
| 60 | +# pragma GCC diagnostic ignored "-Wconversion" |
| 61 | +# pragma GCC diagnostic ignored "-Wsign-conversion" |
| 62 | +# endif |
| 63 | +#endif |
| 64 | + |
| 65 | +// Flex 2.6.4, GCC 9 |
| 66 | +// warning: useless cast to type 'int' [-Wuseless-cast] |
| 67 | +// 1361 | YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); |
| 68 | +// | ^ |
| 69 | +#if defined GCC_VERSION && 900 <= GCC_VERSION |
| 70 | +# pragma GCC diagnostic ignored "-Wuseless-cast" |
| 71 | +#endif |
| 72 | +%} |
| 73 | + |
| 74 | +%option noyywrap nounput noinput batch debug |
| 75 | + |
| 76 | +%{ |
| 77 | + // A number symbol corresponding to the value in provided string. |
| 78 | + yy::parser::symbol_type make_NUMBER(const std::string &s, const yy::parser::location_type& loc); |
| 79 | + yy::parser::symbol_type make_FLOAT(const std::string &s, const yy::parser::location_type& loc); |
| 80 | + yy::parser::symbol_type make_STRING(const std::string &s, const yy::parser::location_type& loc); |
| 81 | + yy::parser::symbol_type make_BOOL(std::string s, const yy::parser::location_type& loc); |
| 82 | +%} |
0 commit comments