linux-zen-desktop/tools/perf/util/pmu.l

49 lines
767 B
Plaintext
Raw Normal View History

2023-08-30 17:31:07 +02:00
%option prefix="perf_pmu_"
2023-10-24 12:59:35 +02:00
%option reentrant
%option bison-bridge
2023-08-30 17:31:07 +02:00
%{
#include <stdlib.h>
#include <linux/bitops.h>
#include "pmu.h"
#include "pmu-bison.h"
2023-10-24 12:59:35 +02: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)
2023-08-30 17:31:07 +02:00
{
2023-10-24 12:59:35 +02:00
YYSTYPE *yylval = perf_pmu_get_lval(scanner);
char *text = perf_pmu_get_text(scanner);
2023-08-30 17:31:07 +02:00
long num;
errno = 0;
2023-10-24 12:59:35 +02:00
num = strtoul(text, NULL, base);
2023-08-30 17:31:07 +02:00
if (errno)
return PP_ERROR;
2023-10-24 12:59:35 +02:00
yylval->num = num;
2023-08-30 17:31:07 +02:00
return PP_VALUE;
}
%}
num_dec [0-9]+
%%
2023-10-24 12:59:35 +02:00
{num_dec} { return value(yyscanner, 10); }
2023-08-30 17:31:07 +02:00
config { return PP_CONFIG; }
- { return '-'; }
: { return ':'; }
, { return ','; }
. { ; }
\n { ; }
%%
2023-10-24 12:59:35 +02:00
int perf_pmu_wrap(void *scanner __maybe_unused)
2023-08-30 17:31:07 +02:00
{
return 1;
}