Skip to content

Question: parsing strings containing two related values #138

@rowlesmr

Description

@rowlesmr

I'm writing a library for some scientific data management, and I have a need to parse strings of the sort "+12.345e-02(13)"**, which contains the value 0.12345 and the error 0.00013.

I can see how I can adapt your library to cope with the leading +. How difficult do you think it would be to extend the parsing to include the bracketed digits? At this point in time, I only need to go from char to double.

I don't know if my code would be worthy of putting back into the library, but I can make everything available.

.

** In the grammar I'm following:
SIGN = [+-]
DIGIT = [0-9]
UINT = DIGIT+
INT = SIGN? UNIT
EXP = [eE] INT
FLOAT = INT EXP | SIGN? DIGIT* '.' UINT EXP? | INT '.' EXP?
NUMB = INT | FLOAT
NUMERIC = NUMB | NUMB '(' UINT ')'

+ = 1 or more of
* = 0 or more of
? = 0 or 1 of
| = or

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions