Coccinelle archive on lore.kernel.org
 help / color / Atom feed
* [Cocci] Parse error on macro function declaration
@ 2019-07-05  7:51 Fuqian Huang
  0 siblings, 0 replies; only message in thread
From: Fuqian Huang @ 2019-07-05  7:51 UTC (permalink / raw)
  To: cocci

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-05  7:51 [Cocci] Parse error on macro function declaration Fuqian Huang

Coccinelle archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/cocci/0 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/ https://lore.kernel.org/cocci \
		cocci@systeme.lip6.fr cocci@archiver.kernel.org
	public-inbox-index cocci


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/fr.lip6.systeme.cocci


AGPL code for this site: git clone https://public-inbox.org/ public-inbox