Skip to content

FP parsing fail #29

Closed
Closed

Description

@jfbastien

The following FP number doesn't parse: 1.e+300.
Error: unexpected token "1.e+300"

The problem is .e if I change it to 1.0e+300 it works.

Activity

  1. binji commented on Jan 28, 2016

    @binji
    Member

    This also fails in the spec repo, I just copied the float lexer from there.

  2. jfbastien commented on Jan 28, 2016

    @jfbastien
    MemberAuthor

    Looking at the C++ grammar:

    floating-literal:
      fractional-constant exponent-part[opt] floating-suffix[opt]
      digit-sequence exponent-part floating-suffix[opt]
    fractional-constant:
      digit-sequence[opt]. digit-sequence
      digit-sequence .
    exponent-part:
      e sign[opt] digit-sequence
      E sign[opt] digit-sequence
    sign: one of
      + -
    digit-sequence:
      digit
      digit-sequence digit
    floating-suffix: one of
      f l F L
    

    Whereas the IEEE-754 examples always have a the zero in 1.0e300. I'm not sure which is right. C++ definitely allows 1. as a valid constant, but that may be a convenience thing?

  3. binji commented on Jan 28, 2016

    @binji
    Member

    Easy enough to support it, so might as well. Fixed in b803868.

  4. sunfishcode commented on Jan 28, 2016

    @sunfishcode
    Member

    I don't have an opinion about which is best, but it would be good in general for parsers to abide by the same restrictions as the spec repo, or to remove the restrictions from the spec repo.

  5. jfbastien commented on Jan 28, 2016

    @jfbastien
    MemberAuthor

    Agreed with @sunfishcode. @rossberg-chromium WDYT we should standardize on?

  6. added a commit that references this issue on Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions