49 lines
767 B
Plaintext
Raw Normal View History

2026-01-21 18:59:54 +08:00
%option prefix="perf_pmu_"
2026-01-29 22:25:33 +08:00
%option reentrant
%option bison-bridge
2026-01-21 18:59:54 +08:00
%{
#include <stdlib.h>
#include <linux/bitops.h>
#include "pmu.h"
#include "pmu-bison.h"
2026-01-29 22:25:33 +08:00
char *perf_pmu_get_text(yyscan_t yyscanner);
YYSTYPE *perf_pmu_get_lval(yyscan_t yyscanner);
static int value(yyscan_t scanner, int base)
2026-01-21 18:59:54 +08:00
{
2026-01-29 22:25:33 +08:00
YYSTYPE *yylval = perf_pmu_get_lval(scanner);
char *text = perf_pmu_get_text(scanner);
2026-01-21 18:59:54 +08:00
long num;
errno = 0;
2026-01-29 22:25:33 +08:00
num = strtoul(text, NULL, base);
2026-01-21 18:59:54 +08:00
if (errno)
return PP_ERROR;
2026-01-29 22:25:33 +08:00
yylval->num = num;
2026-01-21 18:59:54 +08:00
return PP_VALUE;
}
%}
num_dec [0-9]+
%%
2026-01-29 22:25:33 +08:00
{num_dec} { return value(yyscanner, 10); }
2026-01-21 18:59:54 +08:00
config { return PP_CONFIG; }
- { return '-'; }
: { return ':'; }
, { return ','; }
. { ; }
\n { ; }
%%
2026-01-29 22:25:33 +08:00
int perf_pmu_wrap(void *scanner __maybe_unused)
2026-01-21 18:59:54 +08:00
{
return 1;
}