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

Can't escape backticks using emit pragma #1588

Closed
gradha opened this issue Oct 24, 2014 · 1 comment
Closed

Can't escape backticks using emit pragma #1588

gradha opened this issue Oct 24, 2014 · 1 comment

Comments

@gradha
Copy link
Contributor

gradha commented Oct 24, 2014

The following example shows backticks are always replaced in the emit pragma:

const code = """
  char s1[] = "Back`tick";
  char s2[] = "Back\\`tick";

  printf("s1: '%s'\n", s1);
  printf("s2: '%s'\n", s2);
  s2[4] = 0x60;
  printf("m2: '%s'\n", s2);
  """

proc emitTest() =
  {.emit:code.}
  echo "Finished"

when isMainModule: emitTest()

The output of this test is:

s1: 'Backtick'
s2: 'Back\tick'
m2: 'Back`tick'
Finished

Backticks are used to replace nimrod variables in the emmited code, but sometimes it would be useful to be able to emit backticks themselves for string literals. Or maybe leave them as they are if no variable is found for replacement.

@Araq
Copy link
Member

Araq commented Oct 25, 2014

I will implement it as follows: Two backticks within an emit produce a single backtick.

Araq added a commit that referenced this issue Oct 26, 2014
@Araq Araq closed this as completed Nov 12, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants