Page 1 of 1

Syntax highlighting

PostPosted: Wed Feb 16, 2011 8:09 pm
by Henrique Andrade
Dear RATS Community,

According to Wikipedia:
Syntax highlighting (http://en.wikipedia.org/wiki/Syntax_highlighting) is a feature of some text editors that display text—especially source code—in different colors and fonts according to the category of terms. This feature eases writing in a structured language such as a programming language or a markup language as both structures and syntax errors are visually distinct.

I would like to have syntax highlighting in RATS. In my humble opinion, this simple feature makes the programming task more enjoyable.

What do you think? :)

Best regards,

Re: Syntax highlighting

PostPosted: Thu Feb 17, 2011 6:31 am
by ac_1
Henrique Andrade wrote:Dear RATS Community,

According to Wikipedia:
Syntax highlighting (http://en.wikipedia.org/wiki/Syntax_highlighting) is a feature of some text editors that display text—especially source code—in different colors and fonts according to the category of terms. This feature eases writing in a structured language such as a programming language or a markup language as both structures and syntax errors are visually distinct.

I would like to have syntax highlighting in RATS. In my humble opinion, this simple feature makes the programming task more enjoyable.

What do you think? :)

Best regards,


Yes, this is a great idea! I would also like this feature.

In MATLAB, each line in the editor is numbered and then in the Command Window if there is an error in code the compiler indicates at what line and where the error is: either Main Program and/or Function(s). This would also be useful in RATS as-well.

Re: Syntax highlighting

PostPosted: Thu Feb 17, 2011 4:17 pm
by TomDoan
Yes, that's a good idea. It's a bit harder with RATS than with the types of programs you're discussing for several reasons:

1. RATS has many more "keywords". Most programming languages have only about a dozen control words (like function, if, else), some pre-defined data types and everything else is an expression. RATS has those control words plus about 180 other instructions which makes a recognizer a bit more difficult.

2. If you're in the "input" window, RATS is actively watching what you type for Enter keystrokes that will execute instructions. If you look at the behavior of a syntax coloring scheme in a "passive" editor, it will often switch the colors of large chunks of text as type and a line apparently switches to and from being (say) a comment. That's not a problem in that type of situation because the computer can analyze and re-analyze faster than you can type. We would have to be much more careful about turning the analyzer on and off to avoid slowing the execution of the program.

3. We have editors on three distinct platforms (Windows, Mac, Unix) which all have very different text editors.

Before we get to the syntax highlighting, we'll probably add the simpler "bracket" matcher, which looks for matches to { } and () combinations, counting through nesting levels.

Re: Syntax highlighting

PostPosted: Mon Feb 21, 2011 5:52 pm
by Henrique Andrade
Dear Tom,

And if we could use syntax highlighting only in some places, like comment lines?