Skip to content

Add Unicode string escapes and make string padding Unicode-aware#22

Merged
JosunLP merged 5 commits intodevfrom
copilot/fix-errors-and-expand-syntax
Mar 21, 2026
Merged

Add Unicode string escapes and make string padding Unicode-aware#22
JosunLP merged 5 commits intodevfrom
copilot/fix-errors-and-expand-syntax

Conversation

Copy link
Contributor

Copilot AI commented Mar 20, 2026

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 \uXXXX and \xXX escapes

    • String literals now decode fixed-width Unicode and hex escapes during lexing.
    • Invalid hex digits, truncated escapes, and invalid Unicode scalar values are rejected with targeted diagnostics.
  • String stdlib: fix width calculation for Unicode

    • PadLeft and PadRight now use character count instead of UTF-8 byte length.
    • This fixes incorrect padding for accented characters, emoji, and other non-ASCII text.
  • Regression coverage

    • Added lexer tests for:
      • valid Unicode and hex escapes
      • malformed escape digits
      • unterminated escapes
      • invalid Unicode scalar values
    • Added string builtin tests covering Unicode-aware padding.
  • Repository hygiene

    • Ignored generated native compiler output to keep build artifacts out of source control.

Example:

Focus {
    observe "\u0041\x42\u0043";     // ABC
    observe PadLeft("é", 3, "-");   // --é
    observe PadRight("🎯", 4, "-"); // 🎯---
} Relax
Original prompt

Arbeite an der nächsten Itteration von Hypno Script, suche und fixe Fehler, erarbeite neue Features, erweitere die Syntax und baue die standard lib weiter aus. arbeite selbständig. Wenn du etwas nicht weißt, recherchiere online


⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.

Copilot AI and others added 4 commits March 20, 2026 00:46
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
Copilot AI requested a review from JosunLP March 20, 2026 00:55
@JosunLP JosunLP marked this pull request as ready for review March 20, 2026 23:10
Copilot AI review requested due to automatic review settings March 20, 2026 23:10
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 \uXXXX and \xXX escapes inside string literals with targeted diagnostics for malformed/truncated escapes and invalid scalar values.
  • Runtime: make PadLeft/PadRight compute padding using s.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.

@JosunLP JosunLP merged commit 1847390 into dev Mar 21, 2026
6 checks passed
@JosunLP JosunLP deleted the copilot/fix-errors-and-expand-syntax branch March 21, 2026 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants