This repository was archived by the owner on Jun 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
Change char payload #709
Merged
Merged
Change char payload #709
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
e9c0468
change Pconst_char payload(WIP)
butterunderflow b0346b4
tweak & tweak
butterunderflow 1c2fff3
remove Char.chr
butterunderflow d79e980
tweak
butterunderflow fb59e24
bugfix: correct escapes printer
butterunderflow 412d6cc
valid code point verification
butterunderflow 1f70aee
tweak
butterunderflow 332b134
take Res_utf8.repl back
butterunderflow 22f4521
remove wrong simplification
butterunderflow c95f97f
remove unneeded if-else
butterunderflow edaf144
format
butterunderflow 5173895
safe int to char to string
butterunderflow 24c6625
remove Obj.magic in scanner
butterunderflow 2fa0181
remove string_of_int_as_char from stl to Pprintast
butterunderflow 79527b8
refactor
butterunderflow 33540b6
changelog
butterunderflow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -191,8 +191,24 @@ let rec longident f = function | |
|
||
let longident_loc f x = pp f "%a" longident x.txt | ||
|
||
let string_of_int_as_char i = | ||
let str = match Char.unsafe_chr i with | ||
| '\'' -> "\\'" | ||
| '\\' -> "\\\\" | ||
| '\n' -> "\\n" | ||
| '\t' -> "\\t" | ||
| '\r' -> "\\r" | ||
| '\b' -> "\\b" | ||
| ' ' .. '~' as c -> | ||
let s = (Bytes.create [@doesNotRaise]) 1 in | ||
Bytes.unsafe_set s 0 c; | ||
Bytes.unsafe_to_string s | ||
| _ -> Printf.sprintf "\\%d" i | ||
in | ||
Printf.sprintf "\'%s\'" str | ||
|
||
let constant f = function | ||
| Pconst_char i -> pp f "%C" i | ||
| Pconst_char i -> pp f "%s" (string_of_int_as_char i) | ||
| Pconst_string (i, None) -> pp f "%S" i | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above |
||
| Pconst_string (i, Some delim) -> pp f "{%s|%s|%s}" delim i delim | ||
| Pconst_integer (i, None) -> paren (i.[0]='-') (fun f -> pp f "%s") f i | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -553,7 +553,7 @@ let printConstant ?(templateLiteral = false) c = | |
| Pconst_float (s, _) -> Doc.text s | ||
| Pconst_char c -> | ||
let str = | ||
match c with | ||
match Char.unsafe_chr c with | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's still a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems okay, but there may be some duplication with string_of_int_as_char, you may do a clean up later after this commit landed |
||
| '\'' -> "\\'" | ||
| '\\' -> "\\\\" | ||
| '\n' -> "\\n" | ||
|
@@ -564,7 +564,7 @@ let printConstant ?(templateLiteral = false) c = | |
let s = (Bytes.create [@doesNotRaise]) 1 in | ||
Bytes.unsafe_set s 0 c; | ||
Bytes.unsafe_to_string s | ||
| c -> Res_utf8.encodeCodePoint (Obj.magic c) | ||
| _ -> Res_utf8.encodeCodePoint c | ||
in | ||
Doc.text ("'" ^ str ^ "'") | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.