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

add escape sequences in character strings #38

Merged
merged 4 commits into from
Nov 10, 2022
Merged

Conversation

Kljunas2
Copy link
Contributor

Standard escape sequences (those used in java) and ability to write bytes directly (\xbb).

Standard escape sequences (those used in java) and ability to write
bytes directly (\xbb).
@jetomit
Copy link
Collaborator

jetomit commented Nov 10, 2022

I’m inclined to merge this as it seems useful, but it does change the behavior of the assembler a bit (e.g. for C'\' and C'\\'). @jurem, what do you think?

@jetomit
Copy link
Collaborator

jetomit commented Nov 10, 2022

Unterminated C' causes an OutOfMemory exception, not sure what goes wrong.

@jurem
Copy link
Owner

jurem commented Nov 10, 2022

Hi. Thanks! Yes, I think escape seqs support is a useful feature.

Maybe a suggestion not to break the compatibility to any previous assembly code relying on not-escaped strings, a support could be added using two variants:

  1. C'...' ... raw strings (as it was originally)
  2. C"..." ... strings with escape sequences

You should also probably refactor the actual escaped string parsing (the for loop and big switch) out into a separate function. Maybe add it to the Lexer class, e.g., readEscapedString(char terminator), where terminator is " (double quite as suggested above).

@Kljunas2
Copy link
Contributor Author

Could I then terminate it with zero byte like C strings, or should I leave users the choice to manually add zero byte if desired?

@jurem
Copy link
Owner

jurem commented Nov 10, 2022

I guess user should take care for the zero byte terminator if needed. This is still an assembly, don't be too friendly :)

To avoid breaking backwards compatibility, escaped strings need to be
enclosed in double quotes.
Moved code for lexing to Lexer.
@jurem
Copy link
Owner

jurem commented Nov 10, 2022

Yes, I guess that's it! Thanks!!!

@jurem jurem merged commit 224012b into jurem:master Nov 10, 2022
@Kljunas2 Kljunas2 deleted the escape branch November 10, 2022 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants