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

Add initial VBscript to JS transpiling support #32

Merged
merged 11 commits into from
Aug 25, 2019
Merged

Conversation

jsm174
Copy link
Contributor

@jsm174 jsm174 commented Aug 23, 2019

This PR adds initial support for transpiling VBScript into Javascript.

Currently the grammar can handle:

  1. Variable declarations
  2. Const declarations
  3. Subcall statements with params
  4. Subcall statements without params

@codecov
Copy link

codecov bot commented Aug 23, 2019

Codecov Report

Merging #32 into master will increase coverage by 0.1%.
The diff coverage is 95.7%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master     #32     +/-   ##
========================================
+ Coverage    90.3%   90.3%   +0.1%     
========================================
  Files         136     139      +3     
  Lines        8595    8641     +46     
  Branches      988     991      +3     
========================================
+ Hits         7756    7800     +44     
- Misses        509     511      +2     
  Partials      330     330
Impacted Files Coverage Δ
lib/scripting/transpile.ts 100% <100%> (ø)
lib/scripting/post-process.ts 94.8% <94.8%> (ø)
lib/scripting/estree.ts 94.8% <94.8%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3e013fb...0d999e0. Read the comment docs.

@freezy
Copy link
Member

freezy commented Aug 23, 2019

Yay! :)

I've made some progress on the API side, Kicker, Plunger, Primitive and Surface APIs are implemented and should be functional.

If you have a minute to rebase this against master (the physics changes are merged) that would be great, otherwise I'll do it later.

Thanks a lot, this is awesome!

@freezy
Copy link
Member

freezy commented Aug 24, 2019

I refactored quite a lot (don't worry, your code was still immensely helpful!).

There is going to be a lot of post-processing code, so I started by splitting it into two files:

  • estree.ts does only simple stupid things. It basically contains helper classes that instantiate objects according to the ESTree specs. There might even exist a library doing that (I quickly looked but didn't find anything). It never takes in arrays of weird data. Every parameter is just a prop of the object. Some simply mapping is allowed, but otherwise they must stay very simple.
  • post-process.ts does everything too complicated to do inline in the .ne. Functions here take an array what nearley gives them, and they do the complicated logic. They are also documented with examples.

One note: Try to avoid putting rules in the grammar that aren't used. I commented some out, but typically I would assume everything that is in there is currently in use (aka unit-tested).

I think we have a good base now. I'll let you go through it and if you're happy I'll merge!

@jsm174
Copy link
Contributor Author

jsm174 commented Aug 25, 2019

All the changes are fine. I like it! Agree with rules that aren't used, sorry about that!

@freezy freezy merged commit 35dd209 into master Aug 25, 2019
@freezy freezy deleted the feature/scripting branch August 25, 2019 19:48
@freezy
Copy link
Member

freezy commented Aug 25, 2019

Merged, thanks!

For me the next thing would be function definitions. For example:

Sub BallDrain_Hit()
	BallRelease.CreateBall
	BallRelease.Kick 0, -1
End Sub

would become:

function BallDrain_Hit() {
	BallRelease.CreateBall();
	BallRelease.Kick(0, -1);
}

This would allow me to start implementing the event handling that is going on.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants