linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: lkml <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Michael Petlan <mpetlan@redhat.com>,
	Joe Mario <jmario@redhat.com>, Andi Kleen <ak@linux.intel.com>,
	Kajol Jain <kjain@linux.ibm.com>,
	John Garry <john.garry@huawei.com>
Subject: [PATCH 2/4] perf expr: Allow comments in custom metric file
Date: Mon, 11 May 2020 22:53:05 +0200	[thread overview]
Message-ID: <20200511205307.3107775-3-jolsa@kernel.org> (raw)
In-Reply-To: <20200511205307.3107775-1-jolsa@kernel.org>

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


  parent reply	other threads:[~2020-05-11 20:53 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-11 20:53 [PATCHv3 0/4] perf tools: Add support for user defined metric Jiri Olsa
2020-05-11 20:53 ` [PATCH 1/4] perf expr: Add parsing support for multiple expressions Jiri Olsa
2020-05-13  6:50   ` Ian Rogers
2020-05-13 11:25     ` Jiri Olsa
2020-05-11 20:53 ` Jiri Olsa [this message]
2020-05-11 20:53 ` [PATCH 3/4] perf stat: Add --metrics-file option Jiri Olsa
2020-05-13  7:04   ` Ian Rogers
2020-05-13 11:33     ` Jiri Olsa
2020-05-14  3:41       ` Ian Rogers
2020-05-11 20:53 ` [PATCH 4/4] perf expr: Report line number with error Jiri Olsa
2020-05-13  7:09   ` Ian Rogers
2020-05-13 11:34     ` Jiri Olsa
2020-05-13 14:08       ` Arnaldo Carvalho de Melo
2020-05-13 14:46         ` Jiri Olsa
2020-05-13 15:14           ` Arnaldo Carvalho de Melo
2022-01-25 12:34 ` [PATCHv3 0/4] perf tools: Add support for user defined metric John Garry
2022-01-25 12:41   ` Arnaldo Carvalho de Melo
2022-01-25 12:51     ` John Garry

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200511205307.3107775-3-jolsa@kernel.org \
    --to=jolsa@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=jmario@redhat.com \
    --cc=john.garry@huawei.com \
    --cc=kjain@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=mpetlan@redhat.com \
    --cc=namhyung@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).