Skip to content

Conversation

@scrabsha
Copy link
Collaborator

@scrabsha scrabsha commented Apr 25, 2020

As seen in the PR title, src/reader.rs has been modified so that parsing functions accept &str instead of &[u8], which will allow us to handle non-ascii characters as well. Code that called the try_read function was modified so that is uses &str as well.

Additionally, src/reader.rs was refactored and some functions have been refactored in order to make them more idiomatic.

This PR should fix #5. Some edits have to be done in order to merge the PR.

Leo Pourcelot added 5 commits April 24, 2020 18:08
This removes a lot of ambiguity and allows us to ensure that `ClojureRS` will still work with non-ascii characters. Additionaly, a bug lurking in `consume_clojure_whitespaces` was fixed. This bug triggered an error when the function had no whitespaces to consume, while it should not.
A bug was introduced with last commit. User input was not wiped between two call to `read_line` in `main`. As such, everything the user entered was re-evaluated on each return keypress. This commit clears the content of user input between two `read_line` calls. `identifier_parser` was also refactored. This allows us to skip one `format!` call and many clones, making the function execution faster. Its content was also split, resulting in the creation of `first_char`, `cons_str`, `is_identifier_char` and `is_non_numeric_identifier_char`. Next commits will focus on refactoring further the content of `reader.rs`.
Documentation in `reader.rs` said that functions parse `&[u8]` into other types. However, commit `f04d995` modified code so that it parses `&str`. This commit fixes the corresponding documentation.
These three functions had the same similar pattern, which can be simplified by using an `if-let` expression instead of a match as well as the `?` operator, which simplifies error handling.
@scrabsha scrabsha changed the title Use &str instead of &[u8] in reader.rs, and other concerned areas Use &str instead of &[u8] in reader.rs, and other concerned areas, fixes #5 Apr 25, 2020
@scrabsha scrabsha changed the title Use &str instead of &[u8] in reader.rs, and other concerned areas, fixes #5 Use &str instead of &[u8] in reader.rs, and other concerned areas Apr 25, 2020
@scrabsha scrabsha marked this pull request as draft April 25, 2020 10:18
@scrabsha scrabsha marked this pull request as ready for review April 25, 2020 10:29
@scrabsha scrabsha requested a review from Tko1 April 25, 2020 10:31
@Tko1 Tko1 merged commit f44962a into clojure-rs:master Apr 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants