RegEx in UnrealScript EditMode
Submitted by Sunday, 22 May, 2011 - 15:46
on
Okay so Ive been at this for a good week trying to work things out, using regex buddy for testing against java but it seems the version that it uses is different than what the jedit modes use.
Now my issue is in matching braces, now I have seen that this can be tricky using regex and perhaps using some other method might be the go but Im not even sure where to start there. I am willing to try anything even if it includes having to write a plugin or extending jedits functionality as this might head in that direction at some point.
Ive tried various regex's to try and match the cpptext blocks, now to explain it, cpptext blocks are C++ written inside UnrealScript source and Im wanting to highlight them as C++ by importing parts of that mode in instead of adding the keywords in the UnrealScript list. The reason for this is UnrealScript while sharing similarities to C++ doesnt allow the use of keywords such as void, null or virtual for instance.
As an example:
class foo extends bar;
var newfoo newb;
cpptext
{
virtual void BeginDestroy();
virtual UBOOL IsReadyForFinishDestroy();
UBOOL IsHiddenEdAtStartup() const
{
return bHiddenEd;
}
}
Which shouldnt be that hard to do since the braces are always matched and cpptext resides outside any nest. The tricky part is there is also structcpptext which resides in 1 nest always and can contain nested braces but each only contain a nest depth of one, being functions/constructors.
Any help would be greatly appreciated because at this point I feel like Im bangin my head against a wall. Thanks.
Now my issue is in matching braces, now I have seen that this can be tricky using regex and perhaps using some other method might be the go but Im not even sure where to start there. I am willing to try anything even if it includes having to write a plugin or extending jedits functionality as this might head in that direction at some point.
Ive tried various regex's to try and match the cpptext blocks, now to explain it, cpptext blocks are C++ written inside UnrealScript source and Im wanting to highlight them as C++ by importing parts of that mode in instead of adding the keywords in the UnrealScript list. The reason for this is UnrealScript while sharing similarities to C++ doesnt allow the use of keywords such as void, null or virtual for instance.
As an example:
class foo extends bar;
var newfoo newb;
cpptext
{
virtual void BeginDestroy();
virtual UBOOL IsReadyForFinishDestroy();
UBOOL IsHiddenEdAtStartup() const
{
return bHiddenEd;
}
}
Which shouldnt be that hard to do since the braces are always matched and cpptext resides outside any nest. The tricky part is there is also structcpptext which resides in 1 nest always and can contain nested braces but each only contain a nest depth of one, being functions/constructors.
Any help would be greatly appreciated because at this point I feel like Im bangin my head against a wall. Thanks.