Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Basic syntax coloring is easy: just reuse your tokenizer. You already need a tokenizer for your compiler or interpreter. Assign colors to keywords, strings, numbers, and comments. For this simple syntax coloring you don't need to parse, only tokenize, and for pretty much all languages you can do it on a per-line basis.

Auto-formatting is also easy: just don't do it. Does a toy language really need it? I have two languages with syntax coloring and zero languages with auto-formatting. I think syntax coloring is table stakes but auto-formatting is not. You can have an interesting toy language without auto-formatting.



I dunno, there are a few things I like highlighted that you can’t easily do with just a tokenizer, like parameters or function calls.

> Auto-formatting is also easy: just don't do it.

I agree with this, except that auto-closing grouping symbols is extremely useful and turns out to be pretty easy to support.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: