-
Notifications
You must be signed in to change notification settings - Fork 46
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
int parser fails on trailing "e" #28
Comments
I've run into this issue as well while parsing Bencoded content. In this example, parsing "2" from "i2e" is the goal.
Code: The "i2.5h" and "i2e" examples fail in the same way, making it seem like |
floatOrText =
oneOf
[ float |> map (\n -> "Number: " ++ String.fromFloat n)
, chompUntilEndOr "\n" |> getChompedString
]
run floatOrText "not starting with e" --> Ok "not starting with e"
run floatOrText "1e10" --> Ok "Number: 10000000000"
run floatOrText "e should be text" --> Err: ExpectingFloat Example on Ellie: https://ellie-app.com/8yp6MxtzSsna1 After reading https://github.com/elm/expectations, I've opened a separate issue (#44). |
I'm facing a similar issue with character |
@matsumonkie See here for example: You may need to adapt if you want to handle negative numbers. |
Thank you for your answer @rlefevre When I use the [https://package.elm-lang.org/packages/elm/parser/latest/Parser#variable](variable parser) almost exactly like this: typeVar : Parser String
typeVar =
variable
{ start = Char.isLower
, inner = \c -> Char.isAlphaNum c || c == '_'
, reserved = Set.fromList [ "let", "in", "case", "of" ]
} I noticed that it worked fine as long as the variable name doesn't start with the letter |
@matsumonkie I've used this workaround for now: {-| The built-in float parser has a bug with leading 'e'.
See <https://github.com/elm/parser/issues/28>
-}
parseFloat : Parser Float
parseFloat =
{- By making it backtrackable, even if the input starts with an 'e',
we will be able to try out other alternatives instead of getting
stuck on it as an invalid number.
-}
Parser.backtrackable <| Parser.float ExpectingFloat InvalidNumber |
@matsumonkie If the problem comes from But I don't think that there is a problem with variable, for example: Instead you most likely have a This is the So you can either use the Or you can just put the
|
Well... that was exactly it! Sorry for the inconvenience :-S |
int
parser fails to parse42efg
while parsing42abc
works.ellie: https://ellie-app.com/4jqm8pFGXyLa1
Related issues: #14 and #25
The text was updated successfully, but these errors were encountered: