提交 a45badc7 编写于 作者: I Ian Rogers 提交者: Arnaldo Carvalho de Melo

perf expr: Allow numbers to be followed by a dot

Metrics like UNC_M_POWER_SELF_REFRESH encode 100 as "100." and
consequently the 100 is treated as a symbol. Alter the regular
expression to allow the dot to be before or after the number.

Note, this passed the pmu-events test as that tests the validity of a
number using strtod rather than lex code. strtod allows the dot after.

Add a test for this behavior.

Fixes: 26226a97 (perf expr: Move expr lexer to flex)
Signed-off-by: NIan Rogers <irogers@google.com>
Acked-by: NJiri Olsa <jolsa@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: John Garry <john.garry@huawei.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Clarke <pc@us.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 45db55f2
......@@ -38,6 +38,7 @@ int test__expr(struct test *t __maybe_unused, int subtest __maybe_unused)
ret |= test(&ctx, "max(1,2) + 1", 3);
ret |= test(&ctx, "1+1 if 3*4 else 0", 2);
ret |= test(&ctx, "1.1 + 2.1", 3.2);
ret |= test(&ctx, ".1 + 2.", 2.1);
if (ret)
return ret;
......
......@@ -81,7 +81,7 @@ static int str(yyscan_t scanner, int token, int runtime)
}
%}
number [0-9]*\.?[0-9]+
number ([0-9]+\.?[0-9]*|[0-9]*\.?[0-9]+)
sch [-,=]
spec \\{sch}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册