Git Product home page Git Product logo

scheme_editor's Introduction

Scheme-o-matic

This tool is a web-based, locally-hosted editor and debugger for the variant of the programming language Scheme taught in CS 61A.

To try a limited web demo of some of the features, go to http://scheme.pythonanywhere.com!

To run with a homework or lab, download the entire folder and run the command python3 editor.

To run without okpy, run the command python3 editor -f. (note that there may be some initial layout glitches before a file is opened).

This tool has no dependencies, and requires web access only to load the Glyphicons (all other libraries are self contained).

image

full size

scheme_editor's People

Contributors

rahularya50 avatar kavigupta avatar mehrdadn avatar jathak avatar

Stargazers

Rongjun GENG avatar  avatar Weijie XI avatar Clausewitz's CPU0 avatar Kartavya Sharma avatar  avatar  avatar Brandon Shin avatar Ethan Chiu avatar Zehua Jiang avatar Gautam Mittal avatar

Watchers

Pamela Fox avatar James Cloos avatar Sumukh Sridhara avatar  avatar Ja (Thanakul) Wattanawong avatar  avatar Alex Stennet avatar Praveen Batra avatar yichen avatar Tiff avatar Tammy Nguyen avatar  avatar  avatar Eric Wang avatar Alex Kassil avatar Alex Yu avatar Manav Rathod avatar  avatar  avatar Kristy Lee avatar Ryan Moughan avatar  avatar Nicholas Ngai avatar

scheme_editor's Issues

Cut off stack trace serverside if it's too long

(I noticed this issue due to the ridiculously long stack traces for KeyboardInterrupts, but it applies generally as well)

the program

(define (loop n)
  (if (zero? n) (/ 1 0) (loop (- n 1))))

(loop 300)

generates a 1204 line traceback. The Python program

def loop(n):
    if n == 0: 1/0
    return loop(n - 1)
loop(300)

generates the traceback

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 3, in loop
  File "<stdin>", line 3, in loop
  File "<stdin>", line 3, in loop
  [Previous line repeated 297 more times]
  File "<stdin>", line 2, in loop
ZeroDivisionError: division by zero

which is 8 lines long (the [] are actually in the output). We should probably do something similar; though since we annotate with the frame, a simple string match would be insufficient. I think in practice clipping out the intermediate part of a stack trace is completely fine.

Should not be able to shadow special forms

So

scm> (define define +)
define
scm> (define f 5)
f

should work properly, rather than raising an error.

On a related note, unquote outside of quasiquotes should raise a different error.

Infinite loops take up a ridiculous amount of memory

If I run

(define (loop) (loop))
(loop)

then it uses a ridiculous amount of memory

image

this linearly increases, which means it ate 16% of my 8GB memory in 22s, which means it's eating 58 MB/s.

Either it should error with a max recursion depth or it should tail recurse

Python OK + Graphics

If you write a program involving graphics and stick in in OK and then terminate the process while it's running from the GUI, you get a segfault (!!)

Maybe related to #43 ?

Frames don't close if an exception occurs

To reproduce:

  • Run
(define (loop x)
  (if (= x 0)
      (/ 1 0)
      (loop (- x 1))))
(loop 2000)

in a new file

  • Run (define x 5) in the console
  • Open the environment viewer and hit "finish executing the program"

Expected:
The global frame should be open with x = 5

Actual:
2000 other frames are open.

Fix:
Add a client-side check to skip over frames from a previous execution that have closed. Perhaps look at their most recent assignment, and compare it to start_i of the present expr?

Stop button doesn't free memory

There's a memory leak (?) where if you run a command that eats a bunch of memory, it doesn't seem to free it when that command is terminated, or even when you hit Run again, which should reset everything in theory

Non-parse errors in the load show up weird

To reproduce, replace hw10.scm with (/ 1 0). Then open the first test case. The output starts with:

; expect Traceback (most recent call last):
(load 'hw10)

;        0
;        (/ 1 0)
;        Error:
;        division by zero
; expect identity

which makes no sense

Editor process doesn't always terminate

If it's run in a terminal (like in PyCharm, at least on Macos) and PyCharm is closed, then the editor will keep running and occupy the port. It should detect when it's running in the background and terminate itself.

Need to write tests for the interpreter

This is more a long-term thing, but we need to have, like, some test cases for this interpreter before deploying it to students.

Right now there are like 5 doctests, all of which fail.

Handle locked testcases

Currently, locked testcases don't behave properly when running okpy tests - this should be fixed before the first lab.

Weird behavior with parsing

Programs like

(/ 1 0)
)

run and then cause a crash in the interpreter that is not returned to the user.

Seems to be when the first expression has an exception, the second one is not parsed.

Don't create the matching quote

If I type ' the editor adds a ' right after my cursor. This is incorrect behavior since in scheme ' isn't a before/after thing.

Unclear how environment works?

I tried opening HW10 and clicking the "Environments" button, and a console with the following tab popped up

image

But like it didn't have any contents? Not sure how it works

Weird crash - needs investigation?

Open a console, and paste in:

; expect (quote dog) 
(apply id (quote ((quote dog))))

; expect dog 
(apply id (quote (dog)))

; expect (quote (dog)) 
(apply eval
       (quote ((quote (quote (dog))))))

; expect (dog) 
(apply eval
       (list (quote (quote (dog)))))

; expect (quote dog) 
(apply eval
       (quote ((quote (quote dog)))))

and the editor crashes. ???

Block special forms should always be multiple lines

Right now the way factorial is formatted is literally

(define (fact x)
  (if (zero? x) 1 (* x (fact (- x 1)))))

this is hard to read. We should force block special forms define-function, if, let, ... to span multiple lines

Debug + Environment buttons don't work before you hit "Run"

The debugger and environment diagram views rely on the program having previously been run. It should be the case that you can hit "Debug" / "Environment" and the program should immediately rerun.

Questions:

  • If the program has been run, modified, and then the user hits "debug", should the program run again?
  • Should this behavior change depending on whether a debug / environment diagram view is already open?
  • Should it automatically run the program, or just tell the user to hit "Run"?

Related to #9

Handle non-terminating programs better

The way this software handles non-terminating programs could be better.

I suggest allowing the user to cancel programs from the run terminal within the webapp, perhaps by trapping Ctrl+C, or perhaps by adding an explicit stop button (a la IntelliJ/Eclipse)

Error with variadics is misleading

image

The staff interpreter has the following error

scm> . y
Traceback (most recent call last):
  0	(variadic y)
Error: Cannot evaluate variadic symbol

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.