Sorry if this is the wrong place to ask. It could be a Scheme48 question,
though it also could lead to a change in Commander-S which specifically
uses scsh.
By "input editor" I mean a feature that allows S-expression input to be
edited while the user is typing it in. A useful editor has many other
features, but I'm not asking about them. My hypothetical input editor
works with chunks. A chunk may be
- one line containing one S-expression
- one line containing multiple S-expressions
- multiple lines containing one S-expression
- multiple lines containing multiple S-expressions
A chunk is a whole number of lines. A chunk is as short as possible; the
only way to extend an S-expression onto a second line is to have unclosed
parentheses at the end of the first. I believe my definition of chunk is
the unit SLIME works with. The problems of blank input lines, or chunks
with extra closing parentheses at the end, I'll deal with later.
I'd like the editor to use the same grammar as scsh and Scheme48. The
easiest way to do that is to get the current parser state from scsh after
sending each line, either "complete" or "error". Is that possible?
Extra state would be nice, such as locations of matching parens or other
parts of the syntax tree or the nature and location of any error.
Also, scsh must allow the editor to cancel the entire chunk. This is easy
for chunks that hold one S-expression, but might be harder for chunks that
hold more. Is it possible for an S-expression to be evaluated during the
read process and affect the syntax of later S-expressions? (maybe a macro
definition) If so, I can only think of compromise solutions:
- make arrangements to unexecute expressions, which is much
harder than unreading
- weaken the rules about what can be unread when the user
pushes the "cancel" key -- unread only back to the last
incomplete expression
- read S-expressions (possibly waiting for a space, return,
etc. after the last paren or atom component) instead of
lines
- use a grammar that is only partly correct, and have the editor
decide to pass the whole chunk to scsh (or not to, if the user
cancels)
Thanks for your help,
-- Derek
|