parameters: (lst)
docstring: 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)
docstring_summary: Try to obtain a number from a list of tokens. The token types are defined in :py:attr:`waflib.Tools.ccroot.tok_types`.
docstring_tokens: Try to obtain a number from a list of tokens . The token types are defined in : py : attr : waflib . Tools . ccroot . tok_types .
function: def get_num(lst):
  	"""
  	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)
  	"""
  	if not lst: raise PreprocError("empty list for get_num")
  	(p, v) = lst[0]
  	if p == OP:
  		if v == '(':
  			count_par = 1
  			i = 1
  			while i < len(lst):
  				(p, v) = lst[i]
  
  				if p == OP:
  					if v == ')':
  						count_par -= 1
  						if count_par == 0:
  							break
  					elif v == '(':
  						count_par += 1
  				i += 1
  			else:
  				raise PreprocError("rparen expected %r" % lst)
  
  			(num, _) = get_term(lst[1:i])
  			return (num, lst[i+1:])
  
  		elif v == '+':
  			return get_num(lst[1:])
  		elif v == '-':
  			num, lst = get_num(lst[1:])
  			return (reduce_nums('-1', num, '*'), lst)
  		elif v == '!':
  			num, lst = get_num(lst[1:])
  			return (int(not int(num)), lst)
  		elif v == '~':
  			num, lst = get_num(lst[1:])
  			return (~ int(num), lst)
  		else:
  			raise PreprocError("Invalid op token %r for get_num" % lst)
  	elif p == NUM:
  		return v, lst[1:]
  	elif p == IDENT:
  		# all macros should have been replaced, remaining identifiers eval to 0
  		return 0, lst[1:]
  	else:
  		raise PreprocError("Invalid token %r for get_num" % lst)
function_tokens: def get_num ( lst ) : if not lst : raise PreprocError ( "empty list for get_num" ) ( p , v ) = lst [ 0 ] if p == OP : if v == '(' : count_par = 1 i = 1 while i < len ( lst ) : ( p , v ) = lst [ i ] if p == OP : if v == ')' : count_par -= 1 if count_par == 0 : break elif v == '(' : count_par += 1 i += 1 else : raise PreprocError ( "rparen expected %r" % lst ) ( num , _ ) = get_term ( lst [ 1 : i ] ) return ( num , lst [ i + 1 : ] ) elif v == '+' : return get_num ( lst [ 1 : ] ) elif v == '-' : num , lst = get_num ( lst [ 1 : ] ) return ( reduce_nums ( '-1' , num , '*' ) , lst ) elif v == '!' : num , lst = get_num ( lst [ 1 : ] ) return ( int ( not int ( num ) ) , lst ) elif v == '~' : num , lst = get_num ( lst [ 1 : ] ) return ( ~ int ( num ) , lst ) else : raise PreprocError ( "Invalid op token %r for get_num" % lst ) elif p == NUM : return v , lst [ 1 : ] elif p == IDENT : # all macros should have been replaced, remaining identifiers eval to 0 return 0 , lst [ 1 : ] else : raise PreprocError ( "Invalid token %r for get_num" % lst )