Skip to contentSkip to conversation

Adding another metavariable type for the construction of “fresh” source code?

cocci Markus Elfring 2 participants 3 messages Mar 19, 2022

lore
Share & tools
lore
#0 lore raw

Hello,

The software documentation contains the following information at the moment.
https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/20fdb67f4b20a242f222337e13091115884cf6bb/docs/manual/cocci_syntax.tex#L292
https://github.com/coccinelle/coccinelle/blob/ae337fce1512ff15aabc3ad5b6d2e537f97ab62a/docs/manual/cocci_syntax.tex#L292

“…
  \item if a script is given, then it must return a string and the result will be used as is
…”

I imagine that this description would fit better to a metavariable type like “fresh source code” (than the type “fresh identifier”).

Do you care if such metavariables can be applied in a type-safe way according to syntax of supported programming languages?

How are the chances to extend the Coccinelle software accordingly?

Regards,
Markus

#1 lore raw
Quoted 12 lines · Markus Elfring

Hello,

The software documentation contains the following information at the moment.
https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/20fdb67f4b20a242f222337e13091115884cf6bb/docs/manual/cocci_syntax.tex#L292
https://github.com/coccinelle/coccinelle/blob/ae337fce1512ff15aabc3ad5b6d2e537f97ab62a/docs/manual/cocci_syntax.tex#L292

“…
  \item if a script is given, then it must return a string and the result will be used as is
…”

Quoted 7 lines

I imagine that this description would fit better to a metavariable type like “fresh source code” (than the type “fresh identifier”).

Do you care if such metavariables can be applied in a type-safe way according to syntax of supported programming languages?

How are the chances to extend the Coccinelle software accordingly?

The script code of a metavariable of type fresh identifier returns a string that is used as the name of the identifier. There is no such thing as fresh source code. "source code" doesn't give enough information to correctly parse the string.

julia

#2 lore raw
Quoted 2 lines
Quoted 2 lines

The script code of a metavariable of type fresh identifier returns a string that is used as the name of the identifier.

How do you think about to avoid that a provided string violates the syntax rules for a supported programming language?

(Example:
Would you like to distinguish a generated string literal better from an “identifier”?)

Can it matter to check the returned data for compliance with known format restrictions?

Quoted 2 lines

There is no such thing as fresh source code. "source code" doesn't give enough information to correctly parse the string.

I got the impression that some source code could be added by the means of the semantic patch language if data format validation is eventually not performed.

Regards,
Markus