| Server IP : 127.0.0.1 / Your IP : 216.73.216.109 Web Server : Apache/2.4.54 (Win64) OpenSSL/1.1.1q PHP/8.1.10 System : Windows NT DESKTOP-E5T4RUN 10.0 build 19045 (Windows 10) AMD64 User : SERVERWEB ( 0) PHP Version : 8.1.10 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/cygwin64/lib/python3.9/site-packages/pyparsing/__pycache__/ |
Upload File : |
a
�l�a�� �
@ s� d dl Zd dlZddlmZ ddlT ddlmZmZm Z dSdd�e
eef e
eef e
e
ed �d
d�ZdTdd�eee ee ed
�dd�Zeed�dd�Zeed�dd�ZdUddd�e
ee ef e
e
e
e
e
ed�dd�Zeeed�dd�ZdVdd�ee
e
ed�dd �Zeed�d!d"�Zeed�d#d$�Zd%d&de� fe� d'�e
eef e
eef ee eeed(�d)d*�Zed+�ed,�fd-d.�Ze
eef eeef d/�d0d1�Ze
eef eeef d/�d2d3�Zee e!e"d4 ��#d5��\Z$Z%d6d7� ej&j'�(� D �Z)e*d8d9�+e)� d: ��#d;�Z,d<d=� Z-G d>d?� d?e.�Z/e
eeee
eef e
eef f f Z0e
ee0e1e/ee2 f ee0e1e/f f Z3ed%�ed&�fee4e3 e
eef e
eef ed@�dAdB�Z5dg fdCdD�Z6e7e*dE�dF ��#dG�Z8e*dH��#dI�Z9e*dJ��:� �#dK�Z;e*dL��#dM�Z<e7e*dE�dF e<B ��#dN�Z=e=Z>e*dO��#dP�Z?dQdR� e@� �A� D �ZBeZCeZDeZEeZFeZGeZHeZIeZJeZKeZLe$e% ZMZNe,ZOe-ZPe/ZQe5ZRe8ZSe9ZTe;ZUe<ZVe=ZWe>ZXe?ZYdS )W� N� )�__diag__)�*)�_bslash�_flatten�_escape_regex_range_chars�,F)�allow_trailing_delim)�expr�delim�combiner �returnc C s� t | t�rt�| �} djt| �� �t|�|r:d�t|��ndd�}|sNt|�}| t|| � }|rn|t |�7 }|r�t
|��|�S |�|�S dS )a/ Helper to define a delimited list of expressions - the delimiter
defaults to ','. By default, the list elements and delimiters can
have intervening whitespace, and comments, but this can be
overridden by passing ``combine=True`` in the constructor. If
``combine`` is set to ``True``, the matching tokens are
returned as a single token string, with the delimiters included;
otherwise, the matching tokens are returned as a list of tokens,
with the delimiters suppressed.
If ``allow_trailing_delim`` is set to True, then the list may end with
a delimiter.
Example::
delimited_list(Word(alphas)).parse_string("aa,bb,cc") # -> ['aa', 'bb', 'cc']
delimited_list(Word(hexnums), delim=':', combine=True).parse_string("AA:BB:CC:DD:EE") # -> ['AA:BB:CC:DD:EE']
z{expr} [{delim} {expr}]...{end}z [{}]� )r
r �endN)�
isinstance�str_type�
ParserElement�_literalStringClass�format�strZ
streamline�Suppress�
ZeroOrMore�Opt�Combine�set_name)r
r r r ZdlNameZdelimited_list_expr� r �5/usr/lib/python3.9/site-packages/pyparsing/helpers.py�delimited_list
s
�r )�intExpr)r
�int_exprr r
c sr |p|}t � � � �fdd�}|du r8tt��dd� �}n|�� }|�d� |j|dd� |� �d t�� d
�S )a~ Helper to define a counted list of expressions.
This helper defines a pattern of the form::
integer expr expr expr...
where the leading integer tells how many expr expressions follow.
The matched tokens returns the array of expr tokens as a list - the
leading count token is suppressed.
If ``int_expr`` is specified, it should be a pyparsing expression
that produces an integer value.
Example::
counted_array(Word(alphas)).parse_string('2 ab cd ef') # -> ['ab', 'cd']
# in this parser, the leading integer value is given in binary,
# '10' indicating that 2 values are in the array
binary_constant = Word('01').set_parse_action(lambda t: int(t[0], 2))
counted_array(Word(alphas), int_expr=binary_constant).parse_string('10 ab cd ef') # -> ['ab', 'cd']
# if other fields must be parsed after the count but before the
# list items, give the fields results names and they will
# be preserved in the returned ParseResults:
count_with_metadata = integer + Word(alphas)("type")
typed_array = counted_array(Word(alphanums), int_expr=count_with_metadata)("items")
result = typed_array.parse_string("3 bool True True False")
print(result.dump())
# prints
# ['True', 'True', 'False']
# - items: ['True', 'True', 'False']
# - type: 'bool'
c s, |d }� |r�| nt � K � |d d �= d S �Nr )�Empty)�s�l�t�n�Z
array_exprr
r r �count_field_parse_actionh s z/counted_array.<locals>.count_field_parse_actionNc S s t | d �S r )�int�r$ r r r �<lambda>p � zcounted_array.<locals>.<lambda>ZarrayLenT)Zcall_during_tryz(len) z...)�Forward�WordZnums�set_parse_action�copyr �add_parse_actionr )r
r r r'