Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JS AST compilation (blendmaster fork) #481

Closed
gkz opened this issue Apr 6, 2014 · 7 comments
Closed

JS AST compilation (blendmaster fork) #481

gkz opened this issue Apr 6, 2014 · 7 comments

Comments

@gkz
Copy link
Owner

gkz commented Apr 6, 2014

https://github.com/blendmaster/LiveScript/tree/esprima

@blendmaster

wow!

I was thinking of doing something like this in the future, but you are doing it!

@gkz gkz added the discussion label Apr 6, 2014
@vendethiel
Copy link
Contributor

👍

@blendmaster
Copy link

Hey, gkz and Nami-doc, I'm pretty excited about this too. I just wish I had more time to work on it.

One pertinent question is that of inline JS support. Right now, my branch throws an error if the plain JS AST node is encountered, (which is fortunately nowhere in the compiler). Furthermore, I can't think of a good way to take a little snippet of JS and mix it back into the AST. Does CSR support JS inline?

Also, if anybody with more free time than me would like to help, you should be able to jump in with the strategy described in the readme:

https://github.com/blendmaster/LiveScript/tree/esprima#how-to-develop

It's really close on a lot of the test files. The main discrepancy is the use of temporary variables. The kinda-sorta-one-pass compiler is able to "free" temporary vars by compiling a string earlier than we can compile to JS. I think changing the Block#compile strategy to free up vars after every sub-expression would fix this though.

Other stuff to do would be general code quality and documentation in ast.ls. It's a neat compiler, but filled with abuse to make the kinda-sorta-one-pass thing work.

Also, re: source maps, once LS AST -> JS AST works, we'll have to add the column number to lexer.ls as emitted to yylloc in Jison. I was going to do this with coco's lexer a while back, but it's a beast. If anybody is willing to work on column numbers, that's be an equally big step to getting source maps.

@vendethiel
Copy link
Contributor

CSR uses eval, plain and simple.

@blendmaster
Copy link

CSR uses eval, plain and simple.

Huh, so it does. Not the most efficient thing I guess, but at least it's mostly backwards compatible.

http://michaelficarra.github.io/CoffeeScriptRedux/#try:for%20a%20in%20%60some%20stuff%60%0A%20%20c

@michaelficarra
Copy link
Contributor

Yeah, a direct call to eval works just fine. It was suggested that I include a JS parser and parse the JS in backquotes with it, but I think that's overkill. It's a feature that should never be used anyway. Your example did show that CSR isn't caching these expressions, which means I must have forgotten to mark them as having side effects. I'll open an issue for that.

@gkz
Copy link
Owner Author

gkz commented Apr 11, 2014

timeline:

  • Node 0.12 is released, with support for generators
  • LiveScript 1.3 is released
  • The fork is updated with LS1.3, and when everything works is merged
  • Try to add col-numbers and add source maps

@gkz
Copy link
Owner Author

gkz commented Feb 23, 2015

I forgot about this! I'll have to take a look again sometime

@gkz gkz closed this as completed Apr 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants