> Thanks, Julia. This is definitely going in the direction of what I'm after
> but I need it richer :-)
> Is it possible to output the character position on a line of statements?
This is no problem. A position variable contains the following
information:
type pos = { current_element : string;
file :string ;
line : int;
col : int;
line_end : int;
col_end : int; }
> Is it possible to output info about the position of individual arguments in
> a function call? Or parameters in a function declaration?
Maybe arguments could be done by adding commas at the end of the
"identifier" containing the comment. I could try to allow metavariables
to be interpreted inside added comments, which would be a cleaner
solution.
> Is it possible to identify particular statements? E.g. This statement is a
> function declaration, this statement is a function definition, etc?
A function definition is not considered to be a statement.
You can match whatever patterns you want, and put things before and after
them as you like.
In my proposed solution, in the first rule, I just have S@p. But you
could have:
(
f(...);@p1
|
S@p2
)
and then treat the things at the positions p1 and p2 in separate ways.
Actually, you would probably want
f@p0(...);@p1
Then the start of p0 would be the start of the whole term and the end of
p1 would be the end of the whole term. A position variable just records
the position information about the preceding token, which can be a
metavariable.
> If a statement is a stack variable definition then is it possible to show
> the position of the type, name and option assignment operator,
This is no problem, just put position variables on all the things you want
to match, eg:
T@p1 x@p2;
You might run into problems with the case where the declaration
initializes more than one variable, though.
> and then show
> separate sub-statements for the assignment right hand value?
I don't understand the last part, because the right hand side value is an
expression, so it doesn't have sub-statements. If you want to put
comments on all subexpressions, it will be necessary to have metavariables
interpreted within comments.
julia
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)