Coccinelle archive on
 help / color / Atom feed
From: Fuqian Huang <>
Subject: [Cocci] Parse error on macro function declaration
Date: Fri, 5 Jul 2019 15:51:07 +0800
Message-ID: <> (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 cocci script:
@ print @
identifier fn, MARCO;
#define MARCO(name) fn(...) {...}

This fits the grammar above:
id - MARCO
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

                 reply index

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

Reply instructions:

You may reply publically 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:

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

  git send-email \
    --in-reply-to='' \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Coccinelle archive on

Archives are clonable:
	git clone --mirror cocci/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 cocci cocci/ \
	public-inbox-index cocci

Newsgroup available over NNTP:

AGPL code for this site: git clone public-inbox