3 ms·
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 ho
by curveship 12y ago
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.
- tipiirai 12y agoI'm aware of this. Just wanting to avoid going there at this point and hoping that a smaller regex- based thing can do it.
- gosukiwi 12y agoWell, 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.
- tipiirai 12y agoI'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!