|
![](/i/fill.gif) |
Invisible escreveu:
>> OK, so how do you do
>>
>> (\+|-)[0-9]+(\.[0-9]+)?(E(\+|-)?[0-9]{1,3})?
>>
>> in your parser language?
>
> OK, that's one big ol' complex regex, right there.
I see you never looked at perl code.
>> (That is, optional sign, one or more digits, optional decimal point
>> followed by one or more digits, optional E followed by optional sign
>> followed by one to three digits.)
>
> If I've understood the spec correctly, it's
>
> do
> option (char '+' <|> char '-')
> many1 digit
> option (char '.')
> many1 digit
> option (do char 'E'; option (char '+' <|> char '-'); many1 digit)
so, besides the errors, are you satisfied to go the Lisp route and spell
out all functions rather than rely on specialized, more convenient
predefined syntax?
do you really believe spelling out "option (char '+' <|> char '-')" is
any worth as opposed to "(\+|-)"?
> Enforcing that the exponent is less than or equal to 3 digits would be
> slightly more wordy. The obvious way is
>
> xs <- many1 digit
> if length xs > 3 then fail else return ()
no, sorry. Truly overkill against "\d{3}".
--
a game sig: http://tinyurl.com/d3rxz9
Post a reply to this message
|
![](/i/fill.gif) |