Your IP : 216.73.216.213
�� �docutils.nodes��document���)��}�(� rawsource�� ��children�]�h �section���)��}�(hhh]�(h �title���)��}�(h�Using the pyparsing module�h]�(h � generated���)��}�(hhh]�h �Text����1 �����}�(hh�parent�hhh�source�N�line�Nuba�
attributes�}�(�ids�]��classes�]��sectnum�a�names�]��dupnames�]��backrefs�]�u�tagname�hhhhhh Nh!Nubh�Using the pyparsing module�����}�(hhhhhhh Nh!Nubeh"}�(h$]�h&]�h)]�h+]�h-]��auto�K�refid��id1�uh/hhhhhh �@/builddir/build/BUILD/pyparsing-3.0.9/docs/HowToUsePyparsing.rst�h!Kubh �
field_list���)��}�(hhh]�(h �field���)��}�(hhh]�(h �
field_name���)��}�(h�author�h]�h�author�����}�(hhLhhJubah"}�(h$]�h&]�h)]�h+]�h-]�uh/hHhhEh h=h!K ubh �
field_body���)��}�(h�Paul McGuire�h]�h � paragraph���)��}�(hh\h]�h�Paul McGuire�����}�(hh\hh`ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!KhhZubah"}�(h$]�h&]�h)]�h+]�h-]�uh/hXhhEubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/hCh h=h!Khh@hhubhD)��}�(hhh]�(hI)��}�(h�address�h]�h�address�����}�(hh~hh|ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/hHhhyh h=h!K ubhY)��}�(h�ptmcg.pm+pyparsing@gmail.com
�h]�h_)��}�(h�ptmcg.pm+pyparsing@gmail.com�h]�h � reference���)��}�(hh�h]�h�ptmcg.pm+pyparsing@gmail.com�����}�(hhhh�ubah"}�(h$]�h&]�h)]�h+]�h-]��refuri��#mailto:ptmcg.pm+pyparsing@gmail.com�uh/h�hh�ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!Khh�ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/hXhhyubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/hCh h=h!Khh@hhubhD)��}�(hhh]�(hI)��}�(h�revision�h]�h�revision�����}�(hh�hh�ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/hHhh�h h=h!K ubhY)��}�(h�3.0.0�h]�h_)��}�(hh�h]�h�3.0.0�����}�(hh�hh�ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!Khh�ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/hXhh�ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/hCh h=h!Khh@hhubhD)��}�(hhh]�(hI)��}�(h�date�h]�h�date�����}�(hh�hh�ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/hHhh�h h=h!K ubhY)��}�(h�October, 2021
�h]�h_)��}�(h�
October, 2021�h]�h�
October, 2021�����}�(hh�hh�ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!K hh�ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/hXhh�ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/hCh h=h!K hh@hhubhD)��}�(hhh]�(hI)��}�(h� copyright�h]�h� copyright�����}�(hj hj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/hHhj h h=h!K ubhY)��}�(h�)Copyright |copy| 2003-2022 Paul McGuire.
�h]�h_)��}�(h�(Copyright |copy| 2003-2022 Paul McGuire.�h]�(h�
Copyright �����}�(h�
Copyright �hj' ubh�©�����}�(hhhj' ubh� 2003-2022 Paul McGuire.�����}�(h� 2003-2022 Paul McGuire.�hj' ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!Khj# ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/hXhj ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/hCh h=h!Khh@hhubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h>hhhhh h=h!Kubh �substitution_definition���)��}�(h�.. |copy| unicode:: 0xA9
�h]�h�©�����}�(hhhjS ubah"}�(h$]�h&]�h)]��copy�ah+]�h-]�uh/jQ h h=h!K
hhhhubh?)��}�(hhh]�hD)��}�(hhh]�(hI)��}�(h�abstract�h]�h�abstract�����}�(hjj hjh ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/hHhje h h=h!K ubhY)��}�(hX= This document provides how-to instructions for the
pyparsing library, an easy-to-use Python module for constructing
and executing basic text parsers. The pyparsing module is useful
for evaluating user-definable
expressions, processing custom application language commands, or
extracting data from formatted reports.
�h]�h_)��}�(hX< This document provides how-to instructions for the
pyparsing library, an easy-to-use Python module for constructing
and executing basic text parsers. The pyparsing module is useful
for evaluating user-definable
expressions, processing custom application language commands, or
extracting data from formatted reports.�h]�hX< This document provides how-to instructions for the
pyparsing library, an easy-to-use Python module for constructing
and executing basic text parsers. The pyparsing module is useful
for evaluating user-definable
expressions, processing custom application language commands, or
extracting data from formatted reports.�����}�(hj| hjz ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!Khjv ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/hXhje ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/hCh h=h!Khjb hhubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h>hhhhh h=h!Kubh �topic���)��}�(hhh]�(h)��}�(h�Contents�h]�h�Contents�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/hhj� h h=h!Kubh �bullet_list���)��}�(hhh]�h � list_item���)��}�(hhh]�(h_)��}�(hhh]�h�)��}�(hhh]�(h)��}�(hhh]�h�1 �����}�(hhhj� ubah"}�(h$]�h&]�h(ah)]�h+]�h-]�uh/hh Nh!Nhj� ubh�Using the pyparsing module�����}�(hhhj� ubeh"}�(h$]�h<ah&]�h)]�h+]�h-]��refid��using-the-pyparsing-module�uh/h�hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^hj� ubj� )��}�(hhh]�(j� )��}�(hhh]�(h_)��}�(hhh]�h�)��}�(hhh]�(h)��}�(hhh]�h� 1.1 �����}�(hhhj� ubah"}�(h$]�h&]�h(ah)]�h+]�h-]�uh/hh Nh!Nhj� ubh�Steps to follow�����}�(h�Steps to follow�hj� ubeh"}�(h$]��id2�ah&]�h)]�h+]�h-]��refid��steps-to-follow�uh/h�hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^hj� ubj� )��}�(hhh]�(j� )��}�(hhh]�h_)��}�(hhh]�h�)��}�(hhh]�(h)��}�(hhh]�h�1.1.1 �����}�(hhhj ubah"}�(h$]�h&]�h(ah)]�h+]�h-]�uh/hh Nh!Nhj ubh�
Hello, World!�����}�(h�
Hello, World!�hj ubeh"}�(h$]��id3�ah&]�h)]�h+]�h-]��refid��hello-world�uh/h�hj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^hj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj ubj� )��}�(hhh]�h_)��}�(hhh]�h�)��}�(hhh]�(h)��}�(hhh]�h�1.1.2 �����}�(hhhjE ubah"}�(h$]�h&]�h(ah)]�h+]�h-]�uh/hh Nh!NhjB ubh�Usage notes�����}�(h�Usage notes�hjB ubeh"}�(h$]��id4�ah&]�h)]�h+]�h-]��refid��usage-notes�uh/h�hj? ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^hj< ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj ubeh"}�(h$]�h&]��auto-toc�ah)]�h+]�h-]�uh/j� hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubj� )��}�(hhh]�(h_)��}�(hhh]�h�)��}�(hhh]�(h)��}�(hhh]�h� 1.2 �����}�(hhhj� ubah"}�(h$]�h&]�h(ah)]�h+]�h-]�uh/hh Nh!Nhj ubh�Classes�����}�(h�Classes�hj ubeh"}�(h$]��id5�ah&]�h)]�h+]�h-]��refid��classes�uh/h�hj| ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^hjy ubj� )��}�(hhh]�(j� )��}�(hhh]�h_)��}�(hhh]�h�)��}�(hhh]�(h)��}�(hhh]�h�1.2.1 �����}�(hhhj� ubah"}�(h$]�h&]�h(ah)]�h+]�h-]�uh/hh Nh!Nhj� ubh�Classes in the pyparsing module�����}�(h�Classes in the pyparsing module�hj� ubeh"}�(h$]��id6�ah&]�h)]�h+]�h-]��refid��classes-in-the-pyparsing-module�uh/h�hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubj� )��}�(hhh]�h_)��}�(hhh]�h�)��}�(hhh]�(h)��}�(hhh]�h�1.2.2 �����}�(hhhj� ubah"}�(h$]�h&]�h(ah)]�h+]�h-]�uh/hh Nh!Nhj� ubh�Basic ParserElement subclasses�����}�(h�Basic ParserElement subclasses�hj� ubeh"}�(h$]��id7�ah&]�h)]�h+]�h-]��refid��basic-parserelement-subclasses�uh/h�hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubj� )��}�(hhh]�h_)��}�(hhh]�h�)��}�(hhh]�(h)��}�(hhh]�h�1.2.3 �����}�(hhhj ubah"}�(h$]�h&]�h(ah)]�h+]�h-]�uh/hh Nh!Nhj ubh�Expression subclasses�����}�(h�Expression subclasses�hj ubeh"}�(h$]��id8�ah&]�h)]�h+]�h-]��refid��expression-subclasses�uh/h�hj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^hj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubj� )��}�(hhh]�h_)��}�(hhh]�h�)��}�(hhh]�(h)��}�(hhh]�h�1.2.4 �����}�(hhhj? ubah"}�(h$]�h&]�h(ah)]�h+]�h-]�uh/hh Nh!Nhj< ubh�Expression operators�����}�(h�Expression operators�hj< ubeh"}�(h$]��id9�ah&]�h)]�h+]�h-]��refid��expression-operators�uh/h�hj9 ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^hj6 ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubj� )��}�(hhh]�h_)��}�(hhh]�h�)��}�(hhh]�(h)��}�(hhh]�h�1.2.5 �����}�(hhhjo ubah"}�(h$]�h&]�h(ah)]�h+]�h-]�uh/hh Nh!Nhjl ubh�Positional subclasses�����}�(h�Positional subclasses�hjl ubeh"}�(h$]��id10�ah&]�h)]�h+]�h-]��refid��positional-subclasses�uh/h�hji ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^hjf ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubj� )��}�(hhh]�h_)��}�(hhh]�h�)��}�(hhh]�(h)��}�(hhh]�h�1.2.6 �����}�(hhhj� ubah"}�(h$]�h&]�h(ah)]�h+]�h-]�uh/hh Nh!Nhj� ubh�Converter subclasses�����}�(h�Converter subclasses�hj� ubeh"}�(h$]��id11�ah&]�h)]�h+]�h-]��refid��converter-subclasses�uh/h�hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubj� )��}�(hhh]�h_)��}�(hhh]�h�)��}�(hhh]�(h)��}�(hhh]�h�1.2.7 �����}�(hhhj� ubah"}�(h$]�h&]�h(ah)]�h+]�h-]�uh/hh Nh!Nhj� ubh�Special subclasses�����}�(h�Special subclasses�hj� ubeh"}�(h$]��id12�ah&]�h)]�h+]�h-]��refid��special-subclasses�uh/h�hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubj� )��}�(hhh]�h_)��}�(hhh]�h�)��}�(hhh]�(h)��}�(hhh]�h�1.2.8 �����}�(hhhj� ubah"}�(h$]�h&]�h(ah)]�h+]�h-]�uh/hh Nh!Nhj� ubh�
Other classes�����}�(h�
Other classes�hj� ubeh"}�(h$]��id13�ah&]�h)]�h+]�h-]��refid��
other-classes�uh/h�hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubj� )��}�(hhh]�h_)��}�(hhh]�h�)��}�(hhh]�(h)��}�(hhh]�h�1.2.9 �����}�(hhhj/ ubah"}�(h$]�h&]�h(ah)]�h+]�h-]�uh/hh Nh!Nhj, ubh�%Exception classes and Troubleshooting�����}�(h�%Exception classes and Troubleshooting�hj, ubeh"}�(h$]��id14�ah&]�h)]�h+]�h-]��refid��%exception-classes-and-troubleshooting�uh/h�hj) ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^hj& ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubeh"}�(h$]�h&]�jo ah)]�h+]�h-]�uh/j� hjy ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubj� )��}�(hhh]�(h_)��}�(hhh]�h�)��}�(hhh]�(h)��}�(hhh]�h� 1.3 �����}�(hhhjk ubah"}�(h$]�h&]�h(ah)]�h+]�h-]�uh/hh Nh!Nhjh ubh�$Miscellaneous attributes and methods�����}�(h�$Miscellaneous attributes and methods�hjh ubeh"}�(h$]��id15�ah&]�h)]�h+]�h-]��refid��$miscellaneous-attributes-and-methods�uh/h�hje ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^hjb ubj� )��}�(hhh]�(j� )��}�(hhh]�h_)��}�(hhh]�h�)��}�(hhh]�(h)��}�(hhh]�h�1.3.1 �����}�(hhhj� ubah"}�(h$]�h&]�h(ah)]�h+]�h-]�uh/hh Nh!Nhj� ubh�Helper methods�����}�(h�Helper methods�hj� ubeh"}�(h$]��id16�ah&]�h)]�h+]�h-]��refid��helper-methods�uh/h�hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubj� )��}�(hhh]�h_)��}�(hhh]�h�)��}�(hhh]�(h)��}�(hhh]�h�1.3.2 �����}�(hhhj� ubah"}�(h$]�h&]�h(ah)]�h+]�h-]�uh/hh Nh!Nhj� ubh�Helper parse actions�����}�(h�Helper parse actions�hj� ubeh"}�(h$]��id17�ah&]�h)]�h+]�h-]��refid��helper-parse-actions�uh/h�hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubj� )��}�(hhh]�h_)��}�(hhh]�h�)��}�(hhh]�(h)��}�(hhh]�h�1.3.3 �����}�(hhhj� ubah"}�(h$]�h&]�h(ah)]�h+]�h-]�uh/hh Nh!Nhj� ubh�!Common string and token constants�����}�(h�!Common string and token constants�hj� ubeh"}�(h$]��id18�ah&]�h)]�h+]�h-]��refid��!common-string-and-token-constants�uh/h�hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubj� )��}�(hhh]�h_)��}�(hhh]�h�)��}�(hhh]�(h)��}�(hhh]�h�1.3.4 �����}�(hhhj( ubah"}�(h$]�h&]�h(ah)]�h+]�h-]�uh/hh Nh!Nhj% ubh�0Unicode character sets for international parsing�����}�(h�0Unicode character sets for international parsing�hj% ubeh"}�(h$]��id19�ah&]�h)]�h+]�h-]��refid��0unicode-character-sets-for-international-parsing�uh/h�hj" ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^hj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubeh"}�(h$]�h&]�jo ah)]�h+]�h-]�uh/j� hjb ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubj� )��}�(hhh]�(h_)��}�(hhh]�h�)��}�(hhh]�(h)��}�(hhh]�h� 1.4 �����}�(hhhjd ubah"}�(h$]�h&]�h(ah)]�h+]�h-]�uh/hh Nh!Nhja ubh�Generating Railroad Diagrams�����}�(h�Generating Railroad Diagrams�hja ubeh"}�(h$]��id20�ah&]�h)]�h+]�h-]��refid��generating-railroad-diagrams�uh/h�hj^ ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^hj[ ubj� )��}�(hhh]�(j� )��}�(hhh]�h_)��}�(hhh]�h�)��}�(hhh]�(h)��}�(hhh]�h�1.4.1 �����}�(hhhj� ubah"}�(h$]�h&]�h(ah)]�h+]�h-]�uh/hh Nh!Nhj� ubh�Usage�����}�(h�Usage�hj� ubeh"}�(h$]��id21�ah&]�h)]�h+]�h-]��refid��usage�uh/h�hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubj� )��}�(hhh]�h_)��}�(hhh]�h�)��}�(hhh]�(h)��}�(hhh]�h�1.4.2 �����}�(hhhj� ubah"}�(h$]�h&]�h(ah)]�h+]�h-]�uh/hh Nh!Nhj� ubh�Example�����}�(h�Example�hj� ubeh"}�(h$]��id22�ah&]�h)]�h+]�h-]��refid��example�uh/h�hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubj� )��}�(hhh]�h_)��}�(hhh]�h�)��}�(hhh]�(h)��}�(hhh]�h�1.4.3 �����}�(hhhj� ubah"}�(h$]�h&]�h(ah)]�h+]�h-]�uh/hh Nh!Nhj� ubh�
Naming tip�����}�(h�
Naming tip�hj� ubeh"}�(h$]��id23�ah&]�h)]�h+]�h-]��refid��
naming-tip�uh/h�hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubj� )��}�(hhh]�h_)��}�(hhh]�h�)��}�(hhh]�(h)��}�(hhh]�h�1.4.4 �����}�(hhhj! ubah"}�(h$]�h&]�h(ah)]�h+]�h-]�uh/hh Nh!Nhj ubh�
Customization�����}�(h�
Customization�hj ubeh"}�(h$]��id24�ah&]�h)]�h+]�h-]��refid��
customization�uh/h�hj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^hj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubeh"}�(h$]�h&]�jo ah)]�h+]�h-]�uh/j� hj[ ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubeh"}�(h$]�h&]�jo ah)]�h+]�h-]�uh/j� hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubah"}�(h$]�h&]�jo ah)]�h+]�h-]�uh/j� hj� hhh Nh!Nubeh"}�(h$]��contents�ah&]��contents�ah)]��contents�ah+]�h-]�uh/j� h h=h!Khhhhubh_)��}�(hX� Note: While this content is still valid, there are more detailed
descriptions and extensive examples at the `online doc server
<https://pyparsing-docs.readthedocs.io/en/latest/pyparsing.html>`_, and
in the online help for the various pyparsing classes and methods (viewable
using the Python interpreter's built-in ``help()`` function). You will also
find many example scripts in the `examples <https://github.com/pyparsing/pyparsing/tree/master/examples>`_
directory of the pyparsing GitHub repo.�h]�(h�lNote: While this content is still valid, there are more detailed
descriptions and extensive examples at the �����}�(h�lNote: While this content is still valid, there are more detailed
descriptions and extensive examples at the �hjo hhh Nh!Nubh�)��}�(h�U`online doc server
<https://pyparsing-docs.readthedocs.io/en/latest/pyparsing.html>`_�h]�h�online doc server�����}�(hhhjx ubah"}�(h$]�h&]�h)]�h+]�h-]��name��online doc server��refuri��>https://pyparsing-docs.readthedocs.io/en/latest/pyparsing.html�uh/h�hjo ubh �target���)��}�(h�A
<https://pyparsing-docs.readthedocs.io/en/latest/pyparsing.html>�h]�h"}�(h$]��online-doc-server�ah&]�h)]��online doc server�ah+]�h-]��refuri�j� uh/j� �
referenced�Khjo ubh�{, and
in the online help for the various pyparsing classes and methods (viewable
using the Python interpreter’s built-in �����}�(h�y, and
in the online help for the various pyparsing classes and methods (viewable
using the Python interpreter's built-in �hjo hhh Nh!Nubh �literal���)��}�(h�
``help()``�h]�h�help()�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hjo ubh�; function). You will also
find many example scripts in the �����}�(h�; function). You will also
find many example scripts in the �hjo hhh Nh!Nubh�)��}�(h�I`examples <https://github.com/pyparsing/pyparsing/tree/master/examples>`_�h]�h�examples�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]��name��examples�j� �;https://github.com/pyparsing/pyparsing/tree/master/examples�uh/h�hjo ubj� )��}�(h�> <https://github.com/pyparsing/pyparsing/tree/master/examples>�h]�h"}�(h$]��examples�ah&]�h)]��examples�ah+]�h-]��refuri�j� uh/j� j� Khjo ubh�(
directory of the pyparsing GitHub repo.�����}�(h�(
directory of the pyparsing GitHub repo.�hjo hhh Nh!Nubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!Khhhhubh �
transition���)��}�(h�-----------�h]�h"}�(h$]�h&]�h)]�h+]�h-]�uh/j� h h=h!K"hhhhubh_)��}�(hX� **Note**: *In pyparsing 3.0, many method and function names which were
originally written using camelCase have been converted to PEP8-compatible
snake_case. So ``parseString()`` is being renamed to ``parse_string()``,
``delimitedList`` to ``delimited_list``, and so on. You may see the old
names in legacy parsers, and they will be supported for a time with
synonyms, but the synonyms will be removed in a future release.*�h]�(h �strong���)��}�(h�**Note**�h]�h�Note�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�: �����}�(h�: �hj� hhh Nh!Nubh �emphasis���)��}�(hX� *In pyparsing 3.0, many method and function names which were
originally written using camelCase have been converted to PEP8-compatible
snake_case. So ``parseString()`` is being renamed to ``parse_string()``,
``delimitedList`` to ``delimited_list``, and so on. You may see the old
names in legacy parsers, and they will be supported for a time with
synonyms, but the synonyms will be removed in a future release.*�h]�hX� In pyparsing 3.0, many method and function names which were
originally written using camelCase have been converted to PEP8-compatible
snake_case. So ``parseString()`` is being renamed to ``parse_string()``,
``delimitedList`` to ``delimited_list``, and so on. You may see the old
names in legacy parsers, and they will be supported for a time with
synonyms, but the synonyms will be removed in a future release.�����}�(hhhj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!K$hhhhubh_)��}�(hXC *If you are using this documentation, but working with a 2.4.x version of pyparsing,
you'll need to convert methods and arguments from the documented snake_case
names to the legacy camelCase names. In pyparsing 3.0.x, both forms are
supported, but the legacy forms are deprecated; they will be dropped in a
future release.*�h]�j )��}�(hj h]�hXC If you are using this documentation, but working with a 2.4.x version of pyparsing,
you’ll need to convert methods and arguments from the documented snake_case
names to the legacy camelCase names. In pyparsing 3.0.x, both forms are
supported, but the legacy forms are deprecated; they will be dropped in a
future release.�����}�(hhhj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j hj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!K+hhhhubj� )��}�(h�-----------�h]�h"}�(h$]�h&]�h)]�h+]�h-]�uh/j� h h=h!K1hhhhubh
)��}�(hhh]�(h)��}�(hj� h]�(h)��}�(hhh]�h� 1.1 �����}�(hhhj? hhh Nh!Nubah"}�(h$]�h&]�h(ah)]�h+]�h-]�uh/hhj< hhh Nh!Nubh�Steps to follow�����}�(hj� hj< hhh Nh!Nubeh"}�(h$]�h&]�h)]�h+]�h-]�h:Kh;j� uh/hhj9 hhh h=h!K5ubh_)��}�(h�JTo parse an incoming data string, the client code must follow these steps:�h]�h�JTo parse an incoming data string, the client code must follow these steps:�����}�(hjX hjV hhh Nh!Nubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!K7hj9 hhubh �enumerated_list���)��}�(hhh]�(j� )��}�(h��First define the tokens and patterns to be matched, and assign
this to a program variable. Optional results names or parse
actions can also be defined at this time.
�h]�h_)��}�(h��First define the tokens and patterns to be matched, and assign
this to a program variable. Optional results names or parse
actions can also be defined at this time.�h]�h��First define the tokens and patterns to be matched, and assign
this to a program variable. Optional results names or parse
actions can also be defined at this time.�����}�(hjo hjm ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!K9hji ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hjf hhh h=h!Nubj� )��}�(hX Call ``parse_string()`` or ``scan_string()`` on this variable, passing in
the string to
be parsed. During the matching process, whitespace between
tokens is skipped by default (although this can be changed).
When token matches occur, any defined parse action methods are
called.
�h]�h_)��}�(hX Call ``parse_string()`` or ``scan_string()`` on this variable, passing in
the string to
be parsed. During the matching process, whitespace between
tokens is skipped by default (although this can be changed).
When token matches occur, any defined parse action methods are
called.�h]�(h�Call �����}�(h�Call �hj� ubj� )��}�(h�``parse_string()``�h]�h�parse_string()�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh� or �����}�(h� or �hj� ubj� )��}�(h�``scan_string()``�h]�h�
scan_string()�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�� on this variable, passing in
the string to
be parsed. During the matching process, whitespace between
tokens is skipped by default (although this can be changed).
When token matches occur, any defined parse action methods are
called.�����}�(h�� on this variable, passing in
the string to
be parsed. During the matching process, whitespace between
tokens is skipped by default (although this can be changed).
When token matches occur, any defined parse action methods are
called.�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!K=hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hjf hhh h=h!Nubj� )��}�(hX9 Process the parsed results, returned as a ParseResults_ object.
The ParseResults_ object can be accessed as if it were a list of
strings. Matching results may also be accessed as named attributes of
the returned results, if names are defined in the definition of
the token pattern, using ``set_results_name()``.
�h]�h_)��}�(hX7 Process the parsed results, returned as a ParseResults_ object.
The ParseResults_ object can be accessed as if it were a list of
strings. Matching results may also be accessed as named attributes of
the returned results, if names are defined in the definition of
the token pattern, using ``set_results_name()``.�h]�(h�*Process the parsed results, returned as a �����}�(h�*Process the parsed results, returned as a �hj� ubh�)��}�(h�
ParseResults_�h]�h�ParseResults�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]��name��ParseResults�h;�parseresults�uh/h�hj� �resolved�Kubh�
object.
The �����}�(h�
object.
The �hj� ubh�)��}�(h�
ParseResults_�h]�h�ParseResults�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]��name��ParseResults�h;j� uh/h�hj� j� Kubh�� object can be accessed as if it were a list of
strings. Matching results may also be accessed as named attributes of
the returned results, if names are defined in the definition of
the token pattern, using �����}�(h�� object can be accessed as if it were a list of
strings. Matching results may also be accessed as named attributes of
the returned results, if names are defined in the definition of
the token pattern, using �hj� ubj� )��}�(h�``set_results_name()``�h]�h�set_results_name()�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�.�����}�(h�.�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!KDhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hjf hhh h=h!Nubeh"}�(h$]�h&]�h)]�h+]�h-]��enumtype��arabic��prefix�h�suffix�j uh/jd hj9 hhh h=h!K9ubh
)��}�(hhh]�(h)��}�(hj& h]�(h)��}�(hhh]�h�1.1.1 �����}�(hhhj( hhh Nh!Nubah"}�(h$]�h&]�h(ah)]�h+]�h-]�uh/hhj% hhh Nh!Nubh�
Hello, World!�����}�(hj& hj% hhh Nh!Nubeh"}�(h$]�h&]�h)]�h+]�h-]�h:Kh;j) uh/hhj" hhh h=h!KLubh_)��}�(h��The following complete Python program will parse the greeting ``"Hello, World!"``,
or any other greeting of the form "<salutation>, <addressee>!"::�h]�(h�>The following complete Python program will parse the greeting �����}�(h�>The following complete Python program will parse the greeting �hj? hhh Nh!Nubj� )��}�(h�``"Hello, World!"``�h]�h�"Hello, World!"�����}�(hhhjH ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj? ubh�E,
or any other greeting of the form “<salutation>, <addressee>!”:�����}�(h�A,
or any other greeting of the form "<salutation>, <addressee>!":�hj? hhh Nh!Nubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!KNhj" hhubh �
literal_block���)��}�(hX, import pyparsing as pp
greet = pp.Word(pp.alphas) + "," + pp.Word(pp.alphas) + "!"
for greeting_str in [
"Hello, World!",
"Bonjour, Monde!",
"Hola, Mundo!",
"Hallo, Welt!",
]:
greeting = greet.parse_string(greeting_str)
print(greeting)�h]�hX, import pyparsing as pp
greet = pp.Word(pp.alphas) + "," + pp.Word(pp.alphas) + "!"
for greeting_str in [
"Hello, World!",
"Bonjour, Monde!",
"Hola, Mundo!",
"Hallo, Welt!",
]:
greeting = greet.parse_string(greeting_str)
print(greeting)�����}�(hhhjc ubah"}�(h$]�h&]�h)]�h+]�h-]�� xml:space��preserve�uh/ja h!KQhj" hhh h=ubh_)��}�(h�6The parsed tokens are returned in the following form::�h]�h�5The parsed tokens are returned in the following form:�����}�(h�5The parsed tokens are returned in the following form:�hjs hhh Nh!Nubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!K]hj" hhubjb )��}�(h�s['Hello', ',', 'World', '!']
['Bonjour', ',', 'Monde', '!']
['Hola', ',', 'Mundo', '!']
['Hallo', ',', 'Welt', '!']�h]�h�s['Hello', ',', 'World', '!']
['Bonjour', ',', 'Monde', '!']
['Hola', ',', 'Mundo', '!']
['Hallo', ',', 'Welt', '!']�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�jq jr uh/ja h!K_hj" hhh h=ubeh"}�(h$]�j/ ah&]�h)]��
hello, world!�ah+]�h-]�uh/h hj9 hhh h=h!KLubh
)��}�(hhh]�(h)��}�(hjV h]�(h)��}�(hhh]�h�1.1.2 �����}�(hhhj� hhh Nh!Nubah"}�(h$]�h&]�h(ah)]�h+]�h-]�uh/hhj� hhh Nh!Nubh�Usage notes�����}�(hjV hj� hhh Nh!Nubeh"}�(h$]�h&]�h)]�h+]�h-]�h:Kh;jY uh/hhj� hhh h=h!Kfubj� )��}�(hhh]�(j� )��}�(hXw The pyparsing module can be used to interpret simple command
strings or algebraic expressions, or can be used to extract data
from text reports with complicated format and structure ("screen
or report scraping"). However, it is possible that your defined
matching patterns may accept invalid inputs. Use pyparsing to
extract data from strings assumed to be well-formatted.
�h]�h_)��}�(hXv The pyparsing module can be used to interpret simple command
strings or algebraic expressions, or can be used to extract data
from text reports with complicated format and structure ("screen
or report scraping"). However, it is possible that your defined
matching patterns may accept invalid inputs. Use pyparsing to
extract data from strings assumed to be well-formatted.�h]�hXz The pyparsing module can be used to interpret simple command
strings or algebraic expressions, or can be used to extract data
from text reports with complicated format and structure (“screen
or report scraping”). However, it is possible that your defined
matching patterns may accept invalid inputs. Use pyparsing to
extract data from strings assumed to be well-formatted.�����}�(hj� hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!Khhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� hhh h=h!Nubj� )��}�(hX� To keep up the readability of your code, use operators_ such as ``+``, ``|``,
``^``, and ``~`` to combine expressions. You can also combine
string literals with ``ParseExpressions`` - they will be
automatically converted to Literal_ objects. For example::
integer = Word(nums) # simple unsigned integer
variable = Char(alphas) # single letter variable, such as x, z, m, etc.
arith_op = one_of("+ - * /") # arithmetic operators
equation = variable + "=" + integer + arith_op + integer # will match "x=2+2", etc.
In the definition of ``equation``, the string ``"="`` will get added as
a ``Literal("=")``, but in a more readable way.
�h]�(h_)��}�(hX To keep up the readability of your code, use operators_ such as ``+``, ``|``,
``^``, and ``~`` to combine expressions. You can also combine
string literals with ``ParseExpressions`` - they will be
automatically converted to Literal_ objects. For example::�h]�(h�-To keep up the readability of your code, use �����}�(h�-To keep up the readability of your code, use �hj� ubh�)��}�(h�
operators_�h]�h� operators�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]��name�� operators�h;� operators�uh/h�hj� j� Kubh�
such as �����}�(h�
such as �hj� ubj� )��}�(h�``+``�h]�h�+�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�, �����}�(h�, �hj� ubj� )��}�(h�``|``�h]�h�|�����}�(hhhj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�,
�����}�(h�,
�hj� ubj� )��}�(h�``^``�h]�h�^�����}�(hhhj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�, and �����}�(h�, and �hj� ubj� )��}�(h�``~``�h]�h�~�����}�(hhhj+ ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�D to combine expressions. You can also combine
string literals with �����}�(h�D to combine expressions. You can also combine
string literals with �hj� ubj� )��}�(h�``ParseExpressions``�h]�h�ParseExpressions�����}�(hhhj> ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�+ - they will be
automatically converted to �����}�(h�+ - they will be
automatically converted to �hj� ubh�)��}�(h�Literal_�h]�h�Literal�����}�(hhhjQ ubah"}�(h$]�h&]�h)]�h+]�h-]��name��Literal�h;�literal�uh/h�hj� j� Kubh� objects. For example:�����}�(h� objects. For example:�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!Kohj� ubjb )��}�(hX integer = Word(nums) # simple unsigned integer
variable = Char(alphas) # single letter variable, such as x, z, m, etc.
arith_op = one_of("+ - * /") # arithmetic operators
equation = variable + "=" + integer + arith_op + integer # will match "x=2+2", etc.�h]�hX integer = Word(nums) # simple unsigned integer
variable = Char(alphas) # single letter variable, such as x, z, m, etc.
arith_op = one_of("+ - * /") # arithmetic operators
equation = variable + "=" + integer + arith_op + integer # will match "x=2+2", etc.�����}�(hhhjm ubah"}�(h$]�h&]�h)]�h+]�h-]�jq jr uh/ja h!Kthj� h h=ubh_)��}�(h�wIn the definition of ``equation``, the string ``"="`` will get added as
a ``Literal("=")``, but in a more readable way.�h]�(h�In the definition of �����}�(h�In the definition of �hj{ ubj� )��}�(h�``equation``�h]�h�equation�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj{ ubh�
, the string �����}�(h�
, the string �hj{ ubj� )��}�(h�``"="``�h]�h�"="�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj{ ubh� will get added as
a �����}�(h� will get added as
a �hj{ ubj� )��}�(h�``Literal("=")``�h]�h�Literal("=")�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj{ ubh�, but in a more readable way.�����}�(h�, but in a more readable way.�hj{ ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!Kyhj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� hhh h=h!Nubj� )��}�(hXO The pyparsing module's default behavior is to ignore whitespace. This is the
case for 99% of all parsers ever written. This allows you to write simple, clean,
grammars, such as the above ``equation``, without having to clutter it up with
extraneous ``ws`` markers. The ``equation`` grammar will successfully parse all of the
following statements::
x=2+2
x = 2+2
a = 10 * 4
r= 1234/ 100000
Of course, it is quite simple to extend this example to support more elaborate expressions, with
nesting with parentheses, floating point numbers, scientific notation, and named constants
(such as ``e`` or ``pi``). See `fourFn.py <https://github.com/pyparsing/pyparsing/blob/master/examples/fourFn.py>`_,
and `simpleArith.py <https://github.com/pyparsing/pyparsing/blob/master/examples/simpleArith.py>`_
included in the examples directory.
�h]�(h_)��}�(hX^ The pyparsing module's default behavior is to ignore whitespace. This is the
case for 99% of all parsers ever written. This allows you to write simple, clean,
grammars, such as the above ``equation``, without having to clutter it up with
extraneous ``ws`` markers. The ``equation`` grammar will successfully parse all of the
following statements::�h]�(h��The pyparsing module’s default behavior is to ignore whitespace. This is the
case for 99% of all parsers ever written. This allows you to write simple, clean,
grammars, such as the above �����}�(h��The pyparsing module's default behavior is to ignore whitespace. This is the
case for 99% of all parsers ever written. This allows you to write simple, clean,
grammars, such as the above �hj� ubj� )��}�(h�``equation``�h]�h�equation�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�2, without having to clutter it up with
extraneous �����}�(h�2, without having to clutter it up with
extraneous �hj� ubj� )��}�(h�``ws``�h]�h�ws�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh� markers. The �����}�(h� markers. The �hj� ubj� )��}�(h�``equation``�h]�h�equation�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�A grammar will successfully parse all of the
following statements:�����}�(h�A grammar will successfully parse all of the
following statements:�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!K|hj� ubjb )��}�(h�,x=2+2
x = 2+2
a = 10 * 4
r= 1234/ 100000�h]�h�,x=2+2
x = 2+2
a = 10 * 4
r= 1234/ 100000�����}�(hhhj
ubah"}�(h$]�h&]�h)]�h+]�h-]�jq jr uh/ja h!K�hj� h h=ubh_)��}�(hX� Of course, it is quite simple to extend this example to support more elaborate expressions, with
nesting with parentheses, floating point numbers, scientific notation, and named constants
(such as ``e`` or ``pi``). See `fourFn.py <https://github.com/pyparsing/pyparsing/blob/master/examples/fourFn.py>`_,
and `simpleArith.py <https://github.com/pyparsing/pyparsing/blob/master/examples/simpleArith.py>`_
included in the examples directory.�h]�(h��Of course, it is quite simple to extend this example to support more elaborate expressions, with
nesting with parentheses, floating point numbers, scientific notation, and named constants
(such as �����}�(h��Of course, it is quite simple to extend this example to support more elaborate expressions, with
nesting with parentheses, floating point numbers, scientific notation, and named constants
(such as �hj#
ubj� )��}�(h�``e``�h]�h�e�����}�(hhhj,
ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj#
ubh� or �����}�(h� or �hj#
ubj� )��}�(h�``pi``�h]�h�pi�����}�(hhhj?
ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj#
ubh�). See �����}�(h�). See �hj#
ubh�)��}�(h�T`fourFn.py <https://github.com/pyparsing/pyparsing/blob/master/examples/fourFn.py>`_�h]�h� fourFn.py�����}�(hhhjR
ubah"}�(h$]�h&]�h)]�h+]�h-]��name�� fourFn.py�j� �Ehttps://github.com/pyparsing/pyparsing/blob/master/examples/fourFn.py�uh/h�hj#
ubj� )��}�(h�H <https://github.com/pyparsing/pyparsing/blob/master/examples/fourFn.py>�h]�h"}�(h$]�� fourfn-py�ah&]�h)]�� fourfn.py�ah+]�h-]��refuri�jb
uh/j� j� Khj#
ubh�,
and �����}�(h�,
and �hj#
ubh�)��}�(h�^`simpleArith.py <https://github.com/pyparsing/pyparsing/blob/master/examples/simpleArith.py>`_�h]�h�simpleArith.py�����}�(hhhju
ubah"}�(h$]�h&]�h)]�h+]�h-]��name��simpleArith.py�j� �Jhttps://github.com/pyparsing/pyparsing/blob/master/examples/simpleArith.py�uh/h�hj#
ubj� )��}�(h�M <https://github.com/pyparsing/pyparsing/blob/master/examples/simpleArith.py>�h]�h"}�(h$]��simplearith-py�ah&]�h)]��simplearith.py�ah+]�h-]��refuri�j�
uh/j� j� Khj#
ubh�$
included in the examples directory.�����}�(h�$
included in the examples directory.�hj#
ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!K�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� hhh h=h!Nubj� )��}�(hX� To modify pyparsing's default whitespace skipping, you can use one or
more of the following methods:
- use the static method ``ParserElement.set_default_whitespace_chars``
to override the normal set of whitespace chars (``' \t\n'``). For instance
when defining a grammar in which newlines are significant, you should
call ``ParserElement.set_default_whitespace_chars(' \t')`` to remove
newline from the set of skippable whitespace characters. Calling
this method will affect all pyparsing expressions defined afterward.
- call ``leave_whitespace()`` on individual expressions, to suppress the
skipping of whitespace before trying to match the expression
- use ``Combine`` to require that successive expressions must be
adjacent in the input string. For instance, this expression::
real = Word(nums) + '.' + Word(nums)
will match "3.14159", but will also match "3 . 12". It will also
return the matched results as ['3', '.', '14159']. By changing this
expression to::
real = Combine(Word(nums) + '.' + Word(nums))
it will not match numbers with embedded spaces, and it will return a
single concatenated string '3.14159' as the parsed token.
�h]�(h_)��}�(h�dTo modify pyparsing's default whitespace skipping, you can use one or
more of the following methods:�h]�h�fTo modify pyparsing’s default whitespace skipping, you can use one or
more of the following methods:�����}�(hj�
hj�
ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!K�hj�
ubj� )��}�(hhh]�(j� )��}�(hX� use the static method ``ParserElement.set_default_whitespace_chars``
to override the normal set of whitespace chars (``' \t\n'``). For instance
when defining a grammar in which newlines are significant, you should
call ``ParserElement.set_default_whitespace_chars(' \t')`` to remove
newline from the set of skippable whitespace characters. Calling
this method will affect all pyparsing expressions defined afterward.
�h]�h_)��}�(hX� use the static method ``ParserElement.set_default_whitespace_chars``
to override the normal set of whitespace chars (``' \t\n'``). For instance
when defining a grammar in which newlines are significant, you should
call ``ParserElement.set_default_whitespace_chars(' \t')`` to remove
newline from the set of skippable whitespace characters. Calling
this method will affect all pyparsing expressions defined afterward.�h]�(h�use the static method �����}�(h�use the static method �hj�
ubj� )��}�(h�.``ParserElement.set_default_whitespace_chars``�h]�h�*ParserElement.set_default_whitespace_chars�����}�(hhhj�
ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj�
ubh�1
to override the normal set of whitespace chars (�����}�(h�1
to override the normal set of whitespace chars (�hj�
ubj� )��}�(h�``' \t\n'``�h]�h�' \t\n'�����}�(hhhj�
ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj�
ubh�\). For instance
when defining a grammar in which newlines are significant, you should
call �����}�(h�\). For instance
when defining a grammar in which newlines are significant, you should
call �hj�
ubj� )��}�(h�5``ParserElement.set_default_whitespace_chars(' \t')``�h]�h�1ParserElement.set_default_whitespace_chars(' \t')�����}�(hhhj�
ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj�
ubh�� to remove
newline from the set of skippable whitespace characters. Calling
this method will affect all pyparsing expressions defined afterward.�����}�(h�� to remove
newline from the set of skippable whitespace characters. Calling
this method will affect all pyparsing expressions defined afterward.�hj�
ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!K�hj�
ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj�
ubj� )��}�(h��call ``leave_whitespace()`` on individual expressions, to suppress the
skipping of whitespace before trying to match the expression
�h]�h_)��}�(h��call ``leave_whitespace()`` on individual expressions, to suppress the
skipping of whitespace before trying to match the expression�h]�(h�call �����}�(h�call �hj ubj� )��}�(h�``leave_whitespace()``�h]�h�leave_whitespace()�����}�(hhhj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj ubh�h on individual expressions, to suppress the
skipping of whitespace before trying to match the expression�����}�(h�h on individual expressions, to suppress the
skipping of whitespace before trying to match the expression�hj ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!K�hj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj�
ubj� )��}�(hX� use ``Combine`` to require that successive expressions must be
adjacent in the input string. For instance, this expression::
real = Word(nums) + '.' + Word(nums)
will match "3.14159", but will also match "3 . 12". It will also
return the matched results as ['3', '.', '14159']. By changing this
expression to::
real = Combine(Word(nums) + '.' + Word(nums))
it will not match numbers with embedded spaces, and it will return a
single concatenated string '3.14159' as the parsed token.
�h]�(h_)��}�(h�}use ``Combine`` to require that successive expressions must be
adjacent in the input string. For instance, this expression::�h]�(h�use �����}�(h�use �hj; ubj� )��}�(h�``Combine``�h]�h�Combine�����}�(hhhjD ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj; ubh�m to require that successive expressions must be
adjacent in the input string. For instance, this expression:�����}�(h�m to require that successive expressions must be
adjacent in the input string. For instance, this expression:�hj; ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!K�hj7 ubjb )��}�(h�$real = Word(nums) + '.' + Word(nums)�h]�h�$real = Word(nums) + '.' + Word(nums)�����}�(hhhj] ubah"}�(h$]�h&]�h)]�h+]�h-]�jq jr uh/ja h!K�hj7 h h=ubh_)��}�(h��will match "3.14159", but will also match "3 . 12". It will also
return the matched results as ['3', '.', '14159']. By changing this
expression to::�h]�h��will match “3.14159”, but will also match “3 . 12”. It will also
return the matched results as [‘3’, ‘.’, ‘14159’]. By changing this
expression to:�����}�(h��will match "3.14159", but will also match "3 . 12". It will also
return the matched results as ['3', '.', '14159']. By changing this
expression to:�hjk ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!K�hj7 ubjb )��}�(h�-real = Combine(Word(nums) + '.' + Word(nums))�h]�h�-real = Combine(Word(nums) + '.' + Word(nums))�����}�(hhhjz ubah"}�(h$]�h&]�h)]�h+]�h-]�jq jr uh/ja h!K�hj7 h h=ubh_)��}�(h�~it will not match numbers with embedded spaces, and it will return a
single concatenated string '3.14159' as the parsed token.�h]�h��it will not match numbers with embedded spaces, and it will return a
single concatenated string ‘3.14159’ as the parsed token.�����}�(hj� hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!K�hj7 ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj�
ubeh"}�(h$]�h&]�h)]�h+]�h-]��bullet��-�uh/j� h h=h!K�hj�
ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� hhh Nh!Nubj� )��}�(hXl Repetition of expressions can be indicated using ``*`` or ``[]`` notation. An
expression may be multiplied by an integer value (to indicate an exact
repetition count), or indexed with a tuple, representing min and max repetitions
(with ``...`` representing no min or no max, depending whether it is the first or
second tuple element). See the following examples, where n is used to
indicate an integer value:
- ``expr*3`` is equivalent to ``expr + expr + expr``
- ``expr[2, 3]`` is equivalent to ``expr + expr + Opt(expr)``
- ``expr[n, ...]`` or ``expr[n,]`` is equivalent
to ``expr*n + ZeroOrMore(expr)`` (read as "at least n instances of expr")
- ``expr[... ,n]`` is equivalent to ``expr*(0, n)``
(read as "0 to n instances of expr")
- ``expr[...]`` and ``expr[0, ...]`` are equivalent to ``ZeroOrMore(expr)``
- ``expr[1, ...]`` is equivalent to ``OneOrMore(expr)``
Note that ``expr[..., n]`` does not raise an exception if
more than n exprs exist in the input stream; that is,
``expr[..., n]`` does not enforce a maximum number of expr
occurrences. If this behavior is desired, then write
``expr[..., n] + ~expr``.
�h]�(h_)��}�(hX� Repetition of expressions can be indicated using ``*`` or ``[]`` notation. An
expression may be multiplied by an integer value (to indicate an exact
repetition count), or indexed with a tuple, representing min and max repetitions
(with ``...`` representing no min or no max, depending whether it is the first or
second tuple element). See the following examples, where n is used to
indicate an integer value:�h]�(h�1Repetition of expressions can be indicated using �����}�(h�1Repetition of expressions can be indicated using �hj� ubj� )��}�(h�``*``�h]�h�*�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh� or �����}�(h� or �hj� ubj� )��}�(h�``[]``�h]�h�[]�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�� notation. An
expression may be multiplied by an integer value (to indicate an exact
repetition count), or indexed with a tuple, representing min and max repetitions
(with �����}�(h�� notation. An
expression may be multiplied by an integer value (to indicate an exact
repetition count), or indexed with a tuple, representing min and max repetitions
(with �hj� ubj� )��}�(h�``...``�h]�h�...�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�� representing no min or no max, depending whether it is the first or
second tuple element). See the following examples, where n is used to
indicate an integer value:�����}�(h�� representing no min or no max, depending whether it is the first or
second tuple element). See the following examples, where n is used to
indicate an integer value:�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!K�hj� ubj� )��}�(hhh]�(j� )��}�(h�3``expr*3`` is equivalent to ``expr + expr + expr``
�h]�h_)��}�(h�2``expr*3`` is equivalent to ``expr + expr + expr``�h]�(j� )��}�(h�
``expr*3``�h]�h�expr*3�����}�(hhhj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh� is equivalent to �����}�(h� is equivalent to �hj� ubj� )��}�(h�``expr + expr + expr``�h]�h�expr + expr + expr�����}�(hhhj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!K�hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubj� )��}�(h�<``expr[2, 3]`` is equivalent to ``expr + expr + Opt(expr)``
�h]�h_)��}�(h�;``expr[2, 3]`` is equivalent to ``expr + expr + Opt(expr)``�h]�(j� )��}�(h�``expr[2, 3]``�h]�h�
expr[2, 3]�����}�(hhhj6 ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj2 ubh� is equivalent to �����}�(h� is equivalent to �hj2 ubj� )��}�(h�``expr + expr + Opt(expr)``�h]�h�expr + expr + Opt(expr)�����}�(hhhjI ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj2 ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!K�hj. ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubj� )��}�(h�y``expr[n, ...]`` or ``expr[n,]`` is equivalent
to ``expr*n + ZeroOrMore(expr)`` (read as "at least n instances of expr")
�h]�h_)��}�(h�x``expr[n, ...]`` or ``expr[n,]`` is equivalent
to ``expr*n + ZeroOrMore(expr)`` (read as "at least n instances of expr")�h]�(j� )��}�(h�``expr[n, ...]``�h]�h�expr[n, ...]�����}�(hhhjk ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hjg ubh� or �����}�(h� or �hjg ubj� )��}�(h�``expr[n,]``�h]�h�expr[n,]�����}�(hhhj~ ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hjg ubh� is equivalent
to �����}�(h� is equivalent
to �hjg ubj� )��}�(h�``expr*n + ZeroOrMore(expr)``�h]�h�expr*n + ZeroOrMore(expr)�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hjg ubh�- (read as “at least n instances of expr”)�����}�(h�) (read as "at least n instances of expr")�hjg ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!K�hjc ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubj� )��}�(h�W``expr[... ,n]`` is equivalent to ``expr*(0, n)``
(read as "0 to n instances of expr")
�h]�h_)��}�(h�V``expr[... ,n]`` is equivalent to ``expr*(0, n)``
(read as "0 to n instances of expr")�h]�(j� )��}�(h�``expr[... ,n]``�h]�h�expr[... ,n]�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh� is equivalent to �����}�(h� is equivalent to �hj� ubj� )��}�(h�``expr*(0, n)``�h]�h�expr*(0, n)�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�)
(read as “0 to n instances of expr”)�����}�(h�%
(read as "0 to n instances of expr")�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!K�hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubj� )��}�(h�J``expr[...]`` and ``expr[0, ...]`` are equivalent to ``ZeroOrMore(expr)``
�h]�h_)��}�(h�I``expr[...]`` and ``expr[0, ...]`` are equivalent to ``ZeroOrMore(expr)``�h]�(j� )��}�(h�
``expr[...]``�h]�h� expr[...]�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh� and �����}�(h� and �hj� ubj� )��}�(h�``expr[0, ...]``�h]�h�expr[0, ...]�����}�(hhhj
ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh� are equivalent to �����}�(h� are equivalent to �hj� ubj� )��}�(h�``ZeroOrMore(expr)``�h]�h�ZeroOrMore(expr)�����}�(hhhj
ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!K�hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubj� )��}�(h�6``expr[1, ...]`` is equivalent to ``OneOrMore(expr)``
�h]�h_)��}�(h�5``expr[1, ...]`` is equivalent to ``OneOrMore(expr)``�h]�(j� )��}�(h�``expr[1, ...]``�h]�h�expr[1, ...]�����}�(hhhj:
ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj6
ubh� is equivalent to �����}�(h� is equivalent to �hj6
ubj� )��}�(h�``OneOrMore(expr)``�h]�h�OneOrMore(expr)�����}�(hhhjM
ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj6
ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!K�hj2
ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�j� j� uh/j� h h=h!K�hj� ubh_)��}�(h��Note that ``expr[..., n]`` does not raise an exception if
more than n exprs exist in the input stream; that is,
``expr[..., n]`` does not enforce a maximum number of expr
occurrences. If this behavior is desired, then write
``expr[..., n] + ~expr``.�h]�(h�
Note that �����}�(h�
Note that �hjm
ubj� )��}�(h�``expr[..., n]``�h]�h�expr[..., n]�����}�(hhhjv
ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hjm
ubh�V does not raise an exception if
more than n exprs exist in the input stream; that is,
�����}�(h�V does not raise an exception if
more than n exprs exist in the input stream; that is,
�hjm
ubj� )��}�(h�``expr[..., n]``�h]�h�expr[..., n]�����}�(hhhj�
ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hjm
ubh�a does not enforce a maximum number of expr
occurrences. If this behavior is desired, then write
�����}�(h�a does not enforce a maximum number of expr
occurrences. If this behavior is desired, then write
�hjm
ubj� )��}�(h�``expr[..., n] + ~expr``�h]�h�expr[..., n] + ~expr�����}�(hhhj�
ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hjm
ubh�.�����}�(hj hjm
ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!K�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� hhh h=h!Nubj� )��}�(hX� MatchFirst_ expressions are matched left-to-right, and the first
match found will skip all later expressions within, so be sure
to define less-specific patterns after more-specific patterns.
If you are not sure which expressions are most specific, use Or_
expressions (defined using the ``^`` operator) - they will always
match the longest expression, although they are more
compute-intensive.
�h]�h_)��}�(hX� MatchFirst_ expressions are matched left-to-right, and the first
match found will skip all later expressions within, so be sure
to define less-specific patterns after more-specific patterns.
If you are not sure which expressions are most specific, use Or_
expressions (defined using the ``^`` operator) - they will always
match the longest expression, although they are more
compute-intensive.�h]�(h�)��}�(h�MatchFirst_�h]�h�
MatchFirst�����}�(hhhj�
ubah"}�(h$]�h&]�h)]�h+]�h-]��name��
MatchFirst�h;�
matchfirst�uh/h�hj�
j� Kubh�� expressions are matched left-to-right, and the first
match found will skip all later expressions within, so be sure
to define less-specific patterns after more-specific patterns.
If you are not sure which expressions are most specific, use �����}�(h�� expressions are matched left-to-right, and the first
match found will skip all later expressions within, so be sure
to define less-specific patterns after more-specific patterns.
If you are not sure which expressions are most specific, use �hj�
ubh�)��}�(h�Or_�h]�h�Or�����}�(hhhj�
ubah"}�(h$]�h&]�h)]�h+]�h-]��name��Or�h;�or�uh/h�hj�
j� Kubh�
expressions (defined using the �����}�(h�
expressions (defined using the �hj�
ubj� )��}�(h�``^``�h]�h�^�����}�(hhhj�
ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj�
ubh�e operator) - they will always
match the longest expression, although they are more
compute-intensive.�����}�(h�e operator) - they will always
match the longest expression, although they are more
compute-intensive.�hj�
ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!K�hj�
ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� hhh h=h!Nubj� )��}�(h��Or_ expressions will evaluate all of the specified subexpressions
to determine which is the "best" match, that is, which matches
the longest string in the input data. In case of a tie, the
left-most expression in the Or_ list will win.
�h]�h_)��}�(h��Or_ expressions will evaluate all of the specified subexpressions
to determine which is the "best" match, that is, which matches
the longest string in the input data. In case of a tie, the
left-most expression in the Or_ list will win.�h]�(h�)��}�(h�Or_�h]�h�Or�����}�(hhhj ubah"}�(h$]�h&]�h)]�h+]�h-]��name��Or�h;j�
uh/h�hj j� Kubh�� expressions will evaluate all of the specified subexpressions
to determine which is the “best” match, that is, which matches
the longest string in the input data. In case of a tie, the
left-most expression in the �����}�(h�� expressions will evaluate all of the specified subexpressions
to determine which is the "best" match, that is, which matches
the longest string in the input data. In case of a tie, the
left-most expression in the �hj ubh�)��}�(h�Or_�h]�h�Or�����}�(hhhj* ubah"}�(h$]�h&]�h)]�h+]�h-]��name��Or�h;j�
uh/h�hj j� Kubh� list will win.�����}�(h� list will win.�hj ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!K�hj
ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� hhh h=h!Nubj� )��}�(h�xIf parsing the contents of an entire file, pass it to the
``parse_file`` method using::
expr.parse_file(source_file)
�h]�(h_)��}�(h�WIf parsing the contents of an entire file, pass it to the
``parse_file`` method using::�h]�(h�:If parsing the contents of an entire file, pass it to the
�����}�(h�:If parsing the contents of an entire file, pass it to the
�hjO ubj� )��}�(h�``parse_file``�h]�h�
parse_file�����}�(hhhjX ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hjO ubh� method using:�����}�(h� method using:�hjO ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!K�hjK ubjb )��}�(h�expr.parse_file(source_file)�h]�h�expr.parse_file(source_file)�����}�(hhhjq ubah"}�(h$]�h&]�h)]�h+]�h-]�jq jr uh/ja h!K�hjK h h=ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� hhh h=h!Nubj� )��}�(hX� ``ParseExceptions`` will report the location where an expected token
or expression failed to match. For example, if we tried to use our
"Hello, World!" parser to parse "Hello World!" (leaving out the separating
comma), we would get an exception, with the message::
pyparsing.ParseException: Expected "," (6), (1,7)
In the case of complex
expressions, the reported location may not be exactly where you
would expect. See more information under ParseException_ .
�h]�(h_)��}�(hX ``ParseExceptions`` will report the location where an expected token
or expression failed to match. For example, if we tried to use our
"Hello, World!" parser to parse "Hello World!" (leaving out the separating
comma), we would get an exception, with the message::�h]�(j� )��}�(h�``ParseExceptions``�h]�h�ParseExceptions�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�� will report the location where an expected token
or expression failed to match. For example, if we tried to use our
“Hello, World!” parser to parse “Hello World!” (leaving out the separating
comma), we would get an exception, with the message:�����}�(h�� will report the location where an expected token
or expression failed to match. For example, if we tried to use our
"Hello, World!" parser to parse "Hello World!" (leaving out the separating
comma), we would get an exception, with the message:�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!K�hj� ubjb )��}�(h�1pyparsing.ParseException: Expected "," (6), (1,7)�h]�h�1pyparsing.ParseException: Expected "," (6), (1,7)�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�jq jr uh/ja h!K�hj� h h=ubh_)��}�(h��In the case of complex
expressions, the reported location may not be exactly where you
would expect. See more information under ParseException_ .�h]�(h��In the case of complex
expressions, the reported location may not be exactly where you
would expect. See more information under �����}�(h��In the case of complex
expressions, the reported location may not be exactly where you
would expect. See more information under �hj� ubh�)��}�(h�ParseException_�h]�h�ParseException�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]��name��ParseException�h;�parseexception�uh/h�hj� j� Kubh� .�����}�(h� .�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!K�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� hhh h=h!Nubj� )��}�(h��Use the ``Group`` class to enclose logical groups of tokens within a
sublist. This will help organize your results into more
hierarchical form (the default behavior is to return matching
tokens as a flat list of matching input strings).
�h]�h_)��}�(h��Use the ``Group`` class to enclose logical groups of tokens within a
sublist. This will help organize your results into more
hierarchical form (the default behavior is to return matching
tokens as a flat list of matching input strings).�h]�(h�Use the �����}�(h�Use the �hj� ubj� )��}�(h� ``Group``�h]�h�Group�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�� class to enclose logical groups of tokens within a
sublist. This will help organize your results into more
hierarchical form (the default behavior is to return matching
tokens as a flat list of matching input strings).�����}�(h�� class to enclose logical groups of tokens within a
sublist. This will help organize your results into more
hierarchical form (the default behavior is to return matching
tokens as a flat list of matching input strings).�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!K�hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� hhh h=h!Nubj� )��}�(hX� Punctuation may be significant for matching, but is rarely of
much interest in the parsed results. Use the ``suppress()`` method
to keep these tokens from cluttering up your returned lists of
tokens. For example, ``delimited_list()`` matches a succession of
one or more expressions, separated by delimiters (commas by
default), but only returns a list of the actual expressions -
the delimiters are used for parsing, but are suppressed from the
returned output.
�h]�h_)��}�(hX� Punctuation may be significant for matching, but is rarely of
much interest in the parsed results. Use the ``suppress()`` method
to keep these tokens from cluttering up your returned lists of
tokens. For example, ``delimited_list()`` matches a succession of
one or more expressions, separated by delimiters (commas by
default), but only returns a list of the actual expressions -
the delimiters are used for parsing, but are suppressed from the
returned output.�h]�(h�lPunctuation may be significant for matching, but is rarely of
much interest in the parsed results. Use the �����}�(h�lPunctuation may be significant for matching, but is rarely of
much interest in the parsed results. Use the �hj ubj� )��}�(h�``suppress()``�h]�h�
suppress()�����}�(hhhj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj ubh�] method
to keep these tokens from cluttering up your returned lists of
tokens. For example, �����}�(h�] method
to keep these tokens from cluttering up your returned lists of
tokens. For example, �hj ubj� )��}�(h�``delimited_list()``�h]�h�delimited_list()�����}�(hhhj+ ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj ubh�� matches a succession of
one or more expressions, separated by delimiters (commas by
default), but only returns a list of the actual expressions -
the delimiters are used for parsing, but are suppressed from the
returned output.�����}�(h�� matches a succession of
one or more expressions, separated by delimiters (commas by
default), but only returns a list of the actual expressions -
the delimiters are used for parsing, but are suppressed from the
returned output.�hj ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!K�hj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� hhh h=h!Nubj� )��}�(h�mParse actions can be used to convert values from strings to
other data types (ints, floats, booleans, etc.).
�h]�h_)��}�(h�lParse actions can be used to convert values from strings to
other data types (ints, floats, booleans, etc.).�h]�h�lParse actions can be used to convert values from strings to
other data types (ints, floats, booleans, etc.).�����}�(hjP hjN ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!K�hjJ ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� hhh h=h!Nubj� )��}�(hXh Results names are recommended for retrieving tokens from complex
expressions. It is much easier to access a token using its field
name than using a positional index, especially if the expression
contains optional elements. You can also shortcut
the ``set_results_name`` call::
stats = ("AVE:" + real_num.set_results_name("average")
+ "MIN:" + real_num.set_results_name("min")
+ "MAX:" + real_num.set_results_name("max"))
can more simply and cleanly be written as this::
stats = ("AVE:" + real_num("average")
+ "MIN:" + real_num("min")
+ "MAX:" + real_num("max"))
�h]�(h_)��}�(hX Results names are recommended for retrieving tokens from complex
expressions. It is much easier to access a token using its field
name than using a positional index, especially if the expression
contains optional elements. You can also shortcut
the ``set_results_name`` call::�h]�(h��Results names are recommended for retrieving tokens from complex
expressions. It is much easier to access a token using its field
name than using a positional index, especially if the expression
contains optional elements. You can also shortcut
the �����}�(h��Results names are recommended for retrieving tokens from complex
expressions. It is much easier to access a token using its field
name than using a positional index, especially if the expression
contains optional elements. You can also shortcut
the �hjf ubj� )��}�(h�``set_results_name``�h]�h�set_results_name�����}�(hhhjo ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hjf ubh� call:�����}�(h� call:�hjf ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!K�hjb ubjb )��}�(h��stats = ("AVE:" + real_num.set_results_name("average")
+ "MIN:" + real_num.set_results_name("min")
+ "MAX:" + real_num.set_results_name("max"))�h]�h��stats = ("AVE:" + real_num.set_results_name("average")
+ "MIN:" + real_num.set_results_name("min")
+ "MAX:" + real_num.set_results_name("max"))�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�jq jr uh/ja h!K�hjb h h=ubh_)��}�(h�0can more simply and cleanly be written as this::�h]�h�/can more simply and cleanly be written as this:�����}�(h�/can more simply and cleanly be written as this:�hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!K�hjb ubjb )��}�(h�nstats = ("AVE:" + real_num("average")
+ "MIN:" + real_num("min")
+ "MAX:" + real_num("max"))�h]�h�nstats = ("AVE:" + real_num("average")
+ "MIN:" + real_num("min")
+ "MAX:" + real_num("max"))�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�jq jr uh/ja h!K�hjb h h=ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� hhh h=h!Nubj� )��}�(hX Be careful when defining parse actions that modify global variables or
data structures (as in fourFn.py_), especially for low level tokens
or expressions that may occur within an And_ expression; an early element
of an And_ may match, but the overall expression may fail.
�h]�h_)��}�(hX Be careful when defining parse actions that modify global variables or
data structures (as in fourFn.py_), especially for low level tokens
or expressions that may occur within an And_ expression; an early element
of an And_ may match, but the overall expression may fail.�h]�(h�^Be careful when defining parse actions that modify global variables or
data structures (as in ������/ }�(h�^Be careful when defining parse actions that modify global variables or
data structures (as in �hj� ubh�)��}�(h�
fourFn.py_�h]�h� fourFn.py�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]��name�� fourFn.py�j� jb
uh/h�hj� j� Kubh�K), especially for low level tokens
or expressions that may occur within an �����}�(h�K), especially for low level tokens
or expressions that may occur within an �hj� ubh�)��}�(h�And_�h]�h�And�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]��name��And�h;�and�uh/h�hj� j� Kubh�$ expression; an early element
of an �����}�(h�$ expression; an early element
of an �hj� ubh�)��}�(h�And_�h]�h�And�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]��name��And�h;j� uh/h�hj� j� Kubh�0 may match, but the overall expression may fail.�����}�(h�0 may match, but the overall expression may fail.�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!Mhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� hhh h=h!Nubeh"}�(h$]�h&]�h)]�h+]�h-]�j� j� uh/j� h h=h!Khhj� hhubeh"}�(h$]�j_ ah&]�h)]��usage notes�ah+]�h-]�uh/h hj9 hhh h=h!Kfubeh"}�(h$]�j ah&]�h)]��steps to follow�ah+]�h-]�uh/h hhhhh h=h!K5ubh
)��}�(hhh]�(h)��}�(hj� h]�(h)��}�(hhh]�h� 1.2 �����}�(hhhj, hhh Nh!Nubah"}�(h$]�h&]�h(ah)]�h+]�h-]�uh/hhj) hhh Nh!Nubh�Classes�����}�(hj� hj) hhh Nh!Nubeh"}�(h$]�h&]�h)]�h+]�h-]�h:Kh;j� uh/hhj& hhh h=h!Mubh
)��}�(hhh]�(h)��}�(hj� h]�(h)��}�(hhh]�h�1.2.1 �����}�(hhhjI hhh Nh!Nubah"}�(h$]�h&]�h(ah)]�h+]�h-]�uh/hhjF hhh Nh!Nubh�Classes in the pyparsing module�����}�(hj� hjF hhh Nh!Nubeh"}�(h$]�h&]�h)]�h+]�h-]�h:Kh;j� uh/hhjC hhh h=h!Mubh_)��}�(h�_``ParserElement`` - abstract base class for all pyparsing classes;
methods for code to use are:�h]�(j� )��}�(h�``ParserElement``�h]�h�
ParserElement�����}�(hhhjd ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj` ubh�N - abstract base class for all pyparsing classes;
methods for code to use are:�����}�(h�N - abstract base class for all pyparsing classes;
methods for code to use are:�hj` hhh Nh!Nubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M
hjC hhubj� )��}�(hhh]�(j� )��}�(hX� ``parse_string(source_string, parse_all=False)`` - only called once, on the overall
matching pattern; returns a ParseResults_ object that makes the
matched tokens available as a list, and optionally as a dictionary,
or as an object with named attributes; if ``parse_all`` is set to True, then
``parse_string`` will raise a ParseException_ if the grammar does not process
the complete input string.
�h]�h_)��}�(hX� ``parse_string(source_string, parse_all=False)`` - only called once, on the overall
matching pattern; returns a ParseResults_ object that makes the
matched tokens available as a list, and optionally as a dictionary,
or as an object with named attributes; if ``parse_all`` is set to True, then
``parse_string`` will raise a ParseException_ if the grammar does not process
the complete input string.�h]�(j� )��}�(h�0``parse_string(source_string, parse_all=False)``�h]�h�,parse_string(source_string, parse_all=False)�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�@ - only called once, on the overall
matching pattern; returns a �����}�(h�@ - only called once, on the overall
matching pattern; returns a �hj� ubh�)��}�(h�
ParseResults_�h]�h�ParseResults�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]��name��ParseResults�h;j� uh/h�hj� j� Kubh�� object that makes the
matched tokens available as a list, and optionally as a dictionary,
or as an object with named attributes; if �����}�(h�� object that makes the
matched tokens available as a list, and optionally as a dictionary,
or as an object with named attributes; if �hj� ubj� )��}�(h�
``parse_all``�h]�h� parse_all�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh� is set to True, then
�����}�(h� is set to True, then
�hj� ubj� )��}�(h�``parse_string``�h]�h�parse_string�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh� will raise a �����}�(h� will raise a �hj� ubh�)��}�(h�ParseException_�h]�h�ParseException�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]��name��ParseException�h;j� uh/h�hj� j� Kubh�; if the grammar does not process
the complete input string.�����}�(h�; if the grammar does not process
the complete input string.�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!Mhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj} hhh h=h!Nubj� )��}�(h��``parse_file(source_file)`` - a convenience function, that accepts an
input file object or filename. The file contents are passed as a
string to ``parse_string()``. ``parse_file`` also supports the ``parse_all`` argument.
�h]�h_)��}�(h��``parse_file(source_file)`` - a convenience function, that accepts an
input file object or filename. The file contents are passed as a
string to ``parse_string()``. ``parse_file`` also supports the ``parse_all`` argument.�h]�(j� )��}�(h�``parse_file(source_file)``�h]�h�parse_file(source_file)�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�w - a convenience function, that accepts an
input file object or filename. The file contents are passed as a
string to �����}�(h�w - a convenience function, that accepts an
input file object or filename. The file contents are passed as a
string to �hj� ubj� )��}�(h�``parse_string()``�h]�h�parse_string()�����}�(hhhj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�. �����}�(h�. �hj� ubj� )��}�(h�``parse_file``�h]�h�
parse_file�����}�(hhhj% ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh� also supports the �����}�(h� also supports the �hj� ubj� )��}�(h�
``parse_all``�h]�h� parse_all�����}�(hhhj8 ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�
argument.�����}�(h�
argument.�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!Mhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj} hhh h=h!Nubj� )��}�(hX ``scan_string(source_string)`` - generator function, used to find and
extract matching text in the given source string; for each matched text,
returns a tuple of:
- matched tokens (packaged as a ParseResults_ object)
- start location of the matched text in the given source string
- end location in the given source string
``scan_string`` allows you to scan through the input source string for
random matches, instead of exhaustively defining the grammar for the entire
source text (as would be required with ``parse_string``).
�h]�(h_)��}�(h��``scan_string(source_string)`` - generator function, used to find and
extract matching text in the given source string; for each matched text,
returns a tuple of:�h]�(j� )��}�(h�``scan_string(source_string)``�h]�h�scan_string(source_string)�����}�(hhhj_ ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj[ ubh�� - generator function, used to find and
extract matching text in the given source string; for each matched text,
returns a tuple of:�����}�(h�� - generator function, used to find and
extract matching text in the given source string; for each matched text,
returns a tuple of:�hj[ ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!MhjW ubj� )��}�(hhh]�(j� )��}�(h�4matched tokens (packaged as a ParseResults_ object)
�h]�h_)��}�(h�3matched tokens (packaged as a ParseResults_ object)�h]�(h�matched tokens (packaged as a �����}�(h�matched tokens (packaged as a �hj ubh�)��}�(h�
ParseResults_�h]�h�ParseResults�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]��name��ParseResults�h;j� uh/h�hj j� Kubh� object)�����}�(h� object)�hj ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!Mhj{ ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hjx ubj� )��}�(h�>start location of the matched text in the given source string
�h]�h_)��}�(h�=start location of the matched text in the given source string�h]�h�=start location of the matched text in the given source string�����}�(hj� hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M!hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hjx ubj� )��}�(h�(end location in the given source string
�h]�h_)��}�(h�'end location in the given source string�h]�h�'end location in the given source string�����}�(hj� hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M#hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hjx ubeh"}�(h$]�h&]�h)]�h+]�h-]�j� j� uh/j� h h=h!MhjW ubh_)��}�(h��``scan_string`` allows you to scan through the input source string for
random matches, instead of exhaustively defining the grammar for the entire
source text (as would be required with ``parse_string``).�h]�(j� )��}�(h�``scan_string``�h]�h�scan_string�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�� allows you to scan through the input source string for
random matches, instead of exhaustively defining the grammar for the entire
source text (as would be required with �����}�(h�� allows you to scan through the input source string for
random matches, instead of exhaustively defining the grammar for the entire
source text (as would be required with �hj� ubj� )��}�(h�``parse_string``�h]�h�parse_string�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�).�����}�(h�).�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M%hjW ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj} hhh h=h!Nubj� )��}�(h��``transform_string(source_string)`` - convenience wrapper function for
``scan_string``, to process the input source string, and replace matching
text with the tokens returned from parse actions defined in the grammar
(see set_parse_action_).
�h]�h_)��}�(h��``transform_string(source_string)`` - convenience wrapper function for
``scan_string``, to process the input source string, and replace matching
text with the tokens returned from parse actions defined in the grammar
(see set_parse_action_).�h]�(j� )��}�(h�#``transform_string(source_string)``�h]�h�transform_string(source_string)�����}�(hhhj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj ubh�$ - convenience wrapper function for
�����}�(h�$ - convenience wrapper function for
�hj ubj� )��}�(h�``scan_string``�h]�h�scan_string�����}�(hhhj0 ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj ubh��, to process the input source string, and replace matching
text with the tokens returned from parse actions defined in the grammar
(see �����}�(h��, to process the input source string, and replace matching
text with the tokens returned from parse actions defined in the grammar
(see �hj ubh�)��}�(h�set_parse_action_�h]�h�set_parse_action�����}�(hhhjC ubah"}�(h$]�h&]�h)]�h+]�h-]��name��set_parse_action�h;�set-parse-action�uh/h�hj j� Kubh�).�����}�(h�).�hj ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M)hj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj} hhh h=h!Nubj� )��}�(h��``search_string(source_string)`` - another convenience wrapper function for
``scan_string``, returns a list of the matching tokens returned from each
call to ``scan_string``.
�h]�h_)��}�(h��``search_string(source_string)`` - another convenience wrapper function for
``scan_string``, returns a list of the matching tokens returned from each
call to ``scan_string``.�h]�(j� )��}�(h� ``search_string(source_string)``�h]�h�search_string(source_string)�����}�(hhhjm ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hji ubh�, - another convenience wrapper function for
�����}�(h�, - another convenience wrapper function for
�hji ubj� )��}�(h�``scan_string``�h]�h�scan_string�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hji ubh�C, returns a list of the matching tokens returned from each
call to �����}�(h�C, returns a list of the matching tokens returned from each
call to �hji ubj� )��}�(h�``scan_string``�h]�h�scan_string�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hji ubh�.�����}�(hj hji ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M.hje ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj} hhh h=h!Nubj� )��}�(h��``set_name(name)`` - associate a short descriptive name for this
element, useful in displaying exceptions and trace information
�h]�h_)��}�(h�``set_name(name)`` - associate a short descriptive name for this
element, useful in displaying exceptions and trace information�h]�(j� )��}�(h�``set_name(name)``�h]�h�set_name(name)�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�m - associate a short descriptive name for this
element, useful in displaying exceptions and trace information�����}�(h�m - associate a short descriptive name for this
element, useful in displaying exceptions and trace information�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M2hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj} hhh h=h!Nubj� )��}�(hX� ``run_tests(tests_string)`` - useful development and testing method on
expressions, to pass a multiline string of sample strings to test against
the expression. Comment lines (beginning with ``#``) can be inserted
and they will be included in the test output::
digits = Word(nums).set_name("numeric digits")
real_num = Combine(digits + '.' + digits)
real_num.run_tests("""\
# valid number
3.14159
# no integer part
.00001
# no decimal
101
# no decimal value
101.
""")
will print::
# valid number
3.14159
['3.14159']
# no integer part
.00001
^
FAIL: Expected numeric digits, found '.' (at char 0), (line:1, col:1)
# no decimal
101
^
FAIL: Expected ".", found end of text (at char 3), (line:1, col:4)
# no decimal value
101.
^
FAIL: Expected numeric digits, found end of text (at char 4), (line:1, col:5)
�h]�(h_)��}�(hX ``run_tests(tests_string)`` - useful development and testing method on
expressions, to pass a multiline string of sample strings to test against
the expression. Comment lines (beginning with ``#``) can be inserted
and they will be included in the test output::�h]�(j� )��}�(h�``run_tests(tests_string)``�h]�h�run_tests(tests_string)�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�� - useful development and testing method on
expressions, to pass a multiline string of sample strings to test against
the expression. Comment lines (beginning with �����}�(h�� - useful development and testing method on
expressions, to pass a multiline string of sample strings to test against
the expression. Comment lines (beginning with �hj� ubj� )��}�(h�``#``�h]�h�#�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�?) can be inserted
and they will be included in the test output:�����}�(h�?) can be inserted
and they will be included in the test output:�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M5hj� ubjb )��}�(h��digits = Word(nums).set_name("numeric digits")
real_num = Combine(digits + '.' + digits)
real_num.run_tests("""\
# valid number
3.14159
# no integer part
.00001
# no decimal
101
# no decimal value
101.
""")�h]�h��digits = Word(nums).set_name("numeric digits")
real_num = Combine(digits + '.' + digits)
real_num.run_tests("""\
# valid number
3.14159
# no integer part
.00001
# no decimal
101
# no decimal value
101.
""")�����}�(hhhj ubah"}�(h$]�h&]�h)]�h+]�h-]�jq jr uh/ja h!M:hj� h h=ubh_)��}�(h�will print::�h]�h�will print:�����}�(h�will print:�hj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!MJhj� ubjb )��}�(hXN # valid number
3.14159
['3.14159']
# no integer part
.00001
^
FAIL: Expected numeric digits, found '.' (at char 0), (line:1, col:1)
# no decimal
101
^
FAIL: Expected ".", found end of text (at char 3), (line:1, col:4)
# no decimal value
101.
^
FAIL: Expected numeric digits, found end of text (at char 4), (line:1, col:5)�h]�hXN # valid number
3.14159
['3.14159']
# no integer part
.00001
^
FAIL: Expected numeric digits, found '.' (at char 0), (line:1, col:1)
# no decimal
101
^
FAIL: Expected ".", found end of text (at char 3), (line:1, col:4)
# no decimal value
101.
^
FAIL: Expected numeric digits, found end of text (at char 4), (line:1, col:5)�����}�(hhhj) ubah"}�(h$]�h&]�h)]�h+]�h-]�jq jr uh/ja h!MLhj� h h=ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj} hhh h=h!Nubj� )��}�(hX� ``set_results_name(string, list_all_matches=False)`` - name to be given
to tokens matching
the element; if multiple tokens within
a repetition group (such as ``ZeroOrMore`` or ``delimited_list``) the
default is to return only the last matching token - if ``list_all_matches``
is set to True, then a list of all the matching tokens is returned.
``expr.set_results_name("key")`` can also be written ``expr("key")``
(a results name with a trailing '*' character will be
interpreted as setting ``list_all_matches`` to ``True``).
Note:
``set_results_name`` returns a *copy* of the element so that a single
basic element can be referenced multiple times and given
different names within a complex grammar.
�h]�(h_)��}�(hXW ``set_results_name(string, list_all_matches=False)`` - name to be given
to tokens matching
the element; if multiple tokens within
a repetition group (such as ``ZeroOrMore`` or ``delimited_list``) the
default is to return only the last matching token - if ``list_all_matches``
is set to True, then a list of all the matching tokens is returned.�h]�(j� )��}�(h�4``set_results_name(string, list_all_matches=False)``�h]�h�0set_results_name(string, list_all_matches=False)�����}�(hhhjE ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hjA ubh�j - name to be given
to tokens matching
the element; if multiple tokens within
a repetition group (such as �����}�(h�j - name to be given
to tokens matching
the element; if multiple tokens within
a repetition group (such as �hjA ubj� )��}�(h�``ZeroOrMore``�h]�h�
ZeroOrMore�����}�(hhhjX ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hjA ubh� or �����}�(h� or �hjA ubj� )��}�(h�``delimited_list``�h]�h�delimited_list�����}�(hhhjk ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hjA ubh�=) the
default is to return only the last matching token - if �����}�(h�=) the
default is to return only the last matching token - if �hjA ubj� )��}�(h�``list_all_matches``�h]�h�list_all_matches�����}�(hhhj~ ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hjA ubh�D
is set to True, then a list of all the matching tokens is returned.�����}�(h�D
is set to True, then a list of all the matching tokens is returned.�hjA ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M_hj= ubh_)��}�(h��``expr.set_results_name("key")`` can also be written ``expr("key")``
(a results name with a trailing '*' character will be
interpreted as setting ``list_all_matches`` to ``True``).�h]�(j� )��}�(h� ``expr.set_results_name("key")``�h]�h�expr.set_results_name("key")�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh� can also be written �����}�(h� can also be written �hj� ubj� )��}�(h�``expr("key")``�h]�h�expr("key")�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�R
(a results name with a trailing ‘*’ character will be
interpreted as setting �����}�(h�N
(a results name with a trailing '*' character will be
interpreted as setting �hj� ubj� )��}�(h�``list_all_matches``�h]�h�list_all_matches�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh� to �����}�(h� to �hj� ubj� )��}�(h�``True``�h]�h�True�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�).�����}�(h�).�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!Mfhj= ubh_)��}�(h��Note:
``set_results_name`` returns a *copy* of the element so that a single
basic element can be referenced multiple times and given
different names within a complex grammar.�h]�(h�Note:
�����}�(h�Note:
�hj� ubj� )��}�(h�``set_results_name``�h]�h�set_results_name�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh� returns a �����}�(h� returns a �hj� ubj )��}�(h�*copy*�h]�h�copy�����}�(hhhj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j hj� ubh�� of the element so that a single
basic element can be referenced multiple times and given
different names within a complex grammar.�����}�(h�� of the element so that a single
basic element can be referenced multiple times and given
different names within a complex grammar.�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!Mjhj= ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj} hhh h=h!Nubeh"}�(h$]�h&]�h)]�h+]�h-]�j� j� uh/j� h h=h!MhjC hhubj� )��}�(h�.. _set_parse_action:�h]�h"}�(h$]�h&]�h)]�h+]�h-]�h;jS uh/j� h!MohjC hhh h=j� Kubj� )��}�(hhh]�(j� )��}�(hX� ``set_parse_action(*fn)`` - specify one or more functions to call after successful
matching of the element; each function is defined as ``fn(s, loc, toks)``, where:
- ``s`` is the original parse string
- ``loc`` is the location in the string where matching started
- ``toks`` is the list of the matched tokens, packaged as a ParseResults_ object
Parse actions can have any of the following signatures::
fn(s: str, loc: int, tokens: ParseResults)
fn(loc: int, tokens: ParseResults)
fn(tokens: ParseResults)
fn()
Multiple functions can be attached to a ``ParserElement`` by specifying multiple
arguments to ``set_parse_action``, or by calling ``add_parse_action``. Calls to ``set_parse_action``
will replace any previously defined parse actions. ``set_parse_action(None)`` will clear
all previously defined parse actions.
Each parse action function can return a modified ``toks`` list, to perform conversion, or
string modifications. For brevity, ``fn`` may also be a
lambda - here is an example of using a parse action to convert matched
integer tokens from strings to integers::
int_number = Word(nums).set_parse_action(lambda s, l, t: [int(t[0])])
If ``fn`` modifies the ``toks`` list in-place, it does not need to return
and pyparsing will use the modified ``toks`` list.
If ``set_parse_action`` is called with an argument of ``None``, then this clears all parse actions
attached to that expression.
A nice short-cut for calling ``set_parse_action`` is to use it as a decorator::
identifier = Word(alphas, alphanums+"_")
@identifier.set_parse_action
def resolve_identifier(results: ParseResults):
return variable_values.get(results[0])
(Posted by @MisterMiyagi in this SO answer: https://stackoverflow.com/a/63031959/165216)
�h]�(h_)��}�(h��``set_parse_action(*fn)`` - specify one or more functions to call after successful
matching of the element; each function is defined as ``fn(s, loc, toks)``, where:�h]�(j� )��}�(h�``set_parse_action(*fn)``�h]�h�set_parse_action(*fn)�����}�(hhhjC ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj? ubh�o - specify one or more functions to call after successful
matching of the element; each function is defined as �����}�(h�o - specify one or more functions to call after successful
matching of the element; each function is defined as �hj? ubj� )��}�(h�``fn(s, loc, toks)``�h]�h�fn(s, loc, toks)�����}�(hhhjV ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj? ubh�, where:�����}�(h�, where:�hj? ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!Mqhj; ubj� )��}�(hhh]�(j� )��}�(h�#``s`` is the original parse string
�h]�h_)��}�(h�"``s`` is the original parse string�h]�(j� )��}�(h�``s``�h]�h�s�����}�(hhhjz ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hjv ubh� is the original parse string�����}�(h� is the original parse string�hjv ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!Mthjr ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hjo ubj� )��}�(h�=``loc`` is the location in the string where matching started
�h]�h_)��}�(h�<``loc`` is the location in the string where matching started�h]�(j� )��}�(h�``loc``�h]�h�loc�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�5 is the location in the string where matching started�����}�(h�5 is the location in the string where matching started�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!Mvhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hjo ubj� )��}�(h�O``toks`` is the list of the matched tokens, packaged as a ParseResults_ object
�h]�h_)��}�(h�N``toks`` is the list of the matched tokens, packaged as a ParseResults_ object�h]�(j� )��}�(h�``toks``�h]�h�toks�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�2 is the list of the matched tokens, packaged as a �����}�(h�2 is the list of the matched tokens, packaged as a �hj� ubh�)��}�(h�
ParseResults_�h]�h�ParseResults�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]��name��ParseResults�h;j� uh/h�hj� j� Kubh� object�����}�(h� object�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!Mxhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hjo ubeh"}�(h$]�h&]�h)]�h+]�h-]�j� j� uh/j� h h=h!Mthj; ubh_)��}�(h�8Parse actions can have any of the following signatures::�h]�h�7Parse actions can have any of the following signatures:�����}�(h�7Parse actions can have any of the following signatures:�hj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!Mzhj; ubjb )��}�(h�kfn(s: str, loc: int, tokens: ParseResults)
fn(loc: int, tokens: ParseResults)
fn(tokens: ParseResults)
fn()�h]�h�kfn(s: str, loc: int, tokens: ParseResults)
fn(loc: int, tokens: ParseResults)
fn(tokens: ParseResults)
fn()�����}�(hhhj ubah"}�(h$]�h&]�h)]�h+]�h-]�jq jr uh/ja h!M|hj; h h=ubh_)��}�(hX4 Multiple functions can be attached to a ``ParserElement`` by specifying multiple
arguments to ``set_parse_action``, or by calling ``add_parse_action``. Calls to ``set_parse_action``
will replace any previously defined parse actions. ``set_parse_action(None)`` will clear
all previously defined parse actions.�h]�(h�(Multiple functions can be attached to a �����}�(h�(Multiple functions can be attached to a �hj ubj� )��}�(h�``ParserElement``�h]�h�
ParserElement�����}�(hhhj( ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj ubh�% by specifying multiple
arguments to �����}�(h�% by specifying multiple
arguments to �hj ubj� )��}�(h�``set_parse_action``�h]�h�set_parse_action�����}�(hhhj; ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj ubh�, or by calling �����}�(h�, or by calling �hj ubj� )��}�(h�``add_parse_action``�h]�h�add_parse_action�����}�(hhhjN ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj ubh�. Calls to �����}�(h�. Calls to �hj ubj� )��}�(h�``set_parse_action``�h]�h�set_parse_action�����}�(hhhja ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj ubh�4
will replace any previously defined parse actions. �����}�(h�4
will replace any previously defined parse actions. �hj ubj� )��}�(h�``set_parse_action(None)``�h]�h�set_parse_action(None)�����}�(hhhjt ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj ubh�1 will clear
all previously defined parse actions.�����}�(h�1 will clear
all previously defined parse actions.�hj ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M�hj; ubh_)��}�(hX Each parse action function can return a modified ``toks`` list, to perform conversion, or
string modifications. For brevity, ``fn`` may also be a
lambda - here is an example of using a parse action to convert matched
integer tokens from strings to integers::�h]�(h�1Each parse action function can return a modified �����}�(h�1Each parse action function can return a modified �hj� ubj� )��}�(h�``toks``�h]�h�toks�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�E list, to perform conversion, or
string modifications. For brevity, �����}�(h�E list, to perform conversion, or
string modifications. For brevity, �hj� ubj� )��}�(h�``fn``�h]�h�fn�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�~ may also be a
lambda - here is an example of using a parse action to convert matched
integer tokens from strings to integers:�����}�(h�~ may also be a
lambda - here is an example of using a parse action to convert matched
integer tokens from strings to integers:�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M�hj; ubjb )��}�(h�Eint_number = Word(nums).set_parse_action(lambda s, l, t: [int(t[0])])�h]�h�Eint_number = Word(nums).set_parse_action(lambda s, l, t: [int(t[0])])�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�jq jr uh/ja h!M�hj; h h=ubh_)��}�(h�|If ``fn`` modifies the ``toks`` list in-place, it does not need to return
and pyparsing will use the modified ``toks`` list.�h]�(h�If �����}�(h�If �hj� ubj� )��}�(h�``fn``�h]�h�fn�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh� modifies the �����}�(h� modifies the �hj� ubj� )��}�(h�``toks``�h]�h�toks�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�O list in-place, it does not need to return
and pyparsing will use the modified �����}�(h�O list in-place, it does not need to return
and pyparsing will use the modified �hj� ubj� )��}�(h�``toks``�h]�h�toks�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh� list.�����}�(h� list.�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M�hj; ubh_)��}�(h�If ``set_parse_action`` is called with an argument of ``None``, then this clears all parse actions
attached to that expression.�h]�(h�If �����}�(h�If �hj ubj� )��}�(h�``set_parse_action``�h]�h�set_parse_action�����}�(hhhj! ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj ubh� is called with an argument of �����}�(h� is called with an argument of �hj ubj� )��}�(h�``None``�h]�h�None�����}�(hhhj4 ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj ubh�A, then this clears all parse actions
attached to that expression.�����}�(h�A, then this clears all parse actions
attached to that expression.�hj ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M�hj; ubh_)��}�(h�OA nice short-cut for calling ``set_parse_action`` is to use it as a decorator::�h]�(h�A nice short-cut for calling �����}�(h�A nice short-cut for calling �hjM ubj� )��}�(h�``set_parse_action``�h]�h�set_parse_action�����}�(hhhjV ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hjM ubh� is to use it as a decorator:�����}�(h� is to use it as a decorator:�hjM ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M�hj; ubjb )��}�(h��identifier = Word(alphas, alphanums+"_")
@identifier.set_parse_action
def resolve_identifier(results: ParseResults):
return variable_values.get(results[0])�h]�h��identifier = Word(alphas, alphanums+"_")
@identifier.set_parse_action
def resolve_identifier(results: ParseResults):
return variable_values.get(results[0])�����}�(hhhjo ubah"}�(h$]�h&]�h)]�h+]�h-]�jq jr uh/ja h!M�hj; h h=ubh_)��}�(h�X(Posted by @MisterMiyagi in this SO answer: https://stackoverflow.com/a/63031959/165216)�h]�(h�,(Posted by @MisterMiyagi in this SO answer: �����}�(h�,(Posted by @MisterMiyagi in this SO answer: �hj} ubh�)��}�(h�+https://stackoverflow.com/a/63031959/165216�h]�h�+https://stackoverflow.com/a/63031959/165216�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]��refuri�j� uh/h�hj} ubh�)�����}�(h�)�hj} ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M�hj; ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj8 hhh h=h!Nubj� )��}�(h��``add_parse_action`` - similar to ``set_parse_action``, but instead of replacing any
previously defined parse actions, will append the given action or actions to the
existing defined parse actions.
�h]�h_)��}�(h��``add_parse_action`` - similar to ``set_parse_action``, but instead of replacing any
previously defined parse actions, will append the given action or actions to the
existing defined parse actions.�h]�(j� )��}�(h�``add_parse_action``�h]�h�add_parse_action�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh� - similar to �����}�(h� - similar to �hj� ubj� )��}�(h�``set_parse_action``�h]�h�set_parse_action�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh��, but instead of replacing any
previously defined parse actions, will append the given action or actions to the
existing defined parse actions.�����}�(h��, but instead of replacing any
previously defined parse actions, will append the given action or actions to the
existing defined parse actions.�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M�hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj8 hhh h=h!Nubj� )��}�(hXA ``add_condition`` - a simplified form of ``add_parse_action`` if the purpose
of the parse action is to simply do some validation, and raise an exception
if the validation fails. Takes a method that takes the same arguments,
but simply returns ``True`` or ``False``. If ``False`` is returned, an exception will be
raised.
�h]�h_)��}�(hX@ ``add_condition`` - a simplified form of ``add_parse_action`` if the purpose
of the parse action is to simply do some validation, and raise an exception
if the validation fails. Takes a method that takes the same arguments,
but simply returns ``True`` or ``False``. If ``False`` is returned, an exception will be
raised.�h]�(j� )��}�(h�``add_condition``�h]�h�
add_condition�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh� - a simplified form of �����}�(h� - a simplified form of �hj� ubj� )��}�(h�``add_parse_action``�h]�h�add_parse_action�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�� if the purpose
of the parse action is to simply do some validation, and raise an exception
if the validation fails. Takes a method that takes the same arguments,
but simply returns �����}�(h�� if the purpose
of the parse action is to simply do some validation, and raise an exception
if the validation fails. Takes a method that takes the same arguments,
but simply returns �hj� ubj� )��}�(h�``True``�h]�h�True�����}�(hhhj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh� or �����}�(h� or �hj� ubj� )��}�(h� ``False``�h]�h�False�����}�(hhhj! ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�. If �����}�(h�. If �hj� ubj� )��}�(h� ``False``�h]�h�False�����}�(hhhj4 ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�* is returned, an exception will be
raised.�����}�(h�* is returned, an exception will be
raised.�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M�hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj8 hhh h=h!Nubj� )��}�(h��``set_break(break_flag=True)`` - if ``break_flag`` is ``True``, calls ``pdb.set_break()``
as this expression is about to be parsed
�h]�h_)��}�(h��``set_break(break_flag=True)`` - if ``break_flag`` is ``True``, calls ``pdb.set_break()``
as this expression is about to be parsed�h]�(j� )��}�(h�``set_break(break_flag=True)``�h]�h�set_break(break_flag=True)�����}�(hhhj[ ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hjW ubh� - if �����}�(h� - if �hjW ubj� )��}�(h�``break_flag``�h]�h�
break_flag�����}�(hhhjn ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hjW ubh� is �����}�(h� is �hjW ubj� )��}�(h�``True``�h]�h�True�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hjW ubh�, calls �����}�(h�, calls �hjW ubj� )��}�(h�``pdb.set_break()``�h]�h�pdb.set_break()�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hjW ubh�)
as this expression is about to be parsed�����}�(h�)
as this expression is about to be parsed�hjW ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M�hjS ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj8 hhh h=h!Nubj� )��}�(h��``copy()`` - returns a copy of a ``ParserElement``; can be used to use the same
parse expression in different places in a grammar, with different parse actions
attached to each; a short-form ``expr()`` is equivalent to ``expr.copy()``
�h]�h_)��}�(h��``copy()`` - returns a copy of a ``ParserElement``; can be used to use the same
parse expression in different places in a grammar, with different parse actions
attached to each; a short-form ``expr()`` is equivalent to ``expr.copy()``�h]�(j� )��}�(h�
``copy()``�h]�h�copy()�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh� - returns a copy of a �����}�(h� - returns a copy of a �hj� ubj� )��}�(h�``ParserElement``�h]�h�
ParserElement�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh��; can be used to use the same
parse expression in different places in a grammar, with different parse actions
attached to each; a short-form �����}�(h��; can be used to use the same
parse expression in different places in a grammar, with different parse actions
attached to each; a short-form �hj� ubj� )��}�(h�
``expr()``�h]�h�expr()�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh� is equivalent to �����}�(h� is equivalent to �hj� ubj� )��}�(h�``expr.copy()``�h]�h�expr.copy()�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M�hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj8 hhh h=h!Nubj� )��}�(h��``leave_whitespace()`` - change default behavior of skipping
whitespace before starting matching (mostly used internally to the
pyparsing module, rarely used by client code)
�h]�h_)��}�(h��``leave_whitespace()`` - change default behavior of skipping
whitespace before starting matching (mostly used internally to the
pyparsing module, rarely used by client code)�h]�(j� )��}�(h�``leave_whitespace()``�h]�h�leave_whitespace()�����}�(hhhj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj ubh�� - change default behavior of skipping
whitespace before starting matching (mostly used internally to the
pyparsing module, rarely used by client code)�����}�(h�� - change default behavior of skipping
whitespace before starting matching (mostly used internally to the
pyparsing module, rarely used by client code)�hj ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M�hj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj8 hhh h=h!Nubj� )��}�(h��``set_whitespace_chars(chars)`` - define the set of chars to be ignored
as whitespace before trying to match a specific ``ParserElement``, in place of the
default set of whitespace (space, tab, newline, and return)
�h]�h_)��}�(h��``set_whitespace_chars(chars)`` - define the set of chars to be ignored
as whitespace before trying to match a specific ``ParserElement``, in place of the
default set of whitespace (space, tab, newline, and return)�h]�(j� )��}�(h�``set_whitespace_chars(chars)``�h]�h�set_whitespace_chars(chars)�����}�(hhhj= ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj9 ubh�Y - define the set of chars to be ignored
as whitespace before trying to match a specific �����}�(h�Y - define the set of chars to be ignored
as whitespace before trying to match a specific �hj9 ubj� )��}�(h�``ParserElement``�h]�h�
ParserElement�����}�(hhhjP ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj9 ubh�M, in place of the
default set of whitespace (space, tab, newline, and return)�����}�(h�M, in place of the
default set of whitespace (space, tab, newline, and return)�hj9 ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M�hj5 ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj8 hhh h=h!Nubj� )��}�(hXp ``set_default_whitespace_chars(chars)`` - class-level method to override
the default set of whitespace chars for all subsequently created ParserElements
(including copies); useful when defining grammars that treat one or more of the
default whitespace characters as significant (such as a line-sensitive grammar, to
omit newline from the list of ignorable whitespace)
�h]�h_)��}�(hXo ``set_default_whitespace_chars(chars)`` - class-level method to override
the default set of whitespace chars for all subsequently created ParserElements
(including copies); useful when defining grammars that treat one or more of the
default whitespace characters as significant (such as a line-sensitive grammar, to
omit newline from the list of ignorable whitespace)�h]�(j� )��}�(h�'``set_default_whitespace_chars(chars)``�h]�h�#set_default_whitespace_chars(chars)�����}�(hhhjw ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hjs ubhXH - class-level method to override
the default set of whitespace chars for all subsequently created ParserElements
(including copies); useful when defining grammars that treat one or more of the
default whitespace characters as significant (such as a line-sensitive grammar, to
omit newline from the list of ignorable whitespace)�����}�(hXH - class-level method to override
the default set of whitespace chars for all subsequently created ParserElements
(including copies); useful when defining grammars that treat one or more of the
default whitespace characters as significant (such as a line-sensitive grammar, to
omit newline from the list of ignorable whitespace)�hjs ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M�hjo ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj8 hhh h=h!Nubj� )��}�(h��``suppress()`` - convenience function to suppress the output of the
given element, instead of wrapping it with a ``Suppress`` object.
�h]�h_)��}�(h��``suppress()`` - convenience function to suppress the output of the
given element, instead of wrapping it with a ``Suppress`` object.�h]�(j� )��}�(h�``suppress()``�h]�h�
suppress()�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�c - convenience function to suppress the output of the
given element, instead of wrapping it with a �����}�(h�c - convenience function to suppress the output of the
given element, instead of wrapping it with a �hj� ubj� )��}�(h�``Suppress``�h]�h�Suppress�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh� object.�����}�(h� object.�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M�hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj8 hhh h=h!Nubj� )��}�(h��``ignore(expr)`` - function to specify parse expression to be
ignored while matching defined patterns; can be called
repeatedly to specify multiple expressions; useful to specify
patterns of comment syntax, for example
�h]�h_)��}�(h��``ignore(expr)`` - function to specify parse expression to be
ignored while matching defined patterns; can be called
repeatedly to specify multiple expressions; useful to specify
patterns of comment syntax, for example�h]�(j� )��}�(h�``ignore(expr)``�h]�h�ignore(expr)�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�� - function to specify parse expression to be
ignored while matching defined patterns; can be called
repeatedly to specify multiple expressions; useful to specify
patterns of comment syntax, for example�����}�(h�� - function to specify parse expression to be
ignored while matching defined patterns; can be called
repeatedly to specify multiple expressions; useful to specify
patterns of comment syntax, for example�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M�hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj8 hhh h=h!Nubj� )��}�(h�m``set_debug(debug_flag=True)`` - function to enable/disable tracing output
when trying to match this element
�h]�h_)��}�(h�l``set_debug(debug_flag=True)`` - function to enable/disable tracing output
when trying to match this element�h]�(j� )��}�(h�``set_debug(debug_flag=True)``�h]�h�set_debug(debug_flag=True)�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�N - function to enable/disable tracing output
when trying to match this element�����}�(h�N - function to enable/disable tracing output
when trying to match this element�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M�hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj8 hhh h=h!Nubj� )��}�(h�n``validate()`` - function to verify that the defined grammar does not
contain infinitely recursive constructs
�h]�h_)��}�(h�m``validate()`` - function to verify that the defined grammar does not
contain infinitely recursive constructs�h]�(j� )��}�(h�``validate()``�h]�h�
validate()�����}�(hhhj& ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj" ubh�_ - function to verify that the defined grammar does not
contain infinitely recursive constructs�����}�(h�_ - function to verify that the defined grammar does not
contain infinitely recursive constructs�hj" ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M�hj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj8 hhh h=h!Nubeh"}�(h$]�jS ah&]�h)]��set_parse_action�ah+]�h-]�j� j� uh/j� h h=h!MqhjC hh�expect_referenced_by_name�}�jI j. s�expect_referenced_by_id�}�jS j. sj� Kubj� )��}�(h�.. _parse_with_tabs:�h]�h"}�(h$]�h&]�h)]�h+]�h-]�h;�parse-with-tabs�uh/j� h!M�hjC hhh h=j� Kubj� )��}�(hhh]�(j� )��}�(h��``parse_with_tabs()`` - function to override default behavior of converting
tabs to spaces before parsing the input string; rarely used, except when
specifying whitespace-significant grammars using the White_ class.
�h]�h_)��}�(h��``parse_with_tabs()`` - function to override default behavior of converting
tabs to spaces before parsing the input string; rarely used, except when
specifying whitespace-significant grammars using the White_ class.�h]�(j� )��}�(h�``parse_with_tabs()``�h]�h�parse_with_tabs()�����}�(hhhjf ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hjb ubh�� - function to override default behavior of converting
tabs to spaces before parsing the input string; rarely used, except when
specifying whitespace-significant grammars using the �����}�(h�� - function to override default behavior of converting
tabs to spaces before parsing the input string; rarely used, except when
specifying whitespace-significant grammars using the �hjb ubh�)��}�(h�White_�h]�h�White�����}�(hhhjy ubah"}�(h$]�h&]�h)]�h+]�h-]��name��White�h;�white�uh/h�hjb j� Kubh� class.�����}�(h� class.�hjb ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M�hj^ ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj[ hhh h=h!Nubj� )��}�(hX� ``enable_packrat()`` - a class-level static method to enable a memoizing
performance enhancement, known as "packrat parsing". packrat parsing is
disabled by default, since it may conflict with some user programs that use
parse actions. To activate the packrat feature, your
program must call the class method ``ParserElement.enable_packrat()``. For best
results, call ``enable_packrat()`` immediately after importing pyparsing.
�h]�h_)��}�(hX� ``enable_packrat()`` - a class-level static method to enable a memoizing
performance enhancement, known as "packrat parsing". packrat parsing is
disabled by default, since it may conflict with some user programs that use
parse actions. To activate the packrat feature, your
program must call the class method ``ParserElement.enable_packrat()``. For best
results, call ``enable_packrat()`` immediately after importing pyparsing.�h]�(j� )��}�(h�``enable_packrat()``�h]�h�enable_packrat()�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubhX' - a class-level static method to enable a memoizing
performance enhancement, known as “packrat parsing”. packrat parsing is
disabled by default, since it may conflict with some user programs that use
parse actions. To activate the packrat feature, your
program must call the class method �����}�(hX# - a class-level static method to enable a memoizing
performance enhancement, known as "packrat parsing". packrat parsing is
disabled by default, since it may conflict with some user programs that use
parse actions. To activate the packrat feature, your
program must call the class method �hj� ubj� )��}�(h�"``ParserElement.enable_packrat()``�h]�h�ParserElement.enable_packrat()�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�. For best
results, call �����}�(h�. For best
results, call �hj� ubj� )��}�(h�``enable_packrat()``�h]�h�enable_packrat()�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�' immediately after importing pyparsing.�����}�(h�' immediately after importing pyparsing.�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M�hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj[ hhh h=h!Nubj� )��}�(hXv ``enable_left_recursion()`` - a class-level static method to enable
pyparsing with left-recursive (LR) parsers. Similar to ``ParserElement.enable_packrat()``,
your program must call the class method ``ParserElement.enable_left_recursion()`` to
enable this feature. ``enable_left_recursion()`` uses a separate packrat cache, and so
is incompatible with ``enable_packrat()``.
�h]�h_)��}�(hXu ``enable_left_recursion()`` - a class-level static method to enable
pyparsing with left-recursive (LR) parsers. Similar to ``ParserElement.enable_packrat()``,
your program must call the class method ``ParserElement.enable_left_recursion()`` to
enable this feature. ``enable_left_recursion()`` uses a separate packrat cache, and so
is incompatible with ``enable_packrat()``.�h]�(j� )��}�(h�``enable_left_recursion()``�h]�h�enable_left_recursion()�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�` - a class-level static method to enable
pyparsing with left-recursive (LR) parsers. Similar to �����}�(h�` - a class-level static method to enable
pyparsing with left-recursive (LR) parsers. Similar to �hj� ubj� )��}�(h�"``ParserElement.enable_packrat()``�h]�h�ParserElement.enable_packrat()�����}�(hhhj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�*,
your program must call the class method �����}�(h�*,
your program must call the class method �hj� ubj� )��}�(h�)``ParserElement.enable_left_recursion()``�h]�h�%ParserElement.enable_left_recursion()�����}�(hhhj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh� to
enable this feature. �����}�(h� to
enable this feature. �hj� ubj� )��}�(h�``enable_left_recursion()``�h]�h�enable_left_recursion()�����}�(hhhj) ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�< uses a separate packrat cache, and so
is incompatible with �����}�(h�< uses a separate packrat cache, and so
is incompatible with �hj� ubj� )��}�(h�``enable_packrat()``�h]�h�enable_packrat()�����}�(hhhj< ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�.�����}�(hj hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M�hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj[ hhh h=h!Nubeh"}�(h$]�jZ ah&]�h)]��parse_with_tabs�ah+]�h-]�j� j� uh/j� h h=h!M�hjC hhjL }�j^ jP sjN }�jZ jP sj� Kubeh"}�(h$]�j� ah&]�h)]��classes in the pyparsing module�ah+]�h-]�uh/h hj& hhh h=h!Mubh
)��}�(hhh]�(h)��}�(hj� h]�(h)��}�(hhh]�h�1.2.2 �����}�(hhhjp hhh Nh!Nubah"}�(h$]�h&]�h(ah)]�h+]�h-]�uh/hhjm hhh Nh!Nubh�Basic ParserElement subclasses�����}�(hj� hjm hhh Nh!Nubeh"}�(h$]�h&]�h)]�h+]�h-]�h:Kh;j� uh/hhjj hhh h=h!M�ubj� )��}�(h�.. _Literal:�h]�h"}�(h$]�h&]�h)]�h+]�h-]�h;ja uh/j� h!M�hjj hhh h=j� Kubj� )��}�(hhh]�j� )��}�(h�<``Literal`` - construct with a string to be matched exactly
�h]�h_)��}�(h�;``Literal`` - construct with a string to be matched exactly�h]�(j� )��}�(h�``Literal``�h]�h�Literal�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�0 - construct with a string to be matched exactly�����}�(h�0 - construct with a string to be matched exactly�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M�hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� hhh h=h!Nubah"}�(h$]�ja ah&]�h)]��literal�ah+]�h-]�j� j� uh/j� h h=h!M�hjj hhjL }�j� j� sjN }�ja j� sj� Kubj� )��}�(h�.. _CaselessLiteral:�h]�h"}�(h$]�h&]�h)]�h+]�h-]�h;�caselessliteral�uh/j� h!M�hjj hhh h=j� Kubj� )��}�(hhh]�j� )��}�(h��``CaselessLiteral`` - construct with a string to be matched, but
without case checking; results are always returned as the
defining literal, NOT as they are found in the input string
�h]�h_)��}�(h��``CaselessLiteral`` - construct with a string to be matched, but
without case checking; results are always returned as the
defining literal, NOT as they are found in the input string�h]�(j� )��}�(h�``CaselessLiteral``�h]�h�CaselessLiteral�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�� - construct with a string to be matched, but
without case checking; results are always returned as the
defining literal, NOT as they are found in the input string�����}�(h�� - construct with a string to be matched, but
without case checking; results are always returned as the
defining literal, NOT as they are found in the input string�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M�hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� hhh h=h!Nubah"}�(h$]�j� ah&]�h)]��caselessliteral�ah+]�h-]�j� j� uh/j� h h=h!M�hjj hhjL }�j� j� sjN }�j� j� sj� Kubj� )��}�(h�.. _Keyword:�h]�h"}�(h$]�h&]�h)]�h+]�h-]�h;�keyword�uh/j� h!M�hjj hhh h=j� Kubj� )��}�(hhh]�(j� )��}�(h��``Keyword`` - similar to Literal_, but must be immediately followed by
whitespace, punctuation, or other non-keyword characters; prevents
accidental matching of a non-keyword that happens to begin with a
defined keyword
�h]�h_)��}�(h��``Keyword`` - similar to Literal_, but must be immediately followed by
whitespace, punctuation, or other non-keyword characters; prevents
accidental matching of a non-keyword that happens to begin with a
defined keyword�h]�(j� )��}�(h�``Keyword``�h]�h�Keyword�����}�(hhhj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj ubh� - similar to �����}�(h� - similar to �hj ubh�)��}�(h�Literal_�h]�h�Literal�����}�(hhhj+ ubah"}�(h$]�h&]�h)]�h+]�h-]��name��Literal�h;ja uh/h�hj j� Kubh��, but must be immediately followed by
whitespace, punctuation, or other non-keyword characters; prevents
accidental matching of a non-keyword that happens to begin with a
defined keyword�����}�(h��, but must be immediately followed by
whitespace, punctuation, or other non-keyword characters; prevents
accidental matching of a non-keyword that happens to begin with a
defined keyword�hj ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M�hj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj
hhh h=h!Nubj� )��}�(h�O``CaselessKeyword`` - similar to Keyword_, but with caseless matching
behavior
�h]�h_)��}�(h�N``CaselessKeyword`` - similar to Keyword_, but with caseless matching
behavior�h]�(j� )��}�(h�``CaselessKeyword``�h]�h�CaselessKeyword�����}�(hhhjT ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hjP ubh� - similar to �����}�(h� - similar to �hjP ubh�)��}�(h�Keyword_�h]�h�Keyword�����}�(hhhjg ubah"}�(h$]�h&]�h)]�h+]�h-]��name��Keyword�h;j uh/h�hjP j� Kubh�%, but with caseless matching
behavior�����}�(h�%, but with caseless matching
behavior�hjP ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M�hjL ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj
hhh h=h!Nubeh"}�(h$]�j ah&]�h)]��keyword�ah+]�h-]�j� j� uh/j� h h=h!M�hjj hhjL }�j� j sjN }�j j sj� Kubj� )��}�(h� .. _Word:�h]�h"}�(h$]�h&]�h)]�h+]�h-]�h;�word�uh/j� h!M�hjj hhh h=j� Kubj� )��}�(hhh]�(j� )��}�(hX� ``Word`` - one or more contiguous characters; construct with a
string containing the set of allowed initial characters, and an
optional second string of allowed body characters; for instance,
a common ``Word`` construct is to match a code identifier - in C, a
valid identifier must start with an alphabetic character or an
underscore ('_'), followed by a body that can also include numeric
digits. That is, ``a``, ``i``, ``MAX_LENGTH``, ``_a1``, ``b_109_``, and
``plan9FromOuterSpace``
are all valid identifiers; ``9b7z``, ``$a``, ``.section``, and ``0debug``
are not. To
define an identifier using a ``Word``, use either of the following::
Word(alphas+"_", alphanums+"_")
Word(srange("[a-zA-Z_]"), srange("[a-zA-Z0-9_]"))
Pyparsing also provides pre-defined strings ``identchars`` and
``identbodychars`` so that you can also write::
Word(identchars, identbodychars)
If only one
string given, it specifies that the same character set defined
for the initial character is used for the word body; for instance, to
define an identifier that can only be composed of capital letters and
underscores, use one of::
``Word("ABCDEFGHIJKLMNOPQRSTUVWXYZ_")``
``Word(srange("[A-Z_]"))``
A ``Word`` may
also be constructed with any of the following optional parameters:
- ``min`` - indicating a minimum length of matching characters
- ``max`` - indicating a maximum length of matching characters
- ``exact`` - indicating an exact length of matching characters
If ``exact`` is specified, it will override any values for ``min`` or ``max``.
Sometimes you want to define a word using all
characters in a range except for one or two of them; you can do this
with the new ``exclude_chars`` argument. This is helpful if you want to define
a word with all ``printables`` except for a single delimiter character, such
as '.'. Previously, you would have to create a custom string to pass to Word.
With this change, you can just create ``Word(printables, exclude_chars='.')``.
�h]�(h_)��}�(hX� ``Word`` - one or more contiguous characters; construct with a
string containing the set of allowed initial characters, and an
optional second string of allowed body characters; for instance,
a common ``Word`` construct is to match a code identifier - in C, a
valid identifier must start with an alphabetic character or an
underscore ('_'), followed by a body that can also include numeric
digits. That is, ``a``, ``i``, ``MAX_LENGTH``, ``_a1``, ``b_109_``, and
``plan9FromOuterSpace``
are all valid identifiers; ``9b7z``, ``$a``, ``.section``, and ``0debug``
are not. To
define an identifier using a ``Word``, use either of the following::�h]�(j� )��}�(h�``Word``�h]�h�Word�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�� - one or more contiguous characters; construct with a
string containing the set of allowed initial characters, and an
optional second string of allowed body characters; for instance,
a common �����}�(h�� - one or more contiguous characters; construct with a
string containing the set of allowed initial characters, and an
optional second string of allowed body characters; for instance,
a common �hj� ubj� )��}�(h�``Word``�h]�h�Word�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�� construct is to match a code identifier - in C, a
valid identifier must start with an alphabetic character or an
underscore (‘_’), followed by a body that can also include numeric
digits. That is, �����}�(h�� construct is to match a code identifier - in C, a
valid identifier must start with an alphabetic character or an
underscore ('_'), followed by a body that can also include numeric
digits. That is, �hj� ubj� )��}�(h�``a``�h]�h�a�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�, �����}�(h�, �hj� ubj� )��}�(h�``i``�h]�h�i�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�, �����}�(h�, �hj� ubj� )��}�(h�``MAX_LENGTH``�h]�h�
MAX_LENGTH�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�, �����}�(h�, �hj� ubj� )��}�(h�``_a1``�h]�h�_a1�����}�(hhhj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�, �����}�(h�, �hj� ubj� )��}�(h�
``b_109_``�h]�h�b_109_�����}�(hhhj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�, and
�����}�(h�, and
�hj� ubj� )��}�(h�``plan9FromOuterSpace``�h]�h�plan9FromOuterSpace�����}�(hhhj, ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�
are all valid identifiers; �����}�(h�
are all valid identifiers; �hj� ubj� )��}�(h�``9b7z``�h]�h�9b7z�����}�(hhhj? ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�, �����}�(h�, �hj� ubj� )��}�(h�``$a``�h]�h�$a�����}�(hhhjR ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�, �����}�(hj� hj� ubj� )��}�(h�``.section``�h]�h�.section�����}�(hhhjd ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�, and �����}�(h�, and �hj� ubj� )��}�(h�
``0debug``�h]�h�0debug�����}�(hhhjw ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�+
are not. To
define an identifier using a �����}�(h�+
are not. To
define an identifier using a �hj� ubj� )��}�(h�``Word``�h]�h�Word�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�, use either of the following:�����}�(h�, use either of the following:�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M�hj� ubjb )��}�(h�QWord(alphas+"_", alphanums+"_")
Word(srange("[a-zA-Z_]"), srange("[a-zA-Z0-9_]"))�h]�h�QWord(alphas+"_", alphanums+"_")
Word(srange("[a-zA-Z_]"), srange("[a-zA-Z0-9_]"))�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�jq jr uh/ja h!Mhj� h h=ubh_)��}�(h�nPyparsing also provides pre-defined strings ``identchars`` and
``identbodychars`` so that you can also write::�h]�(h�,Pyparsing also provides pre-defined strings �����}�(h�,Pyparsing also provides pre-defined strings �hj� ubj� )��}�(h�``identchars``�h]�h�
identchars�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh� and
�����}�(h� and
�hj� ubj� )��}�(h�``identbodychars``�h]�h�identbodychars�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh� so that you can also write:�����}�(h� so that you can also write:�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!Mhj� ubjb )��}�(h� Word(identchars, identbodychars)�h]�h� Word(identchars, identbodychars)�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�jq jr uh/ja h!Mhj� h h=ubh_)��}�(h��If only one
string given, it specifies that the same character set defined
for the initial character is used for the word body; for instance, to
define an identifier that can only be composed of capital letters and
underscores, use one of::�h]�h��If only one
string given, it specifies that the same character set defined
for the initial character is used for the word body; for instance, to
define an identifier that can only be composed of capital letters and
underscores, use one of:�����}�(h��If only one
string given, it specifies that the same character set defined
for the initial character is used for the word body; for instance, to
define an identifier that can only be composed of capital letters and
underscores, use one of:�hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M
hj� ubjb )��}�(h�B``Word("ABCDEFGHIJKLMNOPQRSTUVWXYZ_")``
``Word(srange("[A-Z_]"))``�h]�h�B``Word("ABCDEFGHIJKLMNOPQRSTUVWXYZ_")``
``Word(srange("[A-Z_]"))``�����}�(hhhj ubah"}�(h$]�h&]�h)]�h+]�h-]�jq jr uh/ja h!Mhj� h h=ubh_)��}�(h�QA ``Word`` may
also be constructed with any of the following optional parameters:�h]�(h�A �����}�(h�A �hj ubj� )��}�(h�``Word``�h]�h�Word�����}�(hhhj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj ubh�G may
also be constructed with any of the following optional parameters:�����}�(h�G may
also be constructed with any of the following optional parameters:�hj ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!Mhj� ubj� )��}�(hhh]�(j� )��}�(h�=``min`` - indicating a minimum length of matching characters
�h]�h_)��}�(h�<``min`` - indicating a minimum length of matching characters�h]�(j� )��}�(h�``min``�h]�h�min�����}�(hhhj> ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj: ubh�5 - indicating a minimum length of matching characters�����}�(h�5 - indicating a minimum length of matching characters�hj: ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!Mhj6 ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj3 ubj� )��}�(h�=``max`` - indicating a maximum length of matching characters
�h]�h_)��}�(h�<``max`` - indicating a maximum length of matching characters�h]�(j� )��}�(h�``max``�h]�h�max�����}�(hhhje ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hja ubh�5 - indicating a maximum length of matching characters�����}�(h�5 - indicating a maximum length of matching characters�hja ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!Mhj] ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj3 ubj� )��}�(h�>``exact`` - indicating an exact length of matching characters
�h]�h_)��}�(h�=``exact`` - indicating an exact length of matching characters�h]�(j� )��}�(h� ``exact``�h]�h�exact�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�4 - indicating an exact length of matching characters�����}�(h�4 - indicating an exact length of matching characters�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!Mhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj3 ubeh"}�(h$]�h&]�h)]�h+]�h-]�j� j� uh/j� h h=h!Mhj� ubh_)��}�(h�NIf ``exact`` is specified, it will override any values for ``min`` or ``max``.�h]�(h�If �����}�(h�If �hj� ubj� )��}�(h� ``exact``�h]�h�exact�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�/ is specified, it will override any values for �����}�(h�/ is specified, it will override any values for �hj� ubj� )��}�(h�``min``�h]�h�min�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh� or �����}�(h� or �hj� ubj� )��}�(h�``max``�h]�h�max�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�.�����}�(hj hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!Mhj� ubh_)��}�(hX� Sometimes you want to define a word using all
characters in a range except for one or two of them; you can do this
with the new ``exclude_chars`` argument. This is helpful if you want to define
a word with all ``printables`` except for a single delimiter character, such
as '.'. Previously, you would have to create a custom string to pass to Word.
With this change, you can just create ``Word(printables, exclude_chars='.')``.�� h]�(h��Sometimes you want to define a word using all
characters in a range except for one or two of them; you can do this
with the new �����}�(h��Sometimes you want to define a word using all
characters in a range except for one or two of them; you can do this
with the new �hj� ubj� )��}�(h�``exclude_chars``�h]�h�
exclude_chars�����}�(hhhj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�A argument. This is helpful if you want to define
a word with all �����}�(h�A argument. This is helpful if you want to define
a word with all �hj� ubj� )��}�(h�``printables``�h]�h�
printables�����}�(hhhj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�� except for a single delimiter character, such
as ‘.’. Previously, you would have to create a custom string to pass to Word.
With this change, you can just create �����}�(h�� except for a single delimiter character, such
as '.'. Previously, you would have to create a custom string to pass to Word.
With this change, you can just create �hj� ubj� )��}�(h�'``Word(printables, exclude_chars='.')``�h]�h�#Word(printables, exclude_chars='.')�����}�(hhhj' ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�.�����}�(hj hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!Mhj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� hhh h=h!Nubj� )��}�(h��``Char`` - a convenience form of ``Word`` that will match just a single character from
a string of matching characters::
single_digit = Char(nums)
�h]�(h_)��}�(h�x``Char`` - a convenience form of ``Word`` that will match just a single character from
a string of matching characters::�h]�(j� )��}�(h�``Char``�h]�h�Char�����}�(hhhjM ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hjI ubh� - a convenience form of �����}�(h� - a convenience form of �hjI ubj� )��}�(h�``Word``�h]�h�Word�����}�(hhhj` ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hjI ubh�N that will match just a single character from
a string of matching characters:�����}�(h�N that will match just a single character from
a string of matching characters:�hjI ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M%hjE ubjb )��}�(h�single_digit = Char(nums)�h]�h�single_digit = Char(nums)�����}�(hhhjy ubah"}�(h$]�h&]�h)]�h+]�h-]�jq jr uh/ja h!M(hjE h h=ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� hhh h=h!Nubj� )��}�(h��``CharsNotIn`` - similar to Word_, but matches characters not
in the given constructor string (accepts only one string for both
initial and body characters); also supports ``min``, ``max``, and ``exact``
optional parameters.
�h]�h_)��}�(h��``CharsNotIn`` - similar to Word_, but matches characters not
in the given constructor string (accepts only one string for both
initial and body characters); also supports ``min``, ``max``, and ``exact``
optional parameters.�h]�(j� )��}�(h�``CharsNotIn``�h]�h�
CharsNotIn�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh� - similar to �����}�(h� - similar to �hj� ubh�)��}�(h�Word_�h]�h�Word�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]��name��Word�h;j� uh/h�hj� j� Kubh��, but matches characters not
in the given constructor string (accepts only one string for both
initial and body characters); also supports �����}�(h��, but matches characters not
in the given constructor string (accepts only one string for both
initial and body characters); also supports �hj� ubj� )��}�(h�``min``�h]�h�min�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�, �����}�(h�, �hj� ubj� )��}�(h�``max``�h]�h�max�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�, and �����}�(h�, and �hj� ubj� )��}�(h� ``exact``�h]�h�exact�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�
optional parameters.�����}�(h�
optional parameters.�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M*hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� hhh h=h!Nubj� )��}�(hXB ``Regex`` - a powerful construct, that accepts a regular expression
to be matched at the current parse position; accepts an optional
``flags`` parameter, corresponding to the flags parameter in the ``re.compile``
method; if the expression includes named sub-fields, they will be
represented in the returned ParseResults_.
�h]�h_)��}�(hXA ``Regex`` - a powerful construct, that accepts a regular expression
to be matched at the current parse position; accepts an optional
``flags`` parameter, corresponding to the flags parameter in the ``re.compile``
method; if the expression includes named sub-fields, they will be
represented in the returned ParseResults_.�h]�(j� )��}�(h� ``Regex``�h]�h�Regex�����}�(hhhj
ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj ubh�| - a powerful construct, that accepts a regular expression
to be matched at the current parse position; accepts an optional
�����}�(h�| - a powerful construct, that accepts a regular expression
to be matched at the current parse position; accepts an optional
�hj ubj� )��}�(h� ``flags``�h]�h�flags�����}�(hhhj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj ubh�8 parameter, corresponding to the flags parameter in the �����}�(h�8 parameter, corresponding to the flags parameter in the �hj ubj� )��}�(h�``re.compile``�h]�h�
re.compile�����}�(hhhj0 ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj ubh�_
method; if the expression includes named sub-fields, they will be
represented in the returned �����}�(h�_
method; if the expression includes named sub-fields, they will be
represented in the returned �hj ubh�)��}�(h�
ParseResults_�h]�h�ParseResults�����}�(hhhjC ubah"}�(h$]�h&]�h)]�h+]�h-]��name��ParseResults�h;j� uh/h�hj j� Kubh�.�����}�(hj hj ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M/hj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� hhh h=h!Nubj� )��}�(hXj ``QuotedString`` - supports the definition of custom quoted string
formats, in addition to pyparsing's built-in ``dbl_quoted_string`` and
``sgl_quoted_string``. ``QuotedString`` allows you to specify the following
parameters:
- ``quote_char`` - string of one or more characters defining the quote delimiting string
- ``esc_char`` - character to escape quotes, typically backslash (default=None)
- ``esc_quote`` - special quote sequence to escape an embedded quote string (such as SQL's "" to escape an embedded ") (default=None)
- ``multiline`` - boolean indicating whether quotes can span multiple lines (default=False)
- ``unquote_results`` - boolean indicating whether the matched text should be unquoted (default=True)
- ``end_quote_char`` - string of one or more characters defining the end of the quote delimited string (default=None => same as ``quote_char``)
�h]�(h_)��}�(h��``QuotedString`` - supports the definition of custom quoted string
formats, in addition to pyparsing's built-in ``dbl_quoted_string`` and
``sgl_quoted_string``. ``QuotedString`` allows you to specify the following
parameters:�h]�(j� )��}�(h�``QuotedString``�h]�h�QuotedString�����}�(hhhjk ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hjg ubh�b - supports the definition of custom quoted string
formats, in addition to pyparsing’s built-in �����}�(h�` - supports the definition of custom quoted string
formats, in addition to pyparsing's built-in �hjg ubj� )��}�(h�``dbl_quoted_string``�h]�h�dbl_quoted_string�����}�(hhhj~ ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hjg ubh� and
�����}�(h� and
�hjg ubj� )��}�(h�``sgl_quoted_string``�h]�h�sgl_quoted_string�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hjg ubh�. �����}�(h�. �hjg ubj� )��}�(h�``QuotedString``�h]�h�QuotedString�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hjg ubh�0 allows you to specify the following
parameters:�����}�(h�0 allows you to specify the following
parameters:�hjg ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M5hjc ubj� )��}�(hhh]�(j� )��}�(h�W``quote_char`` - string of one or more characters defining the quote delimiting string
�h]�h_)��}�(h�V``quote_char`` - string of one or more characters defining the quote delimiting string�h]�(j� )��}�(h�``quote_char``�h]�h�
quote_char�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�H - string of one or more characters defining the quote delimiting string�����}�(h�H - string of one or more characters defining the quote delimiting string�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M:hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubj� )��}�(h�N``esc_char`` - character to escape quotes, typically backslash (default=None)
�h]�h_)��}�(h�M``esc_char`` - character to escape quotes, typically backslash (default=None)�h]�(j� )��}�(h�``esc_char``�h]�h�esc_char�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�A - character to escape quotes, typically backslash (default=None)�����}�(h�A - character to escape quotes, typically backslash (default=None)�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M<hj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubj� )��}�(h��``esc_quote`` - special quote sequence to escape an embedded quote string (such as SQL's "" to escape an embedded ") (default=None)
�h]�h_)��}�(h��``esc_quote`` - special quote sequence to escape an embedded quote string (such as SQL's "" to escape an embedded ") (default=None)�h]�(j� )��}�(h�
``esc_quote``�h]�h� esc_quote�����}�(hhhj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj ubh�~ - special quote sequence to escape an embedded quote string (such as SQL’s “” to escape an embedded “) (default=None)�����}�(h�v - special quote sequence to escape an embedded quote string (such as SQL's "" to escape an embedded ") (default=None)�hj ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M>hj ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubj� )��}�(h�Z``multiline`` - boolean indicating whether quotes can span multiple lines (default=False)
�h]�h_)��}�(h�Y``multiline`` - boolean indicating whether quotes can span multiple lines (default=False)�h]�(j� )��}�(h�
``multiline``�h]�h� multiline�����}�(hhhj= ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj9 ubh�L - boolean indicating whether quotes can span multiple lines (default=False)�����}�(h�L - boolean indicating whether quotes can span multiple lines (default=False)�hj9 ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!M@hj5 ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubj� )��}�(h�d``unquote_results`` - boolean indicating whether the matched text should be unquoted (default=True)
�h]�h_)��}�(h�c``unquote_results`` - boolean indicating whether the matched text should be unquoted (default=True)�h]�(j� )��}�(h�``unquote_results``�h]�h�unquote_results�����}�(hhhjd ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj` ubh�P - boolean indicating whether the matched text should be unquoted (default=True)�����}�(h�P - boolean indicating whether the matched text should be unquoted (default=True)�hj` ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!MBhj\ ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubj� )��}�(h��``end_quote_char`` - string of one or more characters defining the end of the quote delimited string (default=None => same as ``quote_char``)
�h]�h_)��}�(h��``end_quote_char`` - string of one or more characters defining the end of the quote delimited string (default=None => same as ``quote_char``)�h]�(j� )��}�(h�``end_quote_char``�h]�h�end_quote_char�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�l - string of one or more characters defining the end of the quote delimited string (default=None => same as �����}�(h�l - string of one or more characters defining the end of the quote delimited string (default=None => same as �hj� ubj� )��}�(h�``quote_char``�h]�h�
quote_char�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�)�����}�(hj� hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!MDhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�j� j� uh/j� h h=h!M:hjc ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� hhh Nh!Nubeh"}�(h$]�j� ah&]�h)]��word�ah+]�h-]�j� j� uh/j� h h=h!M�hjj hhjL }�j� j� sjN }�j� j� sj� Kubj� )��}�(h�.. _SkipTo:�h]�h"}�(h$]�h&]�h)]�h+]�h-]�h;�skipto�uh/j� h!MFhjj hhh h=j� Kubj� )��}�(hhh]�j� )��}�(hX� ``SkipTo`` - skips ahead in the input string, accepting any
characters up to the specified pattern; may be constructed with
the following optional parameters:
- ``include`` - if set to true, also consumes the match expression
(default is false)
- ``ignore`` - allows the user to specify patterns to not be matched,
to prevent false matches
- ``fail_on`` - if a literal string or expression is given for this argument, it defines an expression that
should cause the SkipTo_ expression to fail, and not skip over that expression
``SkipTo`` can also be written using ``...``::
LBRACE, RBRACE = map(Literal, "{}")
brace_expr = LBRACE + SkipTo(RBRACE) + RBRACE
# can also be written as
brace_expr = LBRACE + ... + RBRACE
�h]�(h_)��}�(h��``SkipTo`` - skips ahead in the input string, accepting any
characters up to the specified pattern; may be constructed with
the following optional parameters:�h]�(j� )��}�(h�
``SkipTo``�h]�h�SkipTo�����}�(hhhj� ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� ubh�� - skips ahead in the input string, accepting any
characters up to the specified pattern; may be constructed with
the following optional parameters:�����}�(h�� - skips ahead in the input string, accepting any
characters up to the specified pattern; may be constructed with
the following optional parameters:�hj� ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!MHhj� ubj� )��}�(hhh]�(j� )��}�(h�T``include`` - if set to true, also consumes the match expression
(default is false)
�h]�h_)��}�(h�S``include`` - if set to true, also consumes the match expression
(default is false)�h]�(j� )��}�(h�``include``�h]�h�include�����}�(hhhj! ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj! ubh�H - if set to true, also consumes the match expression
(default is false)�����}�(h�H - if set to true, also consumes the match expression
(default is false)�hj! ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!MLhj! ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj ! ubj� )��}�(h�]``ignore`` - allows the user to specify patterns to not be matched,
to prevent false matches
�h]�h_)��}�(h�\``ignore`` - allows the user to specify patterns to not be matched,
to prevent false matches�h]�(j� )��}�(h�
``ignore``�h]�h�ignore�����}�(hhhj2! ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj.! ubh�R - allows the user to specify patterns to not be matched,
to prevent false matches�����}�(h�R - allows the user to specify patterns to not be matched,
to prevent false matches�hj.! ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!MOhj*! ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj ! ubj� )��}�(h��``fail_on`` - if a literal string or expression is given for this argument, it defines an expression that
should cause the SkipTo_ expression to fail, and not skip over that expression
�h]�h_)��}�(h��``fail_on`` - if a literal string or expression is given for this argument, it defines an expression that
should cause the SkipTo_ expression to fail, and not skip over that expression�h]�(j� )��}�(h�``fail_on``�h]�h�fail_on�����}�(hhhjY! ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hjU! ubh�p - if a literal string or expression is given for this argument, it defines an expression that
should cause the �����}�(h�p - if a literal string or expression is given for this argument, it defines an expression that
should cause the �hjU! ubh�)��}�(h�SkipTo_�h]�h�SkipTo�����}�(hhhjl! ubah"}�(h$]�h&]�h)]�h+]�h-]��name��SkipTo�h;j� uh/h�hjU! j� Kubh�6 expression to fail, and not skip over that expression�����}�(h�6 expression to fail, and not skip over that expression�hjU! ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!MRhjQ! ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj ! ubeh"}�(h$]�h&]�h)]�h+]�h-]�j� j� uh/j� h h=h!MLhj� ubh_)��}�(h�.``SkipTo`` can also be written using ``...``::�h]�(j� )��}�(h�
``SkipTo``�h]�h�SkipTo�����}�(hhhj�! ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj�! ubh� can also be written using �����}�(h� can also be written using �hj�! ubj� )��}�(h�``...``�h]�h�...�����}�(hhhj�! ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj�! ubh�:�����}�(h�:�hj�! ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/h^h h=h!MUhj� ubjb )��}�(h��LBRACE, RBRACE = map(Literal, "{}")
brace_expr = LBRACE + SkipTo(RBRACE) + RBRACE
# can also be written as
brace_expr = LBRACE + ... + RBRACE�h]�h��LBRACE, RBRACE = map(Literal, "{}")
brace_expr = LBRACE + SkipTo(RBRACE) + RBRACE
# can also be written as
brace_expr = LBRACE + ... + RBRACE�����}�(hhhj�! ubah"}�(h$]�h&]�h)]�h+]�h-]�jq jr uh/ja h!MWhj� h h=ubeh"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj� hhh h=h!Nubah"}�(h$]�j� ah&]�h)]��skipto�ah+]�h-]�j� j� uh/j� h h=h!MHhjj hhjL }�j�! j� sjN }�j� j� sj� Kubj� )��}�(h�
.. _White:�h]�h"}�(h$]�h&]�h)]�h+]�h-]�h;j� uh/j� h!M]hjj hhh h=j� Kubj� )��}�(hhh]�(j� )��}�(hXu ``White`` - also similar to Word_, but matches whitespace
characters. Not usually needed, as whitespace is implicitly
ignored by pyparsing. However, some grammars are whitespace-sensitive,
such as those that use leading tabs or spaces to indicating grouping
or hierarchy. (If matching on tab characters, be sure to call
parse_with_tabs_ on the top-level parse element.)
�h]�h_)��}�(hXt ``White`` - also similar to Word_, but matches whitespace
characters. Not usually needed, as whitespace is implicitly
ignored by pyparsing. However, some grammars are whitespace-sensitive,
such as those that use leading tabs or spaces to indicating grouping
or hierarchy. (If matching on tab characters, be sure to call
parse_with_tabs_ on the top-level parse element.)�h]�(j� )��}�(h� ``White``�h]�h�White�����}�(hhhj�! ubah"}�(h$]�h&]�h)]�h+]�h-]�uh/j� hj�! ubh� - also similar to �����}�(h� - also similar to �hj�! ubh�)��}�(h�Word_�h]�h�Word�����}�(hhhj"