cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
From: Fuqian Huang <huangfq.daxian@gmail.com>
To: cocci@systeme.lip6.fr
Subject: [Cocci] Parse error on macro function declaration
Date: Fri, 5 Jul 2019 15:51:07 +0800	[thread overview]
Message-ID: <CABXRUiSBEB2gy0=9MvWna8nu5kX5mgU3q5OPaXZx-gP2ir5N8g@mail.gmail.com> (raw)

On the grammer manual of cococinelle, #define could follow with a
function declaration.

#define id (PARAMSEQ(id, ε)) [top]
top :: = .... | funcdecl
fundecl ::= [fn_ctype] funinfo ∗ funid ([PARAMSEQ(param, ε)]) { [stmt_seq] }

I try to write the following code to match a function declaration with a marco:
The code try to match:
#define MY_FUNC(name) \
static void show##name() \
{ \
  print("name = %s\n", name); \
}\
MY_FUNC("amy");

My cocci script:
@ print @
identifier fn, MARCO;
@@
#define MARCO(name) fn(...) {...}

This fits the grammar above:
id - MARCO
PARAMSEQ - name
top - funcdecl
funid - fn
But when I run command:
spatch --parse-cocci my.cocci
errors happen:
minus: parse error
  File "my.cocci", line 4, column 20, charpos = 55
  around 'fn',
  whole content = #define MACRO(name) fn(...) {...}

My coccinelle version is 1.0.7
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

                 reply	other threads:[~2019-07-05  7:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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='CABXRUiSBEB2gy0=9MvWna8nu5kX5mgU3q5OPaXZx-gP2ir5N8g@mail.gmail.com' \
    --to=huangfq.daxian@gmail.com \
    --cc=cocci@systeme.lip6.fr \
    /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).