summaryrefslogtreecommitdiff
path: root/module/system/repl/repl.scm
AgeCommit message (Collapse)AuthorFilesLines
2011-12-04,language at REPL sets current-languageAndy Wingo1-1/+4
* module/system/repl/command.scm (language): Set the *current-language*. * module/system/repl/repl.scm (start-repl): Create a new dynamic scope for *current-language*.
2011-09-02more define-syntax-rule usageAndy Wingo1-9/+7
* module/ice-9/boot-9.scm: * module/ice-9/control.scm: * module/ice-9/futures.scm: * module/ice-9/optargs.scm: * module/ice-9/poll.scm: * module/ice-9/receive.scm: * module/ice-9/threads.scm: * module/ice-9/vlist.scm: * module/language/assembly/compile-bytecode.scm: * module/language/ecmascript/compile-tree-il.scm: * module/language/tree-il.scm: * module/oop/goops.scm: * module/oop/goops/simple.scm: * module/oop/goops/stklos.scm: * module/srfi/srfi-1.scm: * module/srfi/srfi-35.scm: * module/srfi/srfi-39.scm: * module/srfi/srfi-45.scm: * module/srfi/srfi-67/compare.scm: * module/sxml/match.scm: * module/system/repl/error-handling.scm: * module/system/repl/repl.scm: * module/system/vm/inspect.scm: * module/texinfo.scm: * module/web/server.scm: Use define-syntax-rule, where it makes sense.
2011-03-17allow ,option on-error report instead of debugAndy Wingo1-2/+5
* module/system/repl/command.scm: * module/system/repl/debug.scm (terminal-width): Move terminal-width here, make it thread-local, and export it. (print-locals, print-frame, print-frames): Default width to terminal-width. * module/system/repl/error-handling.scm (call-with-error-handling): Add `report' and `backtrace' on-error handlers. * module/system/repl/common.scm (repl-default-options): Add on-error REPL option, defaulting to `debug', but which may be changed. * module/system/repl/repl.scm (run-repl): Pass the #:on-error REPL option to call-with-error-handling.
2011-03-03repl.scm understands commentsAndy Wingo1-5/+48
* module/system/repl/repl.scm (read-comment, read-scheme-line-comment) (read-scheme-datum-comment): New helpers. (meta-reader): Take a language instead of a reader. If we have a nonwhitespace char, first check to see that it's a comment, and if so, read it off and loop. (prompting-meta-read): Call meta-reader with the lang.
2011-03-03repl.scm refactorAndy Wingo1-9/+8
* module/system/repl/repl.scm (flush-leading-whitespace): Rename from next-char. (meta-reader): Use flush-leading-whitespace. (run-repl): Use flush-to-newline after the evaluation, which seems to be the same as what we did before.
2011-02-27flush all input on a read errorAndy Wingo1-0/+8
* module/system/repl/repl.scm (flush-all-input): New helper. (prompting-meta-read): Flush all input on a read error, as we could be within some expression or a string or something.
2011-02-11repl.scm: use print-exceptionAndy Wingo1-53/+5
* module/system/repl/repl.scm: Remove custom exception printers in favor of print-exception.
2010-11-18repl read/write using current ports, not captured portsAndy Wingo1-14/+13
Fixes bug in repl meta-commands after activating readline, which changes the current input port. * module/system/repl/common.scm (<repl>): Remove inport and outport fields. (make-repl): Adapt. (repl-read, repl-print): Just read and write to the current ports. * module/system/repl/repl.scm (meta-reader): Meta-read from the current input port. * module/system/repl/command.scm (read-command, define-meta-command): Read from the current input port.
2010-11-18repl.scm displays syntax errors on read as wellAndy Wingo1-19/+28
* module/system/repl/repl.scm (prompting-meta-read): Use display-syntax-error as appropriate.
2010-11-16add proper pretty-printing for syntax errorsAndy Wingo1-2/+25
* module/system/repl/repl.scm (display-syntax-error): New helper, displays a syntax error. (abort-on-error, run-repl): Use it. * libguile/throw.c (handler_message): Re-code the same thing in C.
2010-10-08further repl tweaksAndy Wingo1-1/+1
* module/system/repl/error-handling.scm (error-string): Refactor a little. (call-with-error-handling): Ensure a trailing newline when printing the error-msg. * module/system/repl/repl.scm (run-repl): We don't know the name of the meta-command here.
2010-10-08Fixlets for REPL error handling.Ludovic Courtès1-1/+1
* module/system/repl/error-handling.scm (error-string): Don't call `display-error' when STACK is empty. (call-with-error-handling): Display ERROR-MSG instead of using `format', since ERROR-MSG may contain `format' escapes. * module/system/repl/repl.scm (run-repl): Add missing argument to `format'.
2010-10-05system repl repl commentsAndy Wingo1-2/+3
* module/system/repl/repl.scm (meta-reader): Add a comment about peek, read, and the EOF object.
2010-10-04Revert "repl.scm next-char needed to read EOF from port"Andy Wingo1-1/+1
Actually peek-char => EOF does not guarantee that read-char => EOF. I don't know what to do about this. This reverts commit 6e1dccc42f9ec81e04524ccc0956c692ee423576.
2010-10-03repl.scm next-char needed to read EOF from portAndy Wingo1-1/+1
* module/system/repl/repl.scm (next-char): Actually read off the EOF if we got one. Interesting, this.
2010-09-23avoid traps in repl except when evaluating the expressionAndy Wingo1-1/+2
* module/system/vm/trap-state.scm (with-default-trap-handler): Don't enable traps if we are setting a handler of #f. * module/system/repl/error-handling.scm (call-with-error-handling): Add #:trap-handler arg. * module/system/repl/repl.scm (run-repl): Only have traps enabled while running the thunk. Otherwise we trace on procedures called as part of the repl.
2010-09-02Fix typos.Ludovic Courtès1-1/+1
* module/system/repl/repl.scm (run-repl): Fix variable name: `k', not `key'. * module/texinfo/docbook.scm: Use `(srfi srfi-1)' for `fold'.
2010-08-06,x unbound does not quit replAndy Wingo1-3/+13
* module/system/repl/repl.scm (run-repl): Catch errors executing metacommands. Feature on top of feature...
2010-07-10finally, backtraces only showing frames for the computationAndy Wingo1-1/+7
* module/system/repl/repl.scm (run-repl): Run the thunk in a stack in a prompt, similar to the default prompt. Gives proper backtraces. * module/system/repl/error-handling.scm (call-with-error-handling): Narrow one more outer frame, for the %start-stack thunk invocation. * module/ice-9/boot-9.scm (%start-stack): Reindent.
2010-07-09avoid running the debugger during parsing or compilation at the replAndy Wingo1-3/+26
* module/system/repl/repl.scm (abort-on-error): New helper. (run-repl): Don't enter the debugger during parsing or compilation of a repl expression. If you want to debug compilation, run compilation from the repl, not as part of the repl.
2010-07-09tweaks to new replAndy Wingo1-43/+40
* module/system/repl/command.scm (read-command): Remove a pk. * module/system/repl/repl.scm (run-repl): Export. Use % and abort to implement the prompt.
2010-07-09integrate the debugger into the replAndy Wingo1-51/+74
* module/system/repl/debug.scm: New file, defines a data type to hold state for a debugger stack, and some helper procedures to print the stack or print a frame. Most pieces are from (system vm debug). * module/system/repl/error-handling.scm: New file, implements call-with-error-handling and with-error-handling, and instead of going into a debugger, we go into a recursive repl that happens to have debugging information. Will be removing the old debugger from (system vm debug) shortly. * module/Makefile.am (SYSTEM_SOURCES): Add error-handling and debug scm files. * module/system/repl/repl.scm (prompting-meta-read): Better error handling -- we don't want to go into a debugger when reading a command. (start-repl): Add #:debug keyword argument, and just dispatch to run-repl. (run-repl): New function, with the guts of the old start-repl. Added a prompt, to which a throw to 'quit will abort. * module/system/repl/common.scm (repl-prepare-eval-thunk): New helper. In the future we will use this to not enter the debugger on errors that happen at compile time. (repl-eval): Use repl-prepare-eval-thunk. (repl-print): Run the before-print-hook when printing a value. * module/system/repl/command.scm (*command-table*): Move `option' to the `system' group. Move `trace' to the `profile' group. Add `debug' and `inspect' groups. (command-abbrevs): Rename from command-abbrev, and allow multiple abbreviations. (display-group): Fix the case where abbrev? was #f. (display-summary): Fix alignment of the command and abbreviations. Allow multiple abbreviations. (read-command): Rename from read-datum, and have better error handling. (meta-command): Better error handling. (define-meta-command): Better error handling. (help, show, import, compile, disassemble, time, profile, trace): Fix docstrings and error messages. (define-stack-command): New helper, for commands that operate on a saved stack. (backtrace, up, down, frame, procedure, locals): New debugger commands, in the REPL now. (inspect, pretty-print): New "inspect" commands.
2010-06-26use *repl-stack* instead of *repl-level*Andy Wingo1-6/+11
* module/ice-9/boot-9.scm (*repl-stack*): Instead of repl-level, have a stack. (batch-mode?): Change to poke the stack. * module/ice-9/deprecated.scm (set-batch-mode?!): Update deprecation method. * module/system/repl/common.scm (repl-prompt): Update to poke *repl-stack* to get the level. * module/system/repl/repl.scm (start-repl): Bind *repl-stack* appropriately.
2010-06-19don't bind the-last-stack in repl.scmAndy Wingo1-2/+1
* module/system/repl/repl.scm (start-repl): Don't bind the-last-stack.
2010-06-18repl whitespace fixAndy Wingo1-2/+0
* module/system/repl/repl.scm: Fix whitespace.
2010-06-10bind debugging i/o ports in start-replAndy Wingo1-0/+4
* module/system/repl/repl.scm (start-repl): If the debugging ports are unbound, bind them to the current i/o ports. Allows errors within with-output-to-foo / with-input-from-foo to be sensibly debugged.
2010-06-10repl.scm simplificationsAndy Wingo1-20/+6
* module/system/repl/repl.scm (prompting-meta-read): Use call-with-error-handling. * module/system/vm/debug.scm (call-with-error-handling): Add case for #:on-error 'pass. Have the catch handler return the unspecified value.
2010-06-10start cleaning up repl/debugger error handlingAndy Wingo1-45/+25
* module/system/repl/repl.scm (prompting-meta-read): Catch and print read errors here, returning unspecified in that case. (start-repl): Don't enable the debugger while reading expressions. Adapt with-backtrace to with-error-handling. * module/system/vm/debug.scm (run-debugger, debugger-repl): No need to take a stack, the frames vector is sufficient. (call-with-error-handling, with-error-handling): New public utilities. Notably they do not poke the-last-stack.
2010-06-10hygienic with-backtraceAndy Wingo1-2/+4
* module/system/repl/repl.scm (with-backtrace): Make a syntax-rules macro.
2010-06-02recursive repl supportAndy Wingo1-35/+40
* module/system/repl/common.scm (*repl-level*): New public fluid. (repl-prompt): If *repl-level* is a positive integer, add it to the prompt. * module/system/repl/repl.scm (start-repl): The `lang' argument is now optional, and defaults to (current-language). New kwargs level and welcome; level defaults to 0, or 1+ the existing level, and the welcome is a boolean, true if level is 0. Parameterize *repl-level* during the dynamic extent of this repl. Also, parameterize the-last-stack to #f for the duration of this repl. * module/system/vm/debug.scm (frame->module, debugger-repl): Stubs of a recursive repl implementation. The idea is to be a repl in the lexical context of the error; but it would be nice to be able to operate in the module of the proc too, for example to export bindings. Hmm.
2009-12-22implement a silly debuggerAndy Wingo1-1/+1
* module/system/vm/debug.scm: Implement the skeleton of a debugger. Not very useful yet. * module/system/repl/repl.scm (call-with-backtrace): Have the pre-unwind hook drop the user into the debugger. Hopefully we can have something better within a couple weeks.
2009-10-16language-readers receive environment as an argAndy Wingo1-17/+16
* module/language/assembly/spec.scm: * module/language/brainfuck/spec.scm: * module/language/bytecode/spec.scm: * module/language/ecmascript/spec.scm: * module/language/glil/spec.scm: * module/language/scheme/spec.scm: * module/language/tree-il/spec.scm: Language-readers now take two arguments: the port and the environment. This should allow for compile-environment-specific reader behavior. * module/system/base/compile.scm (read-and-compile): * module/system/repl/common.scm (repl-read): Pass the environment to the language-reader. * module/system/repl/repl.scm (meta-reader, prompting-meta-read): * module/system/repl/command.scm (define-meta-command): Use the second argument to repl-reader, so we avoid frobbing current-reader.
2009-09-21Remove unused variables in system/language.Ludovic Courtès1-1/+1
* module/language/assembly.scm (byte-length): Don't match unused record slots. * module/language/tree-il.scm (tree-il->scheme, post-order!, pre-order!): Likewise. * module/language/tree-il/analyze.scm (analyze-lexicals): Likewise. * module/language/tree-il/compile-glil.scm (flatten): Likewise. * module/language/assembly/disassemble.scm (disassemble-load-program): Don't match unused list elements. * module/language/glil/decompile-assembly.scm (decompile-toplevel, decompile-load-program): Likewise. * module/system/xref.scm (program-callee-rev-vars): Likewise. * module/language/assembly/compile-bytecode.scm (write-bytecode)[write-sized-loader]: Remove. * module/language/assembly/decompile-bytecode.scm (decode-load-program): Factorize `pad' variables. * module/language/ecmascript/base.scm (object->value/string, object->value/number)[v]: Remove. * module/language/ecmascript/tokenize.scm (read-slash)[c0]: Remove. * module/language/objcode/spec.scm (decompile-value)[nargs]: Remove. * module/system/repl/command.scm (time)[vms-start, vms-end]: Remove. * module/system/repl/repl.scm (prompting-meta-read): Use `prompt'.
2009-06-22flush whitespace from the repl input buffer *before* evaluationAndy Wingo1-0/+14
* module/system/repl/repl.scm (start-repl): Given that the input port of the repl is line-buffered, it's likely we have #\newline in the input that is strictly extraneous, an in-band indicator to the repl that it should begin reading now. So flush out that newline, so that you can (read-char) at the repl, and it actually does wait for you to type in a char instead of just returning #\newline. While it's not an overriding concern, this does fix some brainfuck programs that want to input from the user.
2009-06-22meta-commands read off their own argumentsAndy Wingo1-14/+13
* module/system/repl/command.scm: Update copyright. (meta-command): Rework so that it's the various meta-commands that do the reading for their arguments. This way you can compile forms that span more than one line, and forms that need to be read with another language's reader. (define-meta-command): New helper macro. Update commands to use it. (help): Allow ,help on commands too. * module/system/repl/repl.scm: Update copyright. (start-repl): Adjust to give meta-command what it wants.
2009-05-26fix backtraces with compiled boot-9Andy Wingo1-1/+1
* module/ice-9/boot-9.scm (default-pre-unwind-handler): Since we were tail-called by pre-unwind-handler-dispatch, we can't use pre-unwind-handler-dispatch as a narrowing argument. Instead just narrow by one frame. (pre-unwind-handler-dispatch): Deprecate. (error-catching-loop): Remove crack comment and code, and just use default-pre-unwind-handler as our pre-unwind handler. * module/ice-9/stack-catch.scm (stack-catch): * module/system/repl/repl.scm (call-with-backtrace): Use default-pre-unwind-handler directly.
2009-04-22fix erroneous #:use-syntax clausenAndy Wingo1-1/+1
* module/system/repl/command.scm: * module/system/repl/common.scm: * module/system/repl/repl.scm: * module/system/vm/debug.scm: * module/system/vm/trace.scm: Change #:use-syntax to #:use-module, as that's really what we want to do.
2009-02-24unbork the replAndy Wingo1-1/+1
* module/system/repl/repl.scm (meta-reader): Whoops, unbork the repl.
2009-02-24in meta-reader, return directly if the peeked char is EOFAndy Wingo1-3/+9
* module/system/repl/repl.scm (meta-reader): If the (next-char #t) returns EOF, return that EOF directly, as it seems that with guile -q, the subsequent `read' actually waits for another C-d. Dunno why.
2009-01-11finish compiler.texi, wooAndy Wingo1-5/+0
* libguile/objcodes.c (do-pair): Removed unused debuging hack. * module/language/glil/spec.scm (glil): Simplify a bit. * module/system/repl/repl.scm (default-catch-handler): Don't catch vm-error, as vm-backtrace doesn't exist any more. * doc/ref/compiler.texi: Finish documenting GLIL and object code.
2008-12-26repl.scm relies on `display-backtrace' to do everything, some naming tweaksAndy Wingo1-30/+22
* module/ice-9/boot-9.scm (default-pre-unwind-handler): Rename from default-lazy-handler. (pre-unwind-handler-dispatch): Rename from lazy-hadler-dispatch. (error-catching-loop): Adjust caller. * module/system/repl/repl.scm (default-pre-unwind-handler): Remove this definition, in favor of the default one in boot-9. (default-catch-handler): Don't do a vm-backtrace, as we will soon be relying on core machinery to do that for us. (call-with-backtrace): Start a new stack for the thunk. (with-backtrace): Macro version of call-with-backtrace. (start-repl): Use with-backtrace for brevity. Start a stack with #t as the tag instead of repl-eval, because all traces of repl-eval are gone after it does a tail-call. * module/ice-9/debugger.scm: * module/ice-9/debugging/traps.scm: * module/ice-9/stack-catch.scm: Adapt to s/lazy/pre-unwind/ in boot-9.scm.
2008-11-14nifty generic compiler infrastructure -- no more hardcoded passesAndy Wingo1-1/+2
* module/system/base/language.scm (<language>): Rework so that instead of hardcoding passes in the language, we define compilers that translate from one language to another. Add `parser' to the language fields, a bit of a hack but useful for languages with s-expression external representations but with record internal representations. (define-language, *compilation-cache*, invalidate-compilation-cache!) (compute-compilation-order, lookup-compilation-order): Add an algorithm that does a depth-first search for a translation path from a source language to a target language, caching the result in a lookup table. * module/language/scheme/spec.scm: * module/language/ghil/spec.scm: Update to the new language format. * module/language/glil/spec.scm: Add a language specification for GLIL, with a compiler to objcode. Also there are parsers and printers, for repl usage, but for some reason this doesn't work yet. * module/language/objcode/spec.scm: Define a language specification for object code. There is some sleight of hand here, in the "compiler" to values; but there is method behind the madness, because this way we higher levels can pass environments (a module + externals pair) to objcode->program. * module/language/value/spec.scm: Define a language specification for values. There is something intellectually dishonest about this, but it does serve its purpose as a foundation for the language hierarchy. * configure.in: * module/language/Makefile.am * module/language/ghil/Makefile.am * module/language/glil/Makefile.am * module/language/objcode/Makefile.am * module/language/value/Makefile.am: Autotomfoolery for the ghil, glil, objcode, and value languages. * module/language/scheme/translate.scm (translate): Import the bits that understand `compile-time-environment' here, and pass on the relevant portions of the environment to the next compiler pass. * module/system/base/compile.scm (current-language): New procedure, refs the current language fluid, or lazily sets it to scheme. (call-once, call-with-output-file/atomic): Refactor these bits to use with-throw-handler. No functional change. (compile-file, compile-and-load, compile-passes, compile-fold) (compile): Refactor the public interface of the compiler to be generic and simple. Uses `lookup-compilation-order' to find a path from the source language to the target language. * module/system/base/syntax.scm (define-type): Adapt to changes in define-record. (define-record): Instead of expecting all slots in the first form, expect them in the body, and let the first form hold the options. * module/system/il/compile.scm (compile): Adapt to the compilation pass API (three in and two out). * module/system/il/ghil.scm (<ghil-var>, <ghil-env>) (<ghil-toplevel-env>): Adapt to define-record changes. * module/system/il/glil.scm (<glil-vars>): Adapt to define-record changes. (<glil>, print-glil): Add a GLIL record printer that uses unparse. (parse-glil, unparse-glil): Update unparse (formerly known as pprint), and write a parse function. * module/system/repl/common.scm (<repl>): Adapt to define-record changes. (repl-parse): New function, parses the read form using the current language. Something of a hack. (repl-compile): Adapt to changes in `compile'. (repl-eval): Fix up the does-the-language-have-a-compiler check for changes in <language>. * module/system/repl/repl.scm (start-repl): Parse the form before eval. * module/system/repl/command.scm (describe): Parse. (compile): Be more generic. (compile-file): Adapt to changes in compile-file. (disassemble, time, profile, trace): Parse. * module/system/vm/debug.scm: * module/system/vm/assemble.scm: Adapt to define-record changes. * module/language/scheme/translate.scm (receive): Fix an important bug that gave `receive' letrec semantics instead of let semantics. Whoops!
2008-10-09handle throws to unknown keys in the replAndy Wingo1-1/+2
* module/system/repl/repl.scm (default-catch-handler): Don't rethrow if we don't know the key, just print an error.
2008-10-03remove repl.scm's start-stack definitionAndy Wingo1-5/+0
* module/system/repl/repl.scm: Now that we actually compile start-stack, no need to provide our own definition here.
2008-09-25a number of small compilation fixesAndy Wingo1-1/+1
* ice-9/boot-9.scm: Allow a compiled load of posix, networking, and deprecated files. * module/language/scheme/translate.scm (lookup-transformer): Lookup the sc-macro by value, not by name. Works around the fact that compiled macros don't have names, which is probably a bug. * module/system/base/compile.scm (syntax-error) (call-with-compile-error-catch): Throw and catch a key that's not used by anyone else. Write error messages to the error port. * module/system/repl/repl.scm (default-catch-handler): Call display-error with the correct number of arguments. * module/system/vm/frame.scm (frame-program-name): Guard against unbound variables. * ice-9/optargs.scm (let-keywords-template): Don't unquote in a helper procedure. A bit irritating. I suppose we should fix the modules + syncase situation at some point, and then switch to syncase.
2008-09-18fix case in which we can fail to exit the repl cleanlyAndy Wingo1-1/+1
* module/system/repl/repl.scm (next-char): Don't throw if we get an EOF, just return the EOF object. Fixes a case in which we fail to exit cleanly.
2008-09-09really newline on eofAndy Wingo1-1/+1
* module/system/repl/repl.scm (next-char): Another newline-on-eof case.
2008-09-09run the vm repl instead of the scm-style-replAndy Wingo1-13/+21
* ice-9/boot-9.scm (@, @@): Note that these don't work with the compiler. Damn. (top-repl): Run the VM repl. Whooo! * module/system/repl/repl.scm (start-repl): Catch 'quit, as the scm-style-repl does. Newline after input EOF's, so that we don't leave the user's shell messed up.
2008-09-09use #:keywords in module/*.scm, not :keywordsAndy Wingo1-10/+10
* module/system/base/syntax.scm (keywords): Don't enable :keywords, it breaks code that may assume that ':foo is a symbol, like boot-9. * module/*.scm: Don't use :keywords, use #:keywords. The user can decide if she wants #:keywords in their .guile, and :keywords might make us compile modules differently.
2008-08-11ease-of-use improvement to ,m; catch read errors at the replAndy Wingo1-1/+3
* module/system/repl/command.scm (module): Accept e.g. `,m ice-9 popen' in addition to `,m (ice-9 popen)'. * module/system/repl/repl.scm (start-repl): Call read with a backtrace handler too.