7 * Copyright 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
9 * SPDX-License-Identifier: LGPL-2.1-only
14 #include "filter-ast.h"
15 #include "filter-parser.h"
17 static void yyunput (int c, register char * yy_bp , yyscan_t yyscanner)
18 __attribute__((unused));
19 static int input (yyscan_t yyscanner) __attribute__((unused));
23 %x comment_ml comment_sl string_lit char_const
24 %option reentrant yylineno noyywrap bison-bridge
25 %option extra-type="struct filter_parser_ctx *"
34 IS ((u|U)|(u|U)?(l|L|ll|LL)|(l|L|ll|LL)(u|U))
36 INTEGER_SUFFIX [ \n\t]*(U|UL|ULL|LU|LLU|Ul|Ull|lU|llU|u|uL|uLL|Lu|LLu|ul|ull|lu|llu)
41 UCHARLOWERCASE \\u{HEXDIGIT}{4}
42 UCHARUPPERCASE \\U{HEXDIGIT}{8}
44 ID_NONDIGIT {NONDIGIT}|{UCHARLOWERCASE}|{UCHARUPPERCASE}|{ID_EXTRA_CHAR}
45 IDENTIFIER {ID_NONDIGIT}({ID_NONDIGIT}|{DIGIT})*
46 ESCSEQ \\(\'|\"|\?|\\|a|b|f|n|r|t|v|{OCTALDIGIT}{1,3}|u{HEXDIGIT}{4}|U{HEXDIGIT}{8}|x{HEXDIGIT}+)
50 * Using start conditions to deal with comments
54 "/*" BEGIN(comment_ml);
55 <comment_ml>[^*\n]* /* eat anything that's not a '*' */
56 <comment_ml>"*"+[^*/\n]* /* eat up '*'s not followed by '/'s */
57 <comment_ml>\n ++yylineno;
58 <comment_ml>"*"+"/" BEGIN(INITIAL);
60 "//" BEGIN(comment_sl);
61 <comment_sl>[^\n]*\n ++yylineno; BEGIN(INITIAL);
63 L\' BEGIN(char_const); return CHARACTER_CONSTANT_START;
64 \' BEGIN(char_const); return CHARACTER_CONSTANT_START;
65 <char_const>\' BEGIN(INITIAL); return SQUOTE;
67 L\" BEGIN(string_lit); return STRING_LITERAL_START;
68 \" BEGIN(string_lit); return STRING_LITERAL_START;
69 <string_lit>\" BEGIN(INITIAL); return DQUOTE;
71 <char_const,string_lit>ESCSEQ return ESCSEQ;
72 <char_const,string_lit>\n ; /* ignore */
73 <char_const,string_lit>. setstring(yyextra, yylval, yytext); return CHAR_STRING_TOKEN;
76 0[xX]{H}+{IS}? setstring(yyextra, yylval, yytext); return HEXADECIMAL_CONSTANT;
77 0[0-7]*{IS}? setstring(yyextra, yylval, yytext); return OCTAL_CONSTANT;
78 [1-9]{D}*{IS}? setstring(yyextra, yylval, yytext); return DECIMAL_CONSTANT;
80 {D}+{E}{FS}? setstring(yyextra, yylval, yytext); return FLOAT_CONSTANT;
81 {D}*"."{D}+{E}?{FS}? setstring(yyextra, yylval, yytext); return FLOAT_CONSTANT;
82 {D}+"."{D}*{E}?{FS}? setstring(yyextra, yylval, yytext); return FLOAT_CONSTANT;
83 0[xX]{H}+{P}{FS}? setstring(yyextra, yylval, yytext); return FLOAT_CONSTANT;
84 0[xX]{H}*"."{H}+{P}?{FS}? setstring(yyextra, yylval, yytext); return FLOAT_CONSTANT;
85 0[xX]{H}+"."{H}*{P}?{FS}? setstring(yyextra, yylval, yytext); return FLOAT_CONSTANT;
101 ">>" return RIGHT_OP;
116 ";" return SEMICOLON;
117 "..." return DOTDOTDOT;
125 "$"{IDENTIFIER} printf_debug("<GLOBAL_IDENTIFIER %s>\n", yytext); setstring(yyextra, yylval, yytext); return GLOBAL_IDENTIFIER;
126 {IDENTIFIER} printf_debug("<IDENTIFIER %s>\n", yytext); setstring(yyextra, yylval, yytext); return IDENTIFIER;
127 [ \t\n]+ ; /* ignore */