lkml.org 
[lkml]   [2020]   [May]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/4] perf expr: Allow comments in custom metric file
Date
Adding support to use comments within the custom metric file
with both the shell '# ... ' and C '/* ... */ styles.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/util/expr.l | 12 ++++++++++++
1 file changed, 12 insertions(+)

diff --git a/tools/perf/util/expr.l b/tools/perf/util/expr.l
index c6a930ed22e6..e9b294ba09fc 100644
--- a/tools/perf/util/expr.l
+++ b/tools/perf/util/expr.l
@@ -82,6 +82,8 @@ static int str(yyscan_t scanner, int token, int runtime)
%}

%x custom
+%x comment_single
+%x comment_multi

number [0-9]*\.?[0-9]+

@@ -116,6 +118,16 @@ else { return ELSE; }
#smt_on { return SMT_ON; }
{number} { return value(yyscanner); }
{symbol} { return str(yyscanner, ID, sctx->runtime); }
+
+"//" { BEGIN(comment_single); }
+<comment_single>\n { BEGIN(INITIAL); }
+<comment_single>. { }
+
+"/*" { BEGIN(comment_multi); }
+<comment_multi>"*/" { BEGIN(INITIAL); }
+<comment_multi>\n { }
+<comment_multi>. { }
+
"|" { return '|'; }
"^" { return '^'; }
"&" { return '&'; }
--
2.25.4
\
 
 \ /
  Last update: 2020-05-11 22:54    [W:0.113 / U:0.292 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site