HOMEBLOGDEVLOG

Fixup operator handling

Adam C. Clifton
8 Mar 2026

The initial code for my custom programming language would use the character token to define what an operator was eg: + or *. The problem is that some operators are more than one character, eg: += or >>. So what I had originally done was when tokenizing the source code i'd squish anything that could be an operator into the one "character".

This worked 99% of the time, until we get to nested templates, eg: Template<Class<SubClass>> the last two characters should be two separate right angled brackets, but get merged into a special double angled bracket. Then the template parser would fail as it specifically needs a single angled bracket to complete.

When I first ran into the issue, i added a quick hack to work around it, if there was a >!> in the code it would always parse as two angled brackets. Now quick fixes can survive forever, but the time has come for this one.

The operator code now handles a vector of tokens instead of a single one, that means we no longer need to merge characters, and so we don't need the hax on top of it.

Previous: Fix cross name class lookup
Next: Move to company id instead of company index
© Numbat Logic Pty Ltd 2014 - 2026