Skip to content

Float parsing bug related to line continuations #1992

@fingolfin

Description

@fingolfin

Observed behaviour

In the following example, I press enter twice after entering the backslash:

gap> 1.1e\
gap>
Syntax error: Badly Formed Number: need at least one digit in the exponent

^

or

gap> 1.1\
gap>
> ;
1.1

Expected behaviour

A continuation prompt should appear immediately in both cases, e.g.

gap> 1.1e\
> 2;
110.

resp.

gap> 1.1\
> ;
1.1

Analysis

Part of the problem here is that dealing with line continuations is not handled in a uniform manner, but rather the relevant logic has to be replicated everywhere; and it is easy to forget that, or do it wrong.

As a long-term fix, I think we could add a "line reader" as an additional layer between io.c and scanner.c. It would take care of reading the input line by line, keeping track of the current line number, but also of automatically and transparently handling line continuations (including transparent support for CR, CR/LF or LF line ends).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions