Unterminated string literals should be rejected by the lexer

Open
#228 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp
Domain
compilers

Research direction

Start by reproducing the quoted input with an embedded newline and tracing the Wave lexer path that emits the shown token sequence. Identify the lexer handling for string literals and the existing lexer-exception tests or test entry point. Done means the unterminated literal raises a lexer exception instead of producing separate tokens.

Written by the indexing model from the issue text.

Description

At the moment Wave accepts text like this:

"A
B"

which a user might accidentally write, intending to create a multi-line string literal with an embedded newline. In fact these "classic" (pre C++11) string literals disallow newlines.
Unfortunately, Wave has been turning these into a series of tokens:

<UnknownToken>   (#34 ) at /tmp/blah.c (  1/ 1): >"<
IDENTIFIER       (#380) at /tmp/blah.c (  1/ 2): >A<
NEWLINE          (#394) at /tmp/blah.c (  1/ 3): >\n<
IDENTIFIER       (#380) at /tmp/blah.c (  2/ 1): >B<
<UnknownToken>   (#34 ) at /tmp/blah.c (  2/ 2): >"<

It can then go on to do work on these tokens, like directive evaluation, as described in bug #225.

Wave should produce a lexer exception in this case instead.

Dominant language
C++
Stars
29
Forks
55
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from boostorg/wave

All issues in boostorg/wave

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.