Thursday | 21 NOV 2024
[ previous ]
[ next ]

Bad Habits - Syntax Highlighting

Title:
Date: 2022-05-29
Tags:  

Worked on a tiny little project to keep track of examples that I like for work. As a tangent I wrote a syntax highlighter for BASIC, I took the syntax file from my vim config and then wrote js code to parse the content and add in spans.

It feels quite fragile and wrong and I wonder what the correct way of doing syntax highlighting is. I imagine it might be better to build a tokenizer and then do the highlighting with tokens. Currently I just break on spaces and then deal with parens and quotes specifically.

I need to go back and read the crafting interpreters book because I think that was great when I followed it and I've used some of the core ideas but I think I need a refreshed.

For now however the project is done, I have some barebones highlighting and using the dracula theme was great. Love that it has the colors in a very obvious place and named appropriately.

Also dealing with my vim syntax file finally let me update it to add some keywords that the original author missed. I never bothered to before now which was nice.