ASH syntax highlighting in Kate

cakyrespa

Member
http://svn.mfgames.com/KoLmafia/kate/ash.xml

Not really sure if anyone is interested, but I started setting up a syntax highlighting for Kate (a KDE editor). It isn't perfect, but at least most of the variables are highlighted enough for me to enjoy editing. I also think it makes ASH editing just a little easier on the eyes.

I put this into:

$HOME/.kde/share/apps/katepart/syntax/

Then I had to delete the following file so it would scan the syntax directories again.

$HOME/.kde/share/config/katesyntaxhighlightingrc
 

Spiny

Member
I haven't looked at what you posted, but generally go thru the process of:

Highlighting > Sources > C++

Visually what would be different with what you worked up? I'm sure that it would save having to manually go thru the menus each time I look at a new .ash script, but would there be any other advantage?

Thanks.
 

cakyrespa

Member
I haven't looked at what you posted, but generally go thru the process of:

Highlighting > Sources > C++

Visually what would be different with what you worked up? I'm sure that it would save having to manually go thru the menus each time I look at a new .ash script, but would there be any other advantage?

Mainly, it set it up so any file ending in .ash will automatically have this syntax. So, you don't need to manually set it up.

I also made the following keywords: call, remove, exists, foreach, upto by, downto, in, repeat, until.

I made the following types: int, float, boolean, string, location, item, effect, familiar, class, stat, skill, slot, zodiac and keyword. So, just little things that fit more with the ASH stuff instead of C++.
 

Heffed

Member
I made a syntax highlighter for the ConTEXT editor around 3 years ago. There's a thread about it around here somewhere...

Ah, I found it. Scripting tool?

After coming back from my hiatus, I've updated it for the additions made in my absence. If there are any ConTEXT users, I could update the post.
 

dj_d

Member
If there are any users who want to share their emacs settings, I'd be most grateful. Specifically, however you tell it that hashes are comments and apostrophes are not.
 

cakyrespa

Member
If there are any users who want to share their emacs settings, I'd be most grateful. Specifically, however you tell it that hashes are comments and apostrophes are not.

Heh, I could probably create a cc-mode derived mode for ASH too. I did create one of the csharp-modes. But, if you want anything less fancy, can't do much less than that.
 

Veracity

Developer
Staff member
I use emacs and currently just use c-mode for ASH. It's ALMOST good enough, but this little nit causes problems:

$item[bitchin' meatcar]
$skill[Ur-Kel's Aria of Annoyance]

[] are like string delimiters in that context. The result is emacs thinks everything up to the NEXT ' is inside a character literal or something.

My hack workaround is to add a comment to such lines:

item i = $item[bitchin' meatcar]; // '];

That's a hack.

If you create an ASH mode derived from cc-mode, I'd be grateful.
 

Catch-22

Active member
If you create an ASH mode derived from cc-mode, I'd be grateful.

I have been working on an ASH major mode on and off for a while now, but I keep losing interest. I think it currently supports syntax highlighting, comment lines, some reserved words and types used in ASH. Indentation is a bit borked.

I kept getting disheartened because a lot of stuff in the wiki and documentation surrounding Mafia is outdated and unreliable. I think the wiki has potential to be a great resource, but it's currently pretty poorly maintained.

I could possibly post up what I've done so far but I've gotta figure out where I have put it :)

Currently at work and I've got a lot of stuff on this weekend, so I'll see if I get a chance to find it.
 

dj_d

Member
I will pay 1 Mr. A for the first emacs major mode that completely fulfills Veracity's wants and needs.

(Least I can do after everything she does for us - and I'll be happy to get my hands on it too)
 

cakyrespa

Member
It is on. :p

Veracity: Want to give us a list of your "wants and needs" as it pertains to the Emacs mode? I presume it includes font-locking, but best to ask.
 

cakyrespa

Member
I'd much rather a collaborative effort than a reward driven competition.

Bah, moral high ground. :p I was going to do it anyways. Actually, I have a large hunk of a version done. Just need to fix a regex on [] where it is sometimes a string, sometimes not ($item[bob] verses some_map[bob]), and add in the keywords I've missed.

But, first to go see 9.

I should have something posted tonight.
 

cakyrespa

Member
Well, I couldn't figure out the silly little thing with the regex on the aggregates.

Part of it is that ash allows this:

Code:
$item[Doc Galaktik's Ailment Ointment])

but it doesn't allow this:

Code:
string [string] values;
values [Doc's  Galaktik's Ailment Ointment] = "234 bob";

I got a regexp to catch it, but the string matching is catching it first. But, otherwise, I think it is looking pretty decent. I changed it so the [] is treated as string characters, so it looks bad when you have some_map[some_other_map[123]], but at least it doesn't need you to jump through hoops to avoid the font-locking.

http://svn.mfgames.com/KoLmafia/emacs/ash-mode.el

The above link goes to my Subversion server with the Emacs mode. Obviously, I'm open to suggestions on the fix, comments, etc.
 

dj_d

Member
Super cool! Big improvement over raw c-mode.

Veracity, do we have a winner? Or is there anything missing?
 

Catch-22

Active member
Well, I couldn't figure out the silly little thing with the regex on the aggregates.

I got a regexp to catch it, but the string matching is catching it first.

This is because you have the string matcher declared beforehand. In elisp you have to define what you want caught in the order you want them caught, so if the string matching is catching it first, define the string matcher after your map matcher ;)

Difference between what I have and what you have is that mine is not derived from cc-mode. It is it's own file, the downside to that is there's a bit more work involved. If dj_d and Veracity are happy with what you've come up with then this is a good result anyway :)
 

Veracity

Developer
Staff member
I will try this out soon. Unfortunately, I am super busy all day today, but I'll have time by Tuesday evening at the latest. Thanks a lot for your efforts. I have high hopes!
 

cakyrespa

Member
This is because you have the string matcher declared beforehand. In elisp you have to define what you want caught in the order you want them caught, so if the string matching is catching it first, define the string matcher after your map matcher ;)

Difference between what I have and what you have is that mine is not derived from cc-mode. It is it's own file, the downside to that is there's a bit more work involved. If dj_d and Veracity are happy with what you've come up with then this is a good result anyway :)

Yeah, I tried putting it before "c-basic-matchers-before" but at that point, they already identified that it was an errant string. I just need to delve into the code a bit more and find where they determine that first. I went with the safest approach (treating [] as quotes) until I can figure it out.

I do need to figure out the rest of the keywords that I missed (notify comes to mind) and also clean up the "import" matching, I think it is wrong (but it indents okay).
 
Top