I'm finding the bigger functions a little too hard to read.
One of the problems is that, with .addTo(), the construction has shifted
from
begin functional to being operational. Another problem is that the code is
really big. 5x explosion on a 3 line function is much more manageable that
5x
on a 20 line function.
Florian's idea was that we parse the canned JS to generate the AST.
I think this CL exposes the limits of a library of AST construction
combinators,
so I'm in favor of a parsing approach since the bigger functions will be
more
maintainable.
Starting on a JS parser sooner has some advantages.
With a little modification to parse placeholders we could parse the JS(...)
code
and solve the problem we have when substituting expressions of unknown
precedence. We have mostly been very lucky here.
Parsing with placeholders also opens the way for templated generation in
some
places where we generate code by hand. I think we would want named
placeholders
(#FOO) for bigger templates rather than the positional JS-# placeholders,
and
some splicing (#..ARGS) to make that work.
The parser does not have to cover the whole language, e.g. we can omit
parsing
'with', always use // style comments, always use \u escapes for quotes in
strings, limit the syntax of numbers, etc. We can add statements like
switch
and do-while as we need them. Only a subset of the language is on the
critical
path.
https://codereview.chromium.org/12208067/