Code Monkey home page Code Monkey logo

lively.ast's People

Contributors

rksm avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lively.ast's Issues

Errors when using `printAst` and other helper methods related to parsed ASTs

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.

lively.ast.parseFunction: Uncaught (in promise) TypeError: visitor[(override || node.type)] is not a function

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;
  }

endless loops

despite of cfb7db5 there are still endless loops that cause freezes and browser crashes. To reproduce:

  1. lively.next -> open modules browser
  2. open lively.ast/lib/query.js

@levjj

capturing definition wrapper

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.