v2.ocaml.org icon indicating copy to clipboard operation
v2.ocaml.org copied to clipboard

Fix splitting of toplevel phrases

Open pitag-ha opened this issue 3 years ago • 14 comments

There is a FIXME in the code generating html from toplevel blocks. Notice that in the OCaml toplevel (in other languages called REPL), the end of a code phrase is signalized by ;;. I suggest fixing the mentioned FIXME, which consists in two things:

  • at the moment every ;; is split on, even if that ;; belongs to a string inside the code. That needs to be fixed
  • if it was possible to find a more efficient way to do the splitting than using regex, for example using String.split_on_char and/or similar, that would be great.

pitag-ha avatar Apr 15 '21 19:04 pitag-ha

It would also be cool if someone could demonstrate some rough benchmarks for different approaches to improving the efficiency too :))

patricoferris avatar Apr 16 '21 09:04 patricoferris

hey, @patricoferris @pitag-ha I'm interested in working on this issue , can I give it a try :))

yashi-hub avatar Apr 16 '21 12:04 yashi-hub

Hey! @pitag-ha @patricoferris ! I wanted to work on a "medium" issue. This looks good to me! Can I give it a try :)

Riddhima23 avatar Apr 16 '21 14:04 Riddhima23

Sure @yashi-hub, you can go ahead :)

pitag-ha avatar Apr 16 '21 14:04 pitag-ha

Oh wait, I've reacted a bit too fast. Sorry about that! @yashi-hub: I've just remembered that you are already working on an issue (#1402), aren't you?

pitag-ha avatar Apr 16 '21 15:04 pitag-ha

@pitag-ha i am almost done with that issue. I believe I will create a PR by tomorrow for that. And I'll be able to work efficiently for this issue :)

yashi-hub avatar Apr 16 '21 15:04 yashi-hub

Thanks @yashi-hub! Please open a PR for #1402 before starting to work on another issue. We want folks to focus on issues one by one. By the way, you've done a great job so far, thanks for that! :)

pitag-ha avatar Apr 16 '21 15:04 pitag-ha

@Riddhima23, sorry for the confusion! You can go ahead and work on this :)

pitag-ha avatar Apr 16 '21 15:04 pitag-ha

Alright @pitag-ha! Thanks! I'll reach out if I have any doubt :))

Riddhima23 avatar Apr 16 '21 16:04 Riddhima23

@pitag-ha what I have to do is basically to find a more efficient way of splitting strings instead of using regular expressions. For example, let the string be"Ocaml;;great" now I want the output as "Ocaml;;great" but using regular expression(current method) , output would be somewhat " Ocaml" "great" means it splits the words instead of printing it as a whole which needs to be fixed. Please confirm if I have understood it correctly or not :)

Riddhima23 avatar Apr 16 '21 17:04 Riddhima23

Hi @Riddhima23, sorry for the late reply!

let the string be"Ocaml;;great" now I want the output as "Ocaml;;great" but using regular expression(current method)

I don't exactly understand this sentence. What is it that you mean?

I have the impression that you've understood correctly, but I'm not sure :) Just to make sure, let me give a concrete example building on your example. Suppose you have the following toplevel block:

print_endline "OCaml;;great";;
print_endline "OCaml;;super great";;

We want that block to be split into the two toplevel phrases print_endline "OCaml;;great", print_endline "OCaml;;super great" What happens at the moment is that it is split into the four senseless phrases print_endline "OCaml, great", print_endline "OCaml, super great".

So one part of this issue consists in fixing that.

The other part of the issue consists in perform the splitting in a more efficient way than done now (as you've said, now it's done via regex). As I've mentioned in the issue description, for that you you can see if you can use functions like String.split_on_char or similar. Once you've found a different way for the splitting, it would be cool if you could do some benchmarking both on the old way (regex) and on your new way to compare the two.

pitag-ha avatar Apr 21 '21 09:04 pitag-ha

@pitag-ha Thanks for the example.I meant something like this but maybe couldn't put it :) Now I have completely understood the issue.I'll get started and let you know if I have any further query :))

Riddhima23 avatar Apr 22 '21 15:04 Riddhima23

@pitag-ha Thanks for the example.I meant something like this but maybe couldn't put it :) Now I have completely understood the issue.I'll get started and let you know if I have any further query :))

Hi @Riddhima23. Are you still working on this issue? :)

gurleennsidhuu avatar Apr 28 '21 15:04 gurleennsidhuu

@gurleennsidhuu yes

Riddhima23 avatar May 02 '21 14:05 Riddhima23