rouge-ruby / rouge

A pure Ruby code highlighter that is compatible with Pygments
https://rouge.jneen.net/
Other
3.33k stars 735 forks source link

Add Forth lexer #1880

Open tkers opened 1 year ago

tkers commented 1 year ago

This adds a lexer for the Forth programming language.

forth-sample

Since this is a bit of an unusual language (lacking a rigid structure and syntax), there is a bit of a balancing act going on between accuracy and usability. The highlighting rules follow conventions that most editors with Forth support also follow (e.g. considering control structures such as IF/THEN and DO/LOOP as keywords, and considering words such as :, CREATE and VARIABLE as defining words, with the next word highlighted as the function name).

When working with more fancy code constructs that switch between compiler modes, or when creating higher order defining words, some of these highlights will inevitably be incorrect. These inaccuracies are usually limited to (the first word following) parsing words and should not "break the highlighting" for any larger parts of the codebase.