Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evaluate ('e') with bracket in string #27

Open
tom-adsfund opened this issue Oct 4, 2018 · 4 comments
Open

Evaluate ('e') with bracket in string #27

tom-adsfund opened this issue Oct 4, 2018 · 4 comments

Comments

@tom-adsfund
Copy link

This is a good example of why maybe you should use a parser in general!

In the following example if I press 'e' at -> it fails to evaluate the expression because of the bracket in the string.

(require '(clojure [zip :as zip]))
(->
 (nth (iterate zip/next (zip/vector-zip (core/parser "(1 2 3)"))) 8)
 (zip/replace "#(")
 zip/root
)
@ghost
Copy link

ghost commented Oct 15, 2021

Strange issue. Close it?!

@mogenslund
Copy link
Owner

Maybe. When evaluating s-expression at point, the paren matching to figure out the s-expression to evaluate, does not take into account, if a string contains unmatched parenthesis. A much simpler example is
(str "(" "abc")
If the cursor is on "str" and eval-sexp-at-point is called, it will fail, because the paren in the string is not ignored, which it should be, if everything was perfekt. It will seem like the paren to the left has not matching paren, although it has.

@tom-adsfund
Copy link
Author

@mogenslund I recently learned about tree-sitter, an "efficient incremental parser" compiler which has a Clojure parser (https://github.com/sogaiu/tree-sitter-clojure). It might be worth somehow converting the linked public domain parser from the generated C to Clojure, which would then allow powerful structural editing as we envisioned long ago now!

@tom-adsfund
Copy link
Author

Just saw this: https://github.com/nextjournal/lezer-clojure
It's a Clojure parser for the Lezer parser system that produces a Javascript program to parse the code. More naturally compatible with Java.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants