3 ms·
Looks like recursive-descent + precedence climbing. Pretty run-of-the-mill design, but works very well. Some of the identifiers are a bit unwieldy, however; e.
by userbinator 9y ago
Looks like recursive-descent + precedence climbing. Pretty run-of-the-mill design, but works very well.
Some of the identifiers are a bit unwieldy, however; e.g.
parseForOrForInOrForOfStatement
I think something closer to this would be clearer
parse_for_stmts()
since that function AFAICS parses all statements beginning with "for".
- rattray 9y agoHaving delved into Babylon's code quite a bit, I'm honestly appreciative of the lengthier name.
- rattray 9y agoSelf-replying, I did not mean to imply that Babylon's codebase is generally unreadable or overly terse. I actually found it surprisingly easy to work in as someone who's never worked on a parser before. I just meant that the code for for-loops in particular is complicated, and having very specific names helps in that area.
- chubot 9y agoYeah I noticed when looking at the TypeScript compiler itself that the names are ridiculously long. Probably because they edit them in an IDE like VS Code. Does TypeScript minify your code or is that a separate step?
- dgoldstein 9y agoSeparate. The common thing is to use uglifyjs for that.
- shados 9y agoPretty much all editors worth talking about support TypeScript's language server. So even if you're using vim or whatever, you get the full featured editing experience (or at least, most of it). That includes proper auto complete.
- VeejayRampay 9y agoNo one really uses snake case in that context though so maybe parseForStatements()
- z3t4 9y agoIt's less mental work to copy/paste the name then to remember what it does.