<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body><div data-crea="font-wrapper" style="font-family: Tahoma; font-size: 16px; direction: ltr">Hi all,<div></div><div><br></div><div>I am writing a lexer for a SCPI parser. The number format of 488.2 is more tolerant than</div><div>list_to_float/1, it seems.</div><div>.123 and 456. are both valid in 488.2, but list_to_float/1 rejects them.</div><div><br></div><div>I have not yet found an erlang alternative to list_to_float/1,</div><div>my current approach is to add the omitted zeroes and feed the patched string to list_to_float/1.</div><div><br></div><div>This works if the number is only a mantissa, but</div><div>it gets a bit more complicated when there is also an exponent, like 123.e11</div><div>my leex expression for the number looks like</div><div><br></div><div>{MANTISSA}{EXPONENT} : {token, {float, TokenLine, i488tofloat(TokenChars)}}.</div><div><br></div><div>With this approach, I have to parse the string in my function a second time, which is not elegant at all.</div><div><br></div><div>Is there a way to have access to the regex macros (or regex groups) on the left side, like \1, \2?</div><div><br></div><div>I already tried to push back zeroes, but immediately ran into the promised consequences from note 4 on</div><div><a href="http://erlang.org/doc/man/leex.html" style="cursor: inherit;">http://erlang.org/doc/man/leex.html</a>, so I quickly left that alley.<br></div><div><br></div><div>The question might be heretic, but why is list_to_float so strict? Every calculator allows to omit a leading 0 before the decimal point.</div><div><br></div><div>Kind regards,</div><div>Dieter</div><div><br></div><div><br></div><div><br></div><div><br></div></div></body></html>