Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Other notes

Reply
Thread Tools

Re: Other notes

 
 
Nick Coghlan
Guest
Posts: n/a
 
      01-08-2005
Bengt Richter wrote:
> IOW, I think there is a fix: keep tokenizing greedily and tokenize floating point as
> a sequence of integers and operators, and let <integer><dot><integer> be translated by
> the compiler to floating point, and <integer><dotdot><integer> be translated to the
> appropriate generator expression implementation.


That would be:

<int-literal><dot><int-literal> -> float(<int-literal> + "." + <int-literal>)
<int-literal><dot><identifier> -> getattr(int(<int-literal>), <identifier>)
<int-literal><dot><dot><int-literal> -> xrange(<int-literal>, <int-literal>)

However, the problem comes when you realise that 1e3 is also a floating point
literal, as is 1.1e3.

Cheers,
Nick.

--
Nick Coghlan | http://www.velocityreviews.com/forums/(E-Mail Removed) | Brisbane, Australia
---------------------------------------------------------------
http://boredomandlaziness.skystorm.net
 
Reply With Quote
 
 
 
 
Bengt Richter
Guest
Posts: n/a
 
      01-08-2005
On Sat, 08 Jan 2005 18:22:53 +1000, Nick Coghlan <(E-Mail Removed)> wrote:

>Bengt Richter wrote:
>> IOW, I think there is a fix: keep tokenizing greedily and tokenize floating point as
>> a sequence of integers and operators, and let <integer><dot><integer> be translated by
>> the compiler to floating point, and <integer><dotdot><integer> be translated to the
>> appropriate generator expression implementation.

>
>That would be:
>
><int-literal><dot><int-literal> -> float(<int-literal> + "." + <int-literal>)
><int-literal><dot><identifier> -> getattr(int(<int-literal>), <identifier>)
><int-literal><dot><dot><int-literal> -> xrange(<int-literal>, <int-literal>)
>
>However, the problem comes when you realise that 1e3 is also a floating point
>literal, as is 1.1e3.
>

Ok, that requires a little more imagination

I think it can be solved, but I haven't explored it all the way through

The key seems to be to be to condition the recognition of tokens as if recognizing
an old potentially floating point number, but emitting number-relevant separate tokens
so long as there is no embedded spaces. When a number ends, emitting an end marker should
permit the compiler to deal with the various compositions.

We still aren't looking ahead more than one, but we are carrying context, just as we do
to accumulate digits of an integer or characters of a name, but the context may continue
and determine what further tokens are emitted. E.g. the 'e' in the embedded numeric context,
becomes <fexp> rather than a name. In the following, <eon> :== end of number token

1.1 -> <1><dot><1><eon>
1 .1 -> <1><eon><dot><1><eon>
1.e1 -> <1><dot><fexp><1><eon>
1 .e1 -> <1><eon><dot><e1>
1.2e3 -> <1><dot><2><fexp><3><eon>
1..2 -> <1><eon><doubledot><1><eon>
1. .2 -> <1><dot><eon><dot><2><eon> (syntax error)
1 ..2 -> <1><eon><doubledot><1><eon>

I just have the feeling that there is a solution, whatever the hiccups

Regards,
Bengt Richter
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Lotus Notes inotes/webmail Ron P Firefox 1 08-31-2007 03:41 PM
C# 2.0 (Lotus Notes 6 & 7) Create mail document in draft folder for Lotus Notes SteveM ASP .Net 5 08-28-2007 04:16 PM
Accessing email from Notes-mail-server without Lotus Notes installed Bjorn Jensen Perl 0 03-22-2005 01:44 PM
AM-Deadlink notes MsOsWin@anon.com Firefox 0 01-13-2005 12:41 AM
Other notes bearophileHUGS@lycos.com Python 22 01-08-2005 02:18 PM



Advertisments