Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Implement raw strings #46

Merged
merged 9 commits into from
Jan 18, 2024
Merged

Implement raw strings #46

merged 9 commits into from
Jan 18, 2024

Conversation

electrikmilk
Copy link
Owner

This implements a new type of string I'm calling a raw string. If you declare a string value with a single quote (') instead of a double quote ("), this is defined as a raw string so the compiler will not check for inline variables and interpolate new lines, carriage returns, etc. as with standard strings. The parser will only collect characters until the ending single quote.

It does allow for the escaping of single quotes for sanity, however (e.g. "I don't need interpolation or inline variables, but I need a single quote for a contraction word like you're."). So it still interpolates that, but otherwise it just writes the runes to a string builder until it gets to an unescaped single quite.

So, as you can probably imagine, the advantage of raw strings is that they will compile much faster than standard strings if you do not need to use any of those features in a string value.

With a raw string, the parser does not need to...

  • Interpolate the string (convert \n to a new line).
  • Check for inline variables.
    • If so, check that the inline variable references are valid.

The property list generator doesn't need to...

  • Check if the string contains inline variables to create the data structures Shortcuts are required for inline variables in text.

@electrikmilk electrikmilk self-assigned this Jan 18, 2024
@electrikmilk electrikmilk merged commit f72703b into main Jan 18, 2024
2 checks passed
@electrikmilk electrikmilk deleted the raw-strings branch August 5, 2024 00:17
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant