Add parse-only REPL input completeness check - #6543
Draft
fingolfin wants to merge 1 commit into
Draft
Conversation
Alternative frontends (a Julia REPL mode via GAP.jl, Jupyter kernels)
need to know whether input is a complete command sequence, a truncated
prefix of valid input, or contains a syntax error -- without executing
anything. This is the primitive behind Julia's on-Enter check and
Jupyter's is_complete_request.
CHECK_ALL_COMMANDS(instream) parses the input with the interpreter in
ignoring mode and returns a record with 'status' ("complete",
"incomplete" or "error"), 'statements' and 'errors'. Diagnostics are
collected as records (message and caret positions) instead of being
printed. Input is classified as incomplete iff the first syntax error
was caused by the input ending, so an error inside an open construct
still reports "error".
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6543 +/- ##
==========================================
- Coverage 79.00% 78.98% -0.03%
==========================================
Files 684 684
Lines 294205 294285 +80
Branches 8647 8664 +17
==========================================
- Hits 232444 232435 -9
- Misses 59955 60036 +81
- Partials 1806 1814 +8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
fingolfin
commented
Aug 31, 2026
| GAP_THROW(); | ||
|
|
||
| Obj result = NEW_PREC(3); | ||
| AssPRec(result, RNamName("status"), MakeImmString(status)); |
Member
Author
There was a problem hiding this comment.
Maybe an integer with specific defined values (say 0, 1, 2), plus some BindGlobal("COMMAND_STATUS_ERROR", ...)etc for the values would be better: checking strings is error prone (typos...)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
CHECK_ALL_COMMANDS(instream): parse input without executing or printing anything, and classify it as"complete","incomplete"(truncated prefix of valid input) or"error". Diagnostics are returned as records with message and caret positions instead of being printed.This is the primitive alternative frontends need for multi-line editing: a Julia REPL "GAP mode" via GAP.jl, or a Jupyter kernel's
is_complete_request, can ask on every Enter whether the buffer is ready to evaluate, instead of submitting half-typed input.Implementation: the reader runs with the interpreter in ignoring mode (cf. the experiment in #4130, but no asserts are relaxed;
IntrEndis skipped in check mode, so nothing runs, not evenquit;or?help). The scanner records whether the first syntax error was caused by the input ending; only then is input "incomplete", so a typo inside an open construct still reports "error" and cannot trap the user in an editor that never submits.Planned follow-ups: a structured chunk evaluator (per-statement results, captured output and error text, no break loop) and libgap wrappers
GAP_CheckInput/GAP_EvalStringEx.Written with Claude Code (Claude Fable 5).