I'm trying to create a custom syntax highlighter for Smash code, a language for text-based adventure games:
http://www.rinkworks.com/smash/tutorial/
here is a simple block of code:
Statements in Smash code are represented by single letters.
In the example above "c" represents an "if" statement, "C" is and "else" statement, "r:#" generates a random number, "p" prints text to the screen and "g" sends the player to a different location in the game.
blocks of code are determined by tabs
Here are some of the things I'd like to do with syntax highlighting:
I'd like to highlight all the command codes ("c","C","p" etc. there are about 32")
I'd like to have automatic indenting of "if" blocks
Finally like to have code folding for "if" blocks and nested "if" blocks
I've tried these things but I have run into several problems.
Firstly, when I specify the commands that need to be highlighted ("c","C","p" etc) it works fine, except that letters in print statements also get highlited, for example, the second last lind of code in my example above, "c" in "they have the letter c embossed into them" is highlighted when it shouldn't be, how do I fix that?
secondly, how can I implement autoindenting?
and lastly, is code folding even possible?
http://www.rinkworks.com/smash/tutorial/
here is a simple block of code:
Code: Select all
c coins = 0
coins = r:10
p You have no money, you are given {coins} coins
C
p You already have money.
p You look at the coins, they have the letter c embossed into them
g outsideBank
In the example above "c" represents an "if" statement, "C" is and "else" statement, "r:#" generates a random number, "p" prints text to the screen and "g" sends the player to a different location in the game.
blocks of code are determined by tabs
Here are some of the things I'd like to do with syntax highlighting:
I'd like to highlight all the command codes ("c","C","p" etc. there are about 32")
I'd like to have automatic indenting of "if" blocks
Finally like to have code folding for "if" blocks and nested "if" blocks
I've tried these things but I have run into several problems.
Firstly, when I specify the commands that need to be highlighted ("c","C","p" etc) it works fine, except that letters in print statements also get highlited, for example, the second last lind of code in my example above, "c" in "they have the letter c embossed into them" is highlighted when it shouldn't be, how do I fix that?
secondly, how can I implement autoindenting?
and lastly, is code folding even possible?