Giter Site home page Giter Site logo

[feature] debugger REPL? about ast-grep HOT 9 OPEN

vergenzt avatar vergenzt commented on June 14, 2024
[feature] debugger REPL?

from ast-grep.

Comments (9)

HerringtonDarkholme avatar HerringtonDarkholme commented on June 14, 2024 2

Hi @vergenzt, the branch has not been created yet and the API is under design. I will create an issue to track the progress of it.
Thanks for your support 👍

from ast-grep.

HerringtonDarkholme avatar HerringtonDarkholme commented on June 14, 2024 1

thanks for the suggestion! debugger repl looks like a very interesting topic and I will investigate it later.

At the moment, ast-grep's top priority is to ship fix support in napi and python API.
Better debugging experience will be explored later.

from ast-grep.

vergenzt avatar vergenzt commented on June 14, 2024

Oooh! That's exciting! Is there an issue and/or branch I can follow with updates on fix support in the programmatic APIs? I've thought about switching to API usage for my use case but the lack of easy fix support (without having to manually transform ranges) has tipped the balance in favor of YAML for now. I'd love to help test out programmatic fix support!

from ast-grep.

vergenzt avatar vergenzt commented on June 14, 2024

How would you feel about me attempting this debugger feature on my own in parallel? I'm new to Rust so it would take me a while, but I'm curious whether you're open to reviewing progress / a design proposal.

from ast-grep.

vergenzt avatar vergenzt commented on June 14, 2024

A few thoughts:

  • I'm seeing it looks like sg scan and sg run both spawn multiple threads, one per file? So I'm guessing we need a way to force single-threaded one-at-a-time mode if breakpoints are enabled. (Perhaps via a --debug flag? And maybe if that flag is not passed then breakpoints are skipped with a warning to stderr.)

  • I also see that rules don't run one-by-one but appear to be keyed by kind (when present) and run simultaneously. I'm still thinking through how to represent that in debug mode... maybe we just don't do this and instead run rules one by one when --debug is true? Would that be easy to accomplish? IMO performance needn't really be an issue in debug mode.

from ast-grep.

HerringtonDarkholme avatar HerringtonDarkholme commented on June 14, 2024

Hi! Thanks for your input!

I'm more leaning toward to have a debugger on the web playground. https://ast-grep.github.io/playground.html

Reasoning:

  1. building a debugger is pretty hard and requires ncurses or other TUI package
  2. setting a breakpoint is hard (gdb/lldb is a little bit too arcane magic to me)

Pros for building debugger on playground

  1. easier to build UI since it is in web
  2. setting breakpoint is trivial (clicking on node )
  3. it will not bloat shipped binary

from ast-grep.

vergenzt avatar vergenzt commented on June 14, 2024

I didn't think it would be a proper gdb-level breakpoint, just a "breakpoint" as in a place where we tell the code to stop and await user input (i.e. it could just output a prompt token, wait for an input command, respond to that input command, and repeat). But I hear ya that a web debugger makes more sense - I hadn't thought of that since I haven't been able to use the web debugger much yet as I'm using a custom language.

from ast-grep.

HerringtonDarkholme avatar HerringtonDarkholme commented on June 14, 2024

How do you think about making the playground load WASM file?

from ast-grep.

vergenzt avatar vergenzt commented on June 14, 2024

How do you think about making the playground load WASM file?

That would be awesome! Great idea.

from ast-grep.

Related Issues (20)

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.