Skip to contentSkip to conversation

metavariables for initialize/finalize

Cocci Nic Volanschi (R&D) 2 participants 2 messages Jun 20, 2013 – Jul 11, 2013 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Personally, I think that adapting old patches to add the second @@ in any initialization & finalization rule is very easy to do, even automatically. So I see no problem for breaking the backward compatibility on this matter, if it simplifies the implementation.

Nic.

Quoted 42 lines · On Thu, 2013-06-20 at 12:00 +0200, cocci-request at systeme.lip6.fr wrote:

----------------------------------------------------------------------

Message: 1
Date: Wed, 19 Jun 2013 23:37:23 +0200 (CEST)
From: Julia Lawall <[email protected]>
To: cocci at systeme.lip6.fr
Subject: [Cocci] metavariables for initialize/finalize Message-ID:

	<[email protected]>

Content-Type: TEXT/PLAIN; charset=US-ASCII

SmPL allows defining initialize and finalize script rules that are rnu before and after the treatment of any files, repectively. They are useful for managing counters, hash tables, etc. and for defining frequently used script functions.

At the moment, they do not allow the declaration of any metavariables. In particular the syntax is, eg:

@initialize:python@

python code

without the second @@ as found in all other kinds of rules.

The problem is that this makes it impossible to refer to command line arguments (ie virtual identifiers) in the initialize and finalize rules, which can be useful.

One possibility would be to add metavariable declarations, as found elsewhere. This would mean adding @@ to any existing semantic patches that contain initialize and finalize rules.

Another option would be to make the second @@ optional. This preserves backward compatability, but it makes the language more complex, and it is not so easy to implement, because normally I don't parse the script code.

A third option would be to make it possible to refer to eg virtual.xyz directly in the script code, regardless of the language. These would then get replaced by their values from the command line before passing the code to the interpreter of the script language.

Quoted 7 lines

What do you think? I prefer the fist option, because the language remains (indeed, becomes more) uniform. But the backward compatability is an issue. On the other hand, maybe most people don't use initialize and finalize rules?

Thanks,
julia

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://systeme.lip6.fr/pipermail/cocci/attachments/20130620/ea85c568/attachment.html>

#2 lore raw
Quoted 7 lines · Nic Volanschi (R&D)

**
Personally, I think that adapting old patches to add the second @@ in any initialization & finalization rule is very easy to do, even automatically. So I see no problem for breaking the backward compatibility on this matter, if it simplifies the implementation.

I think having a simpler language is more important than backwards compatibility in this case,
so I do not mind either, just make sure that the error message generated
when parsing "old" files
is clear and understandable.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://systeme.lip6.fr/pipermail/cocci/attachments/20130711/8441e90f/attachment.html>