Add Unicode string escapes and make string padding Unicode-aware#22
Merged
Add Unicode string escapes and make string padding Unicode-aware#22
Conversation
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix errors and expand syntax for Hypno Script
Add Unicode string escapes and make string padding Unicode-aware
Mar 20, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves HypnoScript’s Unicode handling by extending string literal lexing with fixed-width hex/Unicode escapes and making runtime string padding operate on Unicode character counts instead of UTF-8 byte lengths.
Changes:
- Lexer: decode
\uXXXXand\xXXescapes inside string literals with targeted diagnostics for malformed/truncated escapes and invalid scalar values. - Runtime: make
PadLeft/PadRightcompute padding usings.chars().count()(Unicode scalar count). - Repo hygiene: ignore generated
hypnoscript-compiler/hypnoscript_output*artifacts.
Reviewed changes
Copilot reviewed 2 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| hypnoscript-runtime/src/string_builtins.rs | Switch padding width calculation to Unicode-aware character counting and add regression tests. |
| hypnoscript-lexer-parser/src/lexer.rs | Add \uXXXX / \xXX string escape decoding with validation plus lexer tests. |
| .gitignore | Ignore native compiler output artifacts to avoid committing generated files. |
| hypnoscript-compiler/hypnoscript_output | Generated artifact appears to be included in the PR and should not be tracked. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This iteration tightens HypnoScript’s text handling in two places: string literal parsing and core string formatting. It extends the language with Unicode/hex escape support and fixes padding behavior for multi-byte characters in the standard library.
Lexer: support
\uXXXXand\xXXescapesString stdlib: fix width calculation for Unicode
PadLeftandPadRightnow use character count instead of UTF-8 byte length.Regression coverage
Repository hygiene
Example:
Original prompt
⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.