clojure-emacs / parseclj Goto Github PK
View Code? Open in Web Editor NEWClojure Parser for Emacs Lisp
License: GNU General Public License v3.0
Clojure Parser for Emacs Lisp
License: GNU General Public License v3.0
This is an error report I worked out with @lambdam privately.
He's facing the following when performing clj-refactor.el cljr-slash
:
Debugger entered--Lisp error: (void-function key)
key((inst uuid))
parseclj-alist-merge(((inst . #f(compiled-function (s) #<bytecode 0x19c8fd5>)) (uuid . #f(compiled-function (s) #<bytecode 0x19c8fe1>))) nil)
parseedn-reduce-branch((ig-repl ((:token-type . :lbrace) (:form . "{") (:pos . 7)) :clj ((:token-type . :lbrace) (:form . "{") (:pos . 1))) ((:token-type . :lparen) (:form . "(") (:pos . 16)) (integrant\.repl) ((:tag-readers)))
parseclj--reduce-coll((integrant\.repl ((:token-type . :lparen) (:form . "(") (:pos . 16)) ig-repl ((:token-type . :lbrace) (:form . "{") (:pos . 7)) :clj ((:token-type . :lbrace) (:form . "{") (:pos . 1))) ((:token-type . :rparen) (:form . ")") (:pos . 31)) parseedn-reduce-branch ((:tag-readers)))
parseclj-parser(parseedn-reduce-leaf parseedn-reduce-branch ((:tag-readers)))
parseedn-read(nil)
parseedn-read-str("{:clj {ig-repl (integrant.repl), d (datomic.api)}, :cljs {}}")
cljr--call-middleware-for-namespace-aliases()
eval((cljr--call-middleware-for-namespace-aliases) nil)
eval-expression((cljr--call-middleware-for-namespace-aliases) nil nil 127)
funcall-interactively(eval-expression (cljr--call-middleware-for-namespace-aliases) nil nil 127)
call-interactively(eval-expression nil nil)
command-execute(eval-expression)
This resonates with various error reports so it would be quite crucial to come up with a fix.
First of all, thanks for making this package!
The recent commit 089160a has dropped a.el from the list of declared dependencies, but the code still requires it. I can't tell for sure whether the require
is actually needed or just a leftover from before the inlining - dropping it from parseclj-ast.el and parseclj-parser.el doesn't cause errors for me.
This allows you to have much more expressive tests (similar to what you get from jasmine/rspec) and simplifies the travis integration a lot.
https://github.com/jorgenschaefer/emacs-buttercup
The project doesn't have many tests yet, so it's better to do something like this sooner rather than later IMO.
Hi! Thanks for your work on parseclj
and parseedn
. I’m still a novice at Emacs and hope you can help me. Also, I wasn’t sure in which repository to file this issue, but I suspect this one is where the problem originates.
I’ve installed the parseedn
package and tried to use it on a simple value, like this:
(parseclj-read-str "42")
It gives me no result and the following message:
Device 1 is not a termcap terminal device
Same for parseclj-read-str
, parseedn-print-str
and parseclj-print-str
.
I’m using Emacs Doom on NixOS with Emacs daemon (but I tried it without daemon running and the effect was the same).
(emacs-version)
GNU Emacs 27.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.27, cairo version 1.16.0)
I’ve installed the package by adding the following to my ~/.doom.d/packages.el
.
(package! parseclj
:recipe (:host github :repo "clojure-emacs/parseclj"))
(package! parseedn
:recipe (:host github :repo "clojure-emacs/parseedn"))
Any help will be appreciated.
I'd move the intro of the design document to the README (and maybe some other parts of it) and link to the document from there. Otherwise people checking out the project might omit a lot of interesting and important information about it.
Currenty, when there's an invalid token, the lexer returns: (concat ":(" (char-to-string char))
, and keeps the cursor at the same position where it was before. This behavior mixed with the fact that parseclj-parse
loops calling parseclj-lex-next
until it reaches :eof
, makes up for infinite loop freezing when there are invalid tokens in the text to parse.
I'm opening this issue since I'm not entirely sure what was the decision behind not having the lexer raise on invalid tokens. Would it be better to raise in the parser?
Seems it has trouble parsing forms like 1/8
e.g. I would have expected the following example with an unmatched closing brace
(require 'parseclj)
(cl-prettyprint (parseclj-parse-clojure "{:a 1}}"))
to give an error such as "At position 7, unmatched :rbrace",
but it returns an emtpy AST
((:node-type . :root)
(:position . 1)
(:children ((:node-type) (:position) (:children))))
Hello,
I've discovered parceclj while browsing clojure-emacs group and I'm not sure I understand the rationale of this project given the existence of tools.analyzer. It would be helpful to include an explanatory paragraph for people like me.
Thank you!
Hi,
the parser fails to parse symbols or keywords containing the pipe |
char, which is otherwise a valid symbol char in Clojure:
user> {:one|two 'three|four}
{:one|two three|four}
To reproduce, eval the following
(parseclj-parse-clojure ":one|two")
(parseclj-parser-error ("Invalid token at 5: \"|\""))
Tiny PR to follow, thanks.
I'm currently in the need of parsing just a fraction of a buffer, so I thought on changing the signature of parseclj-parse-clojure
to something like:
(defun parseclj-parse-clojure (&optional bounds-or-string options)
...)
bounds-or-string
can be either a list (or cons) with positions/markers, a string that will be put into a temp buffer and scanned from (point-min)
to (point-max)
, or nil, in which case just scans from (point)
til the end (current default behavior)
I wanted to hear your thoughts on it before implementing.
My temporary solution is to use narrowing:
(save-excursion
(goto-char (car bounds))
(apply #'narrow-to-region bounds)
(prog1 (parseclj-parse-clojure)
(widen)))
But I think it's not ideal.
I'm working on a performance-critical project that requires repeated parsing with parseclj. I'm interested in knowing whether there's built-in support for caching parsed results. If not, would memoization be an effective way to add this feature? Additionally, are there any caveats or issues to be aware of when implementing caching in conjunction with parseclj? If there's any places I should look, let me know.
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.