Skip to content

feat: raw string literal support (backtick strings) #10

Open

Description

@SchoolyB

Summary

Grayscale supports raw string literals enclosed in backticks (STANDARD.md §2.7.4). The LSP may not fully handle these for syntax awareness.

Example

mut path string = ` + "`" + `C:\Users\test\file.txt` + "`" + `
mut pattern string = ` + "`" + `\d+\.\d+` + "`" + `
mut multi string = ` + "`" + `line1
line2
line3` + "`" + `

Key Details

  • Enclosed in backticks
  • No escape sequence processing (\n is literal)
  • No string interpolation (${x} is literal text)
  • May span multiple lines
  • Cannot contain backticks (no escape mechanism)

Scope

  • Ensure raw strings don't trigger false diagnostics
  • Syntax highlighting awareness (no interpolation highlighting inside backticks)

Activity

  1. SchoolyB commented on Aug 18, 2026

    @SchoolyB
    MemberAuthor

    Implemented in c74cc2a. The scope says "ensure raw strings don't trigger false diagnostics" — diagnostics come from shelling out to grayc, so those were never affected. The real defect was in the symbol scanner.

    Raw string contents were scanned as source. The scanner walked lines without tracking string state, so:

    mut tmpl string = `
    mut PHANTOM int = 1
    const Bogus struct {
    `
    

    produced a phantom variable PHANTOM and a phantom struct Bogus. Worse, the unbalanced { inside the raw string desynced block scanning, so Bogus consumed the following lines as its body — corrupting every symbol declared below it in the file, not just the ones inside the string.

    Fixed with an offset-preserving mask applied before matching: raw-string interiors are blanked to spaces, newlines kept, so line/column positions stay exact. The masker steps over line comments, block comments, regular strings, and char literals, so a backtick inside any of them cannot open a spurious raw string — a comment like // use `foo` no longer swallows the code beneath it. Hover still renders the true source line, not the masked one.

    The above now scans as tmpl only. Highlighting needed no change: the grammar's raw_string rule is an opaque /[^]*/with no interpolation node, andhighlights.scmalready scopes it as@string`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions