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

Float parsing bug related to line continuations #1992

Closed
fingolfin opened this issue Dec 5, 2017 · 1 comment
Closed

Float parsing bug related to line continuations #1992

fingolfin opened this issue Dec 5, 2017 · 1 comment
Labels
kind: bug Issues describing general bugs, and PRs fixing them topic: kernel topic: parser

Comments

@fingolfin
Copy link
Member

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).

@fingolfin fingolfin added kind: bug Issues describing general bugs, and PRs fixing them topic: kernel labels Dec 5, 2017
@fingolfin
Copy link
Member Author

Actually, this doesn't seem to be a bug (or at least not one specific to floats), but rather it seems GAP always acts like this:

gap> 12\
gap> ;
12

vs.

gap> 12
> ;
12

I still think there should be a continuation prompt, in all cases... Thoughts?

fingolfin added a commit to fingolfin/gap that referenced this issue Apr 10, 2018
This ensures that line continuations inside of e.g. integer and float
expressions propery show a line continuation prompt.

Fixes gap-system#1992
fingolfin added a commit to fingolfin/gap that referenced this issue Apr 10, 2018
This ensures that line continuations inside of e.g. integer and float
expressions propery show a line continuation prompt.

Fixes gap-system#1992
fingolfin added a commit to fingolfin/gap that referenced this issue Apr 10, 2018
This ensures that line continuations inside of e.g. integer and float
expressions properly show a line continuation prompt.

Fixes gap-system#1992
fingolfin added a commit to fingolfin/gap that referenced this issue Apr 10, 2018
This ensures that line continuations inside of e.g. integer and float
expressions properly show a line continuation prompt.

Fixes gap-system#1992
fingolfin added a commit to fingolfin/gap that referenced this issue Apr 11, 2018
This ensures that line continuations inside of e.g. integer and float
expressions properly show a line continuation prompt.

Fixes gap-system#1992
fingolfin added a commit that referenced this issue Apr 12, 2018
This ensures that line continuations inside of e.g. integer and float
expressions properly show a line continuation prompt.

Fixes #1992
ChrisJefferson pushed a commit to ChrisJefferson/gap that referenced this issue Jun 14, 2018
This ensures that line continuations inside of e.g. integer and float
expressions properly show a line continuation prompt.

Fixes gap-system#1992
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Issues describing general bugs, and PRs fixing them topic: kernel topic: parser
Projects
None yet
Development

No branches or pull requests

1 participant