Coder Social home page Coder Social logo

debuggableastinterpreter's Introduction

DebuggableASTInterpreter

An AST interpreter that accepts stepping operations

Installation

Install only the interpreter

Metacello new
    baseline: 'DebuggableASTInterpreter';
    repository: 'github://carolahp/DebuggableASTInterpreter';
    load.

Install the debugger

Metacello new
    baseline: 'DebuggableASTInterpreter';
    repository: 'github://carolahp/DebuggableASTInterpreter';
    load: #Debugger.

Execute the following code in a playground with a doIt to test the debugger.

(DASTSpecDebugger on: (DASTSession debug: 'MyObject new doStuff')) openWithFullView 

Install the overlays experiments for debugging in isolation (Experimental!)

That is not yet synchronized with the master branch.

Metacello new
    baseline: 'DebuggableASTInterpreter';
    repository: 'github://carolahp/DebuggableASTInterpreter';
    load: #Overlay.

Example

In a playground, instanciate an interpreter and initialize it with the program you want it to interpret (here: Point x: 1 y: 2)

interpreter := DASTInterpreter new.
interpreter initializeWithProgram: (RBParser parseExpression: 'Point x: 1 y: 2').

You can see the stack of AST nodes the current context still has to interpret by inspecting: interpreter currentContext nodes. The nodes will be interpreted from last to first. Node stack:
Node stack

You can see the value stack of the current context (where the interpreter pushes the values of the AST nodes it interprets) by inspecting: interpreter currentContext stack. It is empty at the moment because nothing has been evaluated yet.

Evaluate interpreter stepInto 3 times to evaluate the receiver and arguments of the #x:y: message being interpreted.
New node stack:
Node stack
New value stack:
Value stack

Finally, the message send itself is ready to be interpreted. If you evaluate interpreter stepOver, the interpreter will pop the receiver and arguments from the value stack, evaluate the message send completely, and push its value on the value stack.
New node stack:
Node stack
New value stack:
Value stack

As you can see, the value of the message send is the point it created: (1@2)

Inspecting the interpreter shows its evaluation stack. The source code of each element in the stack is highlighted accordingly to its evaluation step. It is necessary to refresh the inspector by hand after each step operation.

Node stack

debuggableastinterpreter's People

Contributors

aranega avatar carolahp avatar dupriezt avatar guillep avatar stevencostiou avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.