ASH syntax highlighting in Kate

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.

This is because it's not defined in cc-fonts, it's part of cc-engine and cc-langs.
 
Awesome, that is what I guessed it was. I should have that done then. Not sure if I'm missing other keywords, at some point, I should really go through the Java code and see what I miss (or wait until someone points out my mistake).

Current issues:

* $item[bob's toy] verses some_variable[bob's toy] is still broken. But, at least it is better than before. :)

* cli_execute {... } doesn't font-lock properly.

* Hash comments (# some comment) doesn't work.
 
Not sure if I'm missing other keywords,

For what it is worth, here's all the keywords I have in my notepad++ ash configuration. Maybe you'll find a keyword you're missing. Let me know if you have one that I missed.

$item $effect $class $stat $skill $familiar $slot $location $zodiac $monster $element $items $effects $classes $stats $skills $familiars $slots $locations $monsters $elements $booleans $ints $floats $strings

int float void record string boolean buffer item effect class stat skill familiar slot location zodiac monster element

if else while for from upto downto by foreach in repeat until return switch case break default continue contains sort script notify

enable disable user_confirm logprint print print_html abort cli_execute load_html write writeln form_field visit_url wait to_string to_boolean to_int to_float to_item to_class to_stat to_skill to_effect to_location to_familiar to_monster to_slot to_url today_to_string moon_phase moon_light stat_bonus_today stat_bonus_tomorrow session_logs adventure add_item_condition buy create use eat drink put_closet put_shop put_stash put_display take_closet take_storage take_display take_stash autosell hermit retrieve_item get_inventory is_npc_item is_tradeable daily_special refresh_stash available_amount item_amount closet_amount creatable_amount get_ingredients storage_amount display_amount shop_amount stash_amount pulls_remaining stills_available have_mushroom_plot refresh_status restore_hp restore_mp my_name my_id my_hash in_muscle_sign in_mysticality_sign in_moxie_sign in_bad_moon my_class my_level my_hp my_maxhp my_mp my_maxmp my_primestat my_basestat my_buffedstat my_meat my_adventures my_turncount my_fullness fullness_limit my_inebriety inebriety_limit my_spleen_use spleen_limit can_eat can_drink turns_played can_interact in_hardcore have_skill mp_cost turns_per_cast have_effect use_skill attack steal runaway use_skill throw_item throw_items run_combat can_equip equip equipped_item have_equipped outfit have_outfit my_familiar have_familiar use_familiar familiar_equipment familiar_equipped_equipment familiar_weight weapon_hands item_type weapon_type get_power council current_mcd change_mcd have_chef have_bartender contains_text extract_meat extract_items length index_of last_index_of substring to_lower_case to_upper_case append insert replace delete append_tail append_replacement create_matcher find start end group group_count replace_first replace_all reset replace_string split_string group_string chat_reply entryway hedgemaze guardians chamber tavern random round truncate floor ceil square_root url_encode url_decode get_property set_property count clear file_to_map map_to_file my_location get_monsters expected_damage monster_level_adjustment weight_adjustment mana_cost_modifier raw_damage_absorption damage_absorption_percent daage_reduction elemental_resistance elemental_resistance combat_rate_modifier initiative_modifier experience_bonus meat_drop_modifier item_drop_modifier buffed_hit_stat current_hit_stat monster_element monster_attack monster_defense monster_hp item_drops will_usually_miss will_usually_dodge numeric_modifier boolean_modifier effect_modifier class_modifier stat_modifier mall_price galaktik_cures_discounted get_ccs_action guild_store_available get_counters my_closet_meat get_closet historical_price historical_age is_goal string_modifier batch_open batch_close appearance_rates set_length
 
Last edited by a moderator:
Here's a bit of trickiness. cli_execute is either a keyword or a function name, depending on context. The function just takes a string argument and all is peachy, but the keyword works like this:

Code:
cli_execute {
  # Yes!
  echo Hello world!
  // No
  echo Goodbye, cruel world
}

That is a block delimited by {}, and it would be nice to indent the lines in it appropriately, but the CLI commands are just comments, as far as ASH is concerned.

Try typing it in by hand and watch how it autoindents (and how it reindents when you type a tab) currently...

Edit: And Bale, those are not all keywords. Many are just functions. Keywords:

Code:
	static
	{
		// Constants
		reservedWords.add( "true" );
		reservedWords.add( "false" );

		// Operators
		reservedWords.add( "contains" );
		reservedWords.add( "remove" );
		reservedWords.add( "new" );

		// Control flow
		reservedWords.add( "if" );
		reservedWords.add( "else" );
		reservedWords.add( "foreach" );
		reservedWords.add( "in" );
		reservedWords.add( "for" );
		reservedWords.add( "from" );
		reservedWords.add( "upto" );
		reservedWords.add( "downto" );
		reservedWords.add( "by" );
		reservedWords.add( "while" );
		reservedWords.add( "repeat" );
		reservedWords.add( "until" );
		reservedWords.add( "break" );
		reservedWords.add( "continue" );
		reservedWords.add( "return" );
		reservedWords.add( "exit" );
		reservedWords.add( "switch" );
		reservedWords.add( "case" );
		reservedWords.add( "default" );

		// Data types
		reservedWords.add( "void" );
		reservedWords.add( "boolean" );
		reservedWords.add( "int" );
		reservedWords.add( "float" );
		reservedWords.add( "string" );
		reservedWords.add( "buffer" );
		reservedWords.add( "matcher" );

		reservedWords.add( "item" );
		reservedWords.add( "location" );
		reservedWords.add( "class" );
		reservedWords.add( "stat" );
		reservedWords.add( "skill" );
		reservedWords.add( "effect" );
		reservedWords.add( "familiar" );
		reservedWords.add( "slot" );
		reservedWords.add( "monster" );
		reservedWords.add( "element" );

		reservedWords.add( "record" );
		reservedWords.add( "typedef" );
	}

Edit 2: I think we've not always declare keywords to be be reserved words...

Code:
for i from 1 to 10 by 2
    print( i );
How about "to"?
 
Last edited:
I'm not sure if this is within scope of an emacs mode, or perhaps it's just my unusual style, but I'd expect

Code:
integer sum = 5 +
  2;
to actually indent like:

Code:
integer sum = 5 +
              2;
This works the way I'd expect, by comparison:
Code:
print("bar" +
      "baz");
 
http://www.informatik.uni-hamburg.de/RZ/software/emacs/cc-mode/cc-mode_9.html#SEC33
http://www.informatik.uni-hamburg.de/RZ/software/emacs/cc-mode/cc-mode_7.html#SEC28

Check out the above links. You can set up custom indenting for your style using some of those. I set up my .emacs to include the style I use (but I don't have access to that from work), including one for Mono work verses my personal C# work. I happen to use my default for ASH. Once I get home, I'll see about posting an example .emacs file.
 
Bah, I couldn't find my .emacs example, must have accidently deleted it.

Code:
(defun my-ash-mode-hook ()
   (progn
    (setq tab-width 4)
  (c-set-offset 'substatement-open 0)))
 (add-hook 'ash-mode-hook 'my-ash-mode-hook)

Something like that should work. You can also put a function in the "0" but I forgot if you need a '(some-function) or just (function). Been a while for that and I can't find my examples.

I did make a minor change to the ash-mode, mainly to add the keywords I missed. I didn't put in the built-in functions though.
 
Looking good... any progress on the # comment?

Also, I rescind my earlier request for a change in indentation behavior - I realized what I'm asking for would create inconsistency with other behaviors.
 
Last edited:
# comment support on it's own is relatively easy to setup, the trouble I guess caky is having is with figuring out where it sits in the cc-modes.
 
Looking good... any progress on the # comment?

Yeah, just figuring out how to do it. Implementing C-based commented (// and /**/) is easy, single character EOL comments are a bit harder with cc-mode.

Also, I rescind my earlier request for a change in indentation behavior - I realized what I'm asking for would create inconsistency with other behaviors.

Let me figure out how to do it and put it in some documentation of some sort. That way, if you want it, you know how to do it, but it won't be the default behavior.

http://tinyurl.com/lwh7f3

Oh, for those who are interested, I started collecting the open issues in my bug tracker.
 
Back
Top