Comments (4)
Cool, looking forward to an example.
from filbert.
Alright code stuff, here is what you'd have in pythonRuntime
modules : {
random : new (function() {
var self = this;
self.random = function () { return Math.random(); };
self.randint = function (a, b) { return self.randrange(a, b+1); };
etc. etc.
})(),
math : new (function() {
var self = this;
this.sin = Math.sin;
etc. etc.
})()
}
Then the code they'd enter would be something like the following
import math, random as rand
from math import sin as sine
This would be transformed into the following code.
var math = pythonRuntime.modules.math;
var rand = pythonRuntime.modules.random;
var sin = pythonRuntime.modules.math.sine;
Of course you'd modify the vars and so as normal so you only declare once but that's the model I thought of.
from filbert.
I like it! This should work nicely.
Why would you use self
instead of this
directly in your modules objects?
parseSubscripts
has examples of generating AST nodes to reference runtime objects.
createVarDeclFromId
will help you create an AST node of the form var math = something;
.
from
and import
keywords are currently skipped over in parseStatement
.
We also need to make sure new parsing work is duplicated in filbert_loose.js. There is currently more duplication than necessary between filbert.js and filbert_loose.js.
from filbert.
The self instead of this is a habit to make sure scoping doesn't suddenly screw up by giving me the inner functions scope with this so I also get the one I was trying for. I'll look into those and try and get something done.
Also I have been forgetting to update filbert_loose.js, I'll try and remember to do that. I'm going to need to start having multiple branches here or the different goals will start polluting each other.
from filbert.
Related Issues (20)
- int() rounds negative numbers in the wrong direction HOT 2
- Looping over characters in string gives indexes, not values HOT 1
- [Python] Reassigning a function parameter treats it as undefined until reassignment HOT 1
- Multiple Assignment doesn't work
- Move test python snippets to own files
- Python interpreter
- Implement chained comparisons for numerical ranges (0 < x < 10)
- String to list transformation HOT 2
- Memory usage spikes while trying to parse_dammit certain code. HOT 1
- str(True) and str(False): Cannot read property 'truthy' of undefined
- list.pop(index) doesn't work HOT 3
- Python lists don't have .push method HOT 1
- Null makes its way into ast body.body HOT 1
- v1 target refinement? HOT 2
- Compatibility with browsers HOT 1
- Is the project reviving? HOT 1
- Is there a way to check the types of nodes? (similar to @babel/types) HOT 3
- Taking back parsed object into python code HOT 1
- npm version is out of date HOT 2
- Support of named arguments?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from filbert.