How to fix a parse error for another SmPL script?
Hello,
A simple source code transformation was demonstrated.
https://lore.kernel.org/all/?q=convert%20comma%20to%20semicolon
Concrete patch example:
https://lore.kernel.org/linux-kernel/[email protected]/
Thus I constructed another tiny script variant for the semantic patch language.
@adjustment@
assignment operator ao;
expression e, ex, te, tex;
@@
<+...
te ao e
-,
+;
...+>
tex ao ex;
I stumbled on undesirable behaviour once more also with the software combination “Coccinelle 1.2-00038-g2297fc0f”.
Questionable test result:
Markus_Elfring@Sonne:…/Projekte/Coccinelle/janitor> spatch --parse-cocci convert_comma_to_semicolon.cocci …
minus: parse error:
File "convert_comma_to_semicolon.cocci", line 9, column 1, charpos = 90
around = '...+>',
whole content = ...+>
See also:
Get the non-optional nest construct completely working for SmPL 2017-08-18
https://github.com/coccinelle/coccinelle/issues/114
How can corresponding software components be improved?
Regards,
Markus
Quoted 11 lines · Markus Elfring
Hello,
A simple source code transformation was demonstrated.
https://lore.kernel.org/all/?q=convert%20comma%20to%20semicolonConcrete patch example:
https://lore.kernel.org/linux-kernel/[email protected]/Thus I constructed another tiny script variant for the semantic patch language.
Quoted 10 lines
@adjustment@
assignment operator ao;
expression e, ex, te, tex;
@@
<+...
te ao e
-,
+;
...+>
tex ao ex;
The above semantic patch does not parse because te ao e, is not a valid C term. There is no term in the C language that ends with a comma.
julia
Quoted 24 lines
I stumbled on undesirable behaviour once more also with the software combination “Coccinelle 1.2-00038-g2297fc0f”.
Questionable test result:
Markus_Elfring@Sonne:…/Projekte/Coccinelle/janitor> spatch --parse-cocciconvert_comma_to_semicolon.cocci…
minus: parse error:
File "convert_comma_to_semicolon.cocci", line 9, column 1, charpos = 90
around = '...+>',
whole content = ...+>See also:
Get the non-optional nest construct completely working for SmPL 2017-08-18
https://github.com/coccinelle/coccinelle/issues/114How can corresponding software components be improved?
Regards,
Markus
Quoted 11 lines
Quoted 10 lines
@adjustment@
assignment operator ao;
expression e, ex, te, tex;
@@
<+...
te ao e
-,
+;
...+>
tex ao ex;
Quoted 2 lines
The above semantic patch does not parse because te ao e, is not a valid C term. There is no term in the C language that ends with a comma.
Please reconsider such a view once more.
https://en.cppreference.com/w/c/language/operator_other#Comma_operator
Regards,
Markus
Quoted 11 lines · Markus Elfring
Quoted 11 lines
Quoted 10 lines
@adjustment@
assignment operator ao;
expression e, ex, te, tex;
@@
<+...
te ao e
-,
+;
...+>
tex ao ex;
Quoted 5 lines
Quoted 2 lines
The above semantic patch does not parse because te ao e, is not a valid C term. There is no term in the C language that ends with a comma.
Please reconsider such a view once more.
https://en.cppreference.com/w/c/language/operator_other#Comma_operator
The link you cite says:
The comma operator expression has the form
lhs , rhs
That doesn't end in a comma. There is no rhs within the <+... ...+>
julia
Quoted 4 lines
Regards,
Markus
Re: [cocci] Data processing challenges according to the comma operator
Quoted 9 lines
Quoted 2 lines
Please reconsider such a view once more.
https://en.cppreference.com/w/c/language/operator_other#Comma_operatorThe link you cite says:
The comma operator expression has the form
lhs , rhsThat doesn't end in a comma. There is no rhs within the <+... ...+>
Can subexpressions be supported by the semantic patch language for such a “binary” operator?
Regards,
Markus
Re: [cocci] Data processing challenges according to the comma operator
Quoted 5 lines · Markus Elfring
Quoted 5 lines
Quoted 2 lines
Please reconsider such a view once more.
https://en.cppreference.com/w/c/language/operator_other#Comma_operatorThe link you cite says:
Quoted 7 lines
Quoted 4 lines
The comma operator expression has the form
lhs , rhsThat doesn't end in a comma. There is no rhs within the <+... ...+>
Can subexpressions be supported by the semantic patch language for such a “binary” operator?
A subexpression is also an expression. There is nothing specific about this operator. The rule in Coccinelle is that when you write <+... ...+>, the term in the middle has to be a complete expression or statement.
julia
Re: [cocci] Data processing challenges according to the comma operator
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Please reconsider such a view once more.
https://en.cppreference.com/w/c/language/operator_other#Comma_operatorThe link you cite says:
The comma operator expression has the form
lhs , rhs
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
That doesn't end in a comma. There is no rhs within the <+... ...+>
Can subexpressions be supported by the semantic patch language for such a “binary” operator?
A subexpression is also an expression.
There is a desire to express special source code search restrictions.
Quoted 1 line
There is nothing specific about this operator.
Its parameters should be matched (or even captured) here.
Quoted 2 lines
The rule in Coccinelle is that when you write <+... ...+>, the term in the middle has to be a complete expression or statement.
This should be the case for the discussed SmPL script example.
Regards,
Markus
Re: [cocci] Data processing challenges according to the comma operator
In reply to Julia LawallQuoted 10 lines
Quoted 7 lines
Quoted 4 lines
The comma operator expression has the form
lhs , rhsThat doesn't end in a comma. There is no rhs within the <+... ...+>
Can subexpressions be supported by the semantic patch language for such a “binary” operator?
A subexpression is also an expression. There is nothing specific about this operator.
How do you call the construct of an expression together with an operator (like a comma for example) on the right side?
Quoted 2 lines
The rule in Coccinelle is that when you write <+... ...+>,
the term in the middle has to be a complete expression or statement.
Will additional source code search operators become relevant here?
Do further development resources need to be allocated anyhow?
Regards,
Markus
Re: [cocci] Data processing challenges according to the comma operator
Quoted 5 lines · Markus Elfring
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
The comma operator expression has the form
lhs , rhsThat doesn't end in a comma. There is no rhs within the <+... ...+>
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Can subexpressions be supported by the semantic patch language for such a “binary” operator?
A subexpression is also an expression. There is nothing specific about this operator.
How do you call the construct of an expression together with an operator (like a comma for example) on the right side?
Nothing.
Quoted 8 lines
Quoted 4 lines
The rule in Coccinelle is that when you write <+... ...+>,
the term in the middle has to be a complete expression or statement.Will additional source code search operators become relevant here?
Do further development resources need to be allocated anyhow?
No there is no interest in supporting random fragments of terms. They are hard to parse and it's not clear that the generated code would be even syntactically correct.
julia
Re: [cocci] Data processing challenges according to the comma operator
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
The comma operator expression has the form
lhs , rhsThat doesn't end in a comma. There is no rhs within the <+... ...+>
Can subexpressions be supported by the semantic patch language for such a “binary” operator?
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
A subexpression is also an expression. There is nothing specific about this operator.
How do you call the construct of an expression together with an operator (like a comma for example) on the right side?
Nothing.
Such a feedback hinders a bit the development of a solution, doesn't it?
I would find further clarification helpful for a corresponding terminology.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
The rule in Coccinelle is that when you write <+... ...+>,
the term in the middle has to be a complete expression or statement.Will additional source code search operators become relevant here?
Do further development resources need to be allocated anyhow?
No there is no interest in supporting random fragments of terms.
Different development interests are distributed between involved parties. Syntax items can hopefully be better discussed.
Quoted 2 lines
They are hard to parse and it's not clear that the generated code would be even syntactically correct.
Such application concerns can eventually be clarified better.
Regards,
Markus
Re: [cocci] Data processing challenges according to the comma operator
In reply to Julia LawallQuoted 2 lines
The above semantic patch does not parse because te ao e, is not a valid C term. There is no term in the C language that ends with a comma.
Can a source code search approach (like the following) become supported?
@display@
expression list el;
@@
*el;
https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/587259e014d0c83ac051702354da4d53e0905d12/docs/manual/cocci_syntax.tex#L359-362
https://github.com/coccinelle/coccinelle/blob/2297fc0f90ce8bef78d2977e9aacc188d7e87c6d/docs/manual/cocci_syntax.tex#L359-L362
Questionable test result:
Markus_Elfring@Sonne:…/Projekte/Coccinelle/janitor> spatch --parse-cocci show_comma_expression_statements.cocci …
minus: parse error:
File "show_comma_expression_statements.cocci", line 4, column 1, charpos = 34
around = 'el',
whole content = *el;
Regards,
Markus
Re: [cocci] Code adjustment challenges according to the comma operator (with SmPL)
In reply to Julia LawallQuoted 2 lines
The above semantic patch does not parse because te ao e, is not a valid C term. There is no term in the C language that ends with a comma.
I constructed another tiny script variant for the semantic patch language.
@replacement@
expression x, y;
@@
x
-,
+;
y;
I would like to point out that such a simple source code transformation approach found 156 files from the software “Linux next-20240726” for possible updates. Will further collateral evolution become interesting accordingly?
Regards,
Markus
Re: [cocci] Code adjustment challenges according to the comma operator (with SmPL)
Quoted 15 lines · Markus Elfring
Quoted 2 lines
The above semantic patch does not parse because te ao e, is not a valid C term. There is no term in the C language that ends with a comma.
I constructed another tiny script variant for the semantic patch language.
@replacement@
expression x, y;
@@
x
-,
+;
y;
Quoted 3 lines
I would like to point out that such a simple source code transformation approach found 156 files from the software “Linux next-20240726” for possible updates. Will further collateral evolution become interesting accordingly?
I think that you have to look at the examples and judget whether the use of the comma operator is helpful in each case.
julia
Re: [cocci] Code adjustment challenges according to the comma operator (with SmPL)
Quoted 6 lines
Quoted 3 lines
I would like to point out that such a simple source code transformation approach found 156 files from the software “Linux next-20240726” for possible updates. Will further collateral evolution become interesting accordingly?
I think that you have to look at the examples and judget whether the use of the comma operator is helpful in each case.
Would you become interested to support the integration of another SmPL script variant for the coccicheck tool?
Regards,
Markus
Re: [cocci] Code adjustment challenges according to the comma operator (with SmPL)
Quoted 9 lines · Markus Elfring
Quoted 6 lines
Quoted 3 lines
I would like to point out that such a simple source code transformation approach found 156 files from the software “Linux next-20240726” for possible updates. Will further collateral evolution become interesting accordingly?
I think that you have to look at the examples and judget whether the use of the comma operator is helpful in each case.
Would you become interested to support the integration of another SmPL script variant for the coccicheck tool?
I think that such a script already exists. Or at least the transformation has aready been extensively applied some years ago.
julia
Re: [cocci] Code adjustment challenges according to the comma operator (with SmPL)
Quoted 5 lines
Quoted 2 lines
Would you become interested to support the integration of another SmPL script variant for the coccicheck tool?
I think that such a script already exists. Or at least the transformation has aready been extensively applied some years ago.
Which transformation approaches have you got in mind so far?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/scripts/coccinelle?h=v6.10
Regards,
Markus