Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block comments /* ... */ do not highlight. #3

Open
KJ7LNW opened this issue Mar 21, 2022 · 1 comment
Open

Block comments /* ... */ do not highlight. #3

KJ7LNW opened this issue Mar 21, 2022 · 1 comment

Comments

@KJ7LNW
Copy link

KJ7LNW commented Mar 21, 2022

Hello, thank you for writing this plugin!

It looks like the syntax highlight doesn't support /* ... */ as a comment. They can be used to comment cocci blocks.

Here's a big cocci block I'm working on to refactor xnec2c . The rest of the vim highlight works quite well except for the commented @ add_copy @ section:

// Match the variable definition:
@ struct_name @
typedef cm_t, cmag_t, crnt_t, ct1m_t, ct2m_t, data_t, dataj_t, fpat_t,
	ggrid_t, gnd_t, gwav_t, impedance_data_t, incom_t, matpar_t, near_field_t,
	netcx_t, save_t, segj_t, smat_t, zload_t, vsorc_t;
type T = {cm_t, cmag_t, crnt_t, ct1m_t, ct2m_t, data_t, dataj_t, fpat_t,
	ggrid_t, gnd_t, gwav_t, impedance_data_t, incom_t, matpar_t, near_field_t,
	netcx_t, save_t, segj_t, smat_t, zload_t, vsorc_t};
identifier I;
@@
T I;

/*
// Add the 2nd copy
@ add_copy @
identifier struct_name.I;
type struct_name.T;
fresh identifier P = "prev_"##I;
@@
void diff_structures()
{
}
*/

// Add the compare_T() function call and compare_T function definition for each typedef:
@ r2 @
identifier struct_name.I;
type struct_name.T;
fresh identifier compare_FN = "compare_"##I;
fresh identifier print_FN = "print_"##I;
fresh identifier P = "prev_"##I;
@@
void diff_structures()
{
(
++T P; 
)
(
++FN(&I, &P);
+
)
}
++void compare_FN(T *a, T *b){}
++void print_FN(T *a){}


// Match scalar types:
@ scalars @

type struct_name.T;
type scalar_T = {char, int, double, double complex};
identifier F;
@@

typedef struct
{
	...
	scalar_T F;
	...
} T;



// Match ptrs:
@ ptrs @
type ptr_T;
identifier F;
type struct_name.T;
@@

typedef struct
{
	...
	ptr_T *F;
	...
} T;



// Add the comparisons for scalars:
@ r3 @
identifier r2.compare_FN;
identifier struct_name.I;
identifier scalars.F;
@@
void compare_FN(...)
{
	...
++	if (a->F != b->F) NOMATCH(a, b, I, F);
}

// Add the comparisons for ptrs:
@ r4 @
identifier r2.compare_FN;
identifier struct_name.I;
identifier ptrs.F;
@@
void compare_FN()
{
++	if (mem_bcmp(a->F, b->F)) NOMATCH(a, b, I, F);
}

@ahf
Copy link
Owner

ahf commented Mar 24, 2022

I'll happily accept a PR for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants