Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Escape sequences in string literals #274

Open
5 tasks
MeAmAnUsername opened this issue Mar 16, 2022 · 0 comments
Open
5 tasks

Escape sequences in string literals #274

MeAmAnUsername opened this issue Mar 16, 2022 · 0 comments
Labels
Component: code base The code quality of the project (does not affect functionality) Component: code generation Something that concerns the generated code Component: DSL Something that concerns the design of PIE DSL Priority: medium Status: proposal Enhancement in the proposal stage Type: bug Something isn't working Type: enhancement New feature or request

Comments

@MeAmAnUsername
Copy link
Owner

Summary
Implement and document proper escape characters in string literals

Todo

  • Find reference documentation for what characters exist in Java and what they mean
  • Decide which escape sequences will exist
  • Write tests
  • Implement
  • Update documentation

Reason
Compiler generates incorrect Java code when using an escape sequence which is not legal in Java.

Reproduction steps
Given the string literal "\c"
Expected: it compiles to "c" (with possibly a warning that \c does not do anything) or is an error
Actual: compiles to it compiles to "\c", which gives the following error in Java: "Illegal escape character in string literal"

Description
Currently it just allows everything, and directly passes it to Java (with exception of \$). This does not work because apparently java does not allow invalid escape sequences.
Should decide whether to allow invalid escape sequences (and give a warning that it does not do anything) or to make it an error (like Java).
Probably easiest to just copy the sequences from Java, plus \$

Implementation
Probably best to desugar to the actual character code, and then compile back to escape sequence when generating Java.
This means that the string used internally in the compiler and static semantics is always the literal string without escape sequences.

@MeAmAnUsername MeAmAnUsername added Type: bug Something isn't working Type: enhancement New feature or request Status: proposal Enhancement in the proposal stage Component: DSL Something that concerns the design of PIE DSL Component: code generation Something that concerns the generated code Component: code base The code quality of the project (does not affect functionality) Priority: medium labels Mar 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: code base The code quality of the project (does not affect functionality) Component: code generation Something that concerns the generated code Component: DSL Something that concerns the design of PIE DSL Priority: medium Status: proposal Enhancement in the proposal stage Type: bug Something isn't working Type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant