Syntax Highlighters

Overview

The Computer Science Department at Tufts often uses in-house programming languages to supplement course material. An unfortunate consequence of using languages designed by professors is a total lack of syntax highlighting in code-editing softwares.

My syntax highlighters are implemented for Sublime Text 3, and pattern matching is accomplished through regular expressions in YAML files.


UMASM Highlighters

The initial inspiration for the development of a novel syntax highlighting package was my final project for Machine Structure & Programming (CS 0040), the RPN calculator.

The RPN calculator must be implemented in UMASM, an assembly-level language designed for a univeral machine emulation introduced earlier in the course.

Designing an RPN calculator in an assembly-level language is an interesting challenge, but I found that programming without UMASM specific syntax highlighting was frustrating.

After attempting to program in UMASM for a few minutes, I decided that I
could not bring myself to work with unformatted, not-at-all-beautified,
plain-text code. Since I have a particularly profound proclivity for
productive procrastination, I spent some time implementing a UMASM syntax
highlighter for Sublime 3.

I implemented two versions:

  1. UMASM: The first is simpler. It will style any UMASM source file using a color scheme similar to Sublime’s default C highlighter.
  2. UMASM Improved: The second includes additional regex that will identify and brightly highlight ill-formed code.

The positive effect of the package on the readability of UMASM source code is demonstrated by the following comparison.

The second version of the highlighter can reliably identify and highlight syntactically invalid lines of UMASM source code. The code below incorrectly uses an assignment operator where the walrus operator := is required, and so that line is highlighted.


uSmallTalk Highlighter

The final project for Programming Languages (CS 0105) is written in uSmallTalk, a toy language invented by Norman Ramsey for the course. The positive effect of the package on the readability of uSmallTalk source code is demonstrated by the following comparison.

This syntax highlighter employs more advanced regular expressions to contextually highlight identifiers. For example, the identifier following the keyword method is colored green, but other identifiers are left uncolored.