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

The compiler also fails if a multi-line comment doesn't end at the end of a line.

  <!-- a comment --> and more text
It outputs an empty compiled file.

My honest opinion is that you should consider rewriting the compiler in a classic tokenize-parse-compile style. Several projects (like mustache.js) have had to go through this evolution. Your current solution -- line-by-line with regexes and state flags -- will only get hairier and hairier.



Well, maybe a line-by-line solution is good enough, I mean, it would only target a subset but the code will be readable. I still think though that any compiler which is intended for real apps should do the classic tokenize-parse-compile steps.


I'll start by improving the current implementation and see how far I can go with it without making it crazy.

I'll start tokenizing after a concrete use case.

Definitely keep this in mind. Thanks!


I'm aware of this. Just wanting to avoid going there at this point and hoping that a smaller regex- based thing can do it.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

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

Search: