Skip to content

CRLF token can produce invalid generated C++ (broken string literal) #237

@cavazquez

Description

@cavazquez

Problem

When compiling programs that use the CRLF keyword in DISPLAY (and similar), the C++ backend can fail to compile the generated ldpl-temp.cpp.

Observed g++ errors include missing terminating " character: the emitted source effectively splits a string literal across physical lines, e.g. something like:

cout << "\r
" << flush;

instead of a single-line escape sequence for carriage return + line feed.

Root cause appears to be in the early token rewrite pass in src/ldpl.cpp (compile loop): the CRLF token is replaced with a string that contains a literal newline inside the C++ fragment, which breaks the generated string literal.

LF does not hit this path in the same way and typically compiles.

Minimal LDPL repro

Use the procedure header form your compiler accepts (see related header/token issue). Example:

procedure
display "Hello" crlf

Expected

Generated C++ should use escaped sequences only (e.g. \\r\\n inside one string), so g++ accepts the file.

Actual

C++ compilation fails with string literal errors.

Environment

LDPL 5.x / reference compiler from https://github.com/Lartu/ldpl — reproducible when building the generated ldpl-temp.cpp.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions