mò
„ÞoBc           @   sá  d  Z  d Z d Z y e Wn d" \ Z Z n Xy| d k Z d k Z d k Z d k Z d k	 Z	 e i
 i e i i e	 i e i ƒ  ƒ d d d g ƒ ƒ d	 k l Z l Z Wn1 y e i i d
 e ƒ Wn e GHn X‚  n Xe i d i e i ƒ d Z e i d ƒ d Z e i ƒ  d Z d „  Z d „  Z d „  Z d k l Z h  d d <d d <d d <d d <d d <d d <Z d „  Z  d „  Z! d „  Z" d f  d „  ƒ  YZ# d  „  Z$ e% d! j o e$ e i d ƒ n d S(#   sà   precursor to pfcompile, just enumerates tokens in .pf file

   purpose of this is to keep things extremely simple when bootstrapping;
   I was doing this with the RCS file but each time I change machines
   I lose that trails7  
    pfcompile -- bootstrap compiler for postforth version 1
    Copyright (C) 2005  John Comeau <jc.jcomeau.com>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    s5   Not all needed libraries found, upgrade or check pathi   i    Ni   t   libt   python(   s   gpls	   jclicenses   %s
iÿÿÿÿt   .c          G   s   t  S(   N(   t   False(   t   whatever(    (    t   ./pftokens.pyt
   DebugPrint3   s    c          G   s0   x) t  |  d ƒ t i j o |  d }  q W|  S(   sA   reduces args to lists or scalars, helps with command-line testingi    N(   t   typet   argst   typest	   TupleType(   R   (    (    R   t   noTuples6   s
       c          G   s<   t  |  ƒ }  x) t |  d ƒ t i j o |  d }  q W|  S(   s8   reduces args to scalars, helps with command-line testingi    N(   R   R   R   R	   t   ListType(   R   (    (    R   t   scalars;   s       (   s	   countdicts   /*t   multilineComments   //t   comments   
R   s   2#t   skipnexts   10#s   16#c          G   sx   t  d ƒ t |  ƒ }  |  d } xQ t oI t  d | i | i ƒ | i ƒ  } | d j p | i
 d ƒ o Pq# q# Wd S(   s   skip past next */s   processing multiline commenti    t   skippings   */N(   R   R   R   t	   tokenizert   Truet   listt   pointert   getnextt   tokent   Nonet   endswith(   R   R   R   (    (    R   R   L   s     

  c          G   sx   t  d ƒ t |  ƒ }  |  d } xQ t oI t  d | i | i ƒ | i ƒ  } | d j p | i
 d ƒ o Pq# q# Wd S(   s   skip past following newlines   processing commenti    R   s   
N(   R   R   R   R   R   R   R   R   R   R   R   (   R   R   R   (    (    R   R   V   s     

  c          G   s;   t  |  ƒ }  |  d } t d | i | i ƒ | i ƒ  d  S(   Ni    R   (   R   R   R   R   R   R   R   (   R   R   (    (    R   R   `   s    
R   c           B   s&   t  Z d Z g  Z d „  Z d „  Z RS(   Ni    c         G   sy   t  | ƒ } | d } t t i t | ƒ i ƒ  ƒ } x. | D]& } |  i i | ƒ |  i i d ƒ q; Wt d |  i ƒ d  S(   Ni    s   
R   (   R   R   t
   sourcefilet   mapt   strt   splitt   opent	   readlinest   sourcet   linet   selfR   t   extendt   appendR   (   R"   R   R   R    R!   (    (    R   t   __init__j   s    
 c         C   sH   |  i t |  i ƒ j o d  Sn$ |  i |  i } |  i d 7_ | Sd  S(   Ni   (   R"   R   t   lenR   R   t   next(   R"   R'   (    (    R   R   s   s
    (   t   __name__t
   __module__R   R   R%   R   (    (    (    R   R   f   s   		c          G   sþ   t  d t t f |  ƒ t |  ƒ }  t ƒ  } | i t ƒ t	 ƒ  } x  |  D]˜ } t | ƒ } xƒ t o{ | i ƒ  } t  d | ƒ | d j o Pn | | i ƒ  j o t | | ƒ | ƒ n | d j o | | c d 7<q^ q^ WqI Wt  | ƒ | i ƒ  GHd S(   s—   enumerate postFORTH tokens from program(s) passed in on command line

    using "inside knowledge" of postFORTH, find tokens and output
    as a list
 s'   'pytest %s.%s' should show this; args: R   s   
i   N(   R   R"   t   originalselfR   R   t   dictt   tokenmapt   updatet	   postfortht	   countdictt   tokensR   R   t   pftokenizerR   R   R   R   t   keyst   eval(   R   R0   R   R1   R   R,   (    (    R   t   pftokens{   s,     		    
t   __main__(   i   i    (&   t   __doc__t	   Copyrightt   errormessageR   R   t   syst   osR	   t   ret   pwdt   pathR$   t   sept   joint   getpwuidt   geteuidt   com.jcomeaut   gplt	   jclicenset   stderrt   writet   argvR   R"   t   commandR*   R   R   R   t   com.jcomeau.arcaneR/   R.   R   R   R   R   R4   R(   (   R   R   R7   R   RC   R   R"   R;   R   R   R*   R   R/   R9   R<   R4   R	   R   R   R8   RD   RH   R.   R:   (    (    R   t   ?   s>   -8				<		
	
		