1 /* SPDX-License-Identifier: GPL-3.0-only */
4 * Since we do not supply yywrap(), we use noyywrap to instruct the scanner to
5 * behave as though yywrap() returned 1.
10 * We don't want symbols to clash with those of other flex users, particularly
13 %option prefix="txp_yy"
16 * Generate a scanner that maintains the number of the current line read from
17 * its input in the yylineno variable.
21 /* Generate a bison-compatible scanner. */
22 %option bison-bridge bison-locations
25 * Warn (in particular) if the default rule can be matched but no default rule
31 * Generate a scanner which is portable and safe to use in one or more threads
37 * Generate a scanner which always looks one extra character ahead. This is a
38 * bit faster than an interactive scanner for which look ahead happens only
41 %option never-interactive
46 #define YYSTYPE TXP_YYSTYPE
47 #define YYLTYPE TXP_YYLTYPE
48 #define YY_DECL int txp_yylex(TXP_YYSTYPE *yylval_param, TXP_YYLTYPE *yylloc_param, \
49 struct txp_context *ctx, struct txp_ast_node **ast, txp_yyscan_t yyscanner)
50 #include "txp.bison.h"
51 #define TXP_YY_USER_ACTION do {txp_yylloc->first_line = txp_yylineno;} while (0);
53 DECIMAL_CONSTANT (0|([[:digit:]]{-}[0])[[:digit:]]*)
54 STRING_LITERAL \"([^\"\\\n]|(\\[\"\\abfnrtv]))*\"
55 REGEX_PATTERN \/([^\/\\\n]|(\\[\/\\abfnrtv]))*\/([in])*
64 [[:space:]]+|#.*\n /* skip comments and whitespace */
66 "("|")"|","|"+"|"-"|"*"|"/"|"<"|">" {return yytext[0];}
72 "!=" {return NOT_EQUAL;}
73 "<=" {return LESS_OR_EQUAL;}
74 ">=" {return GREATER_OR_EQUAL;}
75 "=~" {return REGEX_MATCH;}
79 yylval->node = txp_new_ast_leaf_node(NUM);
80 ret = atoi64(yytext, &yylval->node->sv.intval);
83 txp_parse_error(yylloc->first_line, ctx, "%s: %s", yytext,
91 yylval->node = txp_new_ast_leaf_node(STRING_LITERAL);
92 parse_quoted_string(yytext, "\"\"", &yylval->node->sv.strval);
93 return STRING_LITERAL;
98 yylval->node = txp_new_ast_leaf_node(REGEX_PATTERN);
99 ret = txp_parse_regex_pattern(yytext, &yylval->node->sv.re_pattern);
101 txp_parse_error(yylloc->first_line, ctx, "%s: %s", yytext,
105 return REGEX_PATTERN;
109 txp_parse_error(yylloc->first_line, ctx, "unrecognized text: %s",