Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Float parsing is unnecessarily restrictive #290

@rogpeppe

Description

@rogpeppe

PR #171 restricted the possible float syntax, but it's not clear that it was the right thing to do.
The YAML spec itself provides a regexp for floats (-?[1-9](\.[0-9]*[1-9])?(e[-+][1-9][0-9]*)?) that is cast into doubt by the example immediately following (2.3e4) which is not matched by the regexp.

Also, JSON allows floats of the form 2e5 and YAML is supposed to be able to read JSON.

As it seems other implementations treat [0-9]+e[0-9]+ as a string, perhaps we should do that too, despite JSON-incompatibility, but treat it as a float if there's a decimal point in the mantissa or a + or - sign before the exponent.

Metadata

Metadata

Assignees

No one assigned

    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