Skip to content

Lex minus followed immediately by numeric literal as a single token#90

Merged
jlapeyre merged 1 commit into
mainfrom
minus-float-literal
Feb 1, 2024
Merged

Lex minus followed immediately by numeric literal as a single token#90
jlapeyre merged 1 commit into
mainfrom
minus-float-literal

Conversation

@jlapeyre
Copy link
Copy Markdown
Collaborator

@jlapeyre jlapeyre commented Feb 1, 2024

Before this commit, a - preceeding a numeric literal was always lexed as a token apart.

Now lex the minus and the numeric literal as a single token. But only if there is no intervening whitespace. For example -1.23 is a single token. But - 1.123 is three tokens (including a token for the whitespace).

and

Qiskit/qiskit#11584 (comment)

Before this commit, a `-` preceeding a numeric literal was
always lexed as a token apart.

Now lex the minus and the numeric literal as a single token.
But only if there is no intervening whitespace. For example
`-1.23` is a single token. But `-  1.123` is three tokens
(including a token for the whitespace).
@jlapeyre jlapeyre force-pushed the minus-float-literal branch from 37d6c97 to 45c8fd6 Compare February 1, 2024 04:57
@jlapeyre jlapeyre merged commit 600afd5 into main Feb 1, 2024
jlapeyre added a commit that referenced this pull request Feb 1, 2024
… token (#90)"

This reverts commit 600afd5.

The last commit caused expressions like `a-1.23` to be parsed as
`a` followed by `-1.23` rather than correctly as a binary expression.
@jlapeyre jlapeyre deleted the minus-float-literal branch February 2, 2024 05:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant