This repository has moved to https://github.com/LivelyKernel/lively.next/tree/master/lively.ast
livelykernel / lively.ast Goto Github PK
View Code? Open in Web Editor NEWParsing JS code into ASTs and tools to query and transform these trees.
Parsing JS code into ASTs and tools to query and transform these trees.
This repository has moved to https://github.com/LivelyKernel/lively.next/tree/master/lively.ast
When using a definition wrapping function via lively.ast.capturing.rewriteToCaptureTopLevelVariables(..., {declarationWrapper: astForDeclFunc})
then simple assignments are correctly wrapped:
i = i+1
becomes _rec.i = _rec._define('i', 'assignment', _rec.i + 1, _rec);
However, expressions like i++
or i+=1
aren't correctly identified as modifications and not wrapped.
Fix that!
when using livley.ast
lively.ast.parseFunction("function() { 3 + 4}")
We got an error:
lively.modules-with-lively.vm.js:9524 Uncaught (in promise) TypeError: visitor[(override || node.type)] is not a function
at c (https://lively-kernel.org/lively4/lively4-jens/src/external/lively.modules-with-lively.vm.js:9524:35)
at Object.recursive (https://lively-kernel.org/lively4/lively4-jens/src/external/lively.modules-with-lively.vm.js:9525:5)
at forEachNode (https://lively-kernel.org/lively4/lively4-jens/src/external/lively.modules-with-lively.vm.js:18234:10)
at addSource (https://lively-kernel.org/lively4/lively4-jens/src/external/lively.modules-with-lively.vm.js:18293:12)
at Object.parseFunction (https://lively-kernel.org/lively4/lively4-jens/src/external/lively.modules-with-lively.vm.js:18832:32)
By not using "addSource" we got rid of the error... what does it do?
lively.ast.parseFunction = function parseFunction(source, options) {
var src = '(' + source + ')',
ast = lively.ast.parse(src, options);
// /*if (options.addSource) */addSource(ast, src);
return ast.body[0].expression;
}
In versions 0.9.0 and up, I can't successfully call any of the AST helper methods.
> var ast = require('lively.ast')
undefined
> ast.printAst(ast.parse("1 + 2"))
TypeError: Cannot read property 'string' of undefined
at Object.printAst (<yadda\yadda>\node_modules\lively.ast\dist\lively.ast.js:12910:23)
at repl:1:5
at sigintHandlersWrap (vm.js:32:31)
at sigintHandlersWrap (vm.js:96:12)
at ContextifyScript.Script.runInContext (vm.js:31:12)
at REPLServer.defaultEval (repl.js:308:29)
at bound (domain.js:280:14)
at REPLServer.runBound [as eval] (domain.js:293:12)
at REPLServer.<anonymous> (repl.js:489:10)
at emitOne (events.js:101:20)
>
The code above works fine if I use 0.8.1
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.