Implement read-string & read-file#673
Conversation
0699168 to
2c0fb6e
Compare
|
My current implementation cause jank to crash for the following code: (binding [clojure.core/*read-eval* true] (read-string {:eof false :read-cond :preserve} "#?(:jank)"))This is because we throw parse_invalid_reader_conditional error which I think is not playing well with the error reporter. Backtrace |
|
Probably caused due to #647. Shall I just repackage our parser (compile-time) error into a runtime error ( |
jeaye
left a comment
There was a problem hiding this comment.
Nice work, Shantanu. The overall direction is sane, but the implementation has a way to go to fit into the idioms of jank's C++.
This is from a failed assertion. Why did the assertion fail? What were the values? You are suggesting hacky workarounds, but we want to first understand the problem and then consider robust solutions. Hacky workarounds are a last resort. |
e978520 to
0320155
Compare
|
The crash was also fixed, now it gives the same output as was reported in this issue (#647). |
|
Although part of the CI is busted. |
|
Also, is there a way to know when Or perhaps it won't matter? Since the |
read & read-string with optsread & siblings with opts
d401904 to
16df002
Compare
16df002 to
9285548
Compare
393f31e to
c55fad4
Compare
7f91c4b to
5c2ea30
Compare
|
There is a new limitation encountered due to the Here is my summary of the problems with the complete context consolidated in a document. |
|
I've updated the |
read & siblings with optsread-string & read-file
404d11c to
934d393
Compare
934d393 to
345e6a6
Compare
| return error::parse_invalid_reader_conditional( | ||
| { start_token.start, latest_token.end }, | ||
| "Conditional read is not allowed by default. Set the :read-cond reader option to either " | ||
| ":preserve or :allow. Found a nil instead."); |
There was a problem hiding this comment.
I don't think Found a nil instead. is helpful here. I'm also not entirely sure if it's accurate, since we're working with a bool and not a runtime object.
There was a problem hiding this comment.
The allow_reader_conditional boolean is set using the provided reader option (:read-cond) so for the end user this message is more actionable. What do you think?
I don't think Found a nil instead. is helpful here.
Removed.
compiler+runtime/src/cpp/jank/runtime/obj/reader_conditional.cpp
Outdated
Show resolved
Hide resolved
compiler+runtime/src/cpp/jank/runtime/obj/reader_conditional.cpp
Outdated
Show resolved
Hide resolved
| object_ref context::read_string(jtl::immutable_string const &code, | ||
| object_ref const reader_opts, | ||
| u64 const nth_form) |
There was a problem hiding this comment.
There's a lot of code in here now, with very few comments. Some of the code is quite dense. Please do a comment pass for your new code, to see where we can explain more.
There was a problem hiding this comment.
Not much to comment. Added in the few places I saw something worth adding.
d1644ab to
263f239
Compare
263f239 to
d38d5c9
Compare
| processor::processor(lex::processor::iterator const &b, | ||
| lex::processor::iterator const &e, | ||
| object_ref const &extended_features, | ||
| bool const &allow_reader_conditional, |
There was a problem hiding this comment.
We should not take bool by const &, since it's a primitive.
| { | ||
| } | ||
|
|
||
| reader_conditional::reader_conditional(persistent_list_ref f, boolean_ref s) |
Implement
readand it's siblings along with reader options.