Skip to content
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

"3e4" does not parse as 30000 #56

Closed
p6rt opened this issue Jan 18, 2008 · 10 comments
Closed

"3e4" does not parse as 30000 #56

p6rt opened this issue Jan 18, 2008 · 10 comments

Comments

@p6rt
Copy link

p6rt commented Jan 18, 2008

Migrated from rt.perl.org#49910 (status was 'resolved')

Searchable as RT49910$

@p6rt
Copy link
Author

p6rt commented Jan 18, 2008

From @avar

This causes t/operators/numify.t in the spec tests to fail. The only
grammar rule that parses numers with e is for decimals​:
 
  token dec_number {
  \d+[_\d+]* '.' \d+[_\d+]* [ <[Ee]> <[+\-]>? \d+ ]?
  {*}
  }

@p6rt
Copy link
Author

p6rt commented Feb 5, 2008

From zev-perl6@strangersgate.com

The fix is straightforward, but this change should also be made in
STD.pm. This fixes RT #​49910.

Zev

@p6rt
Copy link
Author

p6rt commented Feb 5, 2008

From zev-perl6@strangersgate.com

exponential.patch
Index: languages/perl6/src/parser/grammar.pg
===================================================================
--- languages/perl6/src/parser/grammar.pg	(revision 25537)
+++ languages/perl6/src/parser/grammar.pg	(working copy)
@@ -532,7 +532,7 @@
         | \d+[_\d+]*
             {{ say "Leading 0 does not indicate octal in Perl 6" }}  # FIXME
         ]
-    | \d+[_\d+]*
+    | \d+[_\d+]* [ <[Ee]> <[+\-]>? \d+ ]?
     ]
     {*}
 }

@p6rt
Copy link
Author

p6rt commented Feb 5, 2008

From zev-perl6@strangersgate.com

There is a patch in RT #​50550.

Zev

@p6rt
Copy link
Author

p6rt commented Feb 5, 2008

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Feb 6, 2008

From @jquelin

On 08/02/05 15​:21 -0800, Zev Benjamin via RT wrote​:

There is a patch in RT #​50550.

why on earth did i get a copy of your answer?
seems that it forged a from​:
  From perl6-compiler-return-1739-jquelin=gmail.com@​perl.org

something's fishy in there...

jérôme
--
jquelin@​gmail.com

@p6rt
Copy link
Author

p6rt commented Feb 6, 2008

From @coke

On Feb 5, 2008 4​:41 PM, via RT Zev Benjamin
<parrotbug-followup@​parrotcode.org> wrote​:

# New Ticket Created by Zev Benjamin
# Please include the string​: [perl #​50550]
# in the subject line of all future correspondence about this issue.
# <URL​: http://rt.perl.org/rt3/Ticket/Display.html?id=50550 >

The fix is straightforward, but this change should also be made in
STD.pm. This fixes RT #​49910.

Zev

FYI, I've merged the two tickets.

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Mar 8, 2008

From anjohnson@iee.org

On Tue Feb 05 13​:41​:02 2008, zev-perl6@​strangersgate.com wrote​:

The fix is straightforward, but this change should also be made in
STD.pm. This fixes RT #​49910.

This patch would make 3e-4 a valid integer literal, even though it's not
an integer. Now 300e-2 *is* a whole number, but I'm not sure it should
be accepted as an integer literal.

This is part of the question of what distinguishes an integer from a
floating point number; it can't just be the presence of a decimal point
as the above examples show, but S02 isn't specific. The current version
of dec_number in grammer.pg is too simplistic, it doesn't allow
exponents without both a decimal and at least one fractional digit.

Here are a few examples that need answers from the language lawyers​:
  .1 Legal, or is a leading 0 required?
  1e1 Integer or Float?
  1e-1 Integer or Float?
  10e-1 Integer or Float?
  .1e1 If legal, Integer or Float?
  1.e1 Legal?

- Andrew

@p6rt
Copy link
Author

p6rt commented Apr 6, 2008

From @pmichaud

On Fri Mar 07 23​:08​:14 2008, songmaster wrote​:

On Tue Feb 05 13​:41​:02 2008, zev-perl6@​strangersgate.com wrote​:

The fix is straightforward, but this change should also be made in
STD.pm. This fixes RT #​49910.

This patch would make 3e-4 a valid integer literal, even though it's not
an integer. Now 300e-2 *is* a whole number, but I'm not sure it should
be accepted as an integer literal.

STD.pm has since been updated to have the correct parsing -- the answer
is that an integer literal never has a dot or 'e'.

In r26812 I've just updated rakudo to match STD.pm, so this ticket can
be closed.

This is part of the question of what distinguishes an integer from a
floating point number; it can't just be the presence of a decimal point
as the above examples show, but S02 isn't specific. [...]
Here are a few examples that need answers from the language lawyers​:
.1 Legal, or is a leading 0 required?
1e1 Integer or Float?
1e-1 Integer or Float?
10e-1 Integer or Float?
.1e1 If legal, Integer or Float?
1.e1 Legal?

Just for completeness​:

  .1 Not a legal number (leading digit required)
  1e1 Float
  1e-1 Float
  10e-1 Float
  .1e1 Not a legal number (leading digit required)
  1.e1 Not a legal number (digits required after dot)

Closing ticket, thanks!

Pm

@p6rt
Copy link
Author

p6rt commented Apr 6, 2008

@pmichaud - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Apr 6, 2008
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant