rescript-compiler icon indicating copy to clipboard operation
rescript-compiler copied to clipboard

Clean up string processing: delimiters

Open cknitt opened this issue 3 months ago • 3 comments

First step in cleaning up string processing in the compiler. Define a unified String_kind.t as follows (replacing the existing delim type), make it mandatory and use it throughout the compiler pipeline (with the exception of the Parsetree for now).

    type t =
      | Standard (* Normal JS string with escaping *)
      | Verbatim (* Literal quoted string for tags *)
      | RawJs (* Raw JavaScript expressions *)
      | Template (* Template literals *)

cknitt avatar Sep 06 '25 11:09 cknitt

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript-lang/rescript@7852
@rescript/darwin-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-arm64@7852
@rescript/darwin-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-x64@7852
@rescript/linux-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-arm64@7852
@rescript/linux-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-x64@7852
@rescript/runtime

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/runtime@7852
@rescript/win32-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/win32-x64@7852

commit: 7379d01

pkg-pr-new[bot] avatar Sep 06 '25 11:09 pkg-pr-new[bot]

@codex review this change and explain the use of the various kinds of strings. Is this just a refactor or could it change anything observable? Make comments about style, clarity and possible simplifications.

cristianoc avatar Sep 06 '25 12:09 cristianoc

@cristianoc For now it should be just a refactor that shouldn't change any behavior. I left out the Parsetree on purpose here as that's where things started breaking. 🙂 Can continue there later in a separate PR.

cknitt avatar Sep 06 '25 12:09 cknitt