lkml.org 
[lkml]   [2020]   [Apr]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/3] 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 5561c360cd27..99547182ef79 100644
--- a/tools/perf/util/expr.l
+++ b/tools/perf/util/expr.l
@@ -69,6 +69,8 @@ static int str(yyscan_t scanner, int token)
%}

%x custom
+%x comment_C
+%x comment_sh

number [0-9]+

@@ -103,6 +105,16 @@ else { return ELSE; }
#smt_on { return SMT_ON; }
{number} { return value(yyscanner, 10); }
{symbol} { return str(yyscanner, ID); }
+
+"/*" { BEGIN(comment_C); }
+<comment_C>"*/" { BEGIN(INITIAL); }
+<comment_C>\n { }
+<comment_C>. { }
+
+"#" { BEGIN(comment_sh); }
+<comment_sh>\n { BEGIN(INITIAL); }
+<comment_sh>. { }
+
"|" { return '|'; }
"^" { return '^'; }
"&" { return '&'; }
--
2.25.3
\
 
 \ /
  Last update: 2020-04-21 20:14    [W:0.090 / U:0.316 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site