ó
!Æ^c           @   sº  d  Z  d d l Z d d l Z d d l Z d d l m Z m Z m Z d e j f d „  ƒ  YZ	 d Z
 d Z d Z d Z e Z d	 d
 g Z e j r› g  Z n  d Z d Z i d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d  6Z e j d! e j e j Bƒ Z e j d" ƒ Z e j d# ƒ Z e j d$ e j ƒ Z e j d% e j ƒ Z e j d& e j e j Bƒ Z g  e d' d( ƒ D] \ Z  Z! d) e  e! f ^ qŠZ" i
 d d* 6d+ d, 6d- d. 6d/ d0 6d1 d2 6d3 d4 6d5 d6 6d7 d8 6d9 d: 6d; d< 6Z# d= Z$ d> Z% d? Z& d@ Z' dA Z( e$ e' e& e% g Z) dB dC dD dE g Z* e j d j+ g  e e) e* ƒ D] \ Z, Z- dF e, e- f ^ qVƒ e j. ƒ Z/ d, Z0 d= Z1 dG Z2 d@ Z3 dH „  Z4 i  Z5 dI dJ dK dL dM dN dO dP g Z6 x; e7 e6 ƒ D]- \ Z8 Z9 x e9 j: ƒ  D] Z; e8 e5 e; <qïWqÖWdQ „  Z< dR „  Z= dS „  Z> dT „  Z? dU „  Z@ dV „  ZA g  dW „ ZB dX „  ZC dY „  ZD e j dZ ƒ ZE d[ „  ZF d\ „  ZG d] „  ZH d^ „  ZI d_ „  ZJ d` eK f da „  ƒ  YZL db „  ZM d S(c   sÁ  
C/C++ preprocessor for finding dependencies

Reasons for using the Waf preprocessor by default

#. Some c/c++ extensions (Qt) require a custom preprocessor for obtaining the dependencies (.moc files)
#. Not all compilers provide .d files for obtaining the dependencies (portability)
#. A naive file scanner will not catch the constructs such as "#include foo()"
#. A naive file scanner will catch unnecessary dependencies (change an unused header -> recompile everything)

Regarding the speed concerns:

* the preprocessing is performed only when files must be compiled
* the macros are evaluated only for #if/#elif/#include
* system headers are not scanned by default

Now if you do not want the Waf preprocessor, the tool +gccdeps* uses the .d files produced
during the compilation to track the dependencies (useful when used with the boost libraries).
It only works with gcc >= 4.4 though.

A dumb preprocessor is also available in the tool *c_dumbpreproc*
iÿÿÿÿN(   t   Logst   Utilst   Errorst   PreprocErrorc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s9   /git_repos/PolyLV2/poly_mclk_in/waflib/Tools/c_preproc.pyR       s   i † t   -i–   s   /usr/local/includes   /usr/includei    t   !t   nott   not_eqs   &&t   ands   &=t   and_eqs   ||t   ors   |=t   or_eqt   ^t   xors   ^=t   xor_eqt   &t   bitandt   |t   bitort   ~t   complsc   ^[ 	]*(?:#|%:)[ 	]*(ifdef|ifndef|if|else|elif|endif|include|import|define|undef|pragma)[ 	]*(.*)*$s   ^[a-zA-Z_]\w*s   ^[a-zA-Z_][a-zA-Z0-9_]*[(]s   ^\s*once\s*s   \\*
s7   //.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"s	   =-/!'()<>s	   #~\|^[]{}s   ??t   0i   t   ai   t   bi	   t   ti
   t   ni   t   fi   t   vi   t   ri\   s   \i'   t   't   it   Ot   Tt   st   cs$  0[xX](?P<hex>[a-fA-F0-9]+)(?P<qual1>[uUlL]*)|L*?'(?P<char>(\\.|[^\\'])+)'|(?P<n1>\d+)[Ee](?P<exp0>[+-]*?\d+)(?P<float0>[fFlL]*)|(?P<n2>\d*\.\d+)([Ee](?P<exp1>[+-]*?\d+))?(?P<float1>[fFlL]*)|(?P<n4>\d+\.\d*)([Ee](?P<exp2>[+-]*?\d+))?(?P<float2>[fFlL]*)|(?P<oct>0*)(?P<n0>\d+)(?P<qual2>[uUlL]*)s   L?"([^"\\]|\\.)*"s   [a-zA-Z_]\w*s’   %:%:|<<=|>>=|\.\.\.|<<|<%|<:|<=|>>|>=|\+\+|\+=|--|->|-=|\*=|/=|%:|%=|%>|==|&&|&=|\|\||\|=|\^=|:>|!=|##|[\(\)\{\}\[\]<>\?\|\^\*\+&=:!#;,%/\-\?\~\.]s
   (?P<%s>%s)t   uc         C   s$   |  j  ƒ  } | d d k r  d S| S(   sC   Replace function used with :py:attr:`waflib.Tools.c_preproc.re_cpp`i    t   /t    (   t   group(   t   mR#   (    (    s9   /git_repos/PolyLV2/poly_mclk_in/waflib/Tools/c_preproc.pyt   replŒ   s    s   * / %s   + -s   << >>s	   < <= >= >s   == !=s   & | ^s   && ||t   ,c         C   sÕ  y d |  } Wn t  k
 r- t |  ƒ } n Xy d | } Wn t  k
 r[ t | ƒ } n X| } | d k r{ | | } nV| d k r” | | } n=| d k r­ | | } n$| d k rÆ | | } n| d k rß | | } nò| d k rø | | A} nÙ| d k rt | | k ƒ } n¸| d	 k s1| d
 k r>| | B} n“| d k sV| d k rkt | pb| ƒ } nf| d k sƒ| d k r�| | @} nA| d k s¨| d k r½t | o´| ƒ } n| d k sÕ| d k rêt | | k ƒ } nç | d k s| d k rt | | Aƒ } n¼ | d k r6t | | k ƒ } n› | d k rWt | | k  ƒ } nz | d k rxt | | k ƒ } nY | d k r™t | | k ƒ } n8 | d k r²| | >} n | d k rË| | ?} n d } | S(   sõ   
	Apply arithmetic rules to compute a result

	:param val1: input parameter
	:type val1: int or string
	:param val2: input parameter
	:type val2: int or string
	:param val_op: C operator in *+*, */*, *-*, etc
	:type val_op: string
	:rtype: int
	i    t   %t   +R   t   *R&   R   s   ==R   R   s   ||R   R   R   s   &&R
   s   !=R	   R   s   <=t   <t   >s   >=s   <<s   >>(   t	   TypeErrort   int(   t   val_1t   val_2t   val_opR   R   t   dR$   (    (    s9   /git_repos/PolyLV2/poly_mclk_in/waflib/Tools/c_preproc.pyt   reduce_numsž   sb    c         C   s!  |  s t  d ƒ ‚ n  |  d \ } } | t k rÙ| d k rd } d } x‘ | t |  ƒ k  rÌ |  | \ } } | t k r¿ | d k r£ | d 8} | d k r¼ Pq¼ q¿ | d k r¿ | d 7} q¿ n  | d 7} qL Wt  d |  ƒ ‚ t |  d | !ƒ \ } } | |  | d f S| d k r"t |  d ƒ S| d k rZt |  d ƒ \ } }  t d	 | d
 ƒ |  f S| d k r“t |  d ƒ \ } }  t t | ƒ ƒ |  f S| d k rÆt |  d ƒ \ } }  t | ƒ |  f St  d |  ƒ ‚ nD | t k ró| |  d f S| t k rd |  d f St  d |  ƒ ‚ d S(   s-  
	Try to obtain a number from a list of tokens. The token types are defined in :py:attr:`waflib.Tools.ccroot.tok_types`.

	:param lst: list of preprocessor tokens
	:type lst: list of tuple (tokentype, value)
	:return: a pair containing the number and the rest of the list
	:rtype: tuple(value, list)
	s   empty list for get_numi    t   (i   t   )s   rparen expected %rR-   R   s   -1R.   R   R   s   Invalid op token %r for get_nums   Invalid token %r for get_numN(	   R   t   OPt   lent   get_termt   get_numR7   R2   t   NUMt   IDENT(   t   lstt   pR   t	   count_parR    t   numt   _(    (    s9   /git_repos/PolyLV2/poly_mclk_in/waflib/Tools/c_preproc.pyR=   á   sJ    	
c   
      C   ss  |  s t  d ƒ ‚ n  t |  ƒ \ } }  |  s7 | g  f S|  d \ } } | t k r_| d k rm t |  d ƒ S| d k rZd } d } x  | t |  ƒ k  r|  | \ } } | t k r
| d k rÏ | d 8} q
| d k rè | d 7} q
| d k r
| d k rPqq
n  | d 7} qˆ Wt  d	 |  ƒ ‚ t | ƒ rEt |  d | !ƒ St |  | d ƒ Sq_t |  d ƒ \ } }  |  sŸt | | | ƒ } t t | f g |  ƒ S|  d \ } } | t k rÎt  d
 |  ƒ ‚ n  t | t | k rt | | | ƒ } t t | f g |  ƒ St |  d ƒ \ }	 }  t | |	 | ƒ }	 t t | f | | f t |	 f g |  ƒ Sn  t  d |  ƒ ‚ d S(   sÑ   
	Evaluate an expression recursively, for example::

		1+1+1 -> 2+1 -> 3

	:param lst: list of tokens
	:type lst: list of tuple(token, value)
	:return: the value and the remaining tokens
	:rtype: value, list
	s   empty list for get_termi    R+   i   t   ?R9   R8   t   :s   rparen expected %rs   op expected %rs   cannot reduce %rN(	   R   R=   R:   R<   R;   R2   R7   R>   t   prec(
   R@   RC   RA   R   RB   R    t   num2t   p2t   v2t   num3(    (    s9   /git_repos/PolyLV2/poly_mclk_in/waflib/Tools/c_preproc.pyR<     sR    

,c         C   s   t  |  ƒ \ } }  t | f S(   s¾   
	Take a list of tokens and output true or false for #if/#elif conditions.

	:param lst: a list of tokens
	:type lst: list of tuple(token, value)
	:return: a token
	:rtype: tuple(NUM, int)
	(   R<   R>   (   R@   RC   (    (    s9   /git_repos/PolyLV2/poly_mclk_in/waflib/Tools/c_preproc.pyt   reduce_eval\  s    	c         C   s2   g  |  D] \ } } t  | ƒ ^ q }  d j |  ƒ S(   s   
	Merge a list of tokens into a string

	:param lst: a list of tokens
	:type lst: list of tuple(token, value)
	:rtype: string
	t    (   t   strt   join(   R@   RI   RJ   (    (    s9   /git_repos/PolyLV2/poly_mclk_in/waflib/Tools/c_preproc.pyt	   stringizeh  s    %c         C   sÆ   d } |  d t k r/ | d t k r/ t } nb |  d t k rh | d t k s_ | d t k rh t } n) |  d t k r‘ | d t k r‘ t } n  | s° t d |  | f ƒ ‚ n  | |  d | d f S(   sõ   
	Token pasting works between identifiers, particular operators, and identifiers and numbers::

		a ## b  ->  ab
		> ## =  ->  >=
		a ## 2  ->  a2

	:param t1: token
	:type t1: tuple(type, value)
	:param t2: token
	:type t2: tuple(type, value)
	i    s*   tokens do not make a valid paste %r and %ri   N(   t   NoneR:   R?   R>   R   (   t   t1t   t2t   p1(    (    s9   /git_repos/PolyLV2/poly_mclk_in/waflib/Tools/c_preproc.pyt   paste_tokenss  s     	0	 	c         C   s¬  d } xŸ| t  |  ƒ k  r§|  | \ } } | t k r(| d k r(|  | =| t  |  ƒ k  rš|  | \ } } | t k rª | | k r— t d f |  | <q"t d f |  | <q%| t k r| d k r|  | =|  | \ } } |  | =| | k rÿ t d f |  | <q"t d f |  | <q%t d |  ƒ ‚ qšnr| t k rš| | k ršt | | t ƒ rvt | | ƒ \ } }	 |	 | | <n  | | }
 |
 d } t |
 d t ƒ rð|  | =| } t	 | | | | g ƒ xÒ| D]  } |  j
 | | ƒ | d 7} qÉWqšg  } |  | =| t  |  ƒ k r"t d | ƒ ‚ n  |  | \ } } | t k sJ| d k r]t d | ƒ ‚ n  |  | =g  } d } x9| t  |  ƒ k  rŸ|  | \ } } |  | =| t k rW| d k rW| d k rà| j | | f ƒ | d 7} qœ| d k r| r| j | ƒ n  Pqœ| d	 k rA| s+t d
 | ƒ ‚ n  | j | ƒ g  } qœ| j | | f ƒ qs| j | | f ƒ | d k rƒ| d 7} qs| d k rs| d 8} qsqsWt d ƒ ‚ g  } |
 d } d } x€| t  | ƒ k  rD| | \ } } | t k r›| d k r›| d t  | ƒ k  r…| | d d t k r…| | d d | k r…| | | | d d } | j t t | ƒ f ƒ | d 7} q7| j | | f ƒ nœ| t k r×| d k r×| rÁ| d t  | ƒ k  rÁ| d } | | d d t k rw| | d d | k rw| | | | d d } | rTt | | d ƒ | d <| j | d ƒ q´| j | | f ƒ | j | ƒ n=| | d d t k r™| | d d d k r™g  } t  |
 d ƒ } t  | ƒ } x: | | | d D]& } | j | ƒ | j t d	 f ƒ qÜW| r| j ƒ  n  t  | ƒ d k rŒ| d \ } } | d \ } } | d k rŒ| j ƒ  | d	 k r‰| | k  r‰| j ƒ  q‰qŒn  | | 7} n t | | | d ƒ | d <| d 7} q7| j | | f ƒ n` | t k r$| | k r$| | | } t	 | | | | g ƒ | j | ƒ n | j | | f ƒ | d 7} qÅWt	 | | | | g ƒ x; t t  | ƒ d d d ƒ D] } |  j
 | | | ƒ qyWn  | d 7} q	 Wd S(   s‚  
	Replace the tokens in lst, using the macros provided in defs, and a list of macros that cannot be re-applied

	:param lst: list of tokens
	:type lst: list of tuple(token, value)
	:param defs: macro definitions
	:type defs: dict
	:param ban: macros that cannot be substituted (recursion is not allowed)
	:type ban: list of string
	:return: the new list of tokens
	:rtype: value, list
	i    t   definedi   R8   s   Invalid define expression %rs!   expected ( after %r (got nothing)s   expected ( after %rR9   R+   s   empty param in funcall %rs   malformed macrot   #s   ##iÿÿÿÿt   __VA_ARGS__iþÿÿÿN(   R;   R?   R>   R:   R   t
   isinstanceRN   t   extract_macrot   listt   reduce_tokenst   insertt   appendt   STRRP   RU   t   extendt   popt   range(   R@   t   defst   banR    RA   R   RI   RJ   R   R   t	   macro_deft   to_addt   accut   tmpt   argst	   one_paramt   count_parent	   arg_tablet   jt   toksRR   t   va_tokst   stt   ptt   xt   p3t   v3t   p4t   v4(    (    s9   /git_repos/PolyLV2/poly_mclk_in/waflib/Tools/c_preproc.pyR\   ‹  sè    

	
F
00
#c         C   s‹   t  |  | g  ƒ |  s% t d ƒ ‚ n  |  ri |  d \ } } | t k ri | | k ri t d |  ƒ ‚ qi n  t |  ƒ \ } } t | ƒ d k S(   s  
	Reduce the tokens by :py:func:`waflib.Tools.c_preproc.reduce_tokens` and try to return a 0/1 result by :py:func:`waflib.Tools.c_preproc.reduce_eval`.

	:param lst: list of tokens
	:type lst: list of tuple(token, value)
	:param defs: macro definitions
	:type defs: dict
	:rtype: int
	s   missing tokens to evaluatei    s   missing macro %r(   R\   R   R?   RL   R2   (   R@   Rc   RA   R   (    (    s9   /git_repos/PolyLV2/poly_mclk_in/waflib/Tools/c_preproc.pyt
   eval_macro<  s    
c   	      C   s>  t  |  ƒ } t j |  ƒ rñ| d \ } } | d \ } } | t k rV t d ƒ ‚ n  d } d } i  } d } xh| d 7} | | \ } } | d k rë | t k rÀ | | | <| d 7} | } qÕ| t k rÜ | d k rÜ PqÕt d ƒ ‚ qq | t k rC| t k r| d k r| } qÕ| t k r4| d k r4PqÕt d ƒ ‚ qq | d k r®| t k rx| | | <| d 7} | } qÕ| t k rŸ| d	 k rŸt d
 ƒ ‚ qÕt d ƒ ‚ qq | d	 k rÉt d ƒ ‚ qq t d ƒ ‚ qq W| | | | d g f S| d \ } } t | ƒ d k r'| g  | d g f S| g  d g g f Sd S(   s>  
	Process a macro definition of the form::
		 #define f(x, y) x * y

	into a function or a simple macro without arguments

	:param txt: expression to exact a macro definition from
	:type txt: string
	:return: a tuple containing the name, the list of arguments and the replacement
	:rtype: tuple(string, [list, list])
	i    i   s
   expected (R8   R9   s   unexpected token (3)R+   s   comma or ... expecteds   ...s   not implemented (1)s   comma or ... expected (2)s   not implemented (2)s   unexpected elseR"   RM   N(   R"   RM   (   t   tokenizet   re_funt   searchR:   R   R?   R;   (	   t   txtR   RA   t   nameR   R    t   pindext   paramst   prev(    (    s9   /git_repos/PolyLV2/poly_mclk_in/waflib/Tools/c_preproc.pyRZ   R  sV    


		

	s   ^\s*(<(?:.*)>|"(?:.*)")c         C   s  t  j |  ƒ } | r9 | j d ƒ }  |  d |  d d !f St |  ƒ } t | | d g ƒ | sq t d |  ƒ ‚ n  t | ƒ d k r¬ | d d t k rü d | d d f SnP | d d d k rü | d d d k rü d t | ƒ j	 d ƒ j
 d ƒ f } | St d |  ƒ ‚ d	 S(
   sÃ   
	Process a line in the form::

		#include foo

	:param txt: include line to process
	:type txt: string
	:param defs: macro definitions
	:type defs: dict
	:return: the file name
	:rtype: string
	i   i    iÿÿÿÿt   waf_includes   could not parse include %rt   "R/   R0   N(   t
   re_includeRz   R(   Rx   R\   R   R;   R_   RP   t   lstript   rstrip(   R{   Rc   R)   Rn   t   ret(    (    s9   /git_repos/PolyLV2/poly_mclk_in/waflib/Tools/c_preproc.pyt   extract_include˜  s    ($c         C   sM  |  s t  d ƒ ‚ n  |  d d k r/ t |  ƒ S|  d } | d k rŒ t |  ƒ d k r{ |  d t j k r{ t |  d d	 ƒ St |  d d	 ƒ S| j ƒ  r| d
 k rº t |  ƒ d k rº d SxŒ d D]Q } t |  ƒ | k rÁ |  d d | !j ƒ  rÁ d | t |  d d | !d ƒ f SqÁ Wn0 y t | SWn! t k
 rHt  d |  ƒ ‚ n Xd S(   sy   
	Parse a c character

	:param txt: character to parse
	:type txt: string
	:return: a character literal
	:rtype: string
	s   attempted to parse a null chari    s   \i   Rr   i   i   i   i   R   i   s   could not parse char literal %rN(   i   i   i   (	   R   t   ordR;   t   stringt	   hexdigitsR2   t   isdigitt   chr_esct   KeyError(   R{   R$   R    (    (    s9   /git_repos/PolyLV2/poly_mclk_in/waflib/Tools/c_preproc.pyt
   parse_char»  s&    


%))c         C   s   t  |  ƒ S(   sÁ   
	Convert a string into a list of tokens (shlex.split does not apply to c/c++/d)

	:param s: input to tokenize
	:type s: string
	:return: a list of tokens
	:rtype: list of tuple(token, value)
	(   t   tokenize_private(   R#   (    (    s9   /git_repos/PolyLV2/poly_mclk_in/waflib/Tools/c_preproc.pyRx   Ú  s    	c         C   sÇ  g  } xºt  j |  ƒ D]©} | j } x—t D]�} | | ƒ } | r, | t k rª | t k re t } q¤| j ƒ  d k r† d } t } q¤| j ƒ  d k r¤d } t } q¤nú | t k rO| d ƒ rÔ t	 | d ƒ } q¤| d ƒ rø t	 | d ƒ d ƒ } q¤| d	 ƒ r| d	 ƒ } q¤| d
 ƒ } | r4t
 | ƒ } q¤| d ƒ pI| d ƒ } nU | t k rˆ| d k rpd } q¤| d k r¤d } q¤n | t k r¤| d d !} n  | j | | f ƒ Pq, q, Wq W| S(   Nt   truei   t   falsei    t   octi   t   hexi   t   n0t   chart   n2t   n4s   %:RW   s   %:%:s   ##iÿÿÿÿ(   t	   re_clexert   finditerR(   t	   tok_typesR?   t	   g_optransR:   t   lowerR>   R2   R�   R_   R^   (   R#   R…   t   matchR)   R|   R   (    (    s9   /git_repos/PolyLV2/poly_mclk_in/waflib/Tools/c_preproc.pyRŽ   å  sH    				c         C   s‘   g  } x„ |  D]| } | r | j  d ƒ } | d k rD | j | ƒ q‰ | d k rv | j d | |  | | d f ƒ q‰ t d | ƒ ‚ q q W| S(   Nt   =iÿÿÿÿi    s   %s %si   s   Invalid define expression %r(   t   findR^   t
   ValueError(   R@   R…   t   yt   pos(    (    s9   /git_repos/PolyLV2/poly_mclk_in/waflib/Tools/c_preproc.pyt   format_defines  s    &t   c_parserc           B   sb   e  Z d  Z d
 d
 d „ Z d „  Z d d
 d „ Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z RS(   s~   
	Used by :py:func:`waflib.Tools.c_preproc.scan` to parse c/h files. Note that by default,
	only project headers are parsed.
	c         C   s‘   g  |  _  | d  k r! i  |  _ n t | ƒ |  _ g  |  _ d |  _ g  |  _ | pT g  |  _ g  |  _ g  |  _	 d |  _
 t ƒ  |  _ t ƒ  |  _ d  S(   Ni    RM   (   t   linesRQ   Rc   t   dictt   statet   count_filest   currentnode_stackt	   nodepathst   nodest   namest   curfilet   sett   ban_includest   listed(   t   selfR©   t   defines(    (    s9   /git_repos/PolyLV2/poly_mclk_in/waflib/Tools/c_preproc.pyt   __init__"  s    							c         C   s  y | j  j } Wn* t k
 r< t j t ƒ } | j  _ n X| | f } y | | SWn¬ t k
 r| j | ƒ } | rõ t | d d ƒ r• d } qõ | j
 | j  j ƒ rõ | j  j j | j | j  j ƒ ƒ } | rò t | d d ƒ rò d } qò qõ n  | | | <| SXd S(   s÷   
		Find a file from the input directory

		:param node: directory
		:type node: :py:class:`waflib.Node.Node`
		:param filename: header to find
		:type filename: string
		:return: the node if found, or None
		:rtype: :py:class:`waflib.Node.Node`
		t   childrenN(   t   ctxt   preproc_cache_nodet   AttributeErrorR   t	   lru_cachet   FILE_CACHE_SIZERŒ   t   find_resourcet   getattrRQ   t   is_child_oft   bldnodet   srcnodet   search_nodet	   path_from(   R°   t   nodet   filenamet   cachet   keyR…   Rh   (    (    s9   /git_repos/PolyLV2/poly_mclk_in/waflib/Tools/c_preproc.pyt   cached_find_resourceA  s$    	$
R�   c         C   s_  | j  d ƒ r# |  j j | ƒ d S| |  _ d } | d k rœ | j r€ xO t |  j ƒ D]" } |  j | | ƒ } | rW PqW qW Wqœ |  j |  j d | ƒ } n  | sÕ x0 |  j	 D]" } |  j | | ƒ } | r¬ Pq¬ q¬ Wn  |  j
 } | r/| |  j k r/| | k r| j | ƒ |  j j | ƒ n  |  j | ƒ n, | | k r[| j | ƒ |  j j | ƒ n  | S(   sÀ  
		Try to obtain a node from the filename based from the include paths. Will add
		the node found to :py:attr:`waflib.Tools.c_preproc.c_parser.nodes` or the file name to
		:py:attr:`waflib.Tools.c_preproc.c_parser.names` if no corresponding file is found. Called by
		:py:attr:`waflib.Tools.c_preproc.c_parser.start`.

		:param filename: header to find
		:type filename: string
		:return: the node if found
		:rtype: :py:class:`waflib.Node.Node`
		s   .mocR�   iÿÿÿÿN(   t   endswithR«   R^   RQ   R¬   t   MSVC_VERSIONt   reversedR¨   RÄ   R©   R¯   R®   t   addRª   t   addlines(   R°   RÁ   t   kindt   envt   foundR   R¯   (    (    s9   /git_repos/PolyLV2/poly_mclk_in/waflib/Tools/c_preproc.pyt   tryfind`  s6    			c         C   su   | j  ƒ  } t rD x/ t D]$ \ } } | j | ƒ j | ƒ } q Wn  t j d | ƒ } t j t | ƒ } t	 j
 | ƒ S(   sW  
		Filter the comments from a c/h file, and return the preprocessor lines.
		The regexps :py:attr:`waflib.Tools.c_preproc.re_cpp`, :py:attr:`waflib.Tools.c_preproc.re_nl` and :py:attr:`waflib.Tools.c_preproc.re_lines` are used internally.

		:return: the preprocessor directives as a list of (keyword, line)
		:rtype: a list of string pairs
		RM   (   t   readt   use_trigraphst   trig_deft   splitRO   t   re_nlt   subt   re_cppR*   t   re_linest   findall(   R°   RÀ   t   codeR   R   (    (    s9   /git_repos/PolyLV2/poly_mclk_in/waflib/Tools/c_preproc.pyt   filter_comments�  s    	c         C   s–   y | j  j } Wn* t k
 r< t j t ƒ } | j  _ n Xy | | SWnF t k
 r‘ |  j | ƒ | | <} | j t	 d f ƒ | j
 ƒ  | SXd  S(   NRM   (   R´   t   preproc_cache_linesR¶   R   R·   t   LINE_CACHE_SIZERŒ   RØ   R^   t   POPFILEt   reverse(   R°   RÀ   RÂ   R¤   (    (    s9   /git_repos/PolyLV2/poly_mclk_in/waflib/Tools/c_preproc.pyt   parse_lines¡  s    
c         C   sâ   |  j  j | j ƒ |  j d 7_ |  j t k r@ t d ƒ ‚ n  t j r\ t j d | ƒ n  y |  j	 | ƒ } Wn\ t
 k
 r’ t d | ƒ ‚ nL t k
 rÍ t j d k rÞ t j d | t j ƒ  ƒ qÞ n X|  j j | ƒ d S(   sŽ   
		Add the lines from a header in the list of preprocessor lines to parse

		:param node: header
		:type node: :py:class:`waflib.Node.Node`
		i   s   recursion limit exceededs   preproc: reading file %rs   could not read the file %ri    s   parsing %r failed %sN(   R¨   R^   t   parentR§   t   recursion_limitR   R    t   verboset   debugRÝ   t   EnvironmentErrort	   Exceptiont   errort	   tracebackt
   format_excR¤   R`   (   R°   RÀ   R¤   (    (    s9   /git_repos/PolyLV2/poly_mclk_in/waflib/Tools/c_preproc.pyRÉ   ®  s    	 c         C   si  t  j d | j | j j ƒ | |  _ |  j | ƒ | j r€ t | j ƒ } | j ƒ  |  j	 j
 g  | D] } d | f ^ qd ƒ n  xâ|  j	 rd|  j	 j ƒ  \ } } | t k rÏ |  j d 8_ |  j j ƒ  qƒ n  yT|  j } | d  d k rû | j t ƒ n | d k r| j ƒ  n  | d d k rKt |  j k sBt |  j k rKwƒ qKn  | d k r�t t | ƒ |  j ƒ } | r‚t | d	 <q"t | d	 <n“| d
 k rßt j | ƒ }	 |	 rÒ|	 j ƒ  |  j k rÒt | d	 <q"t | d	 <nC| d k r/t j | ƒ }	 |	 r"|	 j ƒ  |  j k r"t | d	 <q"t | d	 <nó| d k sG| d k rœt | |  j ƒ \ }
 } |  j | |
 | ƒ |  _ | d k r"|  j j |  j ƒ q"n†| d k r | d	 t k rÅt | d	 <q"| d	 t k r"t t | ƒ |  j ƒ rýt | d	 <qýq"n"| d k rI| d	 t k r)t | d	 <q"| d	 t k r"t | d	 <q"nÙ | d k r–y | |  j |  j | ƒ <Wq"t  k
 r’t! d | ƒ ‚ q"XnŒ | d k rèt j | ƒ }	 |	 r"|	 j ƒ  |  j k r"|  j j" |	 j ƒ  ƒ q"n: | d k r"t# j | j$ ƒ  ƒ r"|  j j |  j ƒ q"n  Wqƒ t% k
 r`} t  j& rat  j d | | t' j( ƒ  ƒ qaqƒ Xqƒ Wd S(   sƒ  
		Preprocess a source file to obtain the dependencies, which are accumulated to :py:attr:`waflib.Tools.c_preproc.c_parser.nodes`
		and :py:attr:`waflib.Tools.c_preproc.c_parser.names`.

		:param node: source file
		:type node: :py:class:`waflib.Node.Node`
		:param env: config set containing additional defines to take into account
		:type env: :py:class:`waflib.ConfigSet.ConfigSet`
		s   preproc: scanning %s (in %s)t   definei   i   t   ift   endifi    t   eiÿÿÿÿt   ifdeft   ifndeft   includet   importt   elift   elses   Invalid define line %rt   undeft   pragmas(   preproc: line parsing failed (%s): %s %sN()   R    Rá   R|   RÞ   t   current_fileRÉ   t   DEFINESR¢   RÜ   R¤   R`   Ra   RÛ   R§   R¨   R¦   R^   t	   undefinedt   skippedt   ignoredRw   Rx   Rc   t   acceptedt   re_macRœ   R(   R†   RÍ   R®   RÈ   t   define_nameR¶   R   t   __delitem__t   re_pragma_onceR›   Rã   Rà   Rå   Ræ   (   R°   RÀ   RË   R@   Rr   t   tokent   lineR¦   R…   R)   RÊ   t   incRê   (    (    s9   /git_repos/PolyLV2/poly_mclk_in/waflib/Tools/c_preproc.pyt   startÉ  sˆ    
		
,			c         C   s   t  j | ƒ j ƒ  S(   s_   
		:param line: define line
		:type line: string
		:rtype: string
		:return: the define name
		(   Rù   Rœ   R(   (   R°   Rþ   (    (    s9   /git_repos/PolyLV2/poly_mclk_in/waflib/Tools/c_preproc.pyRú   &  s    N(   R   R   t   __doc__RQ   R²   RÄ   RÍ   RØ   RÝ   RÉ   R   Rú   (    (    (    s9   /git_repos/PolyLV2/poly_mclk_in/waflib/Tools/c_preproc.pyR£     s   	0				]c         C   së   y |  j  j } Wn' t k
 r9 t j d |  j  ƒ ‚ n Xt rr | g  t D] } |  j  j j j	 | ƒ ^ qJ } nC g  | D]6 } | j
 | j j ƒ s© | j
 | j j ƒ ry | ^ qy } t | ƒ } | j |  j d |  j ƒ | j | j f S(   s   
	Get the dependencies using a c/c++ preprocessor, this is required for finding dependencies of the kind::

		#include some_macro()

	This function is bound as a task method on :py:class:`waflib.Tools.c.c` and :py:class:`waflib.Tools.cxx.cxx` for example
	s:   %r is missing a feature such as "c", "cxx" or "includes": i    (   t	   generatort   includes_nodesR¶   R   t   WafErrort   go_absolutet   standard_includest   bldt   roott   find_dirR»   R´   R½   R¼   R£   R   t   inputsRË   Rª   R«   (   t   taskt   incnRr   R©   Rh   (    (    s9   /git_repos/PolyLV2/poly_mclk_in/waflib/Tools/c_preproc.pyt   scan/  s    2C(N   R  t   reRˆ   Rå   t   waflibR    R   R   R  R   R¸   RÚ   RÛ   Rß   t   FalseR  R  t   is_win32RÏ   t   strict_quotesRš   t   compilet
   IGNORECASEt	   MULTILINERÕ   Rù   Ry   Rü   RÒ   t   DOTALLRÔ   t   zipR   R   RÐ   R‹   R>   R:   R?   R_   t   CHARR™   t	   exp_typesRO   R|   t   partt   MR—   Rø   R÷   Rõ   Rö   R*   RG   t   opst	   enumerateRr   t   symsRÑ   R%   R7   R=   R<   RL   RP   RU   R\   Rw   RZ   R‚   R†   R�   Rx   RŽ   R¢   t   objectR£   R  (    (    (    s9   /git_repos/PolyLV2/poly_mclk_in/waflib/Tools/c_preproc.pyt   <module>   s”   $		
2L	J		C	6	E			±		E	#			)	ÿ 