Fsphinx.addnodesdocument)}( rawsourcechildren]docutils.nodessection)}(hhh](h title)}(hUsing the pyparsing moduleh](h generated)}(hhh]h Text1   }(hhparenthhhsourceNlineNuba attributes}(ids]classes]sectnumanames]dupnames]backrefs]utagnamehh hhhh!Nh"NubhUsing the pyparsing module}(hhh hhhh!Nh"Nubeh#}(h%]h']h*]h,]h.]autoKrefidid1uh0hh h hhh!@/builddir/build/BUILD/pyparsing-3.0.9/docs/HowToUsePyparsing.rsth"Kubh field_list)}(hhh](h field)}(hhh](h field_name)}(hauthorh]hauthor}(hhMh hKubah#}(h%]h']h*]h,]h.]uh0hIh hFh!h>h"Kubh field_body)}(h Paul McGuireh]h paragraph)}(hh]h]h Paul McGuire}(hh]h haubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"Kh h[ubah#}(h%]h']h*]h,]h.]uh0hYh hFubeh#}(h%]h']h*]h,]h.]uh0hDh!h>h"Kh hAhhubhE)}(hhh](hJ)}(haddressh]haddress}(hhh h}ubah#}(h%]h']h*]h,]h.]uh0hIh hzh!h>h"KubhZ)}(hptmcg.pm+pyparsing@gmail.com h]h`)}(hptmcg.pm+pyparsing@gmail.comh]h reference)}(hhh]hptmcg.pm+pyparsing@gmail.com}(hhh hubah#}(h%]h']h*]h,]h.]refuri#mailto:ptmcg.pm+pyparsing@gmail.comuh0hh hubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"Kh hubah#}(h%]h']h*]h,]h.]uh0hYh hzubeh#}(h%]h']h*]h,]h.]uh0hDh!h>h"Kh hAhhubhE)}(hhh](hJ)}(hrevisionh]hrevision}(hhh hubah#}(h%]h']h*]h,]h.]uh0hIh hh!h>h"KubhZ)}(h3.0.0h]h`)}(hhh]h3.0.0}(hhh hubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"Kh hubah#}(h%]h']h*]h,]h.]uh0hYh hubeh#}(h%]h']h*]h,]h.]uh0hDh!h>h"Kh hAhhubhE)}(hhh](hJ)}(hdateh]hdate}(hhh hubah#}(h%]h']h*]h,]h.]uh0hIh hh!h>h"KubhZ)}(hOctober, 2021 h]h`)}(h October, 2021h]h October, 2021}(hhh hubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"K h hubah#}(h%]h']h*]h,]h.]uh0hYh hubeh#}(h%]h']h*]h,]h.]uh0hDh!h>h"K h hAhhubhE)}(hhh](hJ)}(h copyrighth]h copyright}(hjh jubah#}(h%]h']h*]h,]h.]uh0hIh jh!h>h"KubhZ)}(h)Copyright |copy| 2003-2022 Paul McGuire. h]h`)}(h(Copyright |copy| 2003-2022 Paul McGuire.h](h Copyright }(h Copyright h j(ubh©}(hhh j(ubh 2003-2022 Paul McGuire.}(h 2003-2022 Paul McGuire.h j(ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"K h j$ubah#}(h%]h']h*]h,]h.]uh0hYh jubeh#}(h%]h']h*]h,]h.]uh0hDh!h>h"K h hAhhubeh#}(h%]h']h*]h,]h.]uh0h?h h hhh!h>h"Kubh substitution_definition)}(h.. |copy| unicode:: 0xA9 h]h©}(hhh jTubah#}(h%]h']h*]copyah,]h.]uh0jRh!h>h"K h h hhubh@)}(hhh]hE)}(hhh](hJ)}(habstracth]habstract}(hjkh jiubah#}(h%]h']h*]h,]h.]uh0hIh jfh!h>h"KubhZ)}(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}h j{ubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"Kh jwubah#}(h%]h']h*]h,]h.]uh0hYh jfubeh#}(h%]h']h*]h,]h.]uh0hDh!h>h"Kh jchhubah#}(h%]h']h*]h,]h.]uh0h?h h hhh!h>h"Kubh topic)}(hhh](h)}(hContentsh]hContents}(hhh jubah#}(h%]h']h*]h,]h.]uh0hh jh!h>h"Kubh bullet_list)}(hhh]h list_item)}(hhh](h`)}(hhh]h)}(hhh](h)}(hhh]h1   }(hhh jubah#}(h%]h']h)ah*]h,]h.]uh0hh!Nh"Nh jubhUsing the pyparsing module}(hhh jubeh#}(h%]h=ah']h*]h,]h.]refidusing-the-pyparsing-moduleuh0hh jubah#}(h%]h']h*]h,]h.]uh0h_h jubj)}(hhh](j)}(hhh](h`)}(hhh]h)}(hhh](h)}(hhh]h 1.1   }(hhh jubah#}(h%]h']h)ah*]h,]h.]uh0hh!Nh"Nh jubhSteps to follow}(hSteps to followh jubeh#}(h%]id2ah']h*]h,]h.]refidsteps-to-followuh0hh jubah#}(h%]h']h*]h,]h.]uh0h_h jubj)}(hhh](j)}(hhh]h`)}(hhh]h)}(hhh](h)}(hhh]h 1.1.1   }(hhh jubah#}(h%]h']h)ah*]h,]h.]uh0hh!Nh"Nh jubh Hello, World!}(h Hello, World!h jubeh#}(h%]id3ah']h*]h,]h.]refid hello-worlduh0hh jubah#}(h%]h']h*]h,]h.]uh0h_h j ubah#}(h%]h']h*]h,]h.]uh0jh j ubj)}(hhh]h`)}(hhh]h)}(hhh](h)}(hhh]h 1.1.2   }(hhh jFubah#}(h%]h']h)ah*]h,]h.]uh0hh!Nh"Nh jCubh Usage notes}(h Usage notesh jCubeh#}(h%]id4ah']h*]h,]h.]refid usage-notesuh0hh j@ubah#}(h%]h']h*]h,]h.]uh0h_h j=ubah#}(h%]h']h*]h,]h.]uh0jh j ubeh#}(h%]h']auto-tocah*]h,]h.]uh0jh jubeh#}(h%]h']h*]h,]h.]uh0jh jubj)}(hhh](h`)}(hhh]h)}(hhh](h)}(hhh]h 1.2   }(hhh jubah#}(h%]h']h)ah*]h,]h.]uh0hh!Nh"Nh jubhClasses}(hClassesh jubeh#}(h%]id5ah']h*]h,]h.]refidclassesuh0hh j}ubah#}(h%]h']h*]h,]h.]uh0h_h jzubj)}(hhh](j)}(hhh]h`)}(hhh]h)}(hhh](h)}(hhh]h 1.2.1   }(hhh jubah#}(h%]h']h)ah*]h,]h.]uh0hh!Nh"Nh jubhClasses in the pyparsing module}(hClasses in the pyparsing moduleh jubeh#}(h%]id6ah']h*]h,]h.]refidclasses-in-the-pyparsing-moduleuh0hh jubah#}(h%]h']h*]h,]h.]uh0h_h jubah#}(h%]h']h*]h,]h.]uh0jh jubj)}(hhh]h`)}(hhh]h)}(hhh](h)}(hhh]h 1.2.2   }(hhh jubah#}(h%]h']h)ah*]h,]h.]uh0hh!Nh"Nh jubhBasic ParserElement subclasses}(hBasic ParserElement subclassesh jubeh#}(h%]id7ah']h*]h,]h.]refidbasic-parserelement-subclassesuh0hh jubah#}(h%]h']h*]h,]h.]uh0h_h jubah#}(h%]h']h*]h,]h.]uh0jh jubj)}(hhh]h`)}(hhh]h)}(hhh](h)}(hhh]h 1.2.3   }(hhh jubah#}(h%]h']h)ah*]h,]h.]uh0hh!Nh"Nh j ubhExpression subclasses}(hExpression subclassesh j ubeh#}(h%]id8ah']h*]h,]h.]refidexpression-subclassesuh0hh j ubah#}(h%]h']h*]h,]h.]uh0h_h jubah#}(h%]h']h*]h,]h.]uh0jh jubj)}(hhh]h`)}(hhh]h)}(hhh](h)}(hhh]h 1.2.4   }(hhh j@ubah#}(h%]h']h)ah*]h,]h.]uh0hh!Nh"Nh j=ubhExpression operators}(hExpression operatorsh j=ubeh#}(h%]id9ah']h*]h,]h.]refidexpression-operatorsuh0hh j:ubah#}(h%]h']h*]h,]h.]uh0h_h j7ubah#}(h%]h']h*]h,]h.]uh0jh jubj)}(hhh]h`)}(hhh]h)}(hhh](h)}(hhh]h 1.2.5   }(hhh jpubah#}(h%]h']h)ah*]h,]h.]uh0hh!Nh"Nh jmubhPositional subclasses}(hPositional subclassesh jmubeh#}(h%]id10ah']h*]h,]h.]refidpositional-subclassesuh0hh jjubah#}(h%]h']h*]h,]h.]uh0h_h jgubah#}(h%]h']h*]h,]h.]uh0jh jubj)}(hhh]h`)}(hhh]h)}(hhh](h)}(hhh]h 1.2.6   }(hhh jubah#}(h%]h']h)ah*]h,]h.]uh0hh!Nh"Nh jubhConverter subclasses}(hConverter subclassesh jubeh#}(h%]id11ah']h*]h,]h.]refidconverter-subclassesuh0hh jubah#}(h%]h']h*]h,]h.]uh0h_h jubah#}(h%]h']h*]h,]h.]uh0jh jubj)}(hhh]h`)}(hhh]h)}(hhh](h)}(hhh]h 1.2.7   }(hhh jubah#}(h%]h']h)ah*]h,]h.]uh0hh!Nh"Nh jubhSpecial subclasses}(hSpecial subclassesh jubeh#}(h%]id12ah']h*]h,]h.]refidspecial-subclassesuh0hh jubah#}(h%]h']h*]h,]h.]uh0h_h jubah#}(h%]h']h*]h,]h.]uh0jh jubj)}(hhh]h`)}(hhh]h)}(hhh](h)}(hhh]h 1.2.8   }(hhh jubah#}(h%]h']h)ah*]h,]h.]uh0hh!Nh"Nh jubh Other classes}(h Other classesh jubeh#}(h%]id13ah']h*]h,]h.]refid other-classesuh0hh jubah#}(h%]h']h*]h,]h.]uh0h_h jubah#}(h%]h']h*]h,]h.]uh0jh jubj)}(hhh]h`)}(hhh]h)}(hhh](h)}(hhh]h 1.2.9   }(hhh j0ubah#}(h%]h']h)ah*]h,]h.]uh0hh!Nh"Nh j-ubh%Exception classes and Troubleshooting}(h%Exception classes and Troubleshootingh j-ubeh#}(h%]id14ah']h*]h,]h.]refid%exception-classes-and-troubleshootinguh0hh j*ubah#}(h%]h']h*]h,]h.]uh0h_h j'ubah#}(h%]h']h*]h,]h.]uh0jh jubeh#}(h%]h']jpah*]h,]h.]uh0jh jzubeh#}(h%]h']h*]h,]h.]uh0jh jubj)}(hhh](h`)}(hhh]h)}(hhh](h)}(hhh]h 1.3   }(hhh jlubah#}(h%]h']h)ah*]h,]h.]uh0hh!Nh"Nh jiubh$Miscellaneous attributes and methods}(h$Miscellaneous attributes and methodsh jiubeh#}(h%]id15ah']h*]h,]h.]refid$miscellaneous-attributes-and-methodsuh0hh jfubah#}(h%]h']h*]h,]h.]uh0h_h jcubj)}(hhh](j)}(hhh]h`)}(hhh]h)}(hhh](h)}(hhh]h 1.3.1   }(hhh jubah#}(h%]h']h)ah*]h,]h.]uh0hh!Nh"Nh jubhHelper methods}(hHelper methodsh jubeh#}(h%]id16ah']h*]h,]h.]refidhelper-methodsuh0hh jubah#}(h%]h']h*]h,]h.]uh0h_h jubah#}(h%]h']h*]h,]h.]uh0jh jubj)}(hhh]h`)}(hhh]h)}(hhh](h)}(hhh]h 1.3.2   }(hhh jubah#}(h%]h']h)ah*]h,]h.]uh0hh!Nh"Nh jubhHelper parse actions}(hHelper parse actionsh jubeh#}(h%]id17ah']h*]h,]h.]refidhelper-parse-actionsuh0hh jubah#}(h%]h']h*]h,]h.]uh0h_h jubah#}(h%]h']h*]h,]h.]uh0jh jubj)}(hhh]h`)}(hhh]h)}(hhh](h)}(hhh]h 1.3.3   }(hhh jubah#}(h%]h']h)ah*]h,]h.]uh0hh!Nh"Nh jubh!Common string and token constants}(h!Common string and token constantsh jubeh#}(h%]id18ah']h*]h,]h.]refid!common-string-and-token-constantsuh0hh jubah#}(h%]h']h*]h,]h.]uh0h_h jubah#}(h%]h']h*]h,]h.]uh0jh jubj)}(hhh]h`)}(hhh]h)}(hhh](h)}(hhh]h 1.3.4   }(hhh j)ubah#}(h%]h']h)ah*]h,]h.]uh0hh!Nh"Nh j&ubh0Unicode character sets for international parsing}(h0Unicode character sets for international parsingh j&ubeh#}(h%]id19ah']h*]h,]h.]refid0unicode-character-sets-for-international-parsinguh0hh j#ubah#}(h%]h']h*]h,]h.]uh0h_h j ubah#}(h%]h']h*]h,]h.]uh0jh jubeh#}(h%]h']jpah*]h,]h.]uh0jh jcubeh#}(h%]h']h*]h,]h.]uh0jh jubj)}(hhh](h`)}(hhh]h)}(hhh](h)}(hhh]h 1.4   }(hhh jeubah#}(h%]h']h)ah*]h,]h.]uh0hh!Nh"Nh jbubhGenerating Railroad Diagrams}(hGenerating Railroad Diagramsh jbubeh#}(h%]id20ah']h*]h,]h.]refidgenerating-railroad-diagramsuh0hh j_ubah#}(h%]h']h*]h,]h.]uh0h_h j\ubj)}(hhh](j)}(hhh]h`)}(hhh]h)}(hhh](h)}(hhh]h 1.4.1   }(hhh jubah#}(h%]h']h)ah*]h,]h.]uh0hh!Nh"Nh jubhUsage}(hUsageh jubeh#}(h%]id21ah']h*]h,]h.]refidusageuh0hh jubah#}(h%]h']h*]h,]h.]uh0h_h jubah#}(h%]h']h*]h,]h.]uh0jh jubj)}(hhh]h`)}(hhh]h)}(hhh](h)}(hhh]h 1.4.2   }(hhh jubah#}(h%]h']h)ah*]h,]h.]uh0hh!Nh"Nh jubhExample}(hExampleh jubeh#}(h%]id22ah']h*]h,]h.]refidexampleuh0hh jubah#}(h%]h']h*]h,]h.]uh0h_h jubah#}(h%]h']h*]h,]h.]uh0jh jubj)}(hhh]h`)}(hhh]h)}(hhh](h)}(hhh]h 1.4.3   }(hhh jubah#}(h%]h']h)ah*]h,]h.]uh0hh!Nh"Nh jubh Naming tip}(h Naming tiph jubeh#}(h%]id23ah']h*]h,]h.]refid naming-tipuh0hh jubah#}(h%]h']h*]h,]h.]uh0h_h jubah#}(h%]h']h*]h,]h.]uh0jh jubj)}(hhh]h`)}(hhh]h)}(hhh](h)}(hhh]h 1.4.4   }(hhh j"ubah#}(h%]h']h)ah*]h,]h.]uh0hh!Nh"Nh jubh Customization}(h Customizationh jubeh#}(h%]id24ah']h*]h,]h.]refid customizationuh0hh jubah#}(h%]h']h*]h,]h.]uh0h_h jubah#}(h%]h']h*]h,]h.]uh0jh jubeh#}(h%]h']jpah*]h,]h.]uh0jh j\ubeh#}(h%]h']h*]h,]h.]uh0jh jubeh#}(h%]h']jpah*]h,]h.]uh0jh jubeh#}(h%]h']h*]h,]h.]uh0jh jubah#}(h%]h']jpah*]h,]h.]uh0jh jhhh!Nh"Nubeh#}(h%]contentsah']contentsah*]contentsah,]h.]uh0jh!h>h"Kh h hhubh`)}(hXNote: While this content is still valid, there are more detailed descriptions and extensive examples at the `online doc server `_, 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 `_ directory of the pyparsing GitHub repo.h](hlNote: While this content is still valid, there are more detailed descriptions and extensive examples at the }(hlNote: While this content is still valid, there are more detailed descriptions and extensive examples at the h jphhh!Nh"Nubh)}(hU`online doc server `_h]honline doc server}(honline doc serverh jyubah#}(h%]h']h*]h,]h.]nameonline doc serverrefuri>https://pyparsing-docs.readthedocs.io/en/latest/pyparsing.htmluh0hh jpubh target)}(hA h]h#}(h%]online-doc-serverah']h*]online doc serverah,]h.]refurijuh0j referencedKh jpubh{, and in the online help for the various pyparsing classes and methods (viewable using the Python interpreter’s built-in }(hy, and in the online help for the various pyparsing classes and methods (viewable using the Python interpreter's built-in h jphhh!Nh"Nubh literal)}(h ``help()``h]hhelp()}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jpubh; function). You will also find many example scripts in the }(h; function). You will also find many example scripts in the h jphhh!Nh"Nubh)}(hI`examples `_h]hexamples}(hexamplesh jubah#}(h%]h']h*]h,]h.]namejj;https://github.com/pyparsing/pyparsing/tree/master/examplesuh0hh jpubj)}(h> h]h#}(h%]examplesah']h*]examplesah,]h.]refurijuh0jjKh jpubh( directory of the pyparsing GitHub repo.}(h( directory of the pyparsing GitHub repo.h jphhh!Nh"Nubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Kh h hhubh transition)}(h -----------h]h#}(h%]h']h*]h,]h.]uh0jh!h>h"K"h h hhubh`)}(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]hNote}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh: }(h: h jhhh!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]hXIn 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.}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"K$h h hhubh`)}(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)}(hjh]hXCIf 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.}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"K+h h hhubj)}(h -----------h]h#}(h%]h']h*]h,]h.]uh0jh!h>h"K1h h hhubh )}(hhh](h)}(hjh](h)}(hhh]h 1.1   }(hhh jAhhh!Nh"Nubah#}(h%]h']h)ah*]h,]h.]uh0hh j>hhh!Nh"NubhSteps to follow}(hjh j>hhh!Nh"Nubeh#}(h%]h']h*]h,]h.]h;Khh"K5ubh`)}(hJTo parse an incoming data string, the client code must follow these steps:h]hJTo parse an incoming data string, the client code must follow these steps:}(hjZh jXhhh!Nh"Nubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"K7h j;hhubh enumerated_list)}(hhh](j)}(hFirst 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`)}(hFirst 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]hFirst 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.}(hjqh joubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"K9h jkubah#}(h%]h']h*]h,]h.]uh0jh jhhhh!h>h"Nubj)}(hXCall ``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`)}(hXCall ``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](hCall }(hCall h jubj)}(h``parse_string()``h]hparse_string()}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh or }(h or h jubj)}(h``scan_string()``h]h scan_string()}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh 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.h jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"K=h jubah#}(h%]h']h*]h,]h.]uh0jh jhhhh!h>h"Nubj)}(hX9Process 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`)}(hX7Process 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 h jubh)}(h ParseResults_h]h ParseResults}(h ParseResultsh jubah#}(h%]h']h*]h,]h.]namejh< parseresultsuh0hh jresolvedKubh object. The }(h object. The h jubh)}(h ParseResults_h]h ParseResults}(h ParseResultsh jubah#}(h%]h']h*]h,]h.]namejhh"KDh jubah#}(h%]h']h*]h,]h.]uh0jh jhhhh!h>h"Nubeh#}(h%]h']h*]h,]h.]enumtypearabicprefixhsuffixj uh0jfh j;hhh!h>h"K9ubh )}(hhh](h)}(hj'h](h)}(hhh]h 1.1.1   }(hhh j*hhh!Nh"Nubah#}(h%]h']h)ah*]h,]h.]uh0hh j'hhh!Nh"Nubh Hello, World!}(hj'h j'hhh!Nh"Nubeh#}(h%]h']h*]h,]h.]h;Khh"KLubh`)}(hThe following complete Python program will parse the greeting ``"Hello, World!"``, or any other greeting of the form ", !"::h](h>The following complete Python program will parse the greeting }(h>The following complete Python program will parse the greeting h jAhhh!Nh"Nubj)}(h``"Hello, World!"``h]h"Hello, World!"}(hhh jJubah#}(h%]h']h*]h,]h.]uh0jh jAubhE, or any other greeting of the form “, !”:}(hA, or any other greeting of the form ", !":h jAhhh!Nh"Nubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"KNh j$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)}(hhh jeubah#}(h%]h']h*]h,]h.] xml:spacepreserveuh0jch!h>h"KQh j$hhubh`)}(h6The parsed tokens are returned in the following form::h]h5The parsed tokens are returned in the following form:}(h5The parsed tokens are returned in the following form:h juhhh!Nh"Nubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"K]h j$hhubjd)}(hs['Hello', ',', 'World', '!'] ['Bonjour', ',', 'Monde', '!'] ['Hola', ',', 'Mundo', '!'] ['Hallo', ',', 'Welt', '!']h]hs['Hello', ',', 'World', '!'] ['Bonjour', ',', 'Monde', '!'] ['Hola', ',', 'Mundo', '!'] ['Hallo', ',', 'Welt', '!']}(hhh jubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"K_h j$hhubeh#}(h%]j0ah']h*] hello, world!ah,]h.]uh0h h j;hhh!h>h"KLubh )}(hhh](h)}(hjWh](h)}(hhh]h 1.1.2   }(hhh jhhh!Nh"Nubah#}(h%]h']h)ah*]h,]h.]uh0hh jhhh!Nh"Nubh Usage notes}(hjWh jhhh!Nh"Nubeh#}(h%]h']h*]h,]h.]h;Khh"Kfubj)}(hhh](j)}(hXwThe 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`)}(hXvThe 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]hXzThe 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.}(hjh jubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"Khh jubah#}(h%]h']h*]h,]h.]uh0jh jhhh!h>h"Nubj)}(hXTo 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`)}(hXTo 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 h jubh)}(h operators_h]h operators}(h operatorsh jubah#}(h%]h']h*]h,]h.]namejh< operatorsuh0hh jjKubh such as }(h such as h jubj)}(h``+``h]h+}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh, }(h, h jubj)}(h``|``h]h|}(hhh j ubah#}(h%]h']h*]h,]h.]uh0jh jubh, }(h, h jubj)}(h``^``h]h^}(hhh j ubah#}(h%]h']h*]h,]h.]uh0jh jubh, and }(h, and h jubj)}(h``~``h]h~}(hhh j- ubah#}(h%]h']h*]h,]h.]uh0jh jubhD to combine expressions. You can also combine string literals with }(hD to combine expressions. You can also combine string literals with h jubj)}(h``ParseExpressions``h]hParseExpressions}(hhh j@ ubah#}(h%]h']h*]h,]h.]uh0jh jubh+ - they will be automatically converted to }(h+ - they will be automatically converted to h jubh)}(hLiteral_h]hLiteral}(hLiteralh jS ubah#}(h%]h']h*]h,]h.]namej[ h<literaluh0hh jjKubh objects. For example:}(h objects. For example:h jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Koh jubjd)}(hXinteger = 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]hXinteger = 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.}(hhh jo ubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"Kth jubh`)}(hwIn the definition of ``equation``, the string ``"="`` will get added as a ``Literal("=")``, but in a more readable way.h](hIn the definition of }(hIn the definition of h j} ubj)}(h ``equation``h]hequation}(hhh j ubah#}(h%]h']h*]h,]h.]uh0jh j} ubh , the string }(h , the string h j} ubj)}(h``"="``h]h"="}(hhh j ubah#}(h%]h']h*]h,]h.]uh0jh j} ubh will get added as a }(h will get added as a h j} ubj)}(h``Literal("=")``h]h Literal("=")}(hhh j ubah#}(h%]h']h*]h,]h.]uh0jh j} ubh, but in a more readable way.}(h, but in a more readable way.h j} ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Kyh jubeh#}(h%]h']h*]h,]h.]uh0jh jhhh!h>h"Nubj)}(hXOThe 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 `_, and `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](hThe 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 }(hThe 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 j ubj)}(h ``equation``h]hequation}(hhh j ubah#}(h%]h']h*]h,]h.]uh0jh j ubh2, without having to clutter it up with extraneous }(h2, without having to clutter it up with extraneous h j ubj)}(h``ws``h]hws}(hhh j ubah#}(h%]h']h*]h,]h.]uh0jh j ubh markers. The }(h markers. The h j ubj)}(h ``equation``h]hequation}(hhh j ubah#}(h%]h']h*]h,]h.]uh0jh j ubhA grammar will successfully parse all of the following statements:}(hA grammar will successfully parse all of the following statements:h j ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"K|h j ubjd)}(h,x=2+2 x = 2+2 a = 10 * 4 r= 1234/ 100000h]h,x=2+2 x = 2+2 a = 10 * 4 r= 1234/ 100000}(hhh j ubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"Kh j ubh`)}(hXOf 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 `_, and `simpleArith.py `_ included in the examples directory.h](hOf 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 }(hOf 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 j% ubj)}(h``e``h]he}(hhh j. ubah#}(h%]h']h*]h,]h.]uh0jh j% ubh or }(h or h j% ubj)}(h``pi``h]hpi}(hhh jA ubah#}(h%]h']h*]h,]h.]uh0jh j% ubh). See }(h). See h j% ubh)}(hT`fourFn.py `_h]h fourFn.py}(h fourFn.pyh jT ubah#}(h%]h']h*]h,]h.]namej\ jEhttps://github.com/pyparsing/pyparsing/blob/master/examples/fourFn.pyuh0hh j% ubj)}(hH h]h#}(h%] fourfn-pyah']h*] fourfn.pyah,]h.]refurijd uh0jjKh j% ubh, and }(h, and h j% ubh)}(h^`simpleArith.py `_h]hsimpleArith.py}(hsimpleArith.pyh jw ubah#}(h%]h']h*]h,]h.]namej jJhttps://github.com/pyparsing/pyparsing/blob/master/examples/simpleArith.pyuh0hh j% ubj)}(hM h]h#}(h%]simplearith-pyah']h*]simplearith.pyah,]h.]refurij uh0jjKh j% ubh$ included in the examples directory.}(h$ included in the examples directory.h j% ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Kh j ubeh#}(h%]h']h*]h,]h.]uh0jh jhhh!h>h"Nubj)}(hXTo 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`)}(hdTo modify pyparsing's default whitespace skipping, you can use one or more of the following methods:h]hfTo modify pyparsing’s default whitespace skipping, you can use one or more of the following methods:}(hj h j ubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"Kh j ubj)}(hhh](j)}(hXuse 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`)}(hXuse 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](huse the static method }(huse the static method h j ubj)}(h.``ParserElement.set_default_whitespace_chars``h]h*ParserElement.set_default_whitespace_chars}(hhh j ubah#}(h%]h']h*]h,]h.]uh0jh j ubh1 to override the normal set of whitespace chars (}(h1 to override the normal set of whitespace chars (h j ubj)}(h ``' \t\n'``h]h' \t\n'}(hhh j ubah#}(h%]h']h*]h,]h.]uh0jh j 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 h j ubj)}(h5``ParserElement.set_default_whitespace_chars(' \t')``h]h1ParserElement.set_default_whitespace_chars(' \t')}(hhh j ubah#}(h%]h']h*]h,]h.]uh0jh j 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.h j ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Kh j ubah#}(h%]h']h*]h,]h.]uh0jh j ubj)}(hcall ``leave_whitespace()`` on individual expressions, to suppress the skipping of whitespace before trying to match the expression h]h`)}(hcall ``leave_whitespace()`` on individual expressions, to suppress the skipping of whitespace before trying to match the expressionh](hcall }(hcall h j ubj)}(h``leave_whitespace()``h]hleave_whitespace()}(hhh j ubah#}(h%]h']h*]h,]h.]uh0jh j ubhh on individual expressions, to suppress the skipping of whitespace before trying to match the expression}(hh on individual expressions, to suppress the skipping of whitespace before trying to match the expressionh j ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Kh j ubah#}(h%]h']h*]h,]h.]uh0jh j ubj)}(hXuse ``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](huse }(huse h j= ubj)}(h ``Combine``h]hCombine}(hhh jF ubah#}(h%]h']h*]h,]h.]uh0jh j= ubhm to require that successive expressions must be adjacent in the input string. For instance, this expression:}(hm to require that successive expressions must be adjacent in the input string. For instance, this expression:h j= ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Kh j9 ubjd)}(h$real = Word(nums) + '.' + Word(nums)h]h$real = Word(nums) + '.' + Word(nums)}(hhh j_ ubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"Kh j9 ubh`)}(hwill 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]hwill match “3.14159”, but will also match “3 . 12”. It will also return the matched results as [‘3’, ‘.’, ‘14159’]. By changing this expression to:}(hwill 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 jm ubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"Kh j9 ubjd)}(h-real = Combine(Word(nums) + '.' + Word(nums))h]h-real = Combine(Word(nums) + '.' + Word(nums))}(hhh j| ubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"Kh j9 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]hit will not match numbers with embedded spaces, and it will return a single concatenated string ‘3.14159’ as the parsed token.}(hj h j ubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"Kh j9 ubeh#}(h%]h']h*]h,]h.]uh0jh j ubeh#}(h%]h']h*]h,]h.]bullet-uh0jh!h>h"Kh j ubeh#}(h%]h']h*]h,]h.]uh0jh jhhh!Nh"Nubj)}(hXlRepetition 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`)}(hXRepetition 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](h1Repetition of expressions can be indicated using }(h1Repetition of expressions can be indicated using h j ubj)}(h``*``h]h*}(hhh j ubah#}(h%]h']h*]h,]h.]uh0jh j ubh or }(h or h j ubj)}(h``[]``h]h[]}(hhh j ubah#}(h%]h']h*]h,]h.]uh0jh j 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 h j ubj)}(h``...``h]h...}(hhh j ubah#}(h%]h']h*]h,]h.]uh0jh j 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:h j ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Kh j ubj)}(hhh](j)}(h3``expr*3`` is equivalent to ``expr + expr + expr`` h]h`)}(h2``expr*3`` is equivalent to ``expr + expr + expr``h](j)}(h ``expr*3``h]hexpr*3}(hhh j ubah#}(h%]h']h*]h,]h.]uh0jh j ubh is equivalent to }(h is equivalent to h j ubj)}(h``expr + expr + expr``h]hexpr + expr + expr}(hhh j ubah#}(h%]h']h*]h,]h.]uh0jh j ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Kh j ubah#}(h%]h']h*]h,]h.]uh0jh j 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]}(hhh j8 ubah#}(h%]h']h*]h,]h.]uh0jh j4 ubh is equivalent to }(h is equivalent to h j4 ubj)}(h``expr + expr + Opt(expr)``h]hexpr + expr + Opt(expr)}(hhh jK ubah#}(h%]h']h*]h,]h.]uh0jh j4 ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Kh j0 ubah#}(h%]h']h*]h,]h.]uh0jh j ubj)}(hy``expr[n, ...]`` or ``expr[n,]`` is equivalent to ``expr*n + ZeroOrMore(expr)`` (read as "at least n instances of expr") h]h`)}(hx``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, ...]}(hhh jm ubah#}(h%]h']h*]h,]h.]uh0jh ji ubh or }(h or h ji ubj)}(h ``expr[n,]``h]hexpr[n,]}(hhh j ubah#}(h%]h']h*]h,]h.]uh0jh ji ubh is equivalent to }(h is equivalent to h ji ubj)}(h``expr*n + ZeroOrMore(expr)``h]hexpr*n + ZeroOrMore(expr)}(hhh j ubah#}(h%]h']h*]h,]h.]uh0jh ji ubh- (read as “at least n instances of expr”)}(h) (read as "at least n instances of expr")h ji ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Kh je ubah#}(h%]h']h*]h,]h.]uh0jh j ubj)}(hW``expr[... ,n]`` is equivalent to ``expr*(0, n)`` (read as "0 to n instances of expr") h]h`)}(hV``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]}(hhh j ubah#}(h%]h']h*]h,]h.]uh0jh j ubh is equivalent to }(h is equivalent to h j ubj)}(h``expr*(0, n)``h]h expr*(0, n)}(hhh j ubah#}(h%]h']h*]h,]h.]uh0jh j ubh) (read as “0 to n instances of expr”)}(h% (read as "0 to n instances of expr")h j ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Kh j ubah#}(h%]h']h*]h,]h.]uh0jh j ubj)}(hJ``expr[...]`` and ``expr[0, ...]`` are equivalent to ``ZeroOrMore(expr)`` h]h`)}(hI``expr[...]`` and ``expr[0, ...]`` are equivalent to ``ZeroOrMore(expr)``h](j)}(h ``expr[...]``h]h expr[...]}(hhh j ubah#}(h%]h']h*]h,]h.]uh0jh j ubh and }(h and h j ubj)}(h``expr[0, ...]``h]h expr[0, ...]}(hhh j ubah#}(h%]h']h*]h,]h.]uh0jh j ubh are equivalent to }(h are equivalent to h j ubj)}(h``ZeroOrMore(expr)``h]hZeroOrMore(expr)}(hhh j ubah#}(h%]h']h*]h,]h.]uh0jh j ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Kh j ubah#}(h%]h']h*]h,]h.]uh0jh j ubj)}(h6``expr[1, ...]`` is equivalent to ``OneOrMore(expr)`` h]h`)}(h5``expr[1, ...]`` is equivalent to ``OneOrMore(expr)``h](j)}(h``expr[1, ...]``h]h expr[1, ...]}(hhh j< ubah#}(h%]h']h*]h,]h.]uh0jh j8 ubh is equivalent to }(h is equivalent to h j8 ubj)}(h``OneOrMore(expr)``h]hOneOrMore(expr)}(hhh jO ubah#}(h%]h']h*]h,]h.]uh0jh j8 ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Kh j4 ubah#}(h%]h']h*]h,]h.]uh0jh j ubeh#}(h%]h']h*]h,]h.]j j uh0jh!h>h"Kh j ubh`)}(hNote 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 h jo ubj)}(h``expr[..., n]``h]h expr[..., n]}(hhh jx ubah#}(h%]h']h*]h,]h.]uh0jh jo ubhV does not raise an exception if more than n exprs exist in the input stream; that is, }(hV does not raise an exception if more than n exprs exist in the input stream; that is, h jo ubj)}(h``expr[..., n]``h]h expr[..., n]}(hhh j ubah#}(h%]h']h*]h,]h.]uh0jh jo ubha does not enforce a maximum number of expr occurrences. If this behavior is desired, then write }(ha does not enforce a maximum number of expr occurrences. If this behavior is desired, then write h jo ubj)}(h``expr[..., n] + ~expr``h]hexpr[..., n] + ~expr}(hhh j ubah#}(h%]h']h*]h,]h.]uh0jh jo ubh.}(hj h jo ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Kh j ubeh#}(h%]h']h*]h,]h.]uh0jh jhhh!h>h"Nubj)}(hXMatchFirst_ 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`)}(hXMatchFirst_ 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}(h MatchFirsth j ubah#}(h%]h']h*]h,]h.]namej h< matchfirstuh0hh j jKubh 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 h j ubh)}(hOr_h]hOr}(hOrh j ubah#}(h%]h']h*]h,]h.]namej h<oruh0hh j jKubh expressions (defined using the }(h expressions (defined using the h j ubj)}(h``^``h]h^}(hhh j ubah#}(h%]h']h*]h,]h.]uh0jh j ubhe operator) - they will always match the longest expression, although they are more compute-intensive.}(he operator) - they will always match the longest expression, although they are more compute-intensive.h j ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Kh j ubah#}(h%]h']h*]h,]h.]uh0jh jhhh!h>h"Nubj)}(hOr_ 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`)}(hOr_ 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)}(hOr_h]hOr}(hOrh jubah#}(h%]h']h*]h,]h.]namejhh"Kh jubah#}(h%]h']h*]h,]h.]uh0jh jhhh!h>h"Nubj)}(hxIf parsing the contents of an entire file, pass it to the ``parse_file`` method using:: expr.parse_file(source_file) h](h`)}(hWIf 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 h jQubj)}(h``parse_file``h]h parse_file}(hhh jZubah#}(h%]h']h*]h,]h.]uh0jh jQubh method using:}(h method using:h jQubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Kh jMubjd)}(hexpr.parse_file(source_file)h]hexpr.parse_file(source_file)}(hhh jsubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"Kh jMubeh#}(h%]h']h*]h,]h.]uh0jh jhhh!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]hParseExceptions}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh 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:h jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Kh jubjd)}(h1pyparsing.ParseException: Expected "," (6), (1,7)h]h1pyparsing.ParseException: Expected "," (6), (1,7)}(hhh jubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"Kh jubh`)}(hIn the case of complex expressions, the reported location may not be exactly where you would expect. See more information under ParseException_ .h](hIn the case of complex expressions, the reported location may not be exactly where you would expect. See more information under }(hIn the case of complex expressions, the reported location may not be exactly where you would expect. See more information under h jubh)}(hParseException_h]hParseException}(hParseExceptionh jubah#}(h%]h']h*]h,]h.]namejh<parseexceptionuh0hh jjKubh .}(h .h jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Kh jubeh#}(h%]h']h*]h,]h.]uh0jh jhhh!h>h"Nubj)}(hUse 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`)}(hUse 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](hUse the }(hUse the h jubj)}(h ``Group``h]hGroup}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh 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).h jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Kh jubah#}(h%]h']h*]h,]h.]uh0jh jhhh!h>h"Nubj)}(hXPunctuation 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`)}(hXPunctuation 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](hlPunctuation may be significant for matching, but is rarely of much interest in the parsed results. Use the }(hlPunctuation may be significant for matching, but is rarely of much interest in the parsed results. Use the h jubj)}(h``suppress()``h]h suppress()}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh] 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, h jubj)}(h``delimited_list()``h]hdelimited_list()}(hhh j-ubah#}(h%]h']h*]h,]h.]uh0jh jubh 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.h jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Kh j ubah#}(h%]h']h*]h,]h.]uh0jh jhhh!h>h"Nubj)}(hmParse actions can be used to convert values from strings to other data types (ints, floats, booleans, etc.). h]h`)}(hlParse actions can be used to convert values from strings to other data types (ints, floats, booleans, etc.).h]hlParse actions can be used to convert values from strings to other data types (ints, floats, booleans, etc.).}(hjRh jPubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"Kh jLubah#}(h%]h']h*]h,]h.]uh0jh jhhh!h>h"Nubj)}(hXhResults 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`)}(hXResults 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](hResults 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 }(hResults 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 jhubj)}(h``set_results_name``h]hset_results_name}(hhh jqubah#}(h%]h']h*]h,]h.]uh0jh jhubh call:}(h call:h jhubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Kh jdubjd)}(hstats = ("AVE:" + real_num.set_results_name("average") + "MIN:" + real_num.set_results_name("min") + "MAX:" + real_num.set_results_name("max"))h]hstats = ("AVE:" + real_num.set_results_name("average") + "MIN:" + real_num.set_results_name("min") + "MAX:" + real_num.set_results_name("max"))}(hhh jubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"Kh jdubh`)}(h0can 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:h jubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"Kh jdubjd)}(hnstats = ("AVE:" + real_num("average") + "MIN:" + real_num("min") + "MAX:" + real_num("max"))h]hnstats = ("AVE:" + real_num("average") + "MIN:" + real_num("min") + "MAX:" + real_num("max"))}(hhh jubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"Kh jdubeh#}(h%]h']h*]h,]h.]uh0jh jhhh!h>h"Nubj)}(hXBe 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`)}(hXBe 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 P}(h^Be careful when defining parse actions that modify global variables or data structures (as in h jubh)}(h fourFn.py_h]h fourFn.py}(h fourFn.pyh jubah#}(h%]h']h*]h,]h.]namejjjd uh0hh jjKubhK), especially for low level tokens or expressions that may occur within an }(hK), especially for low level tokens or expressions that may occur within an h jubh)}(hAnd_h]hAnd}(hAndh jubah#}(h%]h']h*]h,]h.]namejh<anduh0hh jjKubh$ expression; an early element of an }(h$ expression; an early element of an h jubh)}(hAnd_h]hAnd}(hAndh jubah#}(h%]h']h*]h,]h.]namejhh"Mh jubah#}(h%]h']h*]h,]h.]uh0jh jhhh!h>h"Nubeh#}(h%]h']h*]h,]h.]j j uh0jh!h>h"Khh jhhubeh#}(h%]j`ah']h*] usage notesah,]h.]uh0h h j;hhh!h>h"Kfubeh#}(h%]jah']h*]steps to followah,]h.]uh0h h h hhh!h>h"K5ubh )}(hhh](h)}(hjh](h)}(hhh]h 1.2   }(hhh j.hhh!Nh"Nubah#}(h%]h']h)ah*]h,]h.]uh0hh j+hhh!Nh"NubhClasses}(hjh j+hhh!Nh"Nubeh#}(h%]h']h*]h,]h.]h;Khh"Mubh )}(hhh](h)}(hjh](h)}(hhh]h 1.2.1   }(hhh jKhhh!Nh"Nubah#}(h%]h']h)ah*]h,]h.]uh0hh jHhhh!Nh"NubhClasses in the pyparsing module}(hjh jHhhh!Nh"Nubeh#}(h%]h']h*]h,]h.]h;Khh"M ubh`)}(h_``ParserElement`` - abstract base class for all pyparsing classes; methods for code to use are:h](j)}(h``ParserElement``h]h ParserElement}(hhh jfubah#}(h%]h']h*]h,]h.]uh0jh jbubhN - abstract base class for all pyparsing classes; methods for code to use are:}(hN - abstract base class for all pyparsing classes; methods for code to use are:h jbhhh!Nh"Nubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M h jEhhubj)}(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)}(h0``parse_string(source_string, parse_all=False)``h]h,parse_string(source_string, parse_all=False)}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh@ - only called once, on the overall matching pattern; returns a }(h@ - only called once, on the overall matching pattern; returns a h jubh)}(h ParseResults_h]h ParseResults}(h ParseResultsh jubah#}(h%]h']h*]h,]h.]namejhh"Mh jubah#}(h%]h']h*]h,]h.]uh0jh jhhh!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]hparse_file(source_file)}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubhw - a convenience function, that accepts an input file object or filename. The file contents are passed as a string to }(hw - a convenience function, that accepts an input file object or filename. The file contents are passed as a string to h jubj)}(h``parse_string()``h]hparse_string()}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh. }(h. h jubj)}(h``parse_file``h]h parse_file}(hhh j'ubah#}(h%]h']h*]h,]h.]uh0jh jubh also supports the }(h also supports the h jubj)}(h ``parse_all``h]h parse_all}(hhh j:ubah#}(h%]h']h*]h,]h.]uh0jh jubh argument.}(h argument.h jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jubah#}(h%]h']h*]h,]h.]uh0jh jhhh!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]hscan_string(source_string)}(hhh jaubah#}(h%]h']h*]h,]h.]uh0jh j]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:h j]ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jYubj)}(hhh](j)}(h4matched tokens (packaged as a ParseResults_ object) h]h`)}(h3matched tokens (packaged as a ParseResults_ object)h](hmatched tokens (packaged as a }(hmatched tokens (packaged as a h jubh)}(h ParseResults_h]h ParseResults}(h ParseResultsh jubah#}(h%]h']h*]h,]h.]namejhh"Mh j}ubah#}(h%]h']h*]h,]h.]uh0jh jzubj)}(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 stringh]h=start location of the matched text in the given source string}(hjh jubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"M!h jubah#}(h%]h']h*]h,]h.]uh0jh jzubj)}(h(end location in the given source string h]h`)}(h'end location in the given source stringh]h'end location in the given source string}(hjh jubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"M#h jubah#}(h%]h']h*]h,]h.]uh0jh jzubeh#}(h%]h']h*]h,]h.]j j uh0jh!h>h"Mh jYubh`)}(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}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh 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 h jubj)}(h``parse_string``h]h parse_string}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh).}(h).h jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M%h jYubeh#}(h%]h']h*]h,]h.]uh0jh jhhh!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]htransform_string(source_string)}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh$ - convenience wrapper function for }(h$ - convenience wrapper function for h jubj)}(h``scan_string``h]h scan_string}(hhh j2ubah#}(h%]h']h*]h,]h.]uh0jh jubh, 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 h jubh)}(hset_parse_action_h]hset_parse_action}(hset_parse_actionh jEubah#}(h%]h']h*]h,]h.]namejMh<set-parse-actionuh0hh jjKubh).}(h).h jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M)h jubah#}(h%]h']h*]h,]h.]uh0jh jhhh!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]hsearch_string(source_string)}(hhh joubah#}(h%]h']h*]h,]h.]uh0jh jkubh, - another convenience wrapper function for }(h, - another convenience wrapper function for h jkubj)}(h``scan_string``h]h scan_string}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jkubhC, returns a list of the matching tokens returned from each call to }(hC, returns a list of the matching tokens returned from each call to h jkubj)}(h``scan_string``h]h scan_string}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jkubh.}(hj h jkubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M.h jgubah#}(h%]h']h*]h,]h.]uh0jh jhhh!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 informationh](j)}(h``set_name(name)``h]hset_name(name)}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubhm - associate a short descriptive name for this element, useful in displaying exceptions and trace information}(hm - associate a short descriptive name for this element, useful in displaying exceptions and trace informationh jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M2h jubah#}(h%]h']h*]h,]h.]uh0jh jhhh!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]hrun_tests(tests_string)}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh - 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 h jubj)}(h``#``h]h#}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh?) 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:h jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M5h jubjd)}(hdigits = 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]hdigits = 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. """)}(hhh jubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"M:h jubh`)}(h will print::h]h will print:}(h will print:h jubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"MJh jubjd)}(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)}(hhh j+ubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"MLh jubeh#}(h%]h']h*]h,]h.]uh0jh jhhh!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)}(h4``set_results_name(string, list_all_matches=False)``h]h0set_results_name(string, list_all_matches=False)}(hhh jGubah#}(h%]h']h*]h,]h.]uh0jh jCubhj - name to be given to tokens matching the element; if multiple tokens within a repetition group (such as }(hj - name to be given to tokens matching the element; if multiple tokens within a repetition group (such as h jCubj)}(h``ZeroOrMore``h]h ZeroOrMore}(hhh jZubah#}(h%]h']h*]h,]h.]uh0jh jCubh or }(h or h jCubj)}(h``delimited_list``h]hdelimited_list}(hhh jmubah#}(h%]h']h*]h,]h.]uh0jh jCubh=) the default is to return only the last matching token - if }(h=) the default is to return only the last matching token - if h jCubj)}(h``list_all_matches``h]hlist_all_matches}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jCubhD is set to True, then a list of all the matching tokens is returned.}(hD is set to True, then a list of all the matching tokens is returned.h jCubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M_h j?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]hexpr.set_results_name("key")}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh can also be written }(h can also be written h jubj)}(h``expr("key")``h]h expr("key")}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubhR (a results name with a trailing ‘*’ character will be interpreted as setting }(hN (a results name with a trailing '*' character will be interpreted as setting h jubj)}(h``list_all_matches``h]hlist_all_matches}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh to }(h to h jubj)}(h``True``h]hTrue}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh).}(h).h jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mfh j?ubh`)}(hNote: ``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](hNote: }(hNote: h jubj)}(h``set_results_name``h]hset_results_name}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh returns a }(h returns a h jubj)}(h*copy*h]hcopy}(hhh j ubah#}(h%]h']h*]h,]h.]uh0jh jubh 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.h jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mjh j?ubeh#}(h%]h']h*]h,]h.]uh0jh jhhh!h>h"Nubeh#}(h%]h']h*]h,]h.]j j uh0jh!h>h"Mh jEhhubj)}(h.. _set_parse_action:h]h#}(h%]h']h*]h,]h.]hjKubj)}(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]hset_parse_action(*fn)}(hhh jEubah#}(h%]h']h*]h,]h.]uh0jh jAubho - specify one or more functions to call after successful matching of the element; each function is defined as }(ho - specify one or more functions to call after successful matching of the element; each function is defined as h jAubj)}(h``fn(s, loc, toks)``h]hfn(s, loc, toks)}(hhh jXubah#}(h%]h']h*]h,]h.]uh0jh jAubh, where:}(h, where:h jAubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mqh j=ubj)}(hhh](j)}(h#``s`` is the original parse string h]h`)}(h"``s`` is the original parse stringh](j)}(h``s``h]hs}(hhh j|ubah#}(h%]h']h*]h,]h.]uh0jh jxubh is the original parse string}(h is the original parse stringh jxubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mth jtubah#}(h%]h']h*]h,]h.]uh0jh jqubj)}(h=``loc`` is the location in the string where matching started h]h`)}(h<``loc`` is the location in the string where matching startedh](j)}(h``loc``h]hloc}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh5 is the location in the string where matching started}(h5 is the location in the string where matching startedh jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mvh jubah#}(h%]h']h*]h,]h.]uh0jh jqubj)}(hO``toks`` is the list of the matched tokens, packaged as a ParseResults_ object h]h`)}(hN``toks`` is the list of the matched tokens, packaged as a ParseResults_ objecth](j)}(h``toks``h]htoks}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh2 is the list of the matched tokens, packaged as a }(h2 is the list of the matched tokens, packaged as a h jubh)}(h ParseResults_h]h ParseResults}(h ParseResultsh jubah#}(h%]h']h*]h,]h.]namejhh"Mxh jubah#}(h%]h']h*]h,]h.]uh0jh jqubeh#}(h%]h']h*]h,]h.]j j uh0jh!h>h"Mth j=ubh`)}(h8Parse actions can have any of the following signatures::h]h7Parse actions can have any of the following signatures:}(h7Parse actions can have any of the following signatures:h jubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mzh j=ubjd)}(hkfn(s: str, loc: int, tokens: ParseResults) fn(loc: int, tokens: ParseResults) fn(tokens: ParseResults) fn()h]hkfn(s: str, loc: int, tokens: ParseResults) fn(loc: int, tokens: ParseResults) fn(tokens: ParseResults) fn()}(hhh jubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"M|h j=ubh`)}(hX4Multiple 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 h j!ubj)}(h``ParserElement``h]h ParserElement}(hhh j*ubah#}(h%]h']h*]h,]h.]uh0jh j!ubh% by specifying multiple arguments to }(h% by specifying multiple arguments to h j!ubj)}(h``set_parse_action``h]hset_parse_action}(hhh j=ubah#}(h%]h']h*]h,]h.]uh0jh j!ubh, or by calling }(h, or by calling h j!ubj)}(h``add_parse_action``h]hadd_parse_action}(hhh jPubah#}(h%]h']h*]h,]h.]uh0jh j!ubh . Calls to }(h . Calls to h j!ubj)}(h``set_parse_action``h]hset_parse_action}(hhh jcubah#}(h%]h']h*]h,]h.]uh0jh j!ubh4 will replace any previously defined parse actions. }(h4 will replace any previously defined parse actions. h j!ubj)}(h``set_parse_action(None)``h]hset_parse_action(None)}(hhh jvubah#}(h%]h']h*]h,]h.]uh0jh j!ubh1 will clear all previously defined parse actions.}(h1 will clear all previously defined parse actions.h j!ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j=ubh`)}(hXEach 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](h1Each parse action function can return a modified }(h1Each parse action function can return a modified h jubj)}(h``toks``h]htoks}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubhE list, to perform conversion, or string modifications. For brevity, }(hE list, to perform conversion, or string modifications. For brevity, h jubj)}(h``fn``h]hfn}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh~ 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:h jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j=ubjd)}(hEint_number = Word(nums).set_parse_action(lambda s, l, t: [int(t[0])])h]hEint_number = Word(nums).set_parse_action(lambda s, l, t: [int(t[0])])}(hhh jubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"Mh j=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](hIf }(hIf h jubj)}(h``fn``h]hfn}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh modifies the }(h modifies the h jubj)}(h``toks``h]htoks}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubhO list in-place, it does not need to return and pyparsing will use the modified }(hO list in-place, it does not need to return and pyparsing will use the modified h jubj)}(h``toks``h]htoks}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh list.}(h list.h jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j=ubh`)}(hIf ``set_parse_action`` is called with an argument of ``None``, then this clears all parse actions attached to that expression.h](hIf }(hIf h jubj)}(h``set_parse_action``h]hset_parse_action}(hhh j#ubah#}(h%]h']h*]h,]h.]uh0jh jubh is called with an argument of }(h is called with an argument of h jubj)}(h``None``h]hNone}(hhh j6ubah#}(h%]h']h*]h,]h.]uh0jh jubhA, then this clears all parse actions attached to that expression.}(hA, then this clears all parse actions attached to that expression.h jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j=ubh`)}(hOA nice short-cut for calling ``set_parse_action`` is to use it as a decorator::h](hA nice short-cut for calling }(hA nice short-cut for calling h jOubj)}(h``set_parse_action``h]hset_parse_action}(hhh jXubah#}(h%]h']h*]h,]h.]uh0jh jOubh is to use it as a decorator:}(h is to use it as a decorator:h jOubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j=ubjd)}(hidentifier = Word(alphas, alphanums+"_") @identifier.set_parse_action def resolve_identifier(results: ParseResults): return variable_values.get(results[0])h]hidentifier = Word(alphas, alphanums+"_") @identifier.set_parse_action def resolve_identifier(results: ParseResults): return variable_values.get(results[0])}(hhh jqubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"Mh j=ubh`)}(hX(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: h jubh)}(h+https://stackoverflow.com/a/63031959/165216h]h+https://stackoverflow.com/a/63031959/165216}(hhh jubah#}(h%]h']h*]h,]h.]refurijuh0hh jubh)}(h)h jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j=ubeh#}(h%]h']h*]h,]h.]uh0jh j: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]hadd_parse_action}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh - similar to }(h - similar to h jubj)}(h``set_parse_action``h]hset_parse_action}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh, 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.h jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jubah#}(h%]h']h*]h,]h.]uh0jh j: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}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh - a simplified form of }(h - a simplified form of h jubj)}(h``add_parse_action``h]hadd_parse_action}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh 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 h jubj)}(h``True``h]hTrue}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh or }(h or h jubj)}(h ``False``h]hFalse}(hhh j#ubah#}(h%]h']h*]h,]h.]uh0jh jubh. If }(h. If h jubj)}(h ``False``h]hFalse}(hhh j6ubah#}(h%]h']h*]h,]h.]uh0jh jubh* is returned, an exception will be raised.}(h* is returned, an exception will be raised.h jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jubah#}(h%]h']h*]h,]h.]uh0jh j: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 parsedh](j)}(h``set_break(break_flag=True)``h]hset_break(break_flag=True)}(hhh j]ubah#}(h%]h']h*]h,]h.]uh0jh jYubh - if }(h - if h jYubj)}(h``break_flag``h]h break_flag}(hhh jpubah#}(h%]h']h*]h,]h.]uh0jh jYubh is }(h is h jYubj)}(h``True``h]hTrue}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jYubh, calls }(h, calls h jYubj)}(h``pdb.set_break()``h]hpdb.set_break()}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jYubh) as this expression is about to be parsed}(h) as this expression is about to be parsedh jYubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jUubah#}(h%]h']h*]h,]h.]uh0jh j: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]hcopy()}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh - returns a copy of a }(h - returns a copy of a h jubj)}(h``ParserElement``h]h ParserElement}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh; 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 h jubj)}(h ``expr()``h]hexpr()}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh is equivalent to }(h is equivalent to h jubj)}(h``expr.copy()``h]h expr.copy()}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jubah#}(h%]h']h*]h,]h.]uh0jh j: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]hleave_whitespace()}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh - 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)h jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jubah#}(h%]h']h*]h,]h.]uh0jh j: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]hset_whitespace_chars(chars)}(hhh j?ubah#}(h%]h']h*]h,]h.]uh0jh j;ubhY - define the set of chars to be ignored as whitespace before trying to match a specific }(hY - define the set of chars to be ignored as whitespace before trying to match a specific h j;ubj)}(h``ParserElement``h]h ParserElement}(hhh jRubah#}(h%]h']h*]h,]h.]uh0jh j;ubhM, in place of the default set of whitespace (space, tab, newline, and return)}(hM, in place of the default set of whitespace (space, tab, newline, and return)h j;ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j7ubah#}(h%]h']h*]h,]h.]uh0jh j: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)}(hhh jyubah#}(h%]h']h*]h,]h.]uh0jh juubhXH - 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)h juubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jqubah#}(h%]h']h*]h,]h.]uh0jh j: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()}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubhc - convenience function to suppress the output of the given element, instead of wrapping it with a }(hc - convenience function to suppress the output of the given element, instead of wrapping it with a h jubj)}(h ``Suppress``h]hSuppress}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh object.}(h object.h jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jubah#}(h%]h']h*]h,]h.]uh0jh j: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 exampleh](j)}(h``ignore(expr)``h]h ignore(expr)}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh - 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 exampleh jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jubah#}(h%]h']h*]h,]h.]uh0jh j:hhh!h>h"Nubj)}(hm``set_debug(debug_flag=True)`` - function to enable/disable tracing output when trying to match this element h]h`)}(hl``set_debug(debug_flag=True)`` - function to enable/disable tracing output when trying to match this elementh](j)}(h``set_debug(debug_flag=True)``h]hset_debug(debug_flag=True)}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubhN - function to enable/disable tracing output when trying to match this element}(hN - function to enable/disable tracing output when trying to match this elementh jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jubah#}(h%]h']h*]h,]h.]uh0jh j:hhh!h>h"Nubj)}(hn``validate()`` - function to verify that the defined grammar does not contain infinitely recursive constructs h]h`)}(hm``validate()`` - function to verify that the defined grammar does not contain infinitely recursive constructsh](j)}(h``validate()``h]h validate()}(hhh j(ubah#}(h%]h']h*]h,]h.]uh0jh j$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 constructsh j$ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j ubah#}(h%]h']h*]h,]h.]uh0jh j:hhh!h>h"Nubeh#}(h%]jUah']h*]set_parse_actionah,]h.]j j uh0jh!h>h"Mqh jEhhexpect_referenced_by_name}jKj0sexpect_referenced_by_id}jUj0sjKubj)}(h.. _parse_with_tabs:h]h#}(h%]h']h*]h,]h.]h<parse-with-tabsuh0jh"Mh jEhhh!h>jKubj)}(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]hparse_with_tabs()}(hhh jhubah#}(h%]h']h*]h,]h.]uh0jh jdubh - 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 h jdubh)}(hWhite_h]hWhite}(hWhiteh j{ubah#}(h%]h']h*]h,]h.]namejh<whiteuh0hh jdjKubh class.}(h class.h jdubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j`ubah#}(h%]h']h*]h,]h.]uh0jh j]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]henable_packrat()}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubhX' - 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 h jubj)}(h"``ParserElement.enable_packrat()``h]hParserElement.enable_packrat()}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh. For best results, call }(h. For best results, call h jubj)}(h``enable_packrat()``h]henable_packrat()}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh' immediately after importing pyparsing.}(h' immediately after importing pyparsing.h jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jubah#}(h%]h']h*]h,]h.]uh0jh j]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]henable_left_recursion()}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh` - 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 h jubj)}(h"``ParserElement.enable_packrat()``h]hParserElement.enable_packrat()}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh*, your program must call the class method }(h*, your program must call the class method h jubj)}(h)``ParserElement.enable_left_recursion()``h]h%ParserElement.enable_left_recursion()}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh to enable this feature. }(h to enable this feature. h jubj)}(h``enable_left_recursion()``h]henable_left_recursion()}(hhh j+ubah#}(h%]h']h*]h,]h.]uh0jh jubh< uses a separate packrat cache, and so is incompatible with }(h< uses a separate packrat cache, and so is incompatible with h jubj)}(h``enable_packrat()``h]henable_packrat()}(hhh j>ubah#}(h%]h']h*]h,]h.]uh0jh jubh.}(hj h jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jubah#}(h%]h']h*]h,]h.]uh0jh j]hhh!h>h"Nubeh#}(h%]j\ah']h*]parse_with_tabsah,]h.]j j uh0jh!h>h"Mh jEhhjN}j`jRsjP}j\jRsjKubeh#}(h%]jah']h*]classes in the pyparsing moduleah,]h.]uh0h h j(hhh!h>h"M ubh )}(hhh](h)}(hjh](h)}(hhh]h 1.2.2   }(hhh jrhhh!Nh"Nubah#}(h%]h']h)ah*]h,]h.]uh0hh johhh!Nh"NubhBasic ParserElement subclasses}(hjh johhh!Nh"Nubeh#}(h%]h']h*]h,]h.]h;Khh"Mubj)}(h .. _Literal:h]h#}(h%]h']h*]h,]h.]hjKubj)}(hhh]j)}(h<``Literal`` - construct with a string to be matched exactly h]h`)}(h;``Literal`` - construct with a string to be matched exactlyh](j)}(h ``Literal``h]hLiteral}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh0 - construct with a string to be matched exactly}(h0 - construct with a string to be matched exactlyh jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jubah#}(h%]h']h*]h,]h.]uh0jh jhhh!h>h"Nubah#}(h%]jc ah']h*]literalah,]h.]j j uh0jh!h>h"Mh jlhhjN}jjsjP}jc jsjKubj)}(h.. _CaselessLiteral:h]h#}(h%]h']h*]h,]h.]h<caselessliteraluh0jh"Mh jlhhh!h>jKubj)}(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 stringh](j)}(h``CaselessLiteral``h]hCaselessLiteral}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh - 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 stringh jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jubah#}(h%]h']h*]h,]h.]uh0jh jhhh!h>h"Nubah#}(h%]jah']h*]caselessliteralah,]h.]j j uh0jh!h>h"Mh jlhhjN}jjsjP}jjsjKubj)}(h .. _Keyword:h]h#}(h%]h']h*]h,]h.]h<keyworduh0jh"Mh jlhhh!h>jKubj)}(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 keywordh](j)}(h ``Keyword``h]hKeyword}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh - similar to }(h - similar to h jubh)}(hLiteral_h]hLiteral}(hLiteralh j-ubah#}(h%]h']h*]h,]h.]namej5hh"Mh jubah#}(h%]h']h*]h,]h.]uh0jh jhhh!h>h"Nubj)}(hO``CaselessKeyword`` - similar to Keyword_, but with caseless matching behavior h]h`)}(hN``CaselessKeyword`` - similar to Keyword_, but with caseless matching behaviorh](j)}(h``CaselessKeyword``h]hCaselessKeyword}(hhh jVubah#}(h%]h']h*]h,]h.]uh0jh jRubh - similar to }(h - similar to h jRubh)}(hKeyword_h]hKeyword}(hKeywordh jiubah#}(h%]h']h*]h,]h.]namejqhh"Mh jNubah#}(h%]h']h*]h,]h.]uh0jh jhhh!h>h"Nubeh#}(h%]jah']h*]keywordah,]h.]j j uh0jh!h>h"Mh jlhhjN}jjsjP}jjsjKubj)}(h .. _Word:h]h#}(h%]h']h*]h,]h.]h<worduh0jh"Mh jlhhh!h>jKubj)}(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]hWord}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh - 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 h jubj)}(h``Word``h]hWord}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh 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, h jubj)}(h``a``h]ha}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh, }(h, h jubj)}(h``i``h]hi}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh, }(h, h jubj)}(h``MAX_LENGTH``h]h MAX_LENGTH}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh, }(h, h jubj)}(h``_a1``h]h_a1}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh, }(h, h jubj)}(h ``b_109_``h]hb_109_}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh, and }(h, and h jubj)}(h``plan9FromOuterSpace``h]hplan9FromOuterSpace}(hhh j.ubah#}(h%]h']h*]h,]h.]uh0jh jubh are all valid identifiers; }(h are all valid identifiers; h jubj)}(h``9b7z``h]h9b7z}(hhh jAubah#}(h%]h']h*]h,]h.]uh0jh jubh, }(h, h jubj)}(h``$a``h]h$a}(hhh jTubah#}(h%]h']h*]h,]h.]uh0jh jubh, }(hjh jubj)}(h ``.section``h]h.section}(hhh jfubah#}(h%]h']h*]h,]h.]uh0jh jubh, and }(h, and h jubj)}(h ``0debug``h]h0debug}(hhh jyubah#}(h%]h']h*]h,]h.]uh0jh jubh+ are not. To define an identifier using a }(h+ are not. To define an identifier using a h jubj)}(h``Word``h]hWord}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh, use either of the following:}(h, use either of the following:h jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jubjd)}(hQWord(alphas+"_", alphanums+"_") Word(srange("[a-zA-Z_]"), srange("[a-zA-Z0-9_]"))h]hQWord(alphas+"_", alphanums+"_") Word(srange("[a-zA-Z_]"), srange("[a-zA-Z0-9_]"))}(hhh jubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"Mh jubh`)}(hnPyparsing 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 h jubj)}(h``identchars``h]h identchars}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh and }(h and h jubj)}(h``identbodychars``h]hidentbodychars}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh so that you can also write:}(h so that you can also write:h jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jubjd)}(h Word(identchars, identbodychars)h]h Word(identchars, identbodychars)}(hhh jubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"Mh jubh`)}(hIf 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]hIf 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:}(hIf 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 jubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"M h jubjd)}(hB``Word("ABCDEFGHIJKLMNOPQRSTUVWXYZ_")`` ``Word(srange("[A-Z_]"))``h]hB``Word("ABCDEFGHIJKLMNOPQRSTUVWXYZ_")`` ``Word(srange("[A-Z_]"))``}(hhh jubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"Mh jubh`)}(hQA ``Word`` may also be constructed with any of the following optional parameters:h](hA }(hA h jubj)}(h``Word``h]hWord}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubhG may also be constructed with any of the following optional parameters:}(hG may also be constructed with any of the following optional parameters:h jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jubj)}(hhh](j)}(h=``min`` - indicating a minimum length of matching characters h]h`)}(h<``min`` - indicating a minimum length of matching charactersh](j)}(h``min``h]hmin}(hhh j@ubah#}(h%]h']h*]h,]h.]uh0jh j<ubh5 - indicating a minimum length of matching characters}(h5 - indicating a minimum length of matching charactersh j<ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j8ubah#}(h%]h']h*]h,]h.]uh0jh j5ubj)}(h=``max`` - indicating a maximum length of matching characters h]h`)}(h<``max`` - indicating a maximum length of matching charactersh](j)}(h``max``h]hmax}(hhh jgubah#}(h%]h']h*]h,]h.]uh0jh jcubh5 - indicating a maximum length of matching characters}(h5 - indicating a maximum length of matching charactersh jcubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j_ubah#}(h%]h']h*]h,]h.]uh0jh j5ubj)}(h>``exact`` - indicating an exact length of matching characters h]h`)}(h=``exact`` - indicating an exact length of matching charactersh](j)}(h ``exact``h]hexact}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh4 - indicating an exact length of matching characters}(h4 - indicating an exact length of matching charactersh jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jubah#}(h%]h']h*]h,]h.]uh0jh j5ubeh#}(h%]h']h*]h,]h.]j j uh0jh!h>h"Mh jubh`)}(hNIf ``exact`` is specified, it will override any values for ``min`` or ``max``.h](hIf }(hIf h jubj)}(h ``exact``h]hexact}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh/ is specified, it will override any values for }(h/ is specified, it will override any values for h jubj)}(h``min``h]hmin}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh or }(h or h jubj)}(h``max``h]hmax}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh.}(hj h jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jubh`)}(hXSometimes 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](hSometimes 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 }(hSometimes 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 jubj)}(h``exclude_chars``h]h exclude_chars}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubhA argument. This is helpful if you want to define a word with all }(hA argument. This is helpful if you want to define a word with all h jubj)}(h``printables``h]h printables}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh 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 h jubj)}(h'``Word(printables, exclude_chars='.')``h]h#Word(printables, exclude_chars='.')}(hhh j)ubah#}(h%]h']h*]h,]h.]uh0jh jubh.}(hj h jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jubeh#}(h%]h']h*]h,]h.]uh0jh jhhh!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`)}(hx``Char`` - a convenience form of ``Word`` that will match just a single character from a string of matching characters::h](j)}(h``Char``h]hChar}(hhh jOubah#}(h%]h']h*]h,]h.]uh0jh jKubh - a convenience form of }(h - a convenience form of h jKubj)}(h``Word``h]hWord}(hhh jbubah#}(h%]h']h*]h,]h.]uh0jh jKubhN that will match just a single character from a string of matching characters:}(hN that will match just a single character from a string of matching characters:h jKubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M%h jGubjd)}(hsingle_digit = Char(nums)h]hsingle_digit = Char(nums)}(hhh j{ubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"M(h jGubeh#}(h%]h']h*]h,]h.]uh0jh jhhh!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}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh - similar to }(h - similar to h jubh)}(hWord_h]hWord}(hWordh jubah#}(h%]h']h*]h,]h.]namejhh"M*h jubah#}(h%]h']h*]h,]h.]uh0jh jhhh!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]hRegex}(hhh j ubah#}(h%]h']h*]h,]h.]uh0jh jubh| - 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 h jubj)}(h ``flags``h]hflags}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubh8 parameter, corresponding to the flags parameter in the }(h8 parameter, corresponding to the flags parameter in the h jubj)}(h``re.compile``h]h re.compile}(hhh j2ubah#}(h%]h']h*]h,]h.]uh0jh jubh_ 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 h jubh)}(h ParseResults_h]h ParseResults}(h ParseResultsh jEubah#}(h%]h']h*]h,]h.]namejMhh"M/h jubah#}(h%]h']h*]h,]h.]uh0jh jhhh!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}(hhh jmubah#}(h%]h']h*]h,]h.]uh0jh jiubhb - 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 h jiubj)}(h``dbl_quoted_string``h]hdbl_quoted_string}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jiubh and }(h and h jiubj)}(h``sgl_quoted_string``h]hsgl_quoted_string}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jiubh. }(h. h jiubj)}(h``QuotedString``h]h QuotedString}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jiubh0 allows you to specify the following parameters:}(h0 allows you to specify the following parameters:h jiubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M5h jeubj)}(hhh](j)}(hW``quote_char`` - string of one or more characters defining the quote delimiting string h]h`)}(hV``quote_char`` - string of one or more characters defining the quote delimiting stringh](j)}(h``quote_char``h]h quote_char}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubhH - string of one or more characters defining the quote delimiting string}(hH - string of one or more characters defining the quote delimiting stringh jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M:h jubah#}(h%]h']h*]h,]h.]uh0jh jubj)}(hN``esc_char`` - character to escape quotes, typically backslash (default=None) h]h`)}(hM``esc_char`` - character to escape quotes, typically backslash (default=None)h](j)}(h ``esc_char``h]hesc_char}(hhh jubah#}(h%]h']h*]h,]h.]uh0jh jubhA - character to escape quotes, typically backslash (default=None)}(hA - character to escape quotes, typically backslash (default=None)h jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M<h jubah#}(h%]h']h*]h,]h.]uh0jh jubj)}(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}(hhh j ubah#}(h%]h']h*]h,]h.]uh0jh j ubh~ - special quote sequence to escape an embedded quote string (such as SQL’s “” to escape an embedded “) (default=None)}(hv - special quote sequence to escape an embedded quote string (such as SQL's "" to escape an embedded ") (default=None)h j ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M>h j ubah#}(h%]h']h*]h,]h.]uh0jh jubj)}(hZ``multiline`` - boolean indicating whether quotes can span multiple lines (default=False) h]h`)}(hY``multiline`` - boolean indicating whether quotes can span multiple lines (default=False)h](j)}(h ``multiline``h]h multiline}(hhh j? ubah#}(h%]h']h*]h,]h.]uh0jh j; ubhL - boolean indicating whether quotes can span multiple lines (default=False)}(hL - boolean indicating whether quotes can span multiple lines (default=False)h j; ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M@h j7 ubah#}(h%]h']h*]h,]h.]uh0jh jubj)}(hd``unquote_results`` - boolean indicating whether the matched text should be unquoted (default=True) h]h`)}(hc``unquote_results`` - boolean indicating whether the matched text should be unquoted (default=True)h](j)}(h``unquote_results``h]hunquote_results}(hhh jf ubah#}(h%]h']h*]h,]h.]uh0jh jb ubhP - boolean indicating whether the matched text should be unquoted (default=True)}(hP - boolean indicating whether the matched text should be unquoted (default=True)h jb ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"MBh j^ ubah#}(h%]h']h*]h,]h.]uh0jh jubj)}(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]hend_quote_char}(hhh j ubah#}(h%]h']h*]h,]h.]uh0jh j ubhl - string of one or more characters defining the end of the quote delimited string (default=None => same as }(hl - string of one or more characters defining the end of the quote delimited string (default=None => same as h j ubj)}(h``quote_char``h]h quote_char}(hhh j ubah#}(h%]h']h*]h,]h.]uh0jh j ubh)}(hjh j ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"MDh j ubah#}(h%]h']h*]h,]h.]uh0jh jubeh#}(h%]h']h*]h,]h.]j j uh0jh!h>h"M:h jeubeh#}(h%]h']h*]h,]h.]uh0jh jhhh!Nh"Nubeh#}(h%]jah']h*]wordah,]h.]j j uh0jh!h>h"Mh jlhhjN}j jsjP}jjsjKubj)}(h .. _SkipTo:h]h#}(h%]h']h*]h,]h.]h<skiptouh0jh"MFh jlhhh!h>jKubj)}(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]hSkipTo}(hhh j ubah#}(h%]h']h*]h,]h.]uh0jh j 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:h j ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"MHh j ubj)}(hhh](j)}(hT``include`` - if set to true, also consumes the match expression (default is false) h]h`)}(hS``include`` - if set to true, also consumes the match expression (default is false)h](j)}(h ``include``h]hinclude}(hhh j !ubah#}(h%]h']h*]h,]h.]uh0jh j !ubhH - if set to true, also consumes the match expression (default is false)}(hH - if set to true, also consumes the match expression (default is false)h j !ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"MLh j!ubah#}(h%]h']h*]h,]h.]uh0jh j!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 matchesh](j)}(h ``ignore``h]hignore}(hhh j4!ubah#}(h%]h']h*]h,]h.]uh0jh j0!ubhR - allows the user to specify patterns to not be matched, to prevent false matches}(hR - allows the user to specify patterns to not be matched, to prevent false matchesh j0!ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"MOh j,!ubah#}(h%]h']h*]h,]h.]uh0jh j!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 expressionh](j)}(h ``fail_on``h]hfail_on}(hhh j[!ubah#}(h%]h']h*]h,]h.]uh0jh jW!ubhp - if a literal string or expression is given for this argument, it defines an expression that should cause the }(hp - if a literal string or expression is given for this argument, it defines an expression that should cause the h jW!ubh)}(hSkipTo_h]hSkipTo}(hSkipToh jn!ubah#}(h%]h']h*]h,]h.]namejv!hh"MRh jS!ubah#}(h%]h']h*]h,]h.]uh0jh j!ubeh#}(h%]h']h*]h,]h.]j j uh0jh!h>h"MLh j ubh`)}(h.``SkipTo`` can also be written using ``...``::h](j)}(h ``SkipTo``h]hSkipTo}(hhh j!ubah#}(h%]h']h*]h,]h.]uh0jh j!ubh can also be written using }(h can also be written using h j!ubj)}(h``...``h]h...}(hhh j!ubah#}(h%]h']h*]h,]h.]uh0jh j!ubh:}(h:h j!ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"MUh j ubjd)}(hLBRACE, RBRACE = map(Literal, "{}") brace_expr = LBRACE + SkipTo(RBRACE) + RBRACE # can also be written as brace_expr = LBRACE + ... + RBRACEh]hLBRACE, RBRACE = map(Literal, "{}") brace_expr = LBRACE + SkipTo(RBRACE) + RBRACE # can also be written as brace_expr = LBRACE + ... + RBRACE}(hhh j!ubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"MWh j ubeh#}(h%]h']h*]h,]h.]uh0jh j hhh!h>h"Nubah#}(h%]j ah']h*]skiptoah,]h.]j j uh0jh!h>h"MHh jlhhjN}j!j sjP}j j sjKubj)}(h .. _White:h]h#}(h%]h']h*]h,]h.]hjKubj)}(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]hWhite}(hhh j!ubah#}(h%]h']h*]h,]h.]uh0jh j!ubh - also similar to }(h - also similar to h j!ubh)}(hWord_h]hWord}(hWordh j "ubah#}(h%]h']h*]h,]h.]namej"hh"M_h j!ubah#}(h%]h']h*]h,]h.]uh0jh j!hhh!h>h"Nubj)}(h~``Empty`` - a null expression, requiring no characters - will always match; useful for debugging and for specialized grammars h]h`)}(h}``Empty`` - a null expression, requiring no characters - will always match; useful for debugging and for specialized grammarsh](j)}(h ``Empty``h]hEmpty}(hhh jH"ubah#}(h%]h']h*]h,]h.]uh0jh jD"ubht - a null expression, requiring no characters - will always match; useful for debugging and for specialized grammars}(ht - a null expression, requiring no characters - will always match; useful for debugging and for specialized grammarsh jD"ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mfh j@"ubah#}(h%]h']h*]h,]h.]uh0jh j!hhh!h>h"Nubj)}(hj``NoMatch`` - opposite of ``Empty``, will never match; useful for debugging and for specialized grammars h]h`)}(hh``NoMatch`` - opposite of ``Empty``, will never match; useful for debugging and for specialized grammarsh](j)}(h ``NoMatch``h]hNoMatch}(hhh jo"ubah#}(h%]h']h*]h,]h.]uh0jh jk"ubh - opposite of }(h - opposite of h jk"ubj)}(h ``Empty``h]hEmpty}(hhh j"ubah#}(h%]h']h*]h,]h.]uh0jh jk"ubhE, will never match; useful for debugging and for specialized grammars}(hE, will never match; useful for debugging and for specialized grammarsh jk"ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mih jg"ubah#}(h%]h']h*]h,]h.]uh0jh j!hhh!h>h"Nubeh#}(h%]jah']h*]whiteah,]h.]j j uh0jh!h>h"M_h jlhhjN}j"j!sjP}jj!sjKubeh#}(h%]jah']h*]basic parserelement subclassesah,]h.]uh0h h j(hhh!h>h"Mubh )}(hhh](h)}(hj!h](h)}(hhh]h 1.2.3   }(hhh j"hhh!Nh"Nubah#}(h%]h']h)ah*]h,]h.]uh0hh j"hhh!Nh"NubhExpression subclasses}(hj!h j"hhh!Nh"Nubeh#}(h%]h']h*]h,]h.]h;Khh"Mnubj)}(h.. _And:h]h#}(h%]h']h*]h,]h.]hjKubj)}(hhh]j)}(hX``And`` - construct with a list of ``ParserElements``, all of which must match for ``And`` to match; can also be created using the '+' operator; multiple expressions can be ``Anded`` together using the '*' operator as in:: ip_address = Word(nums) + ('.' + Word(nums)) * 3 A tuple can be used as the multiplier, indicating a min/max:: us_phone_number = Word(nums) + ('-' + Word(nums)) * (1,2) A special form of ``And`` is created if the '-' operator is used instead of the '+' operator. In the ``ip_address`` example above, if no trailing '.' and ``Word(nums)`` are found after matching the initial ``Word(nums)``, then pyparsing will back up in the grammar and try other alternatives to ``ip_address``. However, if ``ip_address`` is defined as:: strict_ip_address = Word(nums) - ('.'+Word(nums))*3 then no backing up is done. If the first ``Word(nums)`` of ``strict_ip_address`` is matched, then any mismatch after that will raise a ``ParseSyntaxException``, which will halt the parsing process immediately. By careful use of the '-' operator, grammars can provide meaningful error messages close to the location where the incoming text does not match the specified grammar. h](h`)}(h``And`` - construct with a list of ``ParserElements``, all of which must match for ``And`` to match; can also be created using the '+' operator; multiple expressions can be ``Anded`` together using the '*' operator as in::h](j)}(h``And``h]hAnd}(hhh j"ubah#}(h%]h']h*]h,]h.]uh0jh j"ubh - construct with a list of }(h - construct with a list of h j"ubj)}(h``ParserElements``h]hParserElements}(hhh j"ubah#}(h%]h']h*]h,]h.]uh0jh j"ubh, all of which must match for }(h, all of which must match for h j"ubj)}(h``And``h]hAnd}(hhh j #ubah#}(h%]h']h*]h,]h.]uh0jh j"ubhW to match; can also be created using the ‘+’ operator; multiple expressions can be }(hS to match; can also be created using the '+' operator; multiple expressions can be h j"ubj)}(h ``Anded``h]hAnded}(hhh j#ubah#}(h%]h']h*]h,]h.]uh0jh j"ubh+ together using the ‘*’ operator as in:}(h' together using the '*' operator as in:h j"ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mrh j"ubjd)}(h0ip_address = Word(nums) + ('.' + Word(nums)) * 3h]h0ip_address = Word(nums) + ('.' + Word(nums)) * 3}(hhh j5#ubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"Mwh j"ubh`)}(h=A tuple can be used as the multiplier, indicating a min/max::h]hh"Myh j"ubjd)}(h9us_phone_number = Word(nums) + ('-' + Word(nums)) * (1,2)h]h9us_phone_number = Word(nums) + ('-' + Word(nums)) * (1,2)}(hhh jR#ubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"M{h j"ubh`)}(hXcA special form of ``And`` is created if the '-' operator is used instead of the '+' operator. In the ``ip_address`` example above, if no trailing '.' and ``Word(nums)`` are found after matching the initial ``Word(nums)``, then pyparsing will back up in the grammar and try other alternatives to ``ip_address``. However, if ``ip_address`` is defined as::h](hA special form of }(hA special form of h j`#ubj)}(h``And``h]hAnd}(hhh ji#ubah#}(h%]h']h*]h,]h.]uh0jh j`#ubhU is created if the ‘-‘ operator is used instead of the ‘+’ operator. In the }(hM is created if the '-' operator is used instead of the '+' operator. In the h j`#ubj)}(h``ip_address``h]h ip_address}(hhh j|#ubah#}(h%]h']h*]h,]h.]uh0jh j`#ubh+ example above, if no trailing ‘.’ and }(h' example above, if no trailing '.' and h j`#ubj)}(h``Word(nums)``h]h Word(nums)}(hhh j#ubah#}(h%]h']h*]h,]h.]uh0jh j`#ubh& are found after matching the initial }(h& are found after matching the initial h j`#ubj)}(h``Word(nums)``h]h Word(nums)}(hhh j#ubah#}(h%]h']h*]h,]h.]uh0jh j`#ubhK, then pyparsing will back up in the grammar and try other alternatives to }(hK, then pyparsing will back up in the grammar and try other alternatives to h j`#ubj)}(h``ip_address``h]h ip_address}(hhh j#ubah#}(h%]h']h*]h,]h.]uh0jh j`#ubh. However, if }(h. However, if h j`#ubj)}(h``ip_address``h]h ip_address}(hhh j#ubah#}(h%]h']h*]h,]h.]uh0jh j`#ubh is defined as:}(h is defined as:h j`#ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M}h j"ubjd)}(h3strict_ip_address = Word(nums) - ('.'+Word(nums))*3h]h3strict_ip_address = Word(nums) - ('.'+Word(nums))*3}(hhh j#ubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"Mh j"ubh`)}(hXzthen no backing up is done. If the first ``Word(nums)`` of ``strict_ip_address`` is matched, then any mismatch after that will raise a ``ParseSyntaxException``, which will halt the parsing process immediately. By careful use of the '-' operator, grammars can provide meaningful error messages close to the location where the incoming text does not match the specified grammar.h](h*then no backing up is done. If the first }(h*then no backing up is done. If the first h j#ubj)}(h``Word(nums)``h]h Word(nums)}(hhh j#ubah#}(h%]h']h*]h,]h.]uh0jh j#ubh of }(h of h j#ubj)}(h``strict_ip_address``h]hstrict_ip_address}(hhh j $ubah#}(h%]h']h*]h,]h.]uh0jh j#ubh7 is matched, then any mismatch after that will raise a }(h7 is matched, then any mismatch after that will raise a h j#ubj)}(h``ParseSyntaxException``h]hParseSyntaxException}(hhh j$ubah#}(h%]h']h*]h,]h.]uh0jh j#ubh, which will halt the parsing process immediately. By careful use of the ‘-‘ operator, grammars can provide meaningful error messages close to the location where the incoming text does not match the specified grammar.}(h, which will halt the parsing process immediately. By careful use of the '-' operator, grammars can provide meaningful error messages close to the location where the incoming text does not match the specified grammar.h j#ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j"ubeh#}(h%]h']h*]h,]h.]uh0jh j"hhh!h>h"Nubah#}(h%]jah']h*]andah,]h.]j j uh0jh!h>h"Mrh j"hhjN}jA$j"sjP}jj"sjKubj)}(h.. _Or:h]h#}(h%]h']h*]h,]h.]hjKubj)}(hhh]j)}(h``Or`` - construct with a list of ``ParserElements``, any of which must match for ``Or`` to match; if more than one expression matches, the expression that makes the longest match will be used; can also be created using the '^' operator h]h`)}(h``Or`` - construct with a list of ``ParserElements``, any of which must match for ``Or`` to match; if more than one expression matches, the expression that makes the longest match will be used; can also be created using the '^' operatorh](j)}(h``Or``h]hOr}(hhh j[$ubah#}(h%]h']h*]h,]h.]uh0jh jW$ubh - construct with a list of }(h - construct with a list of h jW$ubj)}(h``ParserElements``h]hParserElements}(hhh jn$ubah#}(h%]h']h*]h,]h.]uh0jh jW$ubh, any of which must match for }(h, any of which must match for h jW$ubj)}(h``Or``h]hOr}(hhh j$ubah#}(h%]h']h*]h,]h.]uh0jh jW$ubh to match; if more than one expression matches, the expression that makes the longest match will be used; can also be created using the ‘^’ operator}(h to match; if more than one expression matches, the expression that makes the longest match will be used; can also be created using the '^' operatorh jW$ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jS$ubah#}(h%]h']h*]h,]h.]uh0jh jP$hhh!h>h"Nubah#}(h%]j ah']h*]orah,]h.]j j uh0jh!h>h"Mh j"hhjN}j$jF$sjP}j jF$sjKubj)}(h.. _MatchFirst:h]h#}(h%]h']h*]h,]h.]hjKubj)}(hhh]j)}(h``MatchFirst`` - construct with a list of ``ParserElements``, any of which must match for ``MatchFirst`` to match; matching is done left-to-right, taking the first expression that matches; can also be created using the '|' operator h]h`)}(h``MatchFirst`` - construct with a list of ``ParserElements``, any of which must match for ``MatchFirst`` to match; matching is done left-to-right, taking the first expression that matches; can also be created using the '|' operatorh](j)}(h``MatchFirst``h]h MatchFirst}(hhh j$ubah#}(h%]h']h*]h,]h.]uh0jh j$ubh - construct with a list of }(h - construct with a list of h j$ubj)}(h``ParserElements``h]hParserElements}(hhh j$ubah#}(h%]h']h*]h,]h.]uh0jh j$ubh, any of which must match for }(h, any of which must match for h j$ubj)}(h``MatchFirst``h]h MatchFirst}(hhh j$ubah#}(h%]h']h*]h,]h.]uh0jh j$ubh to match; matching is done left-to-right, taking the first expression that matches; can also be created using the ‘|’ operator}(h to match; matching is done left-to-right, taking the first expression that matches; can also be created using the '|' operatorh j$ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j$ubah#}(h%]h']h*]h,]h.]uh0jh j$hhh!h>h"Nubah#}(h%]j ah']h*] matchfirstah,]h.]j j uh0jh!h>h"Mh j"hhjN}j%j$sjP}j j$sjKubj)}(h .. _Each:h]h#}(h%]h']h*]h,]h.]h<eachuh0jh"Mh j"hhh!h>jKubj)}(hhh](j)}(h``Each`` - similar to And_, in that all of the provided expressions must match; however, ``Each`` permits matching to be done in any order; can also be created using the '&' operator h]h`)}(h``Each`` - similar to And_, in that all of the provided expressions must match; however, ``Each`` permits matching to be done in any order; can also be created using the '&' operatorh](j)}(h``Each``h]hEach}(hhh j"%ubah#}(h%]h']h*]h,]h.]uh0jh j%ubh - similar to }(h - similar to h j%ubh)}(hAnd_h]hAnd}(hAndh j5%ubah#}(h%]h']h*]h,]h.]namej=%hh"Mh j%ubah#}(h%]h']h*]h,]h.]uh0jh j%hhh!h>h"Nubj)}(hXk``Opt`` - construct with a ``ParserElement``, but this element is not required to match; can be constructed with an optional ``default`` argument, containing a default string or object to be supplied if the given optional parse element is not found in the input string; parse action will only be called if a match is found, or if a default is specified. (``Opt`` was formerly named ``Optional``, but since the standard Python library module ``typing`` now defines ``Optional``, the pyparsing class has been renamed to ``Opt``. A compatibility synonym ``Optional`` is defined, but will be removed in a future release.) h](h`)}(hXa``Opt`` - construct with a ``ParserElement``, but this element is not required to match; can be constructed with an optional ``default`` argument, containing a default string or object to be supplied if the given optional parse element is not found in the input string; parse action will only be called if a match is found, or if a default is specified.h](j)}(h``Opt``h]hOpt}(hhh jq%ubah#}(h%]h']h*]h,]h.]uh0jh jm%ubh - construct with a }(h - construct with a h jm%ubj)}(h``ParserElement``h]h ParserElement}(hhh j%ubah#}(h%]h']h*]h,]h.]uh0jh jm%ubhQ, but this element is not required to match; can be constructed with an optional }(hQ, but this element is not required to match; can be constructed with an optional h jm%ubj)}(h ``default``h]hdefault}(hhh j%ubah#}(h%]h']h*]h,]h.]uh0jh jm%ubh argument, containing a default string or object to be supplied if the given optional parse element is not found in the input string; parse action will only be called if a match is found, or if a default is specified.}(h argument, containing a default string or object to be supplied if the given optional parse element is not found in the input string; parse action will only be called if a match is found, or if a default is specified.h jm%ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh ji%ubh`)}(hX(``Opt`` was formerly named ``Optional``, but since the standard Python library module ``typing`` now defines ``Optional``, the pyparsing class has been renamed to ``Opt``. A compatibility synonym ``Optional`` is defined, but will be removed in a future release.)h](h(}(h(h j%ubj)}(h``Opt``h]hOpt}(hhh j%ubah#}(h%]h']h*]h,]h.]uh0jh j%ubh was formerly named }(h was formerly named h j%ubj)}(h ``Optional``h]hOptional}(hhh j%ubah#}(h%]h']h*]h,]h.]uh0jh j%ubh/, but since the standard Python library module }(h/, but since the standard Python library module h j%ubj)}(h ``typing``h]htyping}(hhh j%ubah#}(h%]h']h*]h,]h.]uh0jh j%ubh now defines }(h now defines h j%ubj)}(h ``Optional``h]hOptional}(hhh j%ubah#}(h%]h']h*]h,]h.]uh0jh j%ubh*, the pyparsing class has been renamed to }(h*, the pyparsing class has been renamed to h j%ubj)}(h``Opt``h]hOpt}(hhh j&ubah#}(h%]h']h*]h,]h.]uh0jh j%ubh. A compatibility synonym }(h. A compatibility synonym h j%ubj)}(h ``Optional``h]hOptional}(hhh j&ubah#}(h%]h']h*]h,]h.]uh0jh j%ubh6 is defined, but will be removed in a future release.)}(h6 is defined, but will be removed in a future release.)h j%ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh ji%ubeh#}(h%]h']h*]h,]h.]uh0jh j%hhh!h>h"Nubj)}(hu``ZeroOrMore`` - similar to ``Opt``, but can be repeated; ``ZeroOrMore(expr)`` can also be written as ``expr[...]``. h]h`)}(ht``ZeroOrMore`` - similar to ``Opt``, but can be repeated; ``ZeroOrMore(expr)`` can also be written as ``expr[...]``.h](j)}(h``ZeroOrMore``h]h ZeroOrMore}(hhh j?&ubah#}(h%]h']h*]h,]h.]uh0jh j;&ubh - similar to }(h - similar to h j;&ubj)}(h``Opt``h]hOpt}(hhh jR&ubah#}(h%]h']h*]h,]h.]uh0jh j;&ubh, but can be repeated; }(h, but can be repeated; h j;&ubj)}(h``ZeroOrMore(expr)``h]hZeroOrMore(expr)}(hhh je&ubah#}(h%]h']h*]h,]h.]uh0jh j;&ubh can also be written as }(h can also be written as h j;&ubj)}(h ``expr[...]``h]h expr[...]}(hhh jx&ubah#}(h%]h']h*]h,]h.]uh0jh j;&ubh.}(hj h j;&ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j7&ubah#}(h%]h']h*]h,]h.]uh0jh j%hhh!h>h"Nubj)}(h``OneOrMore`` - similar to ``ZeroOrMore``, but at least one match must be present; ``OneOrMore(expr)`` can also be written as ``expr[1, ...]``. h]h`)}(h``OneOrMore`` - similar to ``ZeroOrMore``, but at least one match must be present; ``OneOrMore(expr)`` can also be written as ``expr[1, ...]``.h](j)}(h ``OneOrMore``h]h OneOrMore}(hhh j&ubah#}(h%]h']h*]h,]h.]uh0jh j&ubh - similar to }(h - similar to h j&ubj)}(h``ZeroOrMore``h]h ZeroOrMore}(hhh j&ubah#}(h%]h']h*]h,]h.]uh0jh j&ubh*, but at least one match must be present; }(h*, but at least one match must be present; h j&ubj)}(h``OneOrMore(expr)``h]hOneOrMore(expr)}(hhh j&ubah#}(h%]h']h*]h,]h.]uh0jh j&ubh can also be written as }(h can also be written as h j&ubj)}(h``expr[1, ...]``h]h expr[1, ...]}(hhh j&ubah#}(h%]h']h*]h,]h.]uh0jh j&ubh.}(hj h j&ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j&ubah#}(h%]h']h*]h,]h.]uh0jh j%hhh!h>h"Nubj)}(h``FollowedBy`` - a lookahead expression, requires matching of the given expressions, but does not advance the parsing position within the input string h]h`)}(h``FollowedBy`` - a lookahead expression, requires matching of the given expressions, but does not advance the parsing position within the input stringh](j)}(h``FollowedBy``h]h FollowedBy}(hhh j&ubah#}(h%]h']h*]h,]h.]uh0jh j&ubh - a lookahead expression, requires matching of the given expressions, but does not advance the parsing position within the input string}(h - a lookahead expression, requires matching of the given expressions, but does not advance the parsing position within the input stringh j&ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j&ubah#}(h%]h']h*]h,]h.]uh0jh j%hhh!h>h"Nubeh#}(h%]j%ah']h*]eachah,]h.]j j uh0jh!h>h"Mh j"hhjN}j 'j %sjP}j%j %sjKubj)}(h .. _NotAny:h]h#}(h%]h']h*]h,]h.]h<notanyuh0jh"Mh j"hhh!h>jKubj)}(hhh]j)}(h``NotAny`` - a negative lookahead expression, prevents matching of named expressions, does not advance the parsing position within the input string; can also be created using the unary '~' operator h]h`)}(h``NotAny`` - a negative lookahead expression, prevents matching of named expressions, does not advance the parsing position within the input string; can also be created using the unary '~' operatorh](j)}(h ``NotAny``h]hNotAny}(hhh j;'ubah#}(h%]h']h*]h,]h.]uh0jh j7'ubh - a negative lookahead expression, prevents matching of named expressions, does not advance the parsing position within the input string; can also be created using the unary ‘~’ operator}(h - a negative lookahead expression, prevents matching of named expressions, does not advance the parsing position within the input string; can also be created using the unary '~' operatorh j7'ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j3'ubah#}(h%]h']h*]h,]h.]uh0jh j0'hhh!h>h"Nubah#}(h%]j/'ah']h*]notanyah,]h.]j j uh0jh!h>h"Mh j"hhjN}j^'j%'sjP}j/'j%'sjKubj)}(h.. _operators:h]h#}(h%]h']h*]h,]h.]hjKubeh#}(h%]j*ah']h*]expression subclassesah,]h.]uh0h h j(hhh!h>h"Mnubh )}(hhh](h)}(hjQh](h)}(hhh]h 1.2.4   }(hhh jz'hhh!Nh"Nubah#}(h%]h']h)ah*]h,]h.]uh0hh jw'hhh!Nh"NubhExpression operators}(hjQh jw'hhh!Nh"Nubeh#}(h%]h']h*]h,]h.]h;Khh"Mubj)}(hhh](j)}(hI``+`` - creates And_ using the expressions before and after the operator h]h`)}(hH``+`` - creates And_ using the expressions before and after the operatorh](j)}(h``+``h]h+}(hhh j'ubah#}(h%]h']h*]h,]h.]uh0jh j'ubh - creates }(h - creates h j'ubh)}(hAnd_h]hAnd}(hAndh j'ubah#}(h%]h']h*]h,]h.]namej'hh"Mh j'ubah#}(h%]h']h*]h,]h.]uh0jh j'hhh!h>h"Nubj)}(hl``|`` - creates MatchFirst_ (first left-to-right match) using the expressions before and after the operator h]h`)}(hk``|`` - creates MatchFirst_ (first left-to-right match) using the expressions before and after the operatorh](j)}(h``|``h]h|}(hhh j'ubah#}(h%]h']h*]h,]h.]uh0jh j'ubh - creates }(h - creates h j'ubh)}(h MatchFirst_h]h MatchFirst}(h MatchFirsth j'ubah#}(h%]h']h*]h,]h.]namej'hh"Mh j'ubah#}(h%]h']h*]h,]h.]uh0jh j'hhh!h>h"Nubj)}(hX``^`` - creates Or_ (longest match) using the expressions before and after the operator h]h`)}(hW``^`` - creates Or_ (longest match) using the expressions before and after the operatorh](j)}(h``^``h]h^}(hhh j(ubah#}(h%]h']h*]h,]h.]uh0jh j(ubh - creates }(h - creates h j(ubh)}(hOr_h]hOr}(hOrh j'(ubah#}(h%]h']h*]h,]h.]namej/(hh"Mh j (ubah#}(h%]h']h*]h,]h.]uh0jh j'hhh!h>h"Nubj)}(hJ``&`` - creates Each_ using the expressions before and after the operator h]h`)}(hI``&`` - creates Each_ using the expressions before and after the operatorh](j)}(h``&``h]h&}(hhh jP(ubah#}(h%]h']h*]h,]h.]uh0jh jL(ubh - creates }(h - creates h jL(ubh)}(hEach_h]hEach}(hEachh jc(ubah#}(h%]h']h*]h,]h.]namejk(hh"Mh jH(ubah#}(h%]h']h*]h,]h.]uh0jh j'hhh!h>h"Nubj)}(hXQ``*`` - creates And_ by multiplying the expression by the integer operand; if expression is multiplied by a 2-tuple, creates an And_ of ``(min,max)`` expressions (similar to ``{min,max}`` form in regular expressions); if ``min`` is ``None``, interpret as ``(0,max)``; if ``max`` is ``None``, interpret as ``expr*min + ZeroOrMore(expr)`` h]h`)}(hXP``*`` - creates And_ by multiplying the expression by the integer operand; if expression is multiplied by a 2-tuple, creates an And_ of ``(min,max)`` expressions (similar to ``{min,max}`` form in regular expressions); if ``min`` is ``None``, interpret as ``(0,max)``; if ``max`` is ``None``, interpret as ``expr*min + ZeroOrMore(expr)``h](j)}(h``*``h]h*}(hhh j(ubah#}(h%]h']h*]h,]h.]uh0jh j(ubh - creates }(h - creates h j(ubh)}(hAnd_h]hAnd}(hAndh j(ubah#}(h%]h']h*]h,]h.]namej(hh"Mh j(ubah#}(h%]h']h*]h,]h.]uh0jh j'hhh!h>h"Nubj)}(h@``-`` - like ``+`` but with no backup and retry of alternatives h]h`)}(h?``-`` - like ``+`` but with no backup and retry of alternativesh](j)}(h``-``h]h-}(hhh jo)ubah#}(h%]h']h*]h,]h.]uh0jh jk)ubh - like }(h - like h jk)ubj)}(h``+``h]h+}(hhh j)ubah#}(h%]h']h*]h,]h.]uh0jh jk)ubh- but with no backup and retry of alternatives}(h- but with no backup and retry of alternativesh jk)ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jg)ubah#}(h%]h']h*]h,]h.]uh0jh j'hhh!h>h"Nubj)}(h@``~`` - creates NotAny_ using the expression after the operator h]h`)}(h?``~`` - creates NotAny_ using the expression after the operatorh](j)}(h``~``h]h~}(hhh j)ubah#}(h%]h']h*]h,]h.]uh0jh j)ubh - creates }(h - creates h j)ubh)}(hNotAny_h]hNotAny}(hNotAnyh j)ubah#}(h%]h']h*]h,]h.]namej)hh"Mh j)ubah#}(h%]h']h*]h,]h.]uh0jh j'hhh!h>h"Nubj)}(hd``==`` - matching expression to string; returns ``True`` if the string matches the given expression h]h`)}(hc``==`` - matching expression to string; returns ``True`` if the string matches the given expressionh](j)}(h``==``h]h==}(hhh j)ubah#}(h%]h']h*]h,]h.]uh0jh j)ubh* - matching expression to string; returns }(h* - matching expression to string; returns h j)ubj)}(h``True``h]hTrue}(hhh j)ubah#}(h%]h']h*]h,]h.]uh0jh j)ubh+ if the string matches the given expression}(h+ if the string matches the given expressionh j)ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j)ubah#}(h%]h']h*]h,]h.]uh0jh j'hhh!h>h"Nubj)}(h``<<=`` - inserts the expression following the operator as the body of the ``Forward`` expression before the operator (``<<`` can also be used, but ``<<=`` is preferred to avoid operator precedence misinterpretation of the pyparsing expression) h]h`)}(h``<<=`` - inserts the expression following the operator as the body of the ``Forward`` expression before the operator (``<<`` can also be used, but ``<<=`` is preferred to avoid operator precedence misinterpretation of the pyparsing expression)h](j)}(h``<<=``h]h<<=}(hhh j*ubah#}(h%]h']h*]h,]h.]uh0jh j*ubhD - inserts the expression following the operator as the body of the }(hD - inserts the expression following the operator as the body of the h j*ubj)}(h ``Forward``h]hForward}(hhh j2*ubah#}(h%]h']h*]h,]h.]uh0jh j*ubh! expression before the operator (}(h! expression before the operator (h j*ubj)}(h``<<``h]h<<}(hhh jE*ubah#}(h%]h']h*]h,]h.]uh0jh j*ubh can also be used, but }(h can also be used, but h j*ubj)}(h``<<=``h]h<<=}(hhh jX*ubah#}(h%]h']h*]h,]h.]uh0jh j*ubhY is preferred to avoid operator precedence misinterpretation of the pyparsing expression)}(hY is preferred to avoid operator precedence misinterpretation of the pyparsing expression)h j*ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j*ubah#}(h%]h']h*]h,]h.]uh0jh j'hhh!h>h"Nubj)}(hz``...`` - inserts a SkipTo_ expression leading to the next expression, as in ``Keyword("start") + ... + Keyword("end")``. h]h`)}(hy``...`` - inserts a SkipTo_ expression leading to the next expression, as in ``Keyword("start") + ... + Keyword("end")``.h](j)}(h``...``h]h...}(hhh j*ubah#}(h%]h']h*]h,]h.]uh0jh j{*ubh - inserts a }(h - inserts a h j{*ubh)}(hSkipTo_h]hSkipTo}(hSkipToh j*ubah#}(h%]h']h*]h,]h.]namej*hh"Mh jw*ubah#}(h%]h']h*]h,]h.]uh0jh j'hhh!h>h"Nubj)}(hXv``[min, max]`` - specifies repetition similar to ``*`` with ``min`` and ``max`` specified as the minimum and maximum number of repetitions. ``...`` can be used in place of ``None``. For example ``expr[...]`` is equivalent to ``ZeroOrMore(expr)``, ``expr[1, ...]`` is equivalent to ``OneOrMore(expr)``, and ``expr[..., 3]`` is equivalent to "up to 3 instances of ``expr``". h]h`)}(hXt``[min, max]`` - specifies repetition similar to ``*`` with ``min`` and ``max`` specified as the minimum and maximum number of repetitions. ``...`` can be used in place of ``None``. For example ``expr[...]`` is equivalent to ``ZeroOrMore(expr)``, ``expr[1, ...]`` is equivalent to ``OneOrMore(expr)``, and ``expr[..., 3]`` is equivalent to "up to 3 instances of ``expr``".h](j)}(h``[min, max]``h]h [min, max]}(hhh j*ubah#}(h%]h']h*]h,]h.]uh0jh j*ubh# - specifies repetition similar to }(h# - specifies repetition similar to h j*ubj)}(h``*``h]h*}(hhh j*ubah#}(h%]h']h*]h,]h.]uh0jh j*ubh with }(h with h j*ubj)}(h``min``h]hmin}(hhh j*ubah#}(h%]h']h*]h,]h.]uh0jh j*ubh and }(h and h j*ubj)}(h``max``h]hmax}(hhh j+ubah#}(h%]h']h*]h,]h.]uh0jh j*ubh= specified as the minimum and maximum number of repetitions. }(h= specified as the minimum and maximum number of repetitions. h j*ubj)}(h``...``h]h...}(hhh j+ubah#}(h%]h']h*]h,]h.]uh0jh j*ubh can be used in place of }(h can be used in place of h j*ubj)}(h``None``h]hNone}(hhh j,+ubah#}(h%]h']h*]h,]h.]uh0jh j*ubh. For example }(h. For example h j*ubj)}(h ``expr[...]``h]h expr[...]}(hhh j?+ubah#}(h%]h']h*]h,]h.]uh0jh j*ubh is equivalent to }(h is equivalent to h j*ubj)}(h``ZeroOrMore(expr)``h]hZeroOrMore(expr)}(hhh jR+ubah#}(h%]h']h*]h,]h.]uh0jh j*ubh, }(h, h j*ubj)}(h``expr[1, ...]``h]h expr[1, ...]}(hhh je+ubah#}(h%]h']h*]h,]h.]uh0jh j*ubh is equivalent to }(h is equivalent to h j*ubj)}(h``OneOrMore(expr)``h]hOneOrMore(expr)}(hhh jx+ubah#}(h%]h']h*]h,]h.]uh0jh j*ubh, and }(h, and h j*ubj)}(h``expr[..., 3]``h]h expr[..., 3]}(hhh j+ubah#}(h%]h']h*]h,]h.]uh0jh j*ubh* is equivalent to “up to 3 instances of }(h( is equivalent to "up to 3 instances of h j*ubj)}(h``expr``h]hexpr}(hhh j+ubah#}(h%]h']h*]h,]h.]uh0jh j*ubh”.}(h".h j*ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j*ubah#}(h%]h']h*]h,]h.]uh0jh j'hhh!h>h"Nubeh#}(h%]h']h*]h,]h.]j j uh0jh!h>h"Mh jt'hhubeh#}(h%](jZjeh']h*](expression operators operatorseh,]h.]uh0h h j(hhh!h>h"MjN}j+jc'sjP}jjc'sjKubh )}(hhh](h)}(hjh](h)}(hhh]h 1.2.5   }(hhh j+hhh!Nh"Nubah#}(h%]h']h)ah*]h,]h.]uh0hh j+hhh!Nh"NubhPositional subclasses}(hjh j+hhh!Nh"Nubeh#}(h%]h']h*]h,]h.]h;Khh"Mubj)}(hhh](j)}(h0``StringStart`` - matches beginning of the text h]h`)}(h/``StringStart`` - matches beginning of the texth](j)}(h``StringStart``h]h StringStart}(hhh j+ubah#}(h%]h']h*]h,]h.]uh0jh j+ubh - matches beginning of the text}(h - matches beginning of the texth j+ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j+ubah#}(h%]h']h*]h,]h.]uh0jh j+hhh!h>h"Nubj)}(h,``StringEnd`` - matches the end of the text h]h`)}(h+``StringEnd`` - matches the end of the texth](j)}(h ``StringEnd``h]h StringEnd}(hhh j,ubah#}(h%]h']h*]h,]h.]uh0jh j,ubh - matches the end of the text}(h - matches the end of the texth j,ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j,ubah#}(h%]h']h*]h,]h.]uh0jh j+hhh!h>h"Nubj)}(hS``LineStart`` - matches beginning of a line (lines delimited by ``\n`` characters) h]h`)}(hR``LineStart`` - matches beginning of a line (lines delimited by ``\n`` characters)h](j)}(h ``LineStart``h]h LineStart}(hhh jC,ubah#}(h%]h']h*]h,]h.]uh0jh j?,ubh3 - matches beginning of a line (lines delimited by }(h3 - matches beginning of a line (lines delimited by h j?,ubj)}(h``\n``h]h\n}(hhh jV,ubah#}(h%]h']h*]h,]h.]uh0jh j?,ubh characters)}(h characters)h j?,ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j;,ubah#}(h%]h']h*]h,]h.]uh0jh j+hhh!h>h"Nubj)}(h(``LineEnd`` - matches the end of a line h]h`)}(h'``LineEnd`` - matches the end of a lineh](j)}(h ``LineEnd``h]hLineEnd}(hhh j},ubah#}(h%]h']h*]h,]h.]uh0jh jy,ubh - matches the end of a line}(h - matches the end of a lineh jy,ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh ju,ubah#}(h%]h']h*]h,]h.]uh0jh j+hhh!h>h"Nubj)}(h0``WordStart`` - matches a leading word boundary h]h`)}(h/``WordStart`` - matches a leading word boundaryh](j)}(h ``WordStart``h]h WordStart}(hhh j,ubah#}(h%]h']h*]h,]h.]uh0jh j,ubh" - matches a leading word boundary}(h" - matches a leading word boundaryh j,ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j,ubah#}(h%]h']h*]h,]h.]uh0jh j+hhh!h>h"Nubj)}(h1``WordEnd`` - matches a trailing word boundary h]h`)}(h.``WordEnd`` - matches a trailing word boundaryh](j)}(h ``WordEnd``h]hWordEnd}(hhh j,ubah#}(h%]h']h*]h,]h.]uh0jh j,ubh# - matches a trailing word boundary}(h# - matches a trailing word boundaryh j,ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j,ubah#}(h%]h']h*]h,]h.]uh0jh j+hhh!h>h"Nubeh#}(h%]h']h*]h,]h.]j j uh0jh!h>h"Mh j+hhubeh#}(h%]jah']h*]positional subclassesah,]h.]uh0h h j(hhh!h>h"Mubh )}(hhh](h)}(hjh](h)}(hhh]h 1.2.6   }(hhh j,hhh!Nh"Nubah#}(h%]h']h)ah*]h,]h.]uh0hh j,hhh!Nh"NubhConverter subclasses}(hjh j,hhh!Nh"Nubeh#}(h%]h']h*]h,]h.]h;Khh"Mubj)}(hhh](j)}(hX ``Combine`` - joins all matched tokens into a single string, using specified ``join_string`` (default ``join_string=""``); expects all matching tokens to be adjacent, with no intervening whitespace (can be overridden by specifying ``adjacent=False`` in constructor) h]h`)}(hX ``Combine`` - joins all matched tokens into a single string, using specified ``join_string`` (default ``join_string=""``); expects all matching tokens to be adjacent, with no intervening whitespace (can be overridden by specifying ``adjacent=False`` in constructor)h](j)}(h ``Combine``h]hCombine}(hhh j-ubah#}(h%]h']h*]h,]h.]uh0jh j-ubhB - joins all matched tokens into a single string, using specified }(hB - joins all matched tokens into a single string, using specified h j-ubj)}(h``join_string``h]h join_string}(hhh j2-ubah#}(h%]h']h*]h,]h.]uh0jh j-ubh (default }(h (default h j-ubj)}(h``join_string=""``h]hjoin_string=""}(hhh jE-ubah#}(h%]h']h*]h,]h.]uh0jh j-ubho); expects all matching tokens to be adjacent, with no intervening whitespace (can be overridden by specifying }(ho); expects all matching tokens to be adjacent, with no intervening whitespace (can be overridden by specifying h j-ubj)}(h``adjacent=False``h]hadjacent=False}(hhh jX-ubah#}(h%]h']h*]h,]h.]uh0jh j-ubh in constructor)}(h in constructor)h j-ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j-ubah#}(h%]h']h*]h,]h.]uh0jh j-hhh!h>h"Nubj)}(h``Suppress`` - clears matched tokens; useful to keep returned results from being cluttered with required but uninteresting tokens (such as list delimiters) h]h`)}(h``Suppress`` - clears matched tokens; useful to keep returned results from being cluttered with required but uninteresting tokens (such as list delimiters)h](j)}(h ``Suppress``h]hSuppress}(hhh j-ubah#}(h%]h']h*]h,]h.]uh0jh j{-ubh - clears matched tokens; useful to keep returned results from being cluttered with required but uninteresting tokens (such as list delimiters)}(h - clears matched tokens; useful to keep returned results from being cluttered with required but uninteresting tokens (such as list delimiters)h j{-ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jw-ubah#}(h%]h']h*]h,]h.]uh0jh j-hhh!h>h"Nubeh#}(h%]h']h*]h,]h.]j j uh0jh!h>h"Mh j,hhubeh#}(h%]jah']h*]converter subclassesah,]h.]uh0h h j(hhh!h>h"Mubh )}(hhh](h)}(hjh](h)}(hhh]h 1.2.7   }(hhh j-hhh!Nh"Nubah#}(h%]h']h)ah*]h,]h.]uh0hh j-hhh!Nh"NubhSpecial subclasses}(hjh j-hhh!Nh"Nubeh#}(h%]h']h*]h,]h.]h;Khh"Mubj)}(hhh](j)}(h``Group`` - causes the matched tokens to be enclosed in a list; useful in repeated elements like ``ZeroOrMore`` and ``OneOrMore`` to break up matched tokens into groups for each repeated pattern h]h`)}(h``Group`` - causes the matched tokens to be enclosed in a list; useful in repeated elements like ``ZeroOrMore`` and ``OneOrMore`` to break up matched tokens into groups for each repeated patternh](j)}(h ``Group``h]hGroup}(hhh j-ubah#}(h%]h']h*]h,]h.]uh0jh j-ubhX - causes the matched tokens to be enclosed in a list; useful in repeated elements like }(hX - causes the matched tokens to be enclosed in a list; useful in repeated elements like h j-ubj)}(h``ZeroOrMore``h]h ZeroOrMore}(hhh j-ubah#}(h%]h']h*]h,]h.]uh0jh j-ubh and }(h and h j-ubj)}(h ``OneOrMore``h]h OneOrMore}(hhh j-ubah#}(h%]h']h*]h,]h.]uh0jh j-ubhA to break up matched tokens into groups for each repeated pattern}(hA to break up matched tokens into groups for each repeated patternh j-ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j-ubah#}(h%]h']h*]h,]h.]uh0jh j-hhh!h>h"Nubj)}(h``Dict`` - like ``Group``, but also constructs a dictionary, using the ``[0]``'th elements of all enclosed token lists as the keys, and each token list as the value h]h`)}(h``Dict`` - like ``Group``, but also constructs a dictionary, using the ``[0]``'th elements of all enclosed token lists as the keys, and each token list as the valueh](j)}(h``Dict``h]hDict}(hhh j .ubah#}(h%]h']h*]h,]h.]uh0jh j.ubh - like }(h - like h j.ubj)}(h ``Group``h]hGroup}(hhh j3.ubah#}(h%]h']h*]h,]h.]uh0jh j.ubh., but also constructs a dictionary, using the }(h., but also constructs a dictionary, using the h j.ubj)}(h``[0]``h]h[0]}(hhh jF.ubah#}(h%]h']h*]h,]h.]uh0jh j.ubhX’th elements of all enclosed token lists as the keys, and each token list as the value}(hV'th elements of all enclosed token lists as the keys, and each token list as the valueh j.ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j.ubah#}(h%]h']h*]h,]h.]uh0jh j-hhh!h>h"Nubj)}(h``Forward`` - placeholder token used to define recursive token patterns; when defining the actual expression later in the program, insert it into the ``Forward`` object using the ``<<=`` operator (see fourFn.py_ for an example). h]h`)}(h``Forward`` - placeholder token used to define recursive token patterns; when defining the actual expression later in the program, insert it into the ``Forward`` object using the ``<<=`` operator (see fourFn.py_ for an example).h](j)}(h ``Forward``h]hForward}(hhh jm.ubah#}(h%]h']h*]h,]h.]uh0jh ji.ubh - placeholder token used to define recursive token patterns; when defining the actual expression later in the program, insert it into the }(h - placeholder token used to define recursive token patterns; when defining the actual expression later in the program, insert it into the h ji.ubj)}(h ``Forward``h]hForward}(hhh j.ubah#}(h%]h']h*]h,]h.]uh0jh ji.ubh object using the }(h object using the h ji.ubj)}(h``<<=``h]h<<=}(hhh j.ubah#}(h%]h']h*]h,]h.]uh0jh ji.ubh operator (see }(h operator (see h ji.ubh)}(h fourFn.py_h]h fourFn.py}(h fourFn.pyh j.ubah#}(h%]h']h*]h,]h.]namej.jjd uh0hh ji.jKubh for an example).}(h for an example).h ji.ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M h je.ubah#}(h%]h']h*]h,]h.]uh0jh j-hhh!h>h"Nubeh#}(h%]h']h*]h,]h.]j j uh0j h!h>h"Mh j-hhubeh#}(h%]jah']h*]special subclassesah,]h.]uh0h h j(hhh!h>h"Mubh )}(hhh](h)}(hjh](h)}(hhh]h 1.2.8   }(hhh j.hhh!Nh"Nubah#}(h%]h']h)ah*]h,]h.]uh0hh j.hhh!Nh"Nubh Other classes}(hjh j.hhh!Nh"Nubeh#}(h%]h']h*]h,]h.]h;Khh"Mubj)}(h.. _ParseResults:h]h#}(h%]h']h*]h,]h.]hjKubj)}(hhh]j)}(hX}``ParseResults`` - class used to contain and manage the lists of tokens created from parsing the input using the user-defined parse expression. ``ParseResults`` can be accessed in a number of ways: - as a list - total list of elements can be found using ``len()`` - individual elements can be found using ``[0], [1], [-1],`` etc., or retrieved using slices - elements can be deleted using ``del`` - the ``-1``th element can be extracted and removed in a single operation using ``pop()``, or any element can be extracted and removed using ``pop(n)`` - a nested ParseResults_ can be created by using the pyparsing ``Group`` class around elements in an expression:: Word(alphas) + Group(Word(nums)[...]) + Word(alphas) will parse the string "abc 100 200 300 end" as:: ['abc', ['100', '200', '300'], 'end'] If the ``Group`` is constructed using ``aslist=True``, the resulting tokens will be a Python list instead of a ParseResults_. - as a dictionary - if ``set_results_name()`` is used to name elements within the overall parse expression, then these fields can be referenced as dictionary elements or as attributes - the ``Dict`` class generates dictionary entries using the data of the input text - in addition to ParseResults_ listed as ``[ [ a1, b1, c1, ...], [ a2, b2, c2, ...] ]`` it also acts as a dictionary with entries defined as ``{ a1 : [ b1, c1, ... ] }, { a2 : [ b2, c2, ... ] }``; this is especially useful when processing tabular data where the first column contains a key value for that line of data; when constructed with ``aslist=True``, will return an actual Python ``dict`` instead of a ParseResults_. - list elements that are deleted using ``del`` will still be accessible by their dictionary keys - supports ``get()``, ``items()`` and ``keys()`` methods, similar to a dictionary - a keyed item can be extracted and removed using ``pop(key)``. Here ``key`` must be non-numeric (such as a string), in order to use dict extraction instead of list extraction. - new named elements can be added (in a parse action, for instance), using the same syntax as adding an item to a dict (``parse_results["X"] = "new item"``); named elements can be removed using ``del parse_results["X"]`` - as a nested list - results returned from the Group class are encapsulated within their own list structure, so that the tokens can be handled as a hierarchical tree - as an object - named elements can be accessed as if they were attributes of an object: if an element is referenced that does not exist, it will return ``""``. ParseResults_ can also be converted to an ordinary list of strings by calling ``as_list()``. Note that this will strip the results of any field names that have been defined for any embedded parse elements. (The ``pprint`` module is especially good at printing out the nested contents given by ``as_list()``.) Finally, ParseResults_ can be viewed by calling ``dump()``. ``dump()`` will first show the ``as_list()`` output, followed by an indented structure listing parsed tokens that have been assigned results names. Here is sample code illustrating some of these methods:: >>> number = Word(nums) >>> name = Combine(Word(alphas)[...], adjacent=False, join_string=" ") >>> parser = number("house_number") + name("street_name") >>> result = parser.parse_string("123 Main St") >>> print(result) ['123', 'Main St'] >>> print(type(result)) >>> print(repr(result)) (['123', 'Main St'], {'house_number': ['123'], 'street_name': ['Main St']}) >>> result.house_number '123' >>> result["street_name"] 'Main St' >>> result.as_list() ['123', 'Main St'] >>> result.as_dict() {'house_number': '123', 'street_name': 'Main St'} >>> print(result.dump()) ['123', 'Main St'] - house_number: '123' - street_name: 'Main St' h](h`)}(h``ParseResults`` - class used to contain and manage the lists of tokens created from parsing the input using the user-defined parse expression. ``ParseResults`` can be accessed in a number of ways:h](j)}(h``ParseResults``h]h ParseResults}(hhh j/ubah#}(h%]h']h*]h,]h.]uh0jh j/ubh - class used to contain and manage the lists of tokens created from parsing the input using the user-defined parse expression. }(h - class used to contain and manage the lists of tokens created from parsing the input using the user-defined parse expression. h j/ubj)}(h``ParseResults``h]h ParseResults}(hhh j/ubah#}(h%]h']h*]h,]h.]uh0jh j/ubh% can be accessed in a number of ways:}(h% can be accessed in a number of ways:h j/ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j.ubj)}(hhh](j)}(hXas a list - total list of elements can be found using ``len()`` - individual elements can be found using ``[0], [1], [-1],`` etc., or retrieved using slices - elements can be deleted using ``del`` - the ``-1``th element can be extracted and removed in a single operation using ``pop()``, or any element can be extracted and removed using ``pop(n)`` - a nested ParseResults_ can be created by using the pyparsing ``Group`` class around elements in an expression:: Word(alphas) + Group(Word(nums)[...]) + Word(alphas) will parse the string "abc 100 200 300 end" as:: ['abc', ['100', '200', '300'], 'end'] If the ``Group`` is constructed using ``aslist=True``, the resulting tokens will be a Python list instead of a ParseResults_. h](h`)}(h as a listh]h as a list}(hj;/h j9/ubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j5/ubj)}(hhh](j)}(h4total list of elements can be found using ``len()`` h]h`)}(h3total list of elements can be found using ``len()``h](h*total list of elements can be found using }(h*total list of elements can be found using h jN/ubj)}(h ``len()``h]hlen()}(hhh jW/ubah#}(h%]h']h*]h,]h.]uh0jh jN/ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jJ/ubah#}(h%]h']h*]h,]h.]uh0jh jG/ubj)}(h[individual elements can be found using ``[0], [1], [-1],`` etc., or retrieved using slices h]h`)}(hZindividual elements can be found using ``[0], [1], [-1],`` etc., or retrieved using slicesh](h'individual elements can be found using }(h'individual elements can be found using h ju/ubj)}(h``[0], [1], [-1],``h]h[0], [1], [-1],}(hhh j~/ubah#}(h%]h']h*]h,]h.]uh0jh ju/ubh etc., or retrieved using slices}(h etc., or retrieved using slicesh ju/ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jq/ubah#}(h%]h']h*]h,]h.]uh0jh jG/ubj)}(h&elements can be deleted using ``del`` h]h`)}(h%elements can be deleted using ``del``h](helements can be deleted using }(helements can be deleted using h j/ubj)}(h``del``h]hdel}(hhh j/ubah#}(h%]h']h*]h,]h.]uh0jh j/ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M h j/ubah#}(h%]h']h*]h,]h.]uh0jh jG/ubj)}(hthe ``-1``th element can be extracted and removed in a single operation using ``pop()``, or any element can be extracted and removed using ``pop(n)`` h]h`)}(hthe ``-1``th element can be extracted and removed in a single operation using ``pop()``, or any element can be extracted and removed using ``pop(n)``h](hthe }(hthe h j/ubj)}(hS``-1``th element can be extracted and removed in a single operation using ``pop()``h]hO-1``th element can be extracted and removed in a single operation using ``pop()}(hhh j/ubah#}(h%]h']h*]h,]h.]uh0jh j/ubh4, or any element can be extracted and removed using }(h4, or any element can be extracted and removed using h j/ubj)}(h ``pop(n)``h]hpop(n)}(hhh j/ubah#}(h%]h']h*]h,]h.]uh0jh j/ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M"h j/ubah#}(h%]h']h*]h,]h.]uh0jh jG/ubj)}(hXa nested ParseResults_ can be created by using the pyparsing ``Group`` class around elements in an expression:: Word(alphas) + Group(Word(nums)[...]) + Word(alphas) will parse the string "abc 100 200 300 end" as:: ['abc', ['100', '200', '300'], 'end'] If the ``Group`` is constructed using ``aslist=True``, the resulting tokens will be a Python list instead of a ParseResults_. h](h`)}(hoa nested ParseResults_ can be created by using the pyparsing ``Group`` class around elements in an expression::h](h a nested }(h a nested h j0ubh)}(h ParseResults_h]h ParseResults}(h ParseResultsh j 0ubah#}(h%]h']h*]h,]h.]namej0hh"M&h j/ubjd)}(h4Word(alphas) + Group(Word(nums)[...]) + Word(alphas)h]h4Word(alphas) + Group(Word(nums)[...]) + Word(alphas)}(hhh j90ubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"M)h j/ubh`)}(h0will parse the string "abc 100 200 300 end" as::h]h3will parse the string “abc 100 200 300 end” as:}(h/will parse the string "abc 100 200 300 end" as:h jG0ubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"M+h j/ubjd)}(h%['abc', ['100', '200', '300'], 'end']h]h%['abc', ['100', '200', '300'], 'end']}(hhh jV0ubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"M-h j/ubh`)}(h}If the ``Group`` is constructed using ``aslist=True``, the resulting tokens will be a Python list instead of a ParseResults_.h](hIf the }(hIf the h jd0ubj)}(h ``Group``h]hGroup}(hhh jm0ubah#}(h%]h']h*]h,]h.]uh0jh jd0ubh is constructed using }(h is constructed using h jd0ubj)}(h``aslist=True``h]h aslist=True}(hhh j0ubah#}(h%]h']h*]h,]h.]uh0jh jd0ubh:, the resulting tokens will be a Python list instead of a }(h:, the resulting tokens will be a Python list instead of a h jd0ubh)}(h ParseResults_h]h ParseResults}(h ParseResultsh j0ubah#}(h%]h']h*]h,]h.]namej0hh"M/h j/ubeh#}(h%]h']h*]h,]h.]uh0jh jG/ubeh#}(h%]h']h*]h,]h.]j j uh0jh!h>h"Mh j5/ubeh#}(h%]h']h*]h,]h.]uh0jh j2/ubj)}(hXas a dictionary - if ``set_results_name()`` is used to name elements within the overall parse expression, then these fields can be referenced as dictionary elements or as attributes - the ``Dict`` class generates dictionary entries using the data of the input text - in addition to ParseResults_ listed as ``[ [ a1, b1, c1, ...], [ a2, b2, c2, ...] ]`` it also acts as a dictionary with entries defined as ``{ a1 : [ b1, c1, ... ] }, { a2 : [ b2, c2, ... ] }``; this is especially useful when processing tabular data where the first column contains a key value for that line of data; when constructed with ``aslist=True``, will return an actual Python ``dict`` instead of a ParseResults_. - list elements that are deleted using ``del`` will still be accessible by their dictionary keys - supports ``get()``, ``items()`` and ``keys()`` methods, similar to a dictionary - a keyed item can be extracted and removed using ``pop(key)``. Here ``key`` must be non-numeric (such as a string), in order to use dict extraction instead of list extraction. - new named elements can be added (in a parse action, for instance), using the same syntax as adding an item to a dict (``parse_results["X"] = "new item"``); named elements can be removed using ``del parse_results["X"]`` h](h`)}(has a dictionaryh]has a dictionary}(hj0h j0ubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"M2h j0ubj)}(hhh](j)}(hif ``set_results_name()`` is used to name elements within the overall parse expression, then these fields can be referenced as dictionary elements or as attributes h]h`)}(hif ``set_results_name()`` is used to name elements within the overall parse expression, then these fields can be referenced as dictionary elements or as attributesh](hif }(hif h j0ubj)}(h``set_results_name()``h]hset_results_name()}(hhh j0ubah#}(h%]h']h*]h,]h.]uh0jh j0ubh is used to name elements within the overall parse expression, then these fields can be referenced as dictionary elements or as attributes}(h is used to name elements within the overall parse expression, then these fields can be referenced as dictionary elements or as attributesh j0ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M4h j0ubah#}(h%]h']h*]h,]h.]uh0jh j0ubj)}(hXthe ``Dict`` class generates dictionary entries using the data of the input text - in addition to ParseResults_ listed as ``[ [ a1, b1, c1, ...], [ a2, b2, c2, ...] ]`` it also acts as a dictionary with entries defined as ``{ a1 : [ b1, c1, ... ] }, { a2 : [ b2, c2, ... ] }``; this is especially useful when processing tabular data where the first column contains a key value for that line of data; when constructed with ``aslist=True``, will return an actual Python ``dict`` instead of a ParseResults_. h]h`)}(hXthe ``Dict`` class generates dictionary entries using the data of the input text - in addition to ParseResults_ listed as ``[ [ a1, b1, c1, ...], [ a2, b2, c2, ...] ]`` it also acts as a dictionary with entries defined as ``{ a1 : [ b1, c1, ... ] }, { a2 : [ b2, c2, ... ] }``; this is especially useful when processing tabular data where the first column contains a key value for that line of data; when constructed with ``aslist=True``, will return an actual Python ``dict`` instead of a ParseResults_.h](hthe }(hthe h j1ubj)}(h``Dict``h]hDict}(hhh j 1ubah#}(h%]h']h*]h,]h.]uh0jh j1ubhV class generates dictionary entries using the data of the input text - in addition to }(hV class generates dictionary entries using the data of the input text - in addition to h j1ubh)}(h ParseResults_h]h ParseResults}(h ParseResultsh j 1ubah#}(h%]h']h*]h,]h.]namej(1hh"M8h j1ubah#}(h%]h']h*]h,]h.]uh0jh j0ubj)}(h_list elements that are deleted using ``del`` will still be accessible by their dictionary keys h]h`)}(h^list elements that are deleted using ``del`` will still be accessible by their dictionary keysh](h%list elements that are deleted using }(h%list elements that are deleted using h j1ubj)}(h``del``h]hdel}(hhh j1ubah#}(h%]h']h*]h,]h.]uh0jh j1ubh2 will still be accessible by their dictionary keys}(h2 will still be accessible by their dictionary keysh j1ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M?h j1ubah#}(h%]h']h*]h,]h.]uh0jh j0ubj)}(hPsupports ``get()``, ``items()`` and ``keys()`` methods, similar to a dictionary h]h`)}(hOsupports ``get()``, ``items()`` and ``keys()`` methods, similar to a dictionaryh](h supports }(h supports h j1ubj)}(h ``get()``h]hget()}(hhh j1ubah#}(h%]h']h*]h,]h.]uh0jh j1ubh, }(h, h j1ubj)}(h ``items()``h]hitems()}(hhh j1ubah#}(h%]h']h*]h,]h.]uh0jh j1ubh and }(h and h j1ubj)}(h ``keys()``h]hkeys()}(hhh j2ubah#}(h%]h']h*]h,]h.]uh0jh j1ubh! methods, similar to a dictionary}(h! methods, similar to a dictionaryh j1ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"MBh j1ubah#}(h%]h']h*]h,]h.]uh0jh j0ubj)}(ha keyed item can be extracted and removed using ``pop(key)``. Here ``key`` must be non-numeric (such as a string), in order to use dict extraction instead of list extraction. h]h`)}(ha keyed item can be extracted and removed using ``pop(key)``. Here ``key`` must be non-numeric (such as a string), in order to use dict extraction instead of list extraction.h](h0a keyed item can be extracted and removed using }(h0a keyed item can be extracted and removed using h j#2ubj)}(h ``pop(key)``h]hpop(key)}(hhh j,2ubah#}(h%]h']h*]h,]h.]uh0jh j#2ubh. Here }(h. Here h j#2ubj)}(h``key``h]hkey}(hhh j?2ubah#}(h%]h']h*]h,]h.]uh0jh j#2ubhd must be non-numeric (such as a string), in order to use dict extraction instead of list extraction.}(hd must be non-numeric (such as a string), in order to use dict extraction instead of list extraction.h j#2ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"MDh j2ubah#}(h%]h']h*]h,]h.]uh0jh j0ubj)}(hnew named elements can be added (in a parse action, for instance), using the same syntax as adding an item to a dict (``parse_results["X"] = "new item"``); named elements can be removed using ``del parse_results["X"]`` h]h`)}(hnew named elements can be added (in a parse action, for instance), using the same syntax as adding an item to a dict (``parse_results["X"] = "new item"``); named elements can be removed using ``del parse_results["X"]``h](hvnew named elements can be added (in a parse action, for instance), using the same syntax as adding an item to a dict (}(hvnew named elements can be added (in a parse action, for instance), using the same syntax as adding an item to a dict (h jb2ubj)}(h#``parse_results["X"] = "new item"``h]hparse_results["X"] = "new item"}(hhh jk2ubah#}(h%]h']h*]h,]h.]uh0jh jb2ubh'); named elements can be removed using }(h'); named elements can be removed using h jb2ubj)}(h``del parse_results["X"]``h]hdel parse_results["X"]}(hhh j~2ubah#}(h%]h']h*]h,]h.]uh0jh jb2ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"MHh j^2ubah#}(h%]h']h*]h,]h.]uh0jh j0ubeh#}(h%]h']h*]h,]h.]j j uh0jh!h>h"M4h j0ubeh#}(h%]h']h*]h,]h.]uh0jh j2/ubj)}(has a nested list - results returned from the Group class are encapsulated within their own list structure, so that the tokens can be handled as a hierarchical tree h](h`)}(has a nested listh]has a nested list}(hj2h j2ubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"MLh j2ubj)}(hhh]j)}(hresults returned from the Group class are encapsulated within their own list structure, so that the tokens can be handled as a hierarchical tree h]h`)}(hresults returned from the Group class are encapsulated within their own list structure, so that the tokens can be handled as a hierarchical treeh]hresults returned from the Group class are encapsulated within their own list structure, so that the tokens can be handled as a hierarchical tree}(hj2h j2ubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"MNh j2ubah#}(h%]h']h*]h,]h.]uh0jh j2ubah#}(h%]h']h*]h,]h.]j j uh0jh!h>h"MNh j2ubeh#}(h%]h']h*]h,]h.]uh0jh j2/ubj)}(has an object - named elements can be accessed as if they were attributes of an object: if an element is referenced that does not exist, it will return ``""``. h](h`)}(h as an objecth]h as an object}(hj2h j2ubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"MRh j2ubj)}(hhh]j)}(hnamed elements can be accessed as if they were attributes of an object: if an element is referenced that does not exist, it will return ``""``. h]h`)}(hnamed elements can be accessed as if they were attributes of an object: if an element is referenced that does not exist, it will return ``""``.h](hnamed elements can be accessed as if they were attributes of an object: if an element is referenced that does not exist, it will return }(hnamed elements can be accessed as if they were attributes of an object: if an element is referenced that does not exist, it will return h j2ubj)}(h``""``h]h""}(hhh j2ubah#}(h%]h']h*]h,]h.]uh0jh j2ubh.}(hj h j2ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"MTh j2ubah#}(h%]h']h*]h,]h.]uh0jh j2ubah#}(h%]h']h*]h,]h.]j j uh0jh!h>h"MTh j2ubeh#}(h%]h']h*]h,]h.]uh0jh j2/ubeh#}(h%]h']h*]h,]h.]j j uh0jh!h>h"Mh j.ubh`)}(hX5ParseResults_ can also be converted to an ordinary list of strings by calling ``as_list()``. Note that this will strip the results of any field names that have been defined for any embedded parse elements. (The ``pprint`` module is especially good at printing out the nested contents given by ``as_list()``.)h](h)}(h ParseResults_h]h ParseResults}(h ParseResultsh j33ubah#}(h%]h']h*]h,]h.]namej;3hh"MWh j.ubh`)}(hFinally, ParseResults_ can be viewed by calling ``dump()``. ``dump()`` will first show the ``as_list()`` output, followed by an indented structure listing parsed tokens that have been assigned results names.h](h Finally, }(h Finally, h j3ubh)}(h ParseResults_h]h ParseResults}(h ParseResultsh j3ubah#}(h%]h']h*]h,]h.]namej3hh"M]h j.ubh`)}(h8Here is sample code illustrating some of these methods::h]h7Here is sample code illustrating some of these methods:}(h7Here is sample code illustrating some of these methods:h j3ubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mah j.ubjd)}(hX>>> number = Word(nums) >>> name = Combine(Word(alphas)[...], adjacent=False, join_string=" ") >>> parser = number("house_number") + name("street_name") >>> result = parser.parse_string("123 Main St") >>> print(result) ['123', 'Main St'] >>> print(type(result)) >>> print(repr(result)) (['123', 'Main St'], {'house_number': ['123'], 'street_name': ['Main St']}) >>> result.house_number '123' >>> result["street_name"] 'Main St' >>> result.as_list() ['123', 'Main St'] >>> result.as_dict() {'house_number': '123', 'street_name': 'Main St'} >>> print(result.dump()) ['123', 'Main St'] - house_number: '123' - street_name: 'Main St'h]hX>>> number = Word(nums) >>> name = Combine(Word(alphas)[...], adjacent=False, join_string=" ") >>> parser = number("house_number") + name("street_name") >>> result = parser.parse_string("123 Main St") >>> print(result) ['123', 'Main St'] >>> print(type(result)) >>> print(repr(result)) (['123', 'Main St'], {'house_number': ['123'], 'street_name': ['Main St']}) >>> result.house_number '123' >>> result["street_name"] 'Main St' >>> result.as_list() ['123', 'Main St'] >>> result.as_dict() {'house_number': '123', 'street_name': 'Main St'} >>> print(result.dump()) ['123', 'Main St'] - house_number: '123' - street_name: 'Main St'}(hhh j3ubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"Mch j.ubeh#}(h%]h']h*]h,]h.]uh0jh j.hhh!h>h"Nubah#}(h%]jah']h*] parseresultsah,]h.]j j uh0jh!h>h"Mh j.hhjN}j 4j.sjP}jj.sjKubeh#}(h%]jah']h*] other classesah,]h.]uh0h h j(hhh!h>h"Mubh )}(hhh](h)}(hjAh](h)}(hhh]h 1.2.9   }(hhh j4hhh!Nh"Nubah#}(h%]h']h)ah*]h,]h.]uh0hh j4hhh!Nh"Nubh%Exception classes and Troubleshooting}(hjAh j4hhh!Nh"Nubeh#}(h%]h']h*]h,]h.]h;Khh"M|ubj)}(h.. _ParseException:h]h#}(h%]h']h*]h,]h.]hjKubj)}(hhh](j)}(hX``ParseException`` - exception returned when a grammar parse fails; ``ParseExceptions`` have attributes ``loc``, ``msg``, ``line``, ``lineno``, and ``column``; to view the text line and location where the reported ParseException occurs, use:: except ParseException as err: print(err.line) print(" " * (err.column - 1) + "^") print(err) ``ParseExceptions`` also have an ``explain()`` method that gives this same information:: except ParseException as err: print(err.explain()) h](h`)}(h``ParseException`` - exception returned when a grammar parse fails; ``ParseExceptions`` have attributes ``loc``, ``msg``, ``line``, ``lineno``, and ``column``; to view the text line and location where the reported ParseException occurs, use::h](j)}(h``ParseException``h]hParseException}(hhh jI4ubah#}(h%]h']h*]h,]h.]uh0jh jE4ubh2 - exception returned when a grammar parse fails; }(h2 - exception returned when a grammar parse fails; h jE4ubj)}(h``ParseExceptions``h]hParseExceptions}(hhh j\4ubah#}(h%]h']h*]h,]h.]uh0jh jE4ubh have attributes }(h have attributes h jE4ubj)}(h``loc``h]hloc}(hhh jo4ubah#}(h%]h']h*]h,]h.]uh0jh jE4ubh, }(h, h jE4ubj)}(h``msg``h]hmsg}(hhh j4ubah#}(h%]h']h*]h,]h.]uh0jh jE4ubh, }(h, h jE4ubj)}(h``line``h]hline}(hhh j4ubah#}(h%]h']h*]h,]h.]uh0jh jE4ubh, }(hj4h jE4ubj)}(h ``lineno``h]hlineno}(hhh j4ubah#}(h%]h']h*]h,]h.]uh0jh jE4ubh, and }(h, and h jE4ubj)}(h ``column``h]hcolumn}(hhh j4ubah#}(h%]h']h*]h,]h.]uh0jh jE4ubhS; to view the text line and location where the reported ParseException occurs, use:}(hS; to view the text line and location where the reported ParseException occurs, use:h jE4ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jA4ubjd)}(hhexcept ParseException as err: print(err.line) print(" " * (err.column - 1) + "^") print(err)h]hhexcept ParseException as err: print(err.line) print(" " * (err.column - 1) + "^") print(err)}(hhh j4ubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"Mh jA4ubh`)}(hX``ParseExceptions`` also have an ``explain()`` method that gives this same information::h](j)}(h``ParseExceptions``h]hParseExceptions}(hhh j4ubah#}(h%]h']h*]h,]h.]uh0jh j4ubh also have an }(h also have an h j4ubj)}(h ``explain()``h]h explain()}(hhh j4ubah#}(h%]h']h*]h,]h.]uh0jh j4ubh) method that gives this same information:}(h) method that gives this same information:h j4ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jA4ubjd)}(h6except ParseException as err: print(err.explain())h]h6except ParseException as err: print(err.explain())}(hhh j5ubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"Mh jA4ubeh#}(h%]h']h*]h,]h.]uh0jh j>4hhh!h>h"Nubj)}(h``RecursiveGrammarException`` - exception returned by ``validate()`` if the grammar contains a recursive infinite loop, such as:: bad_grammar = Forward() good_token = Literal("A") bad_grammar <<= Opt(good_token) + bad_grammar h](h`)}(h``RecursiveGrammarException`` - exception returned by ``validate()`` if the grammar contains a recursive infinite loop, such as::h](j)}(h``RecursiveGrammarException``h]hRecursiveGrammarException}(hhh j-5ubah#}(h%]h']h*]h,]h.]uh0jh j)5ubh - exception returned by }(h - exception returned by h j)5ubj)}(h``validate()``h]h validate()}(hhh j@5ubah#}(h%]h']h*]h,]h.]uh0jh j)5ubh< if the grammar contains a recursive infinite loop, such as:}(h< if the grammar contains a recursive infinite loop, such as:h j)5ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j%5ubjd)}(h_bad_grammar = Forward() good_token = Literal("A") bad_grammar <<= Opt(good_token) + bad_grammarh]h_bad_grammar = Forward() good_token = Literal("A") bad_grammar <<= Opt(good_token) + bad_grammar}(hhh jY5ubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"Mh j%5ubeh#}(h%]h']h*]h,]h.]uh0jh j>4hhh!h>h"Nubj)}(h``ParseFatalException`` - exception that parse actions can raise to stop parsing immediately. Should be used when a semantic error is found in the input text, such as a mismatched XML tag. h]h`)}(h``ParseFatalException`` - exception that parse actions can raise to stop parsing immediately. Should be used when a semantic error is found in the input text, such as a mismatched XML tag.h](j)}(h``ParseFatalException``h]hParseFatalException}(hhh ju5ubah#}(h%]h']h*]h,]h.]uh0jh jq5ubh - exception that parse actions can raise to stop parsing immediately. Should be used when a semantic error is found in the input text, such as a mismatched XML tag.}(h - exception that parse actions can raise to stop parsing immediately. Should be used when a semantic error is found in the input text, such as a mismatched XML tag.h jq5ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jm5ubah#}(h%]h']h*]h,]h.]uh0jh j>4hhh!h>h"Nubj)}(h``ParseSyntaxException`` - subclass of ``ParseFatalException`` raised when a syntax error is found, based on the use of the '-' operator when defining a sequence of expressions in an And_ expression. h]h`)}(h``ParseSyntaxException`` - subclass of ``ParseFatalException`` raised when a syntax error is found, based on the use of the '-' operator when defining a sequence of expressions in an And_ expression.h](j)}(h``ParseSyntaxException``h]hParseSyntaxException}(hhh j5ubah#}(h%]h']h*]h,]h.]uh0jh j5ubh - subclass of }(h - subclass of h j5ubj)}(h``ParseFatalException``h]hParseFatalException}(hhh j5ubah#}(h%]h']h*]h,]h.]uh0jh j5ubh} raised when a syntax error is found, based on the use of the ‘-‘ operator when defining a sequence of expressions in an }(hy raised when a syntax error is found, based on the use of the '-' operator when defining a sequence of expressions in an h j5ubh)}(hAnd_h]hAnd}(hAndh j5ubah#}(h%]h']h*]h,]h.]namej5hh"Mh j5ubah#}(h%]h']h*]h,]h.]uh0jh j>4hhh!h>h"Nubj)}(hYou can also get some insights into the parsing logic using diagnostic parse actions, and ``set_debug()``, or test the matching of expression fragments by testing them using ``search_string()`` or ``scan_string()``. h]h`)}(hYou can also get some insights into the parsing logic using diagnostic parse actions, and ``set_debug()``, or test the matching of expression fragments by testing them using ``search_string()`` or ``scan_string()``.h](hZYou can also get some insights into the parsing logic using diagnostic parse actions, and }(hZYou can also get some insights into the parsing logic using diagnostic parse actions, and h j5ubj)}(h``set_debug()``h]h set_debug()}(hhh j5ubah#}(h%]h']h*]h,]h.]uh0jh j5ubhE, or test the matching of expression fragments by testing them using }(hE, or test the matching of expression fragments by testing them using h j5ubj)}(h``search_string()``h]hsearch_string()}(hhh j6ubah#}(h%]h']h*]h,]h.]uh0jh j5ubh or }(h or h j5ubj)}(h``scan_string()``h]h scan_string()}(hhh j6ubah#}(h%]h']h*]h,]h.]uh0jh j5ubh.}(hj h j5ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j5ubah#}(h%]h']h*]h,]h.]uh0jh j>4hhh!h>h"Nubj)}(hXOUse ``with_line_numbers`` from ``pyparsing_testing`` to display the input string being parsed, with line and column numbers that correspond to the values reported in set_debug() output:: import pyparsing as pp ppt = pp.testing data = """\ A 100""" expr = pp.Word(pp.alphanums).set_name("word").set_debug() print(ppt.with_line_numbers(data)) expr[...].parseString(data) prints:: . 1 1234567890 1: A| 2: 100| Match word at loc 3(1,4) A ^ Matched word -> ['A'] Match word at loc 11(2,7) 100 ^ Matched word -> ['100'] `with_line_numbers` has several options for displaying control characters, end-of-line and space markers, Unicode symbols for control characters - these are documented in the function's docstring. h](h`)}(hUse ``with_line_numbers`` from ``pyparsing_testing`` to display the input string being parsed, with line and column numbers that correspond to the values reported in set_debug() output::h](hUse }(hUse h j86ubj)}(h``with_line_numbers``h]hwith_line_numbers}(hhh jA6ubah#}(h%]h']h*]h,]h.]uh0jh j86ubh from }(h from h j86ubj)}(h``pyparsing_testing``h]hpyparsing_testing}(hhh jT6ubah#}(h%]h']h*]h,]h.]uh0jh j86ubh to display the input string being parsed, with line and column numbers that correspond to the values reported in set_debug() output:}(h to display the input string being parsed, with line and column numbers that correspond to the values reported in set_debug() output:h j86ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j46ubjd)}(himport pyparsing as pp ppt = pp.testing data = """\ A 100""" expr = pp.Word(pp.alphanums).set_name("word").set_debug() print(ppt.with_line_numbers(data)) expr[...].parseString(data)h]himport pyparsing as pp ppt = pp.testing data = """\ A 100""" expr = pp.Word(pp.alphanums).set_name("word").set_debug() print(ppt.with_line_numbers(data)) expr[...].parseString(data)}(hhh jm6ubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"Mh j46ubh`)}(hprints::h]hprints:}(hprints:h j{6ubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j46ubjd)}(h. 1 1234567890 1: A| 2: 100| Match word at loc 3(1,4) A ^ Matched word -> ['A'] Match word at loc 11(2,7) 100 ^ Matched word -> ['100']h]h. 1 1234567890 1: A| 2: 100| Match word at loc 3(1,4) A ^ Matched word -> ['A'] Match word at loc 11(2,7) 100 ^ Matched word -> ['100']}(hhh j6ubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"Mh j46ubh`)}(h`with_line_numbers` has several options for displaying control characters, end-of-line and space markers, Unicode symbols for control characters - these are documented in the function's docstring.h](h title_reference)}(h`with_line_numbers`h]hwith_line_numbers}(hhh j6ubah#}(h%]h']h*]h,]h.]uh0j6h j6ubh has several options for displaying control characters, end-of-line and space markers, Unicode symbols for control characters - these are documented in the function’s docstring.}(h has several options for displaying control characters, end-of-line and space markers, Unicode symbols for control characters - these are documented in the function's docstring.h j6ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j46ubeh#}(h%]h']h*]h,]h.]uh0jh j>4hhh!h>h"Nubj)}(hXuDiagnostics can be enabled using ``pyparsing.enable_diag`` and passing one of the following enum values defined in ``pyparsing.Diagnostics`` - ``warn_multiple_tokens_in_named_alternation`` - flag to enable warnings when a results name is defined on a MatchFirst_ or Or_ expression with one or more And_ subexpressions - ``warn_ungrouped_named_tokens_in_collection`` - flag to enable warnings when a results name is defined on a containing expression with ungrouped subexpressions that also have results names - ``warn_name_set_on_empty_Forward`` - flag to enable warnings when a ``Forward`` is defined with a results name, but has no contents defined - ``warn_on_parse_using_empty_Forward`` - flag to enable warnings when a ``Forward`` is defined in a grammar but has never had an expression attached to it - ``warn_on_assignment_to_Forward`` - flag to enable warnings when a ``Forward`` is defined but is overwritten by assigning using ``'='`` instead of ``'<<='`` or ``'<<'`` - ``warn_on_multiple_string_args_to_oneof`` - flag to enable warnings when ``one_of`` is incorrectly called with multiple str arguments - ``enable_debug_on_named_expressions`` - flag to auto-enable debug on all subsequent calls to ``ParserElement.set_name`` All warnings can be enabled by calling ``pyparsing.enable_all_warnings()``. Sample:: import pyparsing as pp pp.enable_all_warnings() fwd = pp.Forward().set_results_name("recursive_expr") >>> UserWarning: warn_name_set_on_empty_Forward: setting results name 'recursive_expr' on Forward expression that has no contained expression Warnings can also be enabled using the Python ``-W`` switch (using ``-Wd`` or ``-Wd:::pyparsing``) or setting a non-empty value to the environment variable ``PYPARSINGENABLEALLWARNINGS``. (If using ``-Wd`` for testing, but wishing to disable pyparsing warnings, add ``-Wi:::pyparsing``.) h](h`)}(hDiagnostics can be enabled using ``pyparsing.enable_diag`` and passing one of the following enum values defined in ``pyparsing.Diagnostics``h](h!Diagnostics can be enabled using }(h!Diagnostics can be enabled using h j6ubj)}(h``pyparsing.enable_diag``h]hpyparsing.enable_diag}(hhh j6ubah#}(h%]h']h*]h,]h.]uh0jh j6ubh9 and passing one of the following enum values defined in }(h9 and passing one of the following enum values defined in h j6ubj)}(h``pyparsing.Diagnostics``h]hpyparsing.Diagnostics}(hhh j6ubah#}(h%]h']h*]h,]h.]uh0jh j6ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j6ubj)}(hhh](j)}(h``warn_multiple_tokens_in_named_alternation`` - flag to enable warnings when a results name is defined on a MatchFirst_ or Or_ expression with one or more And_ subexpressions h]h`)}(h``warn_multiple_tokens_in_named_alternation`` - flag to enable warnings when a results name is defined on a MatchFirst_ or Or_ expression with one or more And_ subexpressionsh](j)}(h-``warn_multiple_tokens_in_named_alternation``h]h)warn_multiple_tokens_in_named_alternation}(hhh j6ubah#}(h%]h']h*]h,]h.]uh0jh j6ubh? - flag to enable warnings when a results name is defined on a }(h? - flag to enable warnings when a results name is defined on a h j6ubh)}(h MatchFirst_h]h MatchFirst}(h MatchFirsth j7ubah#}(h%]h']h*]h,]h.]namej7hh"Mh j6ubah#}(h%]h']h*]h,]h.]uh0jh j6ubj)}(h``warn_ungrouped_named_tokens_in_collection`` - flag to enable warnings when a results name is defined on a containing expression with ungrouped subexpressions that also have results names h]h`)}(h``warn_ungrouped_named_tokens_in_collection`` - flag to enable warnings when a results name is defined on a containing expression with ungrouped subexpressions that also have results namesh](j)}(h-``warn_ungrouped_named_tokens_in_collection``h]h)warn_ungrouped_named_tokens_in_collection}(hhh jb7ubah#}(h%]h']h*]h,]h.]uh0jh j^7ubh - flag to enable warnings when a results name is defined on a containing expression with ungrouped subexpressions that also have results names}(h - flag to enable warnings when a results name is defined on a containing expression with ungrouped subexpressions that also have results namesh j^7ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jZ7ubah#}(h%]h']h*]h,]h.]uh0jh j6ubj)}(h``warn_name_set_on_empty_Forward`` - flag to enable warnings when a ``Forward`` is defined with a results name, but has no contents defined h]h`)}(h``warn_name_set_on_empty_Forward`` - flag to enable warnings when a ``Forward`` is defined with a results name, but has no contents definedh](j)}(h"``warn_name_set_on_empty_Forward``h]hwarn_name_set_on_empty_Forward}(hhh j7ubah#}(h%]h']h*]h,]h.]uh0jh j7ubh" - flag to enable warnings when a }(h" - flag to enable warnings when a h j7ubj)}(h ``Forward``h]hForward}(hhh j7ubah#}(h%]h']h*]h,]h.]uh0jh j7ubh< is defined with a results name, but has no contents defined}(h< is defined with a results name, but has no contents definedh j7ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j7ubah#}(h%]h']h*]h,]h.]uh0jh j6ubj)}(h``warn_on_parse_using_empty_Forward`` - flag to enable warnings when a ``Forward`` is defined in a grammar but has never had an expression attached to it h]h`)}(h``warn_on_parse_using_empty_Forward`` - flag to enable warnings when a ``Forward`` is defined in a grammar but has never had an expression attached to ith](j)}(h%``warn_on_parse_using_empty_Forward``h]h!warn_on_parse_using_empty_Forward}(hhh j7ubah#}(h%]h']h*]h,]h.]uh0jh j7ubh" - flag to enable warnings when a }(h" - flag to enable warnings when a h j7ubj)}(h ``Forward``h]hForward}(hhh j7ubah#}(h%]h']h*]h,]h.]uh0jh j7ubhG is defined in a grammar but has never had an expression attached to it}(hG is defined in a grammar but has never had an expression attached to ith j7ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j7ubah#}(h%]h']h*]h,]h.]uh0jh j6ubj)}(h``warn_on_assignment_to_Forward`` - flag to enable warnings when a ``Forward`` is defined but is overwritten by assigning using ``'='`` instead of ``'<<='`` or ``'<<'`` h]h`)}(h``warn_on_assignment_to_Forward`` - flag to enable warnings when a ``Forward`` is defined but is overwritten by assigning using ``'='`` instead of ``'<<='`` or ``'<<'``h](j)}(h!``warn_on_assignment_to_Forward``h]hwarn_on_assignment_to_Forward}(hhh j7ubah#}(h%]h']h*]h,]h.]uh0jh j7ubh" - flag to enable warnings when a }(h" - flag to enable warnings when a h j7ubj)}(h ``Forward``h]hForward}(hhh j8ubah#}(h%]h']h*]h,]h.]uh0jh j7ubh2 is defined but is overwritten by assigning using }(h2 is defined but is overwritten by assigning using h j7ubj)}(h``'='``h]h'='}(hhh j#8ubah#}(h%]h']h*]h,]h.]uh0jh j7ubh instead of }(h instead of h j7ubj)}(h ``'<<='``h]h'<<='}(hhh j68ubah#}(h%]h']h*]h,]h.]uh0jh j7ubh or }(h or h j7ubj)}(h``'<<'``h]h'<<'}(hhh jI8ubah#}(h%]h']h*]h,]h.]uh0jh j7ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j7ubah#}(h%]h']h*]h,]h.]uh0jh j6ubj)}(h``warn_on_multiple_string_args_to_oneof`` - flag to enable warnings when ``one_of`` is incorrectly called with multiple str arguments h]h`)}(h``warn_on_multiple_string_args_to_oneof`` - flag to enable warnings when ``one_of`` is incorrectly called with multiple str argumentsh](j)}(h)``warn_on_multiple_string_args_to_oneof``h]h%warn_on_multiple_string_args_to_oneof}(hhh jk8ubah#}(h%]h']h*]h,]h.]uh0jh jg8ubh - flag to enable warnings when }(h - flag to enable warnings when h jg8ubj)}(h ``one_of``h]hone_of}(hhh j~8ubah#}(h%]h']h*]h,]h.]uh0jh jg8ubh2 is incorrectly called with multiple str arguments}(h2 is incorrectly called with multiple str argumentsh jg8ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jc8ubah#}(h%]h']h*]h,]h.]uh0jh j6ubj)}(hx``enable_debug_on_named_expressions`` - flag to auto-enable debug on all subsequent calls to ``ParserElement.set_name`` h]h`)}(hw``enable_debug_on_named_expressions`` - flag to auto-enable debug on all subsequent calls to ``ParserElement.set_name``h](j)}(h%``enable_debug_on_named_expressions``h]h!enable_debug_on_named_expressions}(hhh j8ubah#}(h%]h']h*]h,]h.]uh0jh j8ubh8 - flag to auto-enable debug on all subsequent calls to }(h8 - flag to auto-enable debug on all subsequent calls to h j8ubj)}(h``ParserElement.set_name``h]hParserElement.set_name}(hhh j8ubah#}(h%]h']h*]h,]h.]uh0jh j8ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j8ubah#}(h%]h']h*]h,]h.]uh0jh j6ubeh#}(h%]h']h*]h,]h.]j j uh0jh!h>h"Mh j6ubh`)}(hTAll warnings can be enabled by calling ``pyparsing.enable_all_warnings()``. Sample::h](h'All warnings can be enabled by calling }(h'All warnings can be enabled by calling h j8ubj)}(h#``pyparsing.enable_all_warnings()``h]hpyparsing.enable_all_warnings()}(hhh j8ubah#}(h%]h']h*]h,]h.]uh0jh j8ubh . Sample:}(h . Sample:h j8ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j6ubjd)}(hXimport pyparsing as pp pp.enable_all_warnings() fwd = pp.Forward().set_results_name("recursive_expr") >>> UserWarning: warn_name_set_on_empty_Forward: setting results name 'recursive_expr' on Forward expression that has no contained expressionh]hXimport pyparsing as pp pp.enable_all_warnings() fwd = pp.Forward().set_results_name("recursive_expr") >>> UserWarning: warn_name_set_on_empty_Forward: setting results name 'recursive_expr' on Forward expression that has no contained expression}(hhh j8ubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"Mh j6ubh`)}(hXWarnings can also be enabled using the Python ``-W`` switch (using ``-Wd`` or ``-Wd:::pyparsing``) or setting a non-empty value to the environment variable ``PYPARSINGENABLEALLWARNINGS``. (If using ``-Wd`` for testing, but wishing to disable pyparsing warnings, add ``-Wi:::pyparsing``.)h](h.Warnings can also be enabled using the Python }(h.Warnings can also be enabled using the Python h j9ubj)}(h``-W``h]h-W}(hhh j9ubah#}(h%]h']h*]h,]h.]uh0jh j9ubh switch (using }(h switch (using h j9ubj)}(h``-Wd``h]h-Wd}(hhh j$9ubah#}(h%]h']h*]h,]h.]uh0jh j9ubh or }(h or h j9ubj)}(h``-Wd:::pyparsing``h]h-Wd:::pyparsing}(hhh j79ubah#}(h%]h']h*]h,]h.]uh0jh j9ubh;) or setting a non-empty value to the environment variable }(h;) or setting a non-empty value to the environment variable h j9ubj)}(h``PYPARSINGENABLEALLWARNINGS``h]hPYPARSINGENABLEALLWARNINGS}(hhh jJ9ubah#}(h%]h']h*]h,]h.]uh0jh j9ubh . (If using }(h . (If using h j9ubj)}(h``-Wd``h]h-Wd}(hhh j]9ubah#}(h%]h']h*]h,]h.]uh0jh j9ubh= for testing, but wishing to disable pyparsing warnings, add }(h= for testing, but wishing to disable pyparsing warnings, add h j9ubj)}(h``-Wi:::pyparsing``h]h-Wi:::pyparsing}(hhh jp9ubah#}(h%]h']h*]h,]h.]uh0jh j9ubh.)}(h.)h j9ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j6ubeh#}(h%]h']h*]h,]h.]uh0jh j>4hhh!h>h"Nubeh#}(h%]jah']h*]parseexceptionah,]h.]j j uh0jh!h>h"Mh j4hhjN}j9j44sjP}jj44sjKubeh#}(h%]jJah']h*]%exception classes and troubleshootingah,]h.]uh0h h j(hhh!h>h"M|ubeh#}(h%]jah']h*]classesah,]h.]uh0h h h hhh!h>h"Mubh )}(hhh](h)}(hj}h](h)}(hhh]h 1.3   }(hhh j9hhh!Nh"Nubah#}(h%]h']h)ah*]h,]h.]uh0hh j9hhh!Nh"Nubh$Miscellaneous attributes and methods}(hj}h j9hhh!Nh"Nubeh#}(h%]h']h*]h,]h.]h;Khh"Mubh )}(hhh](h)}(hjh](h)}(hhh]h 1.3.1   }(hhh j9hhh!Nh"Nubah#}(h%]h']h)ah*]h,]h.]uh0hh j9hhh!Nh"NubhHelper methods}(hjh j9hhh!Nh"Nubeh#}(h%]h']h*]h,]h.]h;Khh"Mubj)}(hhh](j)}(hX;``delimited_list(expr, delim=',')`` - convenience function for matching one or more occurrences of expr, separated by delim. By default, the delimiters are suppressed, so the returned results contain only the separate list elements. Can optionally specify ``combine=True``, indicating that the expressions and delimiters should be returned as one combined value (useful for scoped variables, such as ``"a.b.c"``, or ``"a::b::c"``, or paths such as ``"a/b/c"``). Can also optionally specify ``allow_trailing_delim`` to accept a trailing delimiter at the end of the list. h]h`)}(hX:``delimited_list(expr, delim=',')`` - convenience function for matching one or more occurrences of expr, separated by delim. By default, the delimiters are suppressed, so the returned results contain only the separate list elements. Can optionally specify ``combine=True``, indicating that the expressions and delimiters should be returned as one combined value (useful for scoped variables, such as ``"a.b.c"``, or ``"a::b::c"``, or paths such as ``"a/b/c"``). Can also optionally specify ``allow_trailing_delim`` to accept a trailing delimiter at the end of the list.h](j)}(h#``delimited_list(expr, delim=',')``h]hdelimited_list(expr, delim=',')}(hhh j9ubah#}(h%]h']h*]h,]h.]uh0jh j9ubh - convenience function for matching one or more occurrences of expr, separated by delim. By default, the delimiters are suppressed, so the returned results contain only the separate list elements. Can optionally specify }(h - convenience function for matching one or more occurrences of expr, separated by delim. By default, the delimiters are suppressed, so the returned results contain only the separate list elements. Can optionally specify h j9ubj)}(h``combine=True``h]h combine=True}(hhh j9ubah#}(h%]h']h*]h,]h.]uh0jh j9ubh, indicating that the expressions and delimiters should be returned as one combined value (useful for scoped variables, such as }(h, indicating that the expressions and delimiters should be returned as one combined value (useful for scoped variables, such as h j9ubj)}(h ``"a.b.c"``h]h"a.b.c"}(hhh j:ubah#}(h%]h']h*]h,]h.]uh0jh j9ubh, or }(h, or h j9ubj)}(h ``"a::b::c"``h]h "a::b::c"}(hhh j$:ubah#}(h%]h']h*]h,]h.]uh0jh j9ubh, or paths such as }(h, or paths such as h j9ubj)}(h ``"a/b/c"``h]h"a/b/c"}(hhh j7:ubah#}(h%]h']h*]h,]h.]uh0jh j9ubh). Can also optionally specify }(h). Can also optionally specify h j9ubj)}(h``allow_trailing_delim``h]hallow_trailing_delim}(hhh jJ:ubah#}(h%]h']h*]h,]h.]uh0jh j9ubh7 to accept a trailing delimiter at the end of the list.}(h7 to accept a trailing delimiter at the end of the list.h j9ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j9ubah#}(h%]h']h*]h,]h.]uh0jh j9hhh!h>h"Nubj)}(hX``counted_array(expr)`` - convenience function for a pattern where an list of instances of the given expression are preceded by an integer giving the count of elements in the list. Returns an expression that parses the leading integer, reads exactly that many expressions, and returns the array of expressions in the parse results - the leading integer is suppressed from the results (although it is easily reconstructed by using len on the returned array). h]h`)}(hX``counted_array(expr)`` - convenience function for a pattern where an list of instances of the given expression are preceded by an integer giving the count of elements in the list. Returns an expression that parses the leading integer, reads exactly that many expressions, and returns the array of expressions in the parse results - the leading integer is suppressed from the results (although it is easily reconstructed by using len on the returned array).h](j)}(h``counted_array(expr)``h]hcounted_array(expr)}(hhh jq:ubah#}(h%]h']h*]h,]h.]uh0jh jm:ubhX - convenience function for a pattern where an list of instances of the given expression are preceded by an integer giving the count of elements in the list. Returns an expression that parses the leading integer, reads exactly that many expressions, and returns the array of expressions in the parse results - the leading integer is suppressed from the results (although it is easily reconstructed by using len on the returned array).}(hX - convenience function for a pattern where an list of instances of the given expression are preceded by an integer giving the count of elements in the list. Returns an expression that parses the leading integer, reads exactly that many expressions, and returns the array of expressions in the parse results - the leading integer is suppressed from the results (although it is easily reconstructed by using len on the returned array).h jm:ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh ji:ubah#}(h%]h']h*]h,]h.]uh0jh j9hhh!h>h"Nubj)}(hXM``one_of(choices, caseless=False, as_keyword=False)`` - convenience function for quickly declaring an alternative set of Literal_ expressions. ``choices`` can be passed as a list of strings or as a single string of values separated by spaces. The values are sorted so that longer matches are attempted first; this ensures that a short value does not mask a longer one that starts with the same characters. If ``caseless=True``, will create an alternative set of CaselessLiteral_ tokens. If ``as_keyword=True``, ``one_of`` will declare Keyword_ expressions instead of Literal_ expressions. h]h`)}(hXL``one_of(choices, caseless=False, as_keyword=False)`` - convenience function for quickly declaring an alternative set of Literal_ expressions. ``choices`` can be passed as a list of strings or as a single string of values separated by spaces. The values are sorted so that longer matches are attempted first; this ensures that a short value does not mask a longer one that starts with the same characters. If ``caseless=True``, will create an alternative set of CaselessLiteral_ tokens. If ``as_keyword=True``, ``one_of`` will declare Keyword_ expressions instead of Literal_ expressions.h](j)}(h5``one_of(choices, caseless=False, as_keyword=False)``h]h1one_of(choices, caseless=False, as_keyword=False)}(hhh j:ubah#}(h%]h']h*]h,]h.]uh0jh j:ubhD - convenience function for quickly declaring an alternative set of }(hD - convenience function for quickly declaring an alternative set of h j:ubh)}(hLiteral_h]hLiteral}(hLiteralh j:ubah#}(h%]h']h*]h,]h.]namej:h;hh"Mh j:ubah#}(h%]h']h*]h,]h.]uh0jh j9hhh!h>h"Nubj)}(h``dict_of(key, value)`` - convenience function for quickly declaring a dictionary pattern of ``Dict(ZeroOrMore(Group(key + value)))``. h]h`)}(h``dict_of(key, value)`` - convenience function for quickly declaring a dictionary pattern of ``Dict(ZeroOrMore(Group(key + value)))``.h](j)}(h``dict_of(key, value)``h]hdict_of(key, value)}(hhh j_;ubah#}(h%]h']h*]h,]h.]uh0jh j[;ubhF - convenience function for quickly declaring a dictionary pattern of }(hF - convenience function for quickly declaring a dictionary pattern of h j[;ubj)}(h(``Dict(ZeroOrMore(Group(key + value)))``h]h$Dict(ZeroOrMore(Group(key + value)))}(hhh jr;ubah#}(h%]h']h*]h,]h.]uh0jh j[;ubh.}(hj h j[;ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M h jW;ubah#}(h%]h']h*]h,]h.]uh0jh j9hhh!h>h"Nubj)}(hX``make_html_tags(tag_str)`` and ``make_xml_tags(tag_str)`` - convenience functions to create definitions of opening and closing tag expressions. Returns a pair of expressions, for the corresponding ```` and ```` strings. Includes support for attributes in the opening tag, such as ```` - attributes are returned as named results in the returned ParseResults_. ``make_html_tags`` is less restrictive than ``make_xml_tags``, especially with respect to case sensitivity. h]h`)}(hX``make_html_tags(tag_str)`` and ``make_xml_tags(tag_str)`` - convenience functions to create definitions of opening and closing tag expressions. Returns a pair of expressions, for the corresponding ```` and ```` strings. Includes support for attributes in the opening tag, such as ```` - attributes are returned as named results in the returned ParseResults_. ``make_html_tags`` is less restrictive than ``make_xml_tags``, especially with respect to case sensitivity.h](j)}(h``make_html_tags(tag_str)``h]hmake_html_tags(tag_str)}(hhh j;ubah#}(h%]h']h*]h,]h.]uh0jh j;ubh and }(h and h j;ubj)}(h``make_xml_tags(tag_str)``h]hmake_xml_tags(tag_str)}(hhh j;ubah#}(h%]h']h*]h,]h.]uh0jh j;ubh - convenience functions to create definitions of opening and closing tag expressions. Returns a pair of expressions, for the corresponding }(h - convenience functions to create definitions of opening and closing tag expressions. Returns a pair of expressions, for the corresponding h j;ubj)}(h ````h]h}(hhh j;ubah#}(h%]h']h*]h,]h.]uh0jh j;ubh and }(hj;h j;ubj)}(h ````h]h}(hhh j;ubah#}(h%]h']h*]h,]h.]uh0jh j;ubhG strings. Includes support for attributes in the opening tag, such as }(hG strings. Includes support for attributes in the opening tag, such as h j;ubj)}(h````h]h}(hhh j;ubah#}(h%]h']h*]h,]h.]uh0jh j;ubh< - attributes are returned as named results in the returned }(h< - attributes are returned as named results in the returned h j;ubh)}(h ParseResults_Ih]h ParseResults}(h ParseResultsh j;ubah#}(h%]h']h*]h,]h.]namej;hh"Mh j;ubah#}(h%]h']h*]h,]h.]uh0jh j9hhh!h>h"Nubj)}(hXt ``infix_notation(base_operand, operator_list)`` - convenience function to define a grammar for parsing infix notation expressions with a hierarchical precedence of operators. To use the ``infix_notation`` helper: 1. Define the base "atom" operand term of the grammar. For this simple grammar, the smallest operand is either an integer or a variable. This will be the first argument to the ``infix_notation`` method. 2. Define a list of tuples for each level of operator precedence. Each tuple is of the form ``(operand_expr, num_operands, right_left_assoc, parse_action)``, where: - ``operand_expr`` - the pyparsing expression for the operator; may also be a string, which will be converted to a Literal_; if ``None``, indicates an empty operator, such as the implied multiplication operation between 'm' and 'x' in "y = mx + b". - ``num_operands`` - the number of terms for this operator (must be 1, 2, or 3) - ``right_left_assoc`` is the indicator whether the operator is right or left associative, using the pyparsing-defined constants ``OpAssoc.RIGHT`` and ``OpAssoc.LEFT``. - ``parse_action`` is the parse action to be associated with expressions matching this operator expression (the ``parse_action`` tuple member may be omitted) 3. Call ``infix_notation`` passing the operand expression and the operator precedence list, and save the returned value as the generated pyparsing expression. You can then use this expression to parse input strings, or incorporate it into a larger, more complex grammar. ``infix_notation`` also supports optional arguments ``lpar`` and ``rpar``, to parse groups with symbols other than "(" and ")". They may be passed as strings (in which case they will be converted to ``Suppress`` objects, and suppressed from the parsed results), or passed as pyparsing expressions, in which case they will be kept as-is, and grouped with their contents. For instance, to use "<" and ">" for grouping symbols, you could write:: expr = infix_notation(int_expr, [ (one_of("+ -"), 2, opAssoc.LEFT), ], lpar="<", rpar=">" ) expr.parse_string("3 - <2 + 11>") returning:: [3, '-', [2, '+', 11]] If the grouping symbols are to be retained, then pass them as pyparsing ``Literals``:: expr = infix_notation(int_expr, [ (one_of("+ -"), 2, opAssoc.LEFT), ], lpar=Literal("<"), rpar=Literal(">") ) expr.parse_string("3 - <2 + 11>") returning:: [3, '-', ['<', [2, '+', 11], '>']] h](h`)}(h``infix_notation(base_operand, operator_list)`` - convenience function to define a grammar for parsing infix notation expressions with a hierarchical precedence of operators. To use the ``infix_notation`` helper:h](j)}(h/``infix_notation(base_operand, operator_list)``h]h+infix_notation(base_operand, operator_list)}(hhh jE<ubah#}(h%]h']h*]h,]h.]uh0jh jA<ubh - convenience function to define a grammar for parsing infix notation expressions with a hierarchical precedence of operators. To use the }(h - convenience function to define a grammar for parsing infix notation expressions with a hierarchical precedence of operators. To use the h jA<ubj)}(h``infix_notation``h]hinfix_notation}(hhh jX<ubah#}(h%]h']h*]h,]h.]uh0jh jA<ubh helper:}(h helper:h jA<ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j=<ubjg)}(hhh](j)}(hDefine the base "atom" operand term of the grammar. For this simple grammar, the smallest operand is either an integer or a variable. This will be the first argument to the ``infix_notation`` method. h]h`)}(hDefine the base "atom" operand term of the grammar. For this simple grammar, the smallest operand is either an integer or a variable. This will be the first argument to the ``infix_notation`` method.h](hDefine the base “atom” operand term of the grammar. For this simple grammar, the smallest operand is either an integer or a variable. This will be the first argument to the }(hDefine the base "atom" operand term of the grammar. For this simple grammar, the smallest operand is either an integer or a variable. This will be the first argument to the h jx<ubj)}(h``infix_notation``h]hinfix_notation}(hhh j<ubah#}(h%]h']h*]h,]h.]uh0jh jx<ubh method.}(h method.h jx<ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jt<ubah#}(h%]h']h*]h,]h.]uh0jh jq<ubj)}(hXGDefine a list of tuples for each level of operator precedence. Each tuple is of the form ``(operand_expr, num_operands, right_left_assoc, parse_action)``, where: - ``operand_expr`` - the pyparsing expression for the operator; may also be a string, which will be converted to a Literal_; if ``None``, indicates an empty operator, such as the implied multiplication operation between 'm' and 'x' in "y = mx + b". - ``num_operands`` - the number of terms for this operator (must be 1, 2, or 3) - ``right_left_assoc`` is the indicator whether the operator is right or left associative, using the pyparsing-defined constants ``OpAssoc.RIGHT`` and ``OpAssoc.LEFT``. - ``parse_action`` is the parse action to be associated with expressions matching this operator expression (the ``parse_action`` tuple member may be omitted) h](h`)}(hDefine a list of tuples for each level of operator precedence. Each tuple is of the form ``(operand_expr, num_operands, right_left_assoc, parse_action)``, where:h](hZDefine a list of tuples for each level of operator precedence. Each tuple is of the form }(hZDefine a list of tuples for each level of operator precedence. Each tuple is of the form h j<ubj)}(h@``(operand_expr, num_operands, right_left_assoc, parse_action)``h]h<(operand_expr, num_operands, right_left_assoc, parse_action)}(hhh j<ubah#}(h%]h']h*]h,]h.]uh0jh j<ubh, where:}(h, where:h j<ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M h j<ubj)}(hhh](j)}(h``operand_expr`` - the pyparsing expression for the operator; may also be a string, which will be converted to a Literal_; if ``None``, indicates an empty operator, such as the implied multiplication operation between 'm' and 'x' in "y = mx + b". h]h`)}(h``operand_expr`` - the pyparsing expression for the operator; may also be a string, which will be converted to a Literal_; if ``None``, indicates an empty operator, such as the implied multiplication operation between 'm' and 'x' in "y = mx + b".h](j)}(h``operand_expr``h]h operand_expr}(hhh j<ubah#}(h%]h']h*]h,]h.]uh0jh j<ubha - the pyparsing expression for the operator; may also be a string, which will be converted to a }(ha - the pyparsing expression for the operator; may also be a string, which will be converted to a h j<ubh)}(hLiteral_h]hLiteral}(hLiteralh j<ubah#}(h%]h']h*]h,]h.]namej<hh"M$h j<ubah#}(h%]h']h*]h,]h.]uh0jh j<ubj)}(hN``num_operands`` - the number of terms for this operator (must be 1, 2, or 3) h]h`)}(hM``num_operands`` - the number of terms for this operator (must be 1, 2, or 3)h](j)}(h``num_operands``h]h num_operands}(hhh j =ubah#}(h%]h']h*]h,]h.]uh0jh j=ubh= - the number of terms for this operator (must be 1, 2, or 3)}(h= - the number of terms for this operator (must be 1, 2, or 3)h j=ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M)h j=ubah#}(h%]h']h*]h,]h.]uh0jh j<ubj)}(h``right_left_assoc`` is the indicator whether the operator is right or left associative, using the pyparsing-defined constants ``OpAssoc.RIGHT`` and ``OpAssoc.LEFT``. h]h`)}(h``right_left_assoc`` is the indicator whether the operator is right or left associative, using the pyparsing-defined constants ``OpAssoc.RIGHT`` and ``OpAssoc.LEFT``.h](j)}(h``right_left_assoc``h]hright_left_assoc}(hhh jG=ubah#}(h%]h']h*]h,]h.]uh0jh jC=ubhk is the indicator whether the operator is right or left associative, using the pyparsing-defined constants }(hk is the indicator whether the operator is right or left associative, using the pyparsing-defined constants h jC=ubj)}(h``OpAssoc.RIGHT``h]h OpAssoc.RIGHT}(hhh jZ=ubah#}(h%]h']h*]h,]h.]uh0jh jC=ubh and }(h and h jC=ubj)}(h``OpAssoc.LEFT``h]h OpAssoc.LEFT}(hhh jm=ubah#}(h%]h']h*]h,]h.]uh0jh jC=ubh.}(hj h jC=ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M,h j?=ubah#}(h%]h']h*]h,]h.]uh0jh j<ubj)}(h``parse_action`` is the parse action to be associated with expressions matching this operator expression (the ``parse_action`` tuple member may be omitted) h]h`)}(h``parse_action`` is the parse action to be associated with expressions matching this operator expression (the ``parse_action`` tuple member may be omitted)h](j)}(h``parse_action``h]h parse_action}(hhh j=ubah#}(h%]h']h*]h,]h.]uh0jh j=ubh^ is the parse action to be associated with expressions matching this operator expression (the }(h^ is the parse action to be associated with expressions matching this operator expression (the h j=ubj)}(h``parse_action``h]h parse_action}(hhh j=ubah#}(h%]h']h*]h,]h.]uh0jh j=ubh tuple member may be omitted)}(h tuple member may be omitted)h j=ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M0h j=ubah#}(h%]h']h*]h,]h.]uh0jh j<ubeh#}(h%]h']h*]h,]h.]j j uh0jh!h>h"M$h j<ubeh#}(h%]h']h*]h,]h.]uh0jh jq<ubj)}(hX Call ``infix_notation`` passing the operand expression and the operator precedence list, and save the returned value as the generated pyparsing expression. You can then use this expression to parse input strings, or incorporate it into a larger, more complex grammar. h]h`)}(hX Call ``infix_notation`` passing the operand expression and the operator precedence list, and save the returned value as the generated pyparsing expression. You can then use this expression to parse input strings, or incorporate it into a larger, more complex grammar.h](hCall }(hCall h j=ubj)}(h``infix_notation``h]hinfix_notation}(hhh j=ubah#}(h%]h']h*]h,]h.]uh0jh j=ubh passing the operand expression and the operator precedence list, and save the returned value as the generated pyparsing expression. You can then use this expression to parse input strings, or incorporate it into a larger, more complex grammar.}(h passing the operand expression and the operator precedence list, and save the returned value as the generated pyparsing expression. You can then use this expression to parse input strings, or incorporate it into a larger, more complex grammar.h j=ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M4h j=ubah#}(h%]h']h*]h,]h.]uh0jh jq<ubeh#}(h%]h']h*]h,]h.]j j!j"hj#j uh0jfh j=<ubh`)}(hXq``infix_notation`` also supports optional arguments ``lpar`` and ``rpar``, to parse groups with symbols other than "(" and ")". They may be passed as strings (in which case they will be converted to ``Suppress`` objects, and suppressed from the parsed results), or passed as pyparsing expressions, in which case they will be kept as-is, and grouped with their contents.h](j)}(h``infix_notation``h]hinfix_notation}(hhh j>ubah#}(h%]h']h*]h,]h.]uh0jh j>ubh" also supports optional arguments }(h" also supports optional arguments h j>ubj)}(h``lpar``h]hlpar}(hhh j>ubah#}(h%]h']h*]h,]h.]uh0jh j>ubh and }(h and h j>ubj)}(h``rpar``h]hrpar}(hhh j->ubah#}(h%]h']h*]h,]h.]uh0jh j>ubh, to parse groups with symbols other than “(” and “)”. They may be passed as strings (in which case they will be converted to }(h~, to parse groups with symbols other than "(" and ")". They may be passed as strings (in which case they will be converted to h j>ubj)}(h ``Suppress``h]hSuppress}(hhh j@>ubah#}(h%]h']h*]h,]h.]uh0jh j>ubh objects, and suppressed from the parsed results), or passed as pyparsing expressions, in which case they will be kept as-is, and grouped with their contents.}(h objects, and suppressed from the parsed results), or passed as pyparsing expressions, in which case they will be kept as-is, and grouped with their contents.h j>ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M:h j=<ubh`)}(hHFor instance, to use "<" and ">" for grouping symbols, you could write::h]hOFor instance, to use “<” and “>” for grouping symbols, you could write:}(hGFor instance, to use "<" and ">" for grouping symbols, you could write:h jY>ubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"M@h j=<ubjd)}(hexpr = infix_notation(int_expr, [ (one_of("+ -"), 2, opAssoc.LEFT), ], lpar="<", rpar=">" ) expr.parse_string("3 - <2 + 11>")h]hexpr = infix_notation(int_expr, [ (one_of("+ -"), 2, opAssoc.LEFT), ], lpar="<", rpar=">" ) expr.parse_string("3 - <2 + 11>")}(hhh jh>ubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"MBh j=<ubh`)}(h returning::h]h returning:}(h returning:h jv>ubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"MKh j=<ubjd)}(h[3, '-', [2, '+', 11]]h]h[3, '-', [2, '+', 11]]}(hhh j>ubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"MMh j=<ubh`)}(hVIf the grouping symbols are to be retained, then pass them as pyparsing ``Literals``::h](hHIf the grouping symbols are to be retained, then pass them as pyparsing }(hHIf the grouping symbols are to be retained, then pass them as pyparsing h j>ubj)}(h ``Literals``h]hLiterals}(hhh j>ubah#}(h%]h']h*]h,]h.]uh0jh j>ubh:}(hj!h j>ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"MOh j=<ubjd)}(hexpr = infix_notation(int_expr, [ (one_of("+ -"), 2, opAssoc.LEFT), ], lpar=Literal("<"), rpar=Literal(">") ) expr.parse_string("3 - <2 + 11>")h]hexpr = infix_notation(int_expr, [ (one_of("+ -"), 2, opAssoc.LEFT), ], lpar=Literal("<"), rpar=Literal(">") ) expr.parse_string("3 - <2 + 11>")}(hhh j>ubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"MQh j=<ubh`)}(h returning::h]h returning:}(h returning:h j>ubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"MZh j=<ubjd)}(h"[3, '-', ['<', [2, '+', 11], '>']]h]h"[3, '-', ['<', [2, '+', 11], '>']]}(hhh j>ubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"M\h j=<ubeh#}(h%]h']h*]h,]h.]uh0jh j9hhh!h>h"Nubj)}(hXw``match_previous_literal`` and ``match_previous_expr`` - function to define an expression that matches the same content as was parsed in a previous parse expression. For instance:: first = Word(nums) match_expr = first + ":" + match_previous_literal(first) will match "1:1", but not "1:2". Since this matches at the literal level, this will also match the leading "1:1" in "1:10". In contrast:: first = Word(nums) match_expr = first + ":" + match_previous_expr(first) will *not* match the leading "1:1" in "1:10"; the expressions are evaluated first, and then compared, so "1" is compared with "10". h](h`)}(h``match_previous_literal`` and ``match_previous_expr`` - function to define an expression that matches the same content as was parsed in a previous parse expression. For instance::h](j)}(h``match_previous_literal``h]hmatch_previous_literal}(hhh j>ubah#}(h%]h']h*]h,]h.]uh0jh j>ubh and }(h and h j>ubj)}(h``match_previous_expr``h]hmatch_previous_expr}(hhh j?ubah#}(h%]h']h*]h,]h.]uh0jh j>ubh~ - function to define an expression that matches the same content as was parsed in a previous parse expression. For instance:}(h~ - function to define an expression that matches the same content as was parsed in a previous parse expression. For instance:h j>ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M^h j>ubjd)}(hKfirst = Word(nums) match_expr = first + ":" + match_previous_literal(first)h]hKfirst = Word(nums) match_expr = first + ":" + match_previous_literal(first)}(hhh j?ubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"Mbh j>ubh`)}(h|will match "1:1", but not "1:2". Since this matches at the literal level, this will also match the leading "1:1" in "1:10".h]hwill match “1:1”, but not “1:2”. Since this matches at the literal level, this will also match the leading “1:1” in “1:10”.}(hj)?h j'?ubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"Meh j>ubh`)}(h In contrast::h]h In contrast:}(h In contrast:h j5?ubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mhh j>ubjd)}(hHfirst = Word(nums) match_expr = first + ":" + match_previous_expr(first)h]hHfirst = Word(nums) match_expr = first + ":" + match_previous_expr(first)}(hhh jD?ubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"Mjh j>ubh`)}(hwill *not* match the leading "1:1" in "1:10"; the expressions are evaluated first, and then compared, so "1" is compared with "10".h](hwill }(hwill h jR?ubj)}(h*not*h]hnot}(hhh j[?ubah#}(h%]h']h*]h,]h.]uh0jh jR?ubh match the leading “1:1” in “1:10”; the expressions are evaluated first, and then compared, so “1” is compared with “10”.}(hy match the leading "1:1" in "1:10"; the expressions are evaluated first, and then compared, so "1" is compared with "10".h jR?ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mmh j>ubeh#}(h%]h']h*]h,]h.]uh0jh j9hhh!h>h"Nubj)}(hXZ``nested_expr(opener, closer, content=None, ignore_expr=quoted_string)`` - method for defining nested lists enclosed in opening and closing delimiters. - ``opener`` - opening character for a nested list (default="("); can also be a pyparsing expression - ``closer`` - closing character for a nested list (default=")"); can also be a pyparsing expression - ``content`` - expression for items within the nested lists (default=None) - ``ignore_expr`` - expression for ignoring opening and closing delimiters (default=``quoted_string``) If an expression is not provided for the content argument, the nested expression will capture all whitespace-delimited content between delimiters as a list of separate values. Use the ``ignore_expr`` argument to define expressions that may contain opening or closing characters that should not be treated as opening or closing characters for nesting, such as ``quoted_string`` or a comment expression. Specify multiple expressions using an Or_ or MatchFirst_. The default is ``quoted_string``, but if no expressions are to be ignored, then pass ``None`` for this argument. h](h`)}(h``nested_expr(opener, closer, content=None, ignore_expr=quoted_string)`` - method for defining nested lists enclosed in opening and closing delimiters.h](j)}(hH``nested_expr(opener, closer, content=None, ignore_expr=quoted_string)``h]hDnested_expr(opener, closer, content=None, ignore_expr=quoted_string)}(hhh j?ubah#}(h%]h']h*]h,]h.]uh0jh j~?ubhO - method for defining nested lists enclosed in opening and closing delimiters.}(hO - method for defining nested lists enclosed in opening and closing delimiters.h j~?ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mph jz?ubj)}(hhh](j)}(hc``opener`` - opening character for a nested list (default="("); can also be a pyparsing expression h]h`)}(hb``opener`` - opening character for a nested list (default="("); can also be a pyparsing expressionh](j)}(h ``opener``h]hopener}(hhh j?ubah#}(h%]h']h*]h,]h.]uh0jh j?ubh\ - opening character for a nested list (default=”(“); can also be a pyparsing expression}(hX - opening character for a nested list (default="("); can also be a pyparsing expressionh j?ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Msh j?ubah#}(h%]h']h*]h,]h.]uh0jh j?ubj)}(hc``closer`` - closing character for a nested list (default=")"); can also be a pyparsing expression h]h`)}(hb``closer`` - closing character for a nested list (default=")"); can also be a pyparsing expressionh](j)}(h ``closer``h]hcloser}(hhh j?ubah#}(h%]h']h*]h,]h.]uh0jh j?ubh\ - closing character for a nested list (default=”)”); can also be a pyparsing expression}(hX - closing character for a nested list (default=")"); can also be a pyparsing expressionh j?ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Muh j?ubah#}(h%]h']h*]h,]h.]uh0jh j?ubj)}(hJ``content`` - expression for items within the nested lists (default=None) h]h`)}(hI``content`` - expression for items within the nested lists (default=None)h](j)}(h ``content``h]hcontent}(hhh j?ubah#}(h%]h']h*]h,]h.]uh0jh j?ubh> - expression for items within the nested lists (default=None)}(h> - expression for items within the nested lists (default=None)h j?ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mwh j?ubah#}(h%]h']h*]h,]h.]uh0jh j?ubj)}(he``ignore_expr`` - expression for ignoring opening and closing delimiters (default=``quoted_string``) h]h`)}(hd``ignore_expr`` - expression for ignoring opening and closing delimiters (default=``quoted_string``)h](j)}(h``ignore_expr``h]h ignore_expr}(hhh j@ubah#}(h%]h']h*]h,]h.]uh0jh j@ubhU - expression for ignoring opening and closing delimiters (default=``quoted_string``)}(hU - expression for ignoring opening and closing delimiters (default=``quoted_string``)h j@ubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Myh j@ubah#}(h%]h']h*]h,]h.]uh0jh j?ubeh#}(h%]h']h*]h,]h.]j j uh0jh!h>h"Msh jz?ubh`)}(hIf an expression is not provided for the content argument, the nested expression will capture all whitespace-delimited content between delimiters as a list of separate values.h]hIf an expression is not provided for the content argument, the nested expression will capture all whitespace-delimited content between delimiters as a list of separate values.}(hjB@h j@@ubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"M{h jz?ubh`)}(hXUse the ``ignore_expr`` argument to define expressions that may contain opening or closing characters that should not be treated as opening or closing characters for nesting, such as ``quoted_string`` or a comment expression. Specify multiple expressions using an Or_ or MatchFirst_. The default is ``quoted_string``, but if no expressions are to be ignored, then pass ``None`` for this argument.h](hUse the }(hUse the h jN@ubj)}(h``ignore_expr``h]h ignore_expr}(hhh jW@ubah#}(h%]h']h*]h,]h.]uh0jh jN@ubh argument to define expressions that may contain opening or closing characters that should not be treated as opening or closing characters for nesting, such as }(h argument to define expressions that may contain opening or closing characters that should not be treated as opening or closing characters for nesting, such as h jN@ubj)}(h``quoted_string``h]h quoted_string}(hhh jj@ubah#}(h%]h']h*]h,]h.]uh0jh jN@ubhA or a comment expression. Specify multiple expressions using an }(hA or a comment expression. Specify multiple expressions using an h jN@ubh)}(hOr_h]hOr}(hOrh j}@ubah#}(h%]h']h*]h,]h.]namej@hh"Mh jz?ubeh#}(h%]h']h*]h,]h.]uh0jh j9hhh!h>h"Nubj)}(hX``IndentedBlock(statement_expr, recursive=False, grouped=True)`` - function to define an indented block of statements, similar to indentation-based blocking in Python source code: - ``statement_expr`` - the expression defining a statement that will be found in the indented block; a valid ``IndentedBlock`` must contain at least 1 matching ``statement_expr`` - ``recursive`` - flag indicating whether the IndentedBlock can itself contain nested sub-blocks of the same type of expression (default=False) - ``grouped`` - flag indicating whether the tokens returned from parsing the IndentedBlock should be grouped (default=True) h](h`)}(h``IndentedBlock(statement_expr, recursive=False, grouped=True)`` - function to define an indented block of statements, similar to indentation-based blocking in Python source code:h](j)}(h@``IndentedBlock(statement_expr, recursive=False, grouped=True)``h]hh"Mh j@ubj)}(hhh](j)}(h``statement_expr`` - the expression defining a statement that will be found in the indented block; a valid ``IndentedBlock`` must contain at least 1 matching ``statement_expr`` h]h`)}(h``statement_expr`` - the expression defining a statement that will be found in the indented block; a valid ``IndentedBlock`` must contain at least 1 matching ``statement_expr``h](j)}(h``statement_expr``h]hstatement_expr}(hhh jAubah#}(h%]h']h*]h,]h.]uh0jh jAubhY - the expression defining a statement that will be found in the indented block; a valid }(hY - the expression defining a statement that will be found in the indented block; a valid h jAubj)}(h``IndentedBlock``h]h IndentedBlock}(hhh jAubah#}(h%]h']h*]h,]h.]uh0jh jAubh" must contain at least 1 matching }(h" must contain at least 1 matching h jAubj)}(h``statement_expr``h]hstatement_expr}(hhh j+Aubah#}(h%]h']h*]h,]h.]uh0jh jAubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j@ubah#}(h%]h']h*]h,]h.]uh0jh j@ubj)}(h``recursive`` - flag indicating whether the IndentedBlock can itself contain nested sub-blocks of the same type of expression (default=False) h]h`)}(h``recursive`` - flag indicating whether the IndentedBlock can itself contain nested sub-blocks of the same type of expression (default=False)h](j)}(h ``recursive``h]h recursive}(hhh jMAubah#}(h%]h']h*]h,]h.]uh0jh jIAubh - flag indicating whether the IndentedBlock can itself contain nested sub-blocks of the same type of expression (default=False)}(h - flag indicating whether the IndentedBlock can itself contain nested sub-blocks of the same type of expression (default=False)h jIAubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jEAubah#}(h%]h']h*]h,]h.]uh0jh j@ubj)}(hz``grouped`` - flag indicating whether the tokens returned from parsing the IndentedBlock should be grouped (default=True) h]h`)}(hy``grouped`` - flag indicating whether the tokens returned from parsing the IndentedBlock should be grouped (default=True)h](j)}(h ``grouped``h]hgrouped}(hhh jtAubah#}(h%]h']h*]h,]h.]uh0jh jpAubhn - flag indicating whether the tokens returned from parsing the IndentedBlock should be grouped (default=True)}(hn - flag indicating whether the tokens returned from parsing the IndentedBlock should be grouped (default=True)h jpAubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jlAubah#}(h%]h']h*]h,]h.]uh0jh j@ubeh#}(h%]h']h*]h,]h.]j j uh0jh!h>h"Mh j@ubeh#}(h%]h']h*]h,]h.]uh0jh j9hhh!Nh"Nubeh#}(h%]h']h*]h,]h.]j j uh0jh!h>h"Mh j9hhubj)}(h.. _originalTextFor:h]h#}(h%]h']h*]h,]h.]h<originaltextforuh0jh"Mh j9hhh!h>ubj)}(hhh](j)}(hX ``original_text_for(expr)`` - helper function to preserve the originally parsed text, regardless of any token processing or conversion done by the contained expression. For instance, the following expression:: full_name = Word(alphas) + Word(alphas) will return the parse of "John Smith" as ['John', 'Smith']. In some applications, the actual name as it was given in the input string is what is desired. To do this, use ``original_text_for``:: full_name = original_text_for(Word(alphas) + Word(alphas)) h](h`)}(h``original_text_for(expr)`` - helper function to preserve the originally parsed text, regardless of any token processing or conversion done by the contained expression. For instance, the following expression::h](j)}(h``original_text_for(expr)``h]horiginal_text_for(expr)}(hhh jAubah#}(h%]h']h*]h,]h.]uh0jh jAubh - helper function to preserve the originally parsed text, regardless of any token processing or conversion done by the contained expression. For instance, the following expression:}(h - helper function to preserve the originally parsed text, regardless of any token processing or conversion done by the contained expression. For instance, the following expression:h jAubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jAubjd)}(h'full_name = Word(alphas) + Word(alphas)h]h'full_name = Word(alphas) + Word(alphas)}(hhh jAubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"Mh jAubh`)}(hwill return the parse of "John Smith" as ['John', 'Smith']. In some applications, the actual name as it was given in the input string is what is desired. To do this, use ``original_text_for``::h](hwill return the parse of “John Smith” as [‘John’, ‘Smith’]. In some applications, the actual name as it was given in the input string is what is desired. To do this, use }(hwill return the parse of "John Smith" as ['John', 'Smith']. In some applications, the actual name as it was given in the input string is what is desired. To do this, use h jAubj)}(h``original_text_for``h]horiginal_text_for}(hhh jAubah#}(h%]h']h*]h,]h.]uh0jh jAubh:}(hj!h jAubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jAubjd)}(h:full_name = original_text_for(Word(alphas) + Word(alphas))h]h:full_name = original_text_for(Word(alphas) + Word(alphas))}(hhh jBubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"Mh jAubeh#}(h%]h']h*]h,]h.]uh0jh jAhhh!h>h"Nubj)}(h``ungroup(expr)`` - function to "ungroup" returned tokens; useful to undo the default behavior of And_ to always group the returned tokens, even if there is only one in the list. h]h`)}(h``ungroup(expr)`` - function to "ungroup" returned tokens; useful to undo the default behavior of And_ to always group the returned tokens, even if there is only one in the list.h](j)}(h``ungroup(expr)``h]h ungroup(expr)}(hhh jBubah#}(h%]h']h*]h,]h.]uh0jh jBubhU - function to “ungroup” returned tokens; useful to undo the default behavior of }(hQ - function to "ungroup" returned tokens; useful to undo the default behavior of h jBubh)}(hAnd_h]hAnd}(hAndh j2Bubah#}(h%]h']h*]h,]h.]namej:Bhh"Mh jBubah#}(h%]h']h*]h,]h.]uh0jh jAhhh!h>h"Nubj)}(h``lineno(loc, string)`` - function to give the line number of the location within the string; the first line is line 1, newlines start new rows h]h`)}(h``lineno(loc, string)`` - function to give the line number of the location within the string; the first line is line 1, newlines start new rowsh](j)}(h``lineno(loc, string)``h]hlineno(loc, string)}(hhh j[Bubah#}(h%]h']h*]h,]h.]uh0jh jWBubhx - function to give the line number of the location within the string; the first line is line 1, newlines start new rows}(hx - function to give the line number of the location within the string; the first line is line 1, newlines start new rowsh jWBubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jSBubah#}(h%]h']h*]h,]h.]uh0jh jAhhh!h>h"Nubj)}(h``col(loc, string)`` - function to give the column number of the location within the string; the first column is column 1, newlines reset the column number to 1 h]h`)}(h``col(loc, string)`` - function to give the column number of the location within the string; the first column is column 1, newlines reset the column number to 1h](j)}(h``col(loc, string)``h]hcol(loc, string)}(hhh jBubah#}(h%]h']h*]h,]h.]uh0jh j~Bubh - function to give the column number of the location within the string; the first column is column 1, newlines reset the column number to 1}(h - function to give the column number of the location within the string; the first column is column 1, newlines reset the column number to 1h j~Bubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jzBubah#}(h%]h']h*]h,]h.]uh0jh jAhhh!h>h"Nubj)}(h``line(loc, string)`` - function to retrieve the line of text representing ``lineno(loc, string)``; useful when printing out diagnostic messages for exceptions h]h`)}(h``line(loc, string)`` - function to retrieve the line of text representing ``lineno(loc, string)``; useful when printing out diagnostic messages for exceptionsh](j)}(h``line(loc, string)``h]hline(loc, string)}(hhh jBubah#}(h%]h']h*]h,]h.]uh0jh jBubh6 - function to retrieve the line of text representing }(h6 - function to retrieve the line of text representing h jBubj)}(h``lineno(loc, string)``h]hlineno(loc, string)}(hhh jBubah#}(h%]h']h*]h,]h.]uh0jh jBubh=; useful when printing out diagnostic messages for exceptions}(h=; useful when printing out diagnostic messages for exceptionsh jBubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jBubah#}(h%]h']h*]h,]h.]uh0jh jAhhh!h>h"Nubj)}(hXW``srange(range_spec)`` - function to define a string of characters, given a string of the form used by regexp string ranges, such as ``"[0-9]"`` for all numeric digits, ``"[A-Z_]"`` for uppercase characters plus underscore, and so on (note that ``range_spec`` does not include support for generic regular expressions, just string range specs) h]h`)}(hXV``srange(range_spec)`` - function to define a string of characters, given a string of the form used by regexp string ranges, such as ``"[0-9]"`` for all numeric digits, ``"[A-Z_]"`` for uppercase characters plus underscore, and so on (note that ``range_spec`` does not include support for generic regular expressions, just string range specs)h](j)}(h``srange(range_spec)``h]hsrange(range_spec)}(hhh jBubah#}(h%]h']h*]h,]h.]uh0jh jBubho - function to define a string of characters, given a string of the form used by regexp string ranges, such as }(ho - function to define a string of characters, given a string of the form used by regexp string ranges, such as h jBubj)}(h ``"[0-9]"``h]h"[0-9]"}(hhh jBubah#}(h%]h']h*]h,]h.]uh0jh jBubh for all numeric digits, }(h for all numeric digits, h jBubj)}(h ``"[A-Z_]"``h]h"[A-Z_]"}(hhh j Cubah#}(h%]h']h*]h,]h.]uh0jh jBubh@ for uppercase characters plus underscore, and so on (note that }(h@ for uppercase characters plus underscore, and so on (note that h jBubj)}(h``range_spec``h]h range_spec}(hhh jCubah#}(h%]h']h*]h,]h.]uh0jh jBubhS does not include support for generic regular expressions, just string range specs)}(hS does not include support for generic regular expressions, just string range specs)h jBubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jBubah#}(h%]h']h*]h,]h.]uh0jh jAhhh!h>h"Nubj)}(h``trace_parse_action(fn)`` - decorator function to debug parse actions. Lists each call, called arguments, and return value or exception h]h`)}(h``trace_parse_action(fn)`` - decorator function to debug parse actions. Lists each call, called arguments, and return value or exceptionh](j)}(h``trace_parse_action(fn)``h]htrace_parse_action(fn)}(hhh jCCubah#}(h%]h']h*]h,]h.]uh0jh j?Cubhn - decorator function to debug parse actions. Lists each call, called arguments, and return value or exception}(hn - decorator function to debug parse actions. Lists each call, called arguments, and return value or exceptionh j?Cubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j;Cubah#}(h%]h']h*]h,]h.]uh0jh jAhhh!h>h"Nubeh#}(h%]jAah']h*]originaltextforah,]h.]j j uh0jh!h>h"Mh j9hhjN}jfCjAsjP}jAjAsubeh#}(h%]jah']h*]helper methodsah,]h.]uh0h h j9hhh!h>h"Mubh )}(hhh](h)}(hjh](h)}(hhh]h 1.3.2   }(hhh jxChhh!Nh"Nubah#}(h%]h']h)ah*]h,]h.]uh0hh juChhh!Nh"NubhHelper parse actions}(hjh juChhh!Nh"Nubeh#}(h%]h']h*]h,]h.]h;Khh"Mubj)}(hhh](j)}(h``remove_quotes`` - removes the first and last characters of a quoted string; useful to remove the delimiting quotes from quoted strings h]h`)}(h``remove_quotes`` - removes the first and last characters of a quoted string; useful to remove the delimiting quotes from quoted stringsh](j)}(h``remove_quotes``h]h remove_quotes}(hhh jCubah#}(h%]h']h*]h,]h.]uh0jh jCubhw - removes the first and last characters of a quoted string; useful to remove the delimiting quotes from quoted strings}(hw - removes the first and last characters of a quoted string; useful to remove the delimiting quotes from quoted stringsh jCubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jCubah#}(h%]h']h*]h,]h.]uh0jh jChhh!h>h"Nubj)}(h``replace_with(repl_string)`` - returns a parse action that simply returns the ``repl_string``; useful when using ``transform_string``, or converting HTML entities, as in:: nbsp = Literal(" ").set_parse_action(replace_with("")) h](h`)}(h``replace_with(repl_string)`` - returns a parse action that simply returns the ``repl_string``; useful when using ``transform_string``, or converting HTML entities, as in::h](j)}(h``replace_with(repl_string)``h]hreplace_with(repl_string)}(hhh jCubah#}(h%]h']h*]h,]h.]uh0jh jCubh2 - returns a parse action that simply returns the }(h2 - returns a parse action that simply returns the h jCubj)}(h``repl_string``h]h repl_string}(hhh jCubah#}(h%]h']h*]h,]h.]uh0jh jCubh; useful when using }(h; useful when using h jCubj)}(h``transform_string``h]htransform_string}(hhh jCubah#}(h%]h']h*]h,]h.]uh0jh jCubh%, or converting HTML entities, as in:}(h%, or converting HTML entities, as in:h jCubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jCubjd)}(hBnbsp = Literal(" ").set_parse_action(replace_with(""))h]hBnbsp = Literal(" ").set_parse_action(replace_with(""))}(hhh jDubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"Mh jCubeh#}(h%]h']h*]h,]h.]uh0jh jChhh!h>h"Nubj)}(h``original_text_for``- restores any internal whitespace or suppressed text within the tokens for a matched parse expression. This is especially useful when defining expressions for ``scan_string`` or ``transform_string`` applications. h]h`)}(h``original_text_for``- restores any internal whitespace or suppressed text within the tokens for a matched parse expression. This is especially useful when defining expressions for ``scan_string`` or ``transform_string`` applications.h](j)}(h``original_text_for``h]horiginal_text_for}(hhh jDubah#}(h%]h']h*]h,]h.]uh0jh jDubh- restores any internal whitespace or suppressed text within the tokens for a matched parse expression. This is especially useful when defining expressions for }(h- restores any internal whitespace or suppressed text within the tokens for a matched parse expression. This is especially useful when defining expressions for h jDubj)}(h``scan_string``h]h scan_string}(hhh j/Dubah#}(h%]h']h*]h,]h.]uh0jh jDubh or }(h or h jDubj)}(h``transform_string``h]htransform_string}(hhh jBDubah#}(h%]h']h*]h,]h.]uh0jh jDubh applications.}(h applications.h jDubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jDubah#}(h%]h']h*]h,]h.]uh0jh jChhh!h>h"Nubj)}(hX``with_attribute(*args, **kwargs)`` - helper to create a validating parse action to be used with start tags created with ``make_xml_tags`` or ``make_html_tags``. Use ``with_attribute`` to qualify a starting tag with a required attribute value, to avoid false matches on common tags such as ```` or ``
``. ``with_attribute`` can be called with: - keyword arguments, as in ``(class="Customer", align="right")``, or - a list of name-value tuples, as in ``(("ns1:class", "Customer"), ("ns2:align", "right"))`` An attribute can be specified to have the special value ``with_attribute.ANY_VALUE``, which will match any value - use this to ensure that an attribute is present but any attribute value is acceptable. h](h`)}(hX8``with_attribute(*args, **kwargs)`` - helper to create a validating parse action to be used with start tags created with ``make_xml_tags`` or ``make_html_tags``. Use ``with_attribute`` to qualify a starting tag with a required attribute value, to avoid false matches on common tags such as ```` or ``
``.h](j)}(h#``with_attribute(*args, **kwargs)``h]hwith_attribute(*args, **kwargs)}(hhh jiDubah#}(h%]h']h*]h,]h.]uh0jh jeDubhV - helper to create a validating parse action to be used with start tags created with }(hV - helper to create a validating parse action to be used with start tags created with h jeDubj)}(h``make_xml_tags``h]h make_xml_tags}(hhh j|Dubah#}(h%]h']h*]h,]h.]uh0jh jeDubh or }(h or h jeDubj)}(h``make_html_tags``h]hmake_html_tags}(hhh jDubah#}(h%]h']h*]h,]h.]uh0jh jeDubh. Use }(h. Use h jeDubj)}(h``with_attribute``h]hwith_attribute}(hhh jDubah#}(h%]h']h*]h,]h.]uh0jh jeDubhj to qualify a starting tag with a required attribute value, to avoid false matches on common tags such as }(hj to qualify a starting tag with a required attribute value, to avoid false matches on common tags such as h jeDubj)}(h````h]h}(hhh jDubah#}(h%]h']h*]h,]h.]uh0jh jeDubh or }(hjDh jeDubj)}(h ``
``h]h
}(hhh jDubah#}(h%]h']h*]h,]h.]uh0jh jeDubh.}(hj h jeDubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jaDubh`)}(h&``with_attribute`` can be called with:h](j)}(h``with_attribute``h]hwith_attribute}(hhh jDubah#}(h%]h']h*]h,]h.]uh0jh jDubh can be called with:}(h can be called with:h jDubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jaDubj)}(hhh](j)}(hCkeyword arguments, as in ``(class="Customer", align="right")``, or h]h`)}(hBkeyword arguments, as in ``(class="Customer", align="right")``, orh](hkeyword arguments, as in }(hkeyword arguments, as in h jEubj)}(h%``(class="Customer", align="right")``h]h!(class="Customer", align="right")}(hhh j Eubah#}(h%]h']h*]h,]h.]uh0jh jEubh, or}(h, orh jEubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jDubah#}(h%]h']h*]h,]h.]uh0jh jDubj)}(h[a list of name-value tuples, as in ``(("ns1:class", "Customer"), ("ns2:align", "right"))`` h]h`)}(hZa list of name-value tuples, as in ``(("ns1:class", "Customer"), ("ns2:align", "right"))``h](h#a list of name-value tuples, as in }(h#a list of name-value tuples, as in h j/Eubj)}(h7``(("ns1:class", "Customer"), ("ns2:align", "right"))``h]h3(("ns1:class", "Customer"), ("ns2:align", "right"))}(hhh j8Eubah#}(h%]h']h*]h,]h.]uh0jh j/Eubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j+Eubah#}(h%]h']h*]h,]h.]uh0jh jDubeh#}(h%]h']h*]h,]h.]j j uh0jh!h>h"Mh jaDubh`)}(hAn attribute can be specified to have the special value ``with_attribute.ANY_VALUE``, which will match any value - use this to ensure that an attribute is present but any attribute value is acceptable.h](h8An attribute can be specified to have the special value }(h8An attribute can be specified to have the special value h jXEubj)}(h``with_attribute.ANY_VALUE``h]hwith_attribute.ANY_VALUE}(hhh jaEubah#}(h%]h']h*]h,]h.]uh0jh jXEubhu, which will match any value - use this to ensure that an attribute is present but any attribute value is acceptable.}(hu, which will match any value - use this to ensure that an attribute is present but any attribute value is acceptable.h jXEubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jaDubeh#}(h%]h']h*]h,]h.]uh0jh jChhh!h>h"Nubj)}(h``match_only_at_col(column_number)`` - a parse action that verifies that an expression was matched at a particular column, raising a ``ParseException`` if matching at a different column number; useful when parsing tabular data h]h`)}(h``match_only_at_col(column_number)`` - a parse action that verifies that an expression was matched at a particular column, raising a ``ParseException`` if matching at a different column number; useful when parsing tabular datah](j)}(h$``match_only_at_col(column_number)``h]h match_only_at_col(column_number)}(hhh jEubah#}(h%]h']h*]h,]h.]uh0jh jEubha - a parse action that verifies that an expression was matched at a particular column, raising a }(ha - a parse action that verifies that an expression was matched at a particular column, raising a h jEubj)}(h``ParseException``h]hParseException}(hhh jEubah#}(h%]h']h*]h,]h.]uh0jh jEubhK if matching at a different column number; useful when parsing tabular data}(hK if matching at a different column number; useful when parsing tabular datah jEubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jEubah#}(h%]h']h*]h,]h.]uh0jh jChhh!h>h"Nubj)}(hK``common.convert_to_integer()`` - converts all matched tokens to uppercase h]h`)}(hJ``common.convert_to_integer()`` - converts all matched tokens to uppercaseh](j)}(h``common.convert_to_integer()``h]hcommon.convert_to_integer()}(hhh jEubah#}(h%]h']h*]h,]h.]uh0jh jEubh+ - converts all matched tokens to uppercase}(h+ - converts all matched tokens to uppercaseh jEubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jEubah#}(h%]h']h*]h,]h.]uh0jh jChhh!h>h"Nubj)}(hI``common.convert_to_float()`` - converts all matched tokens to uppercase h]h`)}(hH``common.convert_to_float()`` - converts all matched tokens to uppercaseh](j)}(h``common.convert_to_float()``h]hcommon.convert_to_float()}(hhh jEubah#}(h%]h']h*]h,]h.]uh0jh jEubh+ - converts all matched tokens to uppercase}(h+ - converts all matched tokens to uppercaseh jEubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jEubah#}(h%]h']h*]h,]h.]uh0jh jChhh!h>h"Nubj)}(hI``common.convert_to_date()`` - converts matched token to a datetime.date h]h`)}(hH``common.convert_to_date()`` - converts matched token to a datetime.dateh](j)}(h``common.convert_to_date()``h]hcommon.convert_to_date()}(hhh jFubah#}(h%]h']h*]h,]h.]uh0jh j Fubh, - converts matched token to a datetime.date}(h, - converts matched token to a datetime.dateh j Fubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jFubah#}(h%]h']h*]h,]h.]uh0jh jChhh!h>h"Nubj)}(hQ``common.convert_to_datetime()`` - converts matched token to a datetime.datetime h]h`)}(hP``common.convert_to_datetime()`` - converts matched token to a datetime.datetimeh](j)}(h ``common.convert_to_datetime()``h]hcommon.convert_to_datetime()}(hhh j7Fubah#}(h%]h']h*]h,]h.]uh0jh j3Fubh0 - converts matched token to a datetime.datetime}(h0 - converts matched token to a datetime.datetimeh j3Fubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j/Fubah#}(h%]h']h*]h,]h.]uh0jh jChhh!h>h"Nubj)}(hD``common.strip_html_tags()`` - removes HTML tags from matched token h]h`)}(hC``common.strip_html_tags()`` - removes HTML tags from matched tokenh](j)}(h``common.strip_html_tags()``h]hcommon.strip_html_tags()}(hhh j^Fubah#}(h%]h']h*]h,]h.]uh0jh jZFubh' - removes HTML tags from matched token}(h' - removes HTML tags from matched tokenh jZFubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jVFubah#}(h%]h']h*]h,]h.]uh0jh jChhh!h>h"Nubj)}(hH``common.downcase_tokens()`` - converts all matched tokens to lowercase h]h`)}(hG``common.downcase_tokens()`` - converts all matched tokens to lowercaseh](j)}(h``common.downcase_tokens()``h]hcommon.downcase_tokens()}(hhh jFubah#}(h%]h']h*]h,]h.]uh0jh jFubh+ - converts all matched tokens to lowercase}(h+ - converts all matched tokens to lowercaseh jFubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j}Fubah#}(h%]h']h*]h,]h.]uh0jh jChhh!h>h"Nubj)}(hG``common.upcase_tokens()`` - converts all matched tokens to uppercase h]h`)}(hE``common.upcase_tokens()`` - converts all matched tokens to uppercaseh](j)}(h``common.upcase_tokens()``h]hcommon.upcase_tokens()}(hhh jFubah#}(h%]h']h*]h,]h.]uh0jh jFubh+ - converts all matched tokens to uppercase}(h+ - converts all matched tokens to uppercaseh jFubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jFubah#}(h%]h']h*]h,]h.]uh0jh jChhh!h>h"Nubeh#}(h%]h']h*]h,]h.]j j uh0jh!h>h"Mh jrChhubeh#}(h%]jah']h*]helper parse actionsah,]h.]uh0h h j9hhh!h>h"Mubh )}(hhh](h)}(hj h](h)}(hhh]h 1.3.3   }(hhh jFhhh!Nh"Nubah#}(h%]h']h)ah*]h,]h.]uh0hh jFhhh!Nh"Nubh!Common string and token constants}(hj h jFhhh!Nh"Nubeh#}(h%]h']h*]h,]h.]h;Khh"Mubj)}(hhh](j)}(h(``alphas`` - same as ``string.letters`` h]h`)}(h'``alphas`` - same as ``string.letters``h](j)}(h ``alphas``h]halphas}(hhh jGubah#}(h%]h']h*]h,]h.]uh0jh jFubh - same as }(h - same as h jFubj)}(h``string.letters``h]hstring.letters}(hhh jGubah#}(h%]h']h*]h,]h.]uh0jh jFubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jFubah#}(h%]h']h*]h,]h.]uh0jh jFhhh!h>h"Nubj)}(h%``nums`` - same as ``string.digits`` h]h`)}(h$``nums`` - same as ``string.digits``h](j)}(h``nums``h]hnums}(hhh j5Gubah#}(h%]h']h*]h,]h.]uh0jh j1Gubh - same as }(h - same as h j1Gubj)}(h``string.digits``h]h string.digits}(hhh jHGubah#}(h%]h']h*]h,]h.]uh0jh j1Gubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j-Gubah#}(h%]h']h*]h,]h.]uh0jh jFhhh!h>h"Nubj)}(h6``alphanums`` - a string containing ``alphas + nums`` h]h`)}(h5``alphanums`` - a string containing ``alphas + nums``h](j)}(h ``alphanums``h]h alphanums}(hhh jjGubah#}(h%]h']h*]h,]h.]uh0jh jfGubh - a string containing }(h - a string containing h jfGubj)}(h``alphas + nums``h]h alphas + nums}(hhh j}Gubah#}(h%]h']h*]h,]h.]uh0jh jfGubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jbGubah#}(h%]h']h*]h,]h.]uh0jh jFhhh!h>h"Nubj)}(h``alphas8bit`` - a string containing alphabetic 8-bit characters:: ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ h](h`)}(hB``alphas8bit`` - a string containing alphabetic 8-bit characters::h](j)}(h``alphas8bit``h]h alphas8bit}(hhh jGubah#}(h%]h']h*]h,]h.]uh0jh jGubh3 - a string containing alphabetic 8-bit characters:}(h3 - a string containing alphabetic 8-bit characters:h jGubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jGubjd)}(hzÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþh]hzÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ}(hhh jGubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"Mh jGubeh#}(h%]h']h*]h,]h.]uh0jh jFhhh!h>h"Nubj)}(hS``printables`` - same as ``string.printable``, minus the space (``' '``) character h]h`)}(hR``printables`` - same as ``string.printable``, minus the space (``' '``) characterh](j)}(h``printables``h]h printables}(hhh jGubah#}(h%]h']h*]h,]h.]uh0jh jGubh - same as }(h - same as h jGubj)}(h``string.printable``h]hstring.printable}(hhh jGubah#}(h%]h']h*]h,]h.]uh0jh jGubh, minus the space (}(h, minus the space (h jGubj)}(h``' '``h]h' '}(hhh jGubah#}(h%]h']h*]h,]h.]uh0jh jGubh ) character}(h ) characterh jGubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jGubah#}(h%]h']h*]h,]h.]uh0jh jFhhh!h>h"Nubj)}(h4``empty`` - a global ``Empty()``; will always match h]h`)}(h3``empty`` - a global ``Empty()``; will always matchh](j)}(h ``empty``h]hempty}(hhh j!Hubah#}(h%]h']h*]h,]h.]uh0jh jHubh - a global }(h - a global h jHubj)}(h ``Empty()``h]hEmpty()}(hhh j4Hubah#}(h%]h']h*]h,]h.]uh0jh jHubh; will always match}(h; will always matchh jHubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jHubah#}(h%]h']h*]h,]h.]uh0jh jFhhh!h>h"Nubj)}(hh``sgl_quoted_string`` - a string of characters enclosed in 's; may include whitespace, but not newlines h]h`)}(hg``sgl_quoted_string`` - a string of characters enclosed in 's; may include whitespace, but not newlinesh](j)}(h``sgl_quoted_string``h]hsgl_quoted_string}(hhh j[Hubah#}(h%]h']h*]h,]h.]uh0jh jWHubhT - a string of characters enclosed in ‘s; may include whitespace, but not newlines}(hR - a string of characters enclosed in 's; may include whitespace, but not newlinesh jWHubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jSHubah#}(h%]h']h*]h,]h.]uh0jh jFhhh!h>h"Nubj)}(hh``dbl_quoted_string`` - a string of characters enclosed in "s; may include whitespace, but not newlines h]h`)}(hg``dbl_quoted_string`` - a string of characters enclosed in "s; may include whitespace, but not newlinesh](j)}(h``dbl_quoted_string``h]hdbl_quoted_string}(hhh jHubah#}(h%]h']h*]h,]h.]uh0jh j~HubhT - a string of characters enclosed in “s; may include whitespace, but not newlines}(hR - a string of characters enclosed in "s; may include whitespace, but not newlinesh j~Hubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jzHubah#}(h%]h']h*]h,]h.]uh0jh jFhhh!h>h"Nubj)}(h>``quoted_string`` - ``sgl_quoted_string | dbl_quoted_string`` h]h`)}(h=``quoted_string`` - ``sgl_quoted_string | dbl_quoted_string``h](j)}(h``quoted_string``h]h quoted_string}(hhh jHubah#}(h%]h']h*]h,]h.]uh0jh jHubh - }(h - h jHubj)}(h)``sgl_quoted_string | dbl_quoted_string``h]h%sgl_quoted_string | dbl_quoted_string}(hhh jHubah#}(h%]h']h*]h,]h.]uh0jh jHubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jHubah#}(h%]h']h*]h,]h.]uh0jh jFhhh!h>h"Nubj)}(h``c_style_comment`` - a comment block delimited by ``'/*'`` and ``'*/'`` sequences; can span multiple lines, but does not support nesting of comments h]h`)}(h``c_style_comment`` - a comment block delimited by ``'/*'`` and ``'*/'`` sequences; can span multiple lines, but does not support nesting of commentsh](j)}(h``c_style_comment``h]hc_style_comment}(hhh jHubah#}(h%]h']h*]h,]h.]uh0jh jHubh - a comment block delimited by }(h - a comment block delimited by h jHubj)}(h``'/*'``h]h'/*'}(hhh jHubah#}(h%]h']h*]h,]h.]uh0jh jHubh and }(h and h jHubj)}(h``'*/'``h]h'*/'}(hhh jIubah#}(h%]h']h*]h,]h.]uh0jh jHubhM sequences; can span multiple lines, but does not support nesting of comments}(hM sequences; can span multiple lines, but does not support nesting of commentsh jHubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M h jHubah#}(h%]h']h*]h,]h.]uh0jh jFhhh!h>h"Nubj)}(h``html_comment`` - a comment block delimited by ``''`` sequences; can span multiple lines, but does not support nesting of comments h]h`)}(h``html_comment`` - a comment block delimited by ``''`` sequences; can span multiple lines, but does not support nesting of commentsh](j)}(h``html_comment``h]h html_comment}(hhh j+Iubah#}(h%]h']h*]h,]h.]uh0jh j'Iubh - a comment block delimited by }(h - a comment block delimited by h j'Iubj)}(h ``''``h]h'-->'}(hhh jQIubah#}(h%]h']h*]h,]h.]uh0jh j'IubhM sequences; can span multiple lines, but does not support nesting of comments}(hM sequences; can span multiple lines, but does not support nesting of commentsh j'Iubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M h j#Iubah#}(h%]h']h*]h,]h.]uh0jh jFhhh!h>h"Nubj)}(h``comma_separated_list`` - similar to ``delimited_list``, except that the list expressions can be any text value, or a quoted string; quoted strings can safely include commas without incorrectly breaking the string into two tokens h]h`)}(h``comma_separated_list`` - similar to ``delimited_list``, except that the list expressions can be any text value, or a quoted string; quoted strings can safely include commas without incorrectly breaking the string into two tokensh](j)}(h``comma_separated_list``h]hcomma_separated_list}(hhh jxIubah#}(h%]h']h*]h,]h.]uh0jh jtIubh - similar to }(h - similar to h jtIubj)}(h``delimited_list``h]hdelimited_list}(hhh jIubah#}(h%]h']h*]h,]h.]uh0jh jtIubh, except that the list expressions can be any text value, or a quoted string; quoted strings can safely include commas without incorrectly breaking the string into two tokens}(h, except that the list expressions can be any text value, or a quoted string; quoted strings can safely include commas without incorrectly breaking the string into two tokensh jtIubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jpIubah#}(h%]h']h*]h,]h.]uh0jh jFhhh!h>h"Nubj)}(h_``rest_of_line`` - all remaining printable characters up to but not including the next newline h]h`)}(h^``rest_of_line`` - all remaining printable characters up to but not including the next newlineh](j)}(h``rest_of_line``h]h rest_of_line}(hhh jIubah#}(h%]h']h*]h,]h.]uh0jh jIubhN - all remaining printable characters up to but not including the next newline}(hN - all remaining printable characters up to but not including the next newlineh jIubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jIubah#}(h%]h']h*]h,]h.]uh0jh jFhhh!h>h"Nubj)}(hW``common.integer`` - an integer with no leading sign; parsed token is converted to int h]h`)}(hV``common.integer`` - an integer with no leading sign; parsed token is converted to inth](j)}(h``common.integer``h]hcommon.integer}(hhh jIubah#}(h%]h']h*]h,]h.]uh0jh jIubhD - an integer with no leading sign; parsed token is converted to int}(hD - an integer with no leading sign; parsed token is converted to inth jIubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jIubah#}(h%]h']h*]h,]h.]uh0jh jFhhh!h>h"Nubj)}(hQ``common.hex_integer`` - a hexadecimal integer; parsed token is converted to int h]h`)}(hP``common.hex_integer`` - a hexadecimal integer; parsed token is converted to inth](j)}(h``common.hex_integer``h]hcommon.hex_integer}(hhh jJubah#}(h%]h']h*]h,]h.]uh0jh jIubh: - a hexadecimal integer; parsed token is converted to int}(h: - a hexadecimal integer; parsed token is converted to inth jIubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jIubah#}(h%]h']h*]h,]h.]uh0jh jFhhh!h>h"Nubj)}(hd``common.signed_integer`` - an integer with optional leading sign; parsed token is converted to int h]h`)}(hc``common.signed_integer`` - an integer with optional leading sign; parsed token is converted to inth](j)}(h``common.signed_integer``h]hcommon.signed_integer}(hhh j'Jubah#}(h%]h']h*]h,]h.]uh0jh j#JubhJ - an integer with optional leading sign; parsed token is converted to int}(hJ - an integer with optional leading sign; parsed token is converted to inth j#Jubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jJubah#}(h%]h']h*]h,]h.]uh0jh jFhhh!h>h"Nubj)}(h^``common.fraction`` - signed_integer '/' signed_integer; parsed tokens are converted to float h]h`)}(h]``common.fraction`` - signed_integer '/' signed_integer; parsed tokens are converted to floath](j)}(h``common.fraction``h]hcommon.fraction}(hhh jNJubah#}(h%]h']h*]h,]h.]uh0jh jJJubhN - signed_integer ‘/’ signed_integer; parsed tokens are converted to float}(hJ - signed_integer '/' signed_integer; parsed tokens are converted to floath jJJubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jFJubah#}(h%]h']h*]h,]h.]uh0jh jFhhh!h>h"Nubj)}(h]``common.mixed_integer`` - signed_integer '-' fraction; parsed tokens are converted to float h]h`)}(h\``common.mixed_integer`` - signed_integer '-' fraction; parsed tokens are converted to floath](j)}(h``common.mixed_integer``h]hcommon.mixed_integer}(hhh juJubah#}(h%]h']h*]h,]h.]uh0jh jqJubhH - signed_integer ‘-‘ fraction; parsed tokens are converted to float}(hD - signed_integer '-' fraction; parsed tokens are converted to floath jqJubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jmJubah#}(h%]h']h*]h,]h.]uh0jh jFhhh!h>h"Nubj)}(hD``common.real`` - real number; parsed tokens are converted to float h]h`)}(hC``common.real`` - real number; parsed tokens are converted to floath](j)}(h``common.real``h]h common.real}(hhh jJubah#}(h%]h']h*]h,]h.]uh0jh jJubh4 - real number; parsed tokens are converted to float}(h4 - real number; parsed tokens are converted to floath jJubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M!h jJubah#}(h%]h']h*]h,]h.]uh0jh jFhhh!h>h"Nubj)}(hh``common.sci_real`` - real number with optional scientific notation; parsed tokens are convert to float h]h`)}(hg``common.sci_real`` - real number with optional scientific notation; parsed tokens are convert to floath](j)}(h``common.sci_real``h]hcommon.sci_real}(hhh jJubah#}(h%]h']h*]h,]h.]uh0jh jJubhT - real number with optional scientific notation; parsed tokens are convert to float}(hT - real number with optional scientific notation; parsed tokens are convert to floath jJubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M#h jJubah#}(h%]h']h*]h,]h.]uh0jh jFhhh!h>h"Nubj)}(hn``common.number`` - any numeric expression; parsed tokens are returned as converted by the matched expression h]h`)}(hm``common.number`` - any numeric expression; parsed tokens are returned as converted by the matched expressionh](j)}(h``common.number``h]h common.number}(hhh jJubah#}(h%]h']h*]h,]h.]uh0jh jJubh\ - any numeric expression; parsed tokens are returned as converted by the matched expression}(h\ - any numeric expression; parsed tokens are returned as converted by the matched expressionh jJubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M%h jJubah#}(h%]h']h*]h,]h.]uh0jh jFhhh!h>h"Nubj)}(hR``common.fnumber`` - any numeric expression; parsed tokens are converted to float h]h`)}(hQ``common.fnumber`` - any numeric expression; parsed tokens are converted to floath](j)}(h``common.fnumber``h]hcommon.fnumber}(hhh jKubah#}(h%]h']h*]h,]h.]uh0jh j Kubh? - any numeric expression; parsed tokens are converted to float}(h? - any numeric expression; parsed tokens are converted to floath j Kubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M'h j Kubah#}(h%]h']h*]h,]h.]uh0jh jFhhh!h>h"Nubj)}(h``common.identifier`` - a programming identifier (follows Python's syntax convention of leading alpha or "_", followed by 0 or more alpha, num, or "_") h]h`)}(h``common.identifier`` - a programming identifier (follows Python's syntax convention of leading alpha or "_", followed by 0 or more alpha, num, or "_")h](j)}(h``common.identifier``h]hcommon.identifier}(hhh j8Kubah#}(h%]h']h*]h,]h.]uh0jh j4Kubh - a programming identifier (follows Python’s syntax convention of leading alpha or “_”, followed by 0 or more alpha, num, or “_”)}(h - a programming identifier (follows Python's syntax convention of leading alpha or "_", followed by 0 or more alpha, num, or "_")h j4Kubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M)h j0Kubah#}(h%]h']h*]h,]h.]uh0jh jFhhh!h>h"Nubj)}(h'``common.ipv4_address`` - IPv4 address h]h`)}(h&``common.ipv4_address`` - IPv4 addressh](j)}(h``common.ipv4_address``h]hcommon.ipv4_address}(hhh j_Kubah#}(h%]h']h*]h,]h.]uh0jh j[Kubh - IPv4 address}(h - IPv4 addressh j[Kubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M,h jWKubah#}(h%]h']h*]h,]h.]uh0jh jFhhh!h>h"Nubj)}(h'``common.ipv6_address`` - IPv6 address h]h`)}(h&``common.ipv6_address`` - IPv6 addressh](j)}(h``common.ipv6_address``h]hcommon.ipv6_address}(hhh jKubah#}(h%]h']h*]h,]h.]uh0jh jKubh - IPv6 address}(h - IPv6 addressh jKubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M.h j~Kubah#}(h%]h']h*]h,]h.]uh0jh jFhhh!h>h"Nubj)}(hH``common.mac_address`` - MAC address (with ":", "-", or "." delimiters) h]h`)}(hG``common.mac_address`` - MAC address (with ":", "-", or "." delimiters)h](j)}(h``common.mac_address``h]hcommon.mac_address}(hhh jKubah#}(h%]h']h*]h,]h.]uh0jh jKubh= - MAC address (with “:”, “-“, or “.” delimiters)}(h1 - MAC address (with ":", "-", or "." delimiters)h jKubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M0h jKubah#}(h%]h']h*]h,]h.]uh0jh jFhhh!h>h"Nubj)}(h8``common.iso8601_date`` - date in ``YYYY-MM-DD`` format h]h`)}(h7``common.iso8601_date`` - date in ``YYYY-MM-DD`` formath](j)}(h``common.iso8601_date``h]hcommon.iso8601_date}(hhh jKubah#}(h%]h']h*]h,]h.]uh0jh jKubh - date in }(h - date in h jKubj)}(h``YYYY-MM-DD``h]h YYYY-MM-DD}(hhh jKubah#}(h%]h']h*]h,]h.]uh0jh jKubh format}(h formath jKubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M2h jKubah#}(h%]h']h*]h,]h.]uh0jh jFhhh!h>h"Nubj)}(h``common.iso8601_datetime`` - datetime in ``YYYY-MM-DDThh:mm:ss.s(Z|+-00:00)`` format; trailing seconds, milliseconds, and timezone optional; accepts separating ``'T'`` or ``' '`` h]h`)}(h``common.iso8601_datetime`` - datetime in ``YYYY-MM-DDThh:mm:ss.s(Z|+-00:00)`` format; trailing seconds, milliseconds, and timezone optional; accepts separating ``'T'`` or ``' '``h](j)}(h``common.iso8601_datetime``h]hcommon.iso8601_datetime}(hhh jLubah#}(h%]h']h*]h,]h.]uh0jh j Lubh - datetime in }(h - datetime in h j Lubj)}(h$``YYYY-MM-DDThh:mm:ss.s(Z|+-00:00)``h]h YYYY-MM-DDThh:mm:ss.s(Z|+-00:00)}(hhh j!Lubah#}(h%]h']h*]h,]h.]uh0jh j LubhS format; trailing seconds, milliseconds, and timezone optional; accepts separating }(hS format; trailing seconds, milliseconds, and timezone optional; accepts separating h j Lubj)}(h``'T'``h]h'T'}(hhh j4Lubah#}(h%]h']h*]h,]h.]uh0jh j Lubh or }(h or h j Lubj)}(h``' '``h]h' '}(hhh jGLubah#}(h%]h']h*]h,]h.]uh0jh j Lubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M4h jLubah#}(h%]h']h*]h,]h.]uh0jh jFhhh!h>h"Nubj)}(h``common.url`` - matches URL strings and returns a ParseResults with named fields like those returned by ``urllib.parse.urlparse()`` h]h`)}(h``common.url`` - matches URL strings and returns a ParseResults with named fields like those returned by ``urllib.parse.urlparse()``h](j)}(h``common.url``h]h common.url}(hhh jiLubah#}(h%]h']h*]h,]h.]uh0jh jeLubh[ - matches URL strings and returns a ParseResults with named fields like those returned by }(h[ - matches URL strings and returns a ParseResults with named fields like those returned by h jeLubj)}(h``urllib.parse.urlparse()``h]hurllib.parse.urlparse()}(hhh j|Lubah#}(h%]h']h*]h,]h.]uh0jh jeLubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M7h jaLubah#}(h%]h']h*]h,]h.]uh0jh jFhhh!h>h"Nubeh#}(h%]h']h*]h,]h.]j j uh0jh!h>h"Mh jFhhubeh#}(h%]jah']h*]!common string and token constantsah,]h.]uh0h h j9hhh!h>h"Mubh )}(hhh](h)}(hj:h](h)}(hhh]h 1.3.4   }(hhh jLhhh!Nh"Nubah#}(h%]h']h)ah*]h,]h.]uh0hh jLhhh!Nh"Nubh0Unicode character sets for international parsing}(hj:h jLhhh!Nh"Nubeh#}(h%]h']h*]h,]h.]h;Khh"M<ubh`)}(hX Pyparsing includes the ``unicode`` namespace that contains definitions for ``alphas``, ``nums``, ``alphanums``, ``identchars``, ``identbodychars``, and ``printables`` for character ranges besides 7- or 8-bit ASCII. You can access them using code like the following::h](hPyparsing includes the }(hPyparsing includes the h jLhhh!Nh"Nubj)}(h ``unicode``h]hunicode}(hhh jLubah#}(h%]h']h*]h,]h.]uh0jh jLubh) namespace that contains definitions for }(h) namespace that contains definitions for h jLhhh!Nh"Nubj)}(h ``alphas``h]halphas}(hhh jLubah#}(h%]h']h*]h,]h.]uh0jh jLubh, }(h, h jLhhh!Nh"Nubj)}(h``nums``h]hnums}(hhh jLubah#}(h%]h']h*]h,]h.]uh0jh jLubh, }(h, h jLubj)}(h ``alphanums``h]h alphanums}(hhh jMubah#}(h%]h']h*]h,]h.]uh0jh jLubh, }(h, h jLhhh!Nh"Nubj)}(h``identchars``h]h identchars}(hhh jMubah#}(h%]h']h*]h,]h.]uh0jh jLubh, }(hjLh jLubj)}(h``identbodychars``h]hidentbodychars}(hhh j'Mubah#}(h%]h']h*]h,]h.]uh0jh jLubh, and }(h, and h jLhhh!Nh"Nubj)}(h``printables``h]h printables}(hhh j:Mubah#}(h%]h']h*]h,]h.]uh0jh jLubhc for character ranges besides 7- or 8-bit ASCII. You can access them using code like the following:}(hc for character ranges besides 7- or 8-bit ASCII. You can access them using code like the following:h jLhhh!Nh"Nubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M=h jLhhubjd)}(himport pyparsing as pp ppu = pp.unicode greek_word = pp.Word(ppu.Greek.alphas) greek_word[...].parse_string("Καλημέρα κόσμε")h]himport pyparsing as pp ppu = pp.unicode greek_word = pp.Word(ppu.Greek.alphas) greek_word[...].parse_string("Καλημέρα κόσμε")}(hhh jSMubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"MAh jLhhubh`)}(h*The following language ranges are defined.h]h*The following language ranges are defined.}(hjcMh jaMhhh!Nh"Nubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"MGh jLhhubh table)}(hhh]h tgroup)}(hhh](h colspec)}(hhh]h#}(h%]h']h*]h,]h.]colwidthKuh0jyMh jvMubjzM)}(hhh]h#}(h%]h']h*]h,]h.]colwidthKuh0jyMh jvMubjzM)}(hhh]h#}(h%]h']h*]h,]h.]colwidthK0uh0jyMh jvMubh tbody)}(hhh](h row)}(hhh](h entry)}(hhh]h`)}(h Unicode seth]h Unicode set}(hjMh jMubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"MJh jMubah#}(h%]h']h*]h,]h.]uh0jMh jMubjM)}(hhh]h`)}(hAlternate namesh]hAlternate names}(hjMh jMubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"MJh jMubah#}(h%]h']h*]h,]h.]uh0jMh jMubjM)}(hhh]h`)}(h Descriptionh]h Description}(hjMh jMubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"MJh jMubah#}(h%]h']h*]h,]h.]uh0jMh jMubeh#}(h%]h']h*]h,]h.]uh0jMh jMubjM)}(hhh](jM)}(hhh]h`)}(hArabich]hArabic}(hjMh jMubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"MLh jMubah#}(h%]h']h*]h,]h.]uh0jMh jMubjM)}(hhh]h`)}(hالعربيةh]hالعربية}(hjNh j Nubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"MLh j Nubah#}(h%]h']h*]h,]h.]uh0jMh jMubjM)}(hhh]h#}(h%]h']h*]h,]h.]uh0jMh jMubeh#}(h%]h']h*]h,]h.]uh0jMh jMubjM)}(hhh](jM)}(hhh]h`)}(hChineseh]hChinese}(hj8Nh j6Nubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"MMh j3Nubah#}(h%]h']h*]h,]h.]uh0jMh j0NubjM)}(hhh]h`)}(h中文h]h中文}(hjONh jMNubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"MMh jJNubah#}(h%]h']h*]h,]h.]uh0jMh j0NubjM)}(hhh]h#}(h%]h']h*]h,]h.]uh0jMh j0Nubeh#}(h%]h']h*]h,]h.]uh0jMh jMubjM)}(hhh](jM)}(hhh]h`)}(hCyrillich]hCyrillic}(hjxNh jvNubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"MNh jsNubah#}(h%]h']h*]h,]h.]uh0jMh jpNubjM)}(hhh]h`)}(hкириллицаh]hкириллица}(hjNh jNubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"MNh jNubah#}(h%]h']h*]h,]h.]uh0jMh jpNubjM)}(hhh]h#}(h%]h']h*]h,]h.]uh0jMh jpNubeh#}(h%]h']h*]h,]h.]uh0jMh jMubjM)}(hhh](jM)}(hhh]h`)}(hGreekh]hGreek}(hjNh jNubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"MOh jNubah#}(h%]h']h*]h,]h.]uh0jMh jNubjM)}(hhh]h`)}(hΕλληνικάh]hΕλληνικά}(hjNh jNubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"MOh jNubah#}(h%]h']h*]h,]h.]uh0jMh jNubjM)}(hhh]h#}(h%]h']h*]h,]h.]uh0jMh jNubeh#}(h%]h']h*]h,]h.]uh0jMh jMubjM)}(hhh](jM)}(hhh]h`)}(hHebrewh]hHebrew}(hjNh jNubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"MPh jNubah#}(h%]h']h*]h,]h.]uh0jMh jNubjM)}(hhh]h`)}(hעִברִיתh]hעִברִית}(hjOh j Oubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"MPh j Oubah#}(h%]h']h*]h,]h.]uh0jMh jNubjM)}(hhh]h#}(h%]h']h*]h,]h.]uh0jMh jNubeh#}(h%]h']h*]h,]h.]uh0jMh jMubjM)}(hhh](jM)}(hhh]h`)}(hJapaneseh]hJapanese}(hj8Oh j6Oubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"MQh j3Oubah#}(h%]h']h*]h,]h.]uh0jMh j0OubjM)}(hhh]h`)}(h 日本語h]h 日本語}(hjOOh jMOubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"MQh jJOubah#}(h%]h']h*]h,]h.]uh0jMh j0OubjM)}(hhh]h`)}(h+Union of Kanji, Katakana, and Hiragana setsh]h+Union of Kanji, Katakana, and Hiragana sets}(hjfOh jdOubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"MQh jaOubah#}(h%]h']h*]h,]h.]uh0jMh j0Oubeh#}(h%]h']h*]h,]h.]uh0jMh jMubjM)}(hhh](jM)}(hhh]h`)}(hJapanese.Kanjih]hJapanese.Kanji}(hjOh jOubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"MRh jOubah#}(h%]h']h*]h,]h.]uh0jMh j~OubjM)}(hhh]h`)}(h漢字h]h漢字}(hjOh jOubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"MRh jOubah#}(h%]h']h*]h,]h.]uh0jMh j~OubjM)}(hhh]h#}(h%]h']h*]h,]h.]uh0jMh j~Oubeh#}(h%]h']h*]h,]h.]uh0jMh jMubjM)}(hhh](jM)}(hhh]h`)}(hJapanese.Katakanah]hJapanese.Katakana}(hjOh jOubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"MSh jOubah#}(h%]h']h*]h,]h.]uh0jMh jOubjM)}(hhh]h`)}(h カタカナh]h カタカナ}(hjOh jOubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"MSh jOubah#}(h%]h']h*]h,]h.]uh0jMh jOubjM)}(hhh]h#}(h%]h']h*]h,]h.]uh0jMh jOubeh#}(h%]h']h*]h,]h.]uh0jMh jMubjM)}(hhh](jM)}(hhh]h`)}(hJapanese.Hiraganah]hJapanese.Hiragana}(hjPh jPubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"MTh jPubah#}(h%]h']h*]h,]h.]uh0jMh jOubjM)}(hhh]h`)}(h ひらがなh]h ひらがな}(hjPh jPubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"MTh jPubah#}(h%]h']h*]h,]h.]uh0jMh jOubjM)}(hhh]h#}(h%]h']h*]h,]h.]uh0jMh jOubeh#}(h%]h']h*]h,]h.]uh0jMh jMubjM)}(hhh](jM)}(hhh]h`)}(hHangulh]hHangul}(hjFPh jDPubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"MUh jAPubah#}(h%]h']h*]h,]h.]uh0jMh j>PubjM)}(hhh]h`)}(hKorean, 한국어h]hKorean, 한국어}(hj]Ph j[Pubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"MUh jXPubah#}(h%]h']h*]h,]h.]uh0jMh j>PubjM)}(hhh]h#}(h%]h']h*]h,]h.]uh0jMh j>Pubeh#}(h%]h']h*]h,]h.]uh0jMh jMubjM)}(hhh](jM)}(hhh]h`)}(hLatin1h]hLatin1}(hjPh jPubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"MVh jPubah#}(h%]h']h*]h,]h.]uh0jMh j~PubjM)}(hhh]h#}(h%]h']h*]h,]h.]uh0jMh j~PubjM)}(hhh]h`)}(h+All Unicode characters up to code point 255h]h+All Unicode characters up to code point 255}(hjPh jPubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"MVh jPubah#}(h%]h']h*]h,]h.]uh0jMh j~Pubeh#}(h%]h']h*]h,]h.]uh0jMh jMubjM)}(hhh](jM)}(hhh]h`)}(hLatinAh]hLatinA}(hjPh jPubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"MWh jPubah#}(h%]h']h*]h,]h.]uh0jMh jPubjM)}(hhh]h#}(h%]h']h*]h,]h.]uh0jMh jPubjM)}(hhh]h#}(h%]h']h*]h,]h.]uh0jMh jPubeh#}(h%]h']h*]h,]h.]uh0jMh jMubjM)}(hhh](jM)}(hhh]h`)}(hLatinBh]hLatinB}(hjPh jPubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"MXh jPubah#}(h%]h']h*]h,]h.]uh0jMh jPubjM)}(hhh]h#}(h%]h']h*]h,]h.]uh0jMh jPubjM)}(hhh]h#}(h%]h']h*]h,]h.]uh0jMh jPubeh#}(h%]h']h*]h,]h.]uh0jMh jMubjM)}(hhh](jM)}(hhh]h`)}(hThaih]hThai}(hj*Qh j(Qubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"MYh j%Qubah#}(h%]h']h*]h,]h.]uh0jMh j"QubjM)}(hhh]h`)}(h ไทยh]h ไทย}(hjAQh j?Qubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"MYh jh"MZh jeQubah#}(h%]h']h*]h,]h.]uh0jMh jbQubjM)}(hhh]h`)}(hदेवनागरीh]hदेवनागरी}(hjQh jQubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"MZh j|Qubah#}(h%]h']h*]h,]h.]uh0jMh jbQubjM)}(hhh]h#}(h%]h']h*]h,]h.]uh0jMh jbQubeh#}(h%]h']h*]h,]h.]uh0jMh jMubjM)}(hhh](jM)}(hhh]h`)}(hBasicMultilingualPlaneh]hBasicMultilingualPlane}(hjQh jQubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"M[h jQubah#}(h%]h']h*]h,]h.]uh0jMh jQubjM)}(hhh]h`)}(hBMPh]hBMP}(hjQh jQubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"M[h jQubah#}(h%]h']h*]h,]h.]uh0jMh jQubjM)}(hhh]h`)}(h-All Unicode characters up to code point 65535h]h-All Unicode characters up to code point 65535}(hjQh jQubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"M[h jQubah#}(h%]h']h*]h,]h.]uh0jMh jQubeh#}(h%]h']h*]h,]h.]uh0jMh jMubjM)}(hhh](jM)}(hhh]h`)}(hCJKh]hCJK}(hjQh jQubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"M\h jQubah#}(h%]h']h*]h,]h.]uh0jMh jQubjM)}(hhh]h#}(h%]h']h*]h,]h.]uh0jMh jQubjM)}(hhh]h`)}(h+Union of Chinese, Japanese, and Korean setsh]h+Union of Chinese, Japanese, and Korean sets}(hjRh jRubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"M\h jRubah#}(h%]h']h*]h,]h.]uh0jMh jQubeh#}(h%]h']h*]h,]h.]uh0jMh jMubeh#}(h%]h']h*]h,]h.]uh0jMh jvMubeh#}(h%]h']h*]h,]h.]colsKuh0jtMh jqMubah#}(h%]h']h*]h,]h.]aligndefaultuh0joMh jLhhh!h>h"Nubh`)}(hThe base ``unicode`` class also includes definitions based on all Unicode code points up to ``sys.maxunicode``. This set will include emojis, wingdings, and many other specialized and typographical variant characters.h](h The base }(h The base h jERhhh!Nh"Nubj)}(h ``unicode``h]hunicode}(hhh jNRubah#}(h%]h']h*]h,]h.]uh0jh jERubhH class also includes definitions based on all Unicode code points up to }(hH class also includes definitions based on all Unicode code points up to h jERhhh!Nh"Nubj)}(h``sys.maxunicode``h]hsys.maxunicode}(hhh jaRubah#}(h%]h']h*]h,]h.]uh0jh jERubhk. This set will include emojis, wingdings, and many other specialized and typographical variant characters.}(hk. This set will include emojis, wingdings, and many other specialized and typographical variant characters.h jERhhh!Nh"Nubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M_h jLhhubeh#}(h%]jCah']h*]0unicode character sets for international parsingah,]h.]uh0h h j9hhh!h>h"M<ubeh#}(h%]jah']h*]$miscellaneous attributes and methodsah,]h.]uh0h h h hhh!h>h"Mubh )}(hhh](h)}(hjvh](h)}(hhh]h 1.4   }(hhh jRhhh!Nh"Nubah#}(h%]h']h)ah*]h,]h.]uh0hh jRhhh!Nh"NubhGenerating Railroad Diagrams}(hjvh jRhhh!Nh"Nubeh#}(h%]h']h*]h,]h.]h;Khh"Mdubh`)}(hXUGrammars are conventionally represented in what are called "railroad diagrams", which allow you to visually follow the sequence of tokens in a grammar along lines which are a bit like train tracks. You might want to generate a railroad diagram for your grammar in order to better understand it yourself, or maybe to communicate it to others.h]hXYGrammars are conventionally represented in what are called “railroad diagrams”, which allow you to visually follow the sequence of tokens in a grammar along lines which are a bit like train tracks. You might want to generate a railroad diagram for your grammar in order to better understand it yourself, or maybe to communicate it to others.}(hjRh jRhhh!Nh"Nubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"Meh jRhhubh )}(hhh](h)}(hjh](h)}(hhh]h 1.4.1   }(hhh jRhhh!Nh"Nubah#}(h%]h']h)ah*]h,]h.]uh0hh jRhhh!Nh"NubhUsage}(hjh jRhhh!Nh"Nubeh#}(h%]h']h*]h,]h.]h;Khh"Mjubh`)}(hX+To generate a railroad diagram in pyparsing, you first have to install pyparsing with the ``diagrams`` extra. To do this, just run ``pip install pyparsing[diagrams]``, and make sure you add ``pyparsing[diagrams]`` to any ``setup.py`` or ``requirements.txt`` that specifies pyparsing as a dependency.h](hZTo generate a railroad diagram in pyparsing, you first have to install pyparsing with the }(hZTo generate a railroad diagram in pyparsing, you first have to install pyparsing with the h jRhhh!Nh"Nubj)}(h ``diagrams``h]hdiagrams}(hhh jRubah#}(h%]h']h*]h,]h.]uh0jh jRubh extra. To do this, just run }(h extra. To do this, just run h jRhhh!Nh"Nubj)}(h#``pip install pyparsing[diagrams]``h]hpip install pyparsing[diagrams]}(hhh jRubah#}(h%]h']h*]h,]h.]uh0jh jRubh, and make sure you add }(h, and make sure you add h jRhhh!Nh"Nubj)}(h``pyparsing[diagrams]``h]hpyparsing[diagrams]}(hhh jRubah#}(h%]h']h*]h,]h.]uh0jh jRubh to any }(h to any h jRhhh!Nh"Nubj)}(h ``setup.py``h]hsetup.py}(hhh jSubah#}(h%]h']h*]h,]h.]uh0jh jRubh or }(h or h jRhhh!Nh"Nubj)}(h``requirements.txt``h]hrequirements.txt}(hhh j%Subah#}(h%]h']h*]h,]h.]uh0jh jRubh* that specifies pyparsing as a dependency.}(h* that specifies pyparsing as a dependency.h jRhhh!Nh"Nubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mkh jRhhubh`)}(htCreate your parser as you normally would. Then call ``create_diagram()``, passing the name of an output HTML file.::h](h4Create your parser as you normally would. Then call }(h4Create your parser as you normally would. Then call h j>Shhh!Nh"Nubj)}(h``create_diagram()``h]hcreate_diagram()}(hhh jGSubah#}(h%]h']h*]h,]h.]uh0jh j>Subh+, passing the name of an output HTML file.:}(h+, passing the name of an output HTML file.:h j>Shhh!Nh"Nubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Moh jRhhubjd)}(hstreet_address = Word(nums).set_name("house_number") + Word(alphas)[1, ...].set_name("street_name") street_address.set_name("street_address") street_address.create_diagram("street_address_diagram.html")h]hstreet_address = Word(nums).set_name("house_number") + Word(alphas)[1, ...].set_name("street_name") street_address.set_name("street_address") street_address.create_diagram("street_address_diagram.html")}(hhh j`Subah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"Mqh jRhhubh`)}(hZThis will result in the railroad diagram being written to ``street_address_diagram.html``.h](h:This will result in the railroad diagram being written to }(h:This will result in the railroad diagram being written to h jnShhh!Nh"Nubj)}(h``street_address_diagram.html``h]hstreet_address_diagram.html}(hhh jwSubah#}(h%]h']h*]h,]h.]uh0jh jnSubh.}(hj h jnShhh!Nh"Nubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Muh jRhhubh`)}(hDiagrams usually will vertically wrap expressions containing more than 3 terms. You can override this by passing the `vertical` argument to `create_diagram` with a larger value.h](huDiagrams usually will vertically wrap expressions containing more than 3 terms. You can override this by passing the }(huDiagrams usually will vertically wrap expressions containing more than 3 terms. You can override this by passing the h jShhh!Nh"Nubj6)}(h `vertical`h]hvertical}(hhh jSubah#}(h%]h']h*]h,]h.]uh0j6h jSubh argument to }(h argument to h jShhh!Nh"Nubj6)}(h`create_diagram`h]hcreate_diagram}(hhh jSubah#}(h%]h']h*]h,]h.]uh0j6h jSubh with a larger value.}(h with a larger value.h jShhh!Nh"Nubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mwh jRhhubeh#}(h%]jah']h*]usageah,]h.]uh0h h jRhhh!h>h"Mjubh )}(hhh](h)}(hjh](h)}(hhh]h 1.4.2   }(hhh jShhh!Nh"Nubah#}(h%]h']h)ah*]h,]h.]uh0hh jShhh!Nh"NubhExample}(hjh jShhh!Nh"Nubeh#}(h%]h']h*]h,]h.]h;Khh"M{ubh`)}(hYou can view an example railroad diagram generated from `a pyparsing grammar for SQL SELECT statements <_static/sql_railroad.html>`_.h](h8You can view an example railroad diagram generated from }(h8You can view an example railroad diagram generated from h jShhh!Nh"Nubh)}(hL`a pyparsing grammar for SQL SELECT statements <_static/sql_railroad.html>`_h]h-a pyparsing grammar for SQL SELECT statements}(h-a pyparsing grammar for SQL SELECT statementsh jSubah#}(h%]h']h*]h,]h.]name-a pyparsing grammar for SQL SELECT statementsj_static/sql_railroad.htmluh0hh jSubj)}(h <_static/sql_railroad.html>h]h#}(h%]-a-pyparsing-grammar-for-sql-select-statementsah']h*]-a pyparsing grammar for sql select statementsah,]h.]refurijTuh0jjKh jSubh.}(hj h jShhh!Nh"Nubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"M|h jShhubeh#}(h%]jah']h*]exampleah,]h.]uh0h h jRhhh!h>h"M{ubh )}(hhh](h)}(hjh](h)}(hhh]h 1.4.3   }(hhh j'Thhh!Nh"Nubah#}(h%]h']h)ah*]h,]h.]uh0hh j$Thhh!Nh"Nubh Naming tip}(hjh j$Thhh!Nh"Nubeh#}(h%]h']h*]h,]h.]h;Khh"Mubh`)}(hXParser elements that are separately named will be broken out as their own sub-diagrams. As a short-cut alternative to going through and adding ``.set_name()`` calls on all your sub-expressions, you can use ``autoname_elements()`` after defining your complete grammar. For example::h](hParser elements that are separately named will be broken out as their own sub-diagrams. As a short-cut alternative to going through and adding }(hParser elements that are separately named will be broken out as their own sub-diagrams. As a short-cut alternative to going through and adding h j>Thhh!Nh"Nubj)}(h``.set_name()``h]h .set_name()}(hhh jGTubah#}(h%]h']h*]h,]h.]uh0jh j>Tubh0 calls on all your sub-expressions, you can use }(h0 calls on all your sub-expressions, you can use h j>Thhh!Nh"Nubj)}(h``autoname_elements()``h]hautoname_elements()}(hhh jZTubah#}(h%]h']h*]h,]h.]uh0jh j>Tubh3 after defining your complete grammar. For example:}(h3 after defining your complete grammar. For example:h j>Thhh!Nh"Nubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j!Thhubjd)}(hNa = pp.Literal("a") b = pp.Literal("b").set_name("bbb") pp.autoname_elements()h]hNa = pp.Literal("a") b = pp.Literal("b").set_name("bbb") pp.autoname_elements()}(hhh jsTubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"Mh j!Thhubh`)}(h;`a` will get named "a", while `b` will keep its name "bbb".h](j6)}(h`a`h]ha}(hhh jTubah#}(h%]h']h*]h,]h.]uh0j6h jTubh will get named “a”, while }(h will get named "a", while h jThhh!Nh"Nubj6)}(h`b`h]hb}(hhh jTubah#}(h%]h']h*]h,]h.]uh0j6h jTubh will keep its name “bbb”.}(h will keep its name "bbb".h jThhh!Nh"Nubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j!Thhubeh#}(h%]j ah']h*] naming tipah,]h.]uh0h h jRhhh!h>h"Mubh )}(hhh](h)}(hj3h](h)}(hhh]h 1.4.4   }(hhh jThhh!Nh"Nubah#}(h%]h']h)ah*]h,]h.]uh0hh jThhh!Nh"Nubh Customization}(hj3h jThhh!Nh"Nubeh#}(h%]h']h*]h,]h.]h;Khh"Mubh`)}(hXlYou can customize the resulting diagram in a few ways. To do so, run ``pyparsing.diagrams.to_railroad`` to convert your grammar into a form understood by the `railroad-diagrams `_ module, and then ``pyparsing.diagrams.railroad_to_html`` to convert that into an HTML document. For example::h](hEYou can customize the resulting diagram in a few ways. To do so, run }(hEYou can customize the resulting diagram in a few ways. To do so, run h jThhh!Nh"Nubj)}(h"``pyparsing.diagrams.to_railroad``h]hpyparsing.diagrams.to_railroad}(hhh jTubah#}(h%]h']h*]h,]h.]uh0jh jTubh7 to convert your grammar into a form understood by the }(h7 to convert your grammar into a form understood by the h jThhh!Nh"Nubh)}(h``railroad-diagrams `_h]hrailroad-diagrams}(hrailroad-diagramsh jTubah#}(h%]h']h*]h,]h.]namejTjIhttps://github.com/tabatkins/railroad-diagrams/blob/gh-pages/README-py.mduh0hh jTubj)}(hL h]h#}(h%]railroad-diagramsah']h*]railroad-diagramsah,]h.]refurijUuh0jjKh jTubh module, and then }(h module, and then h jThhh!Nh"Nubj)}(h'``pyparsing.diagrams.railroad_to_html``h]h#pyparsing.diagrams.railroad_to_html}(hhh jUubah#}(h%]h']h*]h,]h.]uh0jh jTubh4 to convert that into an HTML document. For example:}(h4 to convert that into an HTML document. For example:h jThhh!Nh"Nubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jThhubjd)}(hfrom pyparsing.diagram import to_railroad, railroad_to_html with open('output.html', 'w') as fp: railroad = to_railroad(my_grammar) fp.write(railroad_to_html(railroad))h]hfrom pyparsing.diagram import to_railroad, railroad_to_html with open('output.html', 'w') as fp: railroad = to_railroad(my_grammar) fp.write(railroad_to_html(railroad))}(hhh j-Uubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"Mh jThhubh`)}(hIThis will result in the railroad diagram being written to ``output.html``h](h:This will result in the railroad diagram being written to }(h:This will result in the railroad diagram being written to h j;Uhhh!Nh"Nubj)}(h``output.html``h]h output.html}(hhh jDUubah#}(h%]h']h*]h,]h.]uh0jh j;Uubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jThhubh`)}(hXYou can then pass in additional keyword arguments to ``pyparsing.diagrams.to_railroad``, which will be passed into the ``Diagram()`` constructor of the underlying library, `as explained here `_.h](h5You can then pass in additional keyword arguments to }(h5You can then pass in additional keyword arguments to h jXUhhh!Nh"Nubj)}(h"``pyparsing.diagrams.to_railroad``h]hpyparsing.diagrams.to_railroad}(hhh jaUubah#}(h%]h']h*]h,]h.]uh0jh jXUubh , which will be passed into the }(h , which will be passed into the h jXUhhh!Nh"Nubj)}(h ``Diagram()``h]h Diagram()}(hhh jtUubah#}(h%]h']h*]h,]h.]uh0jh jXUubh( constructor of the underlying library, }(h( constructor of the underlying library, h jXUhhh!Nh"Nubh)}(hi`as explained here `_h]has explained here}(has explained hereh jUubah#}(h%]h']h*]h,]h.]nameas explained herejRhttps://github.com/tabatkins/railroad-diagrams/blob/gh-pages/README-py.md#diagramsuh0hh jXUubj)}(hU h]h#}(h%]as-explained-hereah']h*]as explained hereah,]h.]refurijUuh0jjKh jXUubh.}(hj h jXUhhh!Nh"Nubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jThhubh`)}(hZIn addition, you can edit global options in the underlying library, by editing constants::h]hYIn addition, you can edit global options in the underlying library, by editing constants:}(hYIn addition, you can edit global options in the underlying library, by editing constants:h jUhhh!Nh"Nubah#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jThhubjd)}(hfrom pyparsing.diagram import to_railroad, railroad_to_html import railroad railroad.DIAGRAM_CLASS = "my-custom-class" my_railroad = to_railroad(my_grammar)h]hfrom pyparsing.diagram import to_railroad, railroad_to_html import railroad railroad.DIAGRAM_CLASS = "my-custom-class" my_railroad = to_railroad(my_grammar)}(hhh jUubah#}(h%]h']h*]h,]h.]jsjtuh0jch!h>h"Mh jThhubh`)}(hyThese options `are documented here `_.h](hThese options }(hThese options h jUhhh!Nh"Nubh)}(hj`are documented here `_h]hare documented here}(hare documented hereh jUubah#}(h%]h']h*]h,]h.]nameare documented herejQhttps://github.com/tabatkins/railroad-diagrams/blob/gh-pages/README-py.md#optionsuh0hh jUubj)}(hT h]h#}(h%]are-documented-hereah']h*]are documented hereah,]h.]refurijUuh0jjKh jUubh.}(hj h jUhhh!Nh"Nubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jThhubh`)}(hFinally, you can edit the HTML produced by ``pyparsing.diagrams.railroad_to_html`` by passing in certain keyword arguments that will be used in the HTML template. Currently, these are:h](h+Finally, you can edit the HTML produced by }(h+Finally, you can edit the HTML produced by h jUhhh!Nh"Nubj)}(h'``pyparsing.diagrams.railroad_to_html``h]h#pyparsing.diagrams.railroad_to_html}(hhh jVubah#}(h%]h']h*]h,]h.]uh0jh jUubhf by passing in certain keyword arguments that will be used in the HTML template. Currently, these are:}(hf by passing in certain keyword arguments that will be used in the HTML template. Currently, these are:h jUhhh!Nh"Nubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jThhubj)}(hhh](j)}(hn``head``: A string containing HTML to use in the ```` tag. This might be a stylesheet or other metadata h]h`)}(hm``head``: A string containing HTML to use in the ```` tag. This might be a stylesheet or other metadatah](j)}(h``head``h]hhead}(hhh j,Vubah#}(h%]h']h*]h,]h.]uh0jh j(Vubh): A string containing HTML to use in the }(h): A string containing HTML to use in the h j(Vubj)}(h ````h]h}(hhh j?Vubah#}(h%]h']h*]h,]h.]uh0jh j(Vubh2 tag. This might be a stylesheet or other metadata}(h2 tag. This might be a stylesheet or other metadatah j(Vubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j$Vubah#}(h%]h']h*]h,]h.]uh0jh j!Vhhh!h>h"Nubj)}(h``body``: A string containing HTML to use in the ```` tag, above the actual diagram. This might consist of a heading, description, or JavaScript. h]h`)}(h``body``: A string containing HTML to use in the ```` tag, above the actual diagram. This might consist of a heading, description, or JavaScript.h](j)}(h``body``h]hbody}(hhh jfVubah#}(h%]h']h*]h,]h.]uh0jh jbVubh): A string containing HTML to use in the }(h): A string containing HTML to use in the h jbVubj)}(h ````h]h}(hhh jyVubah#}(h%]h']h*]h,]h.]uh0jh jbVubh\ tag, above the actual diagram. This might consist of a heading, description, or JavaScript.}(h\ tag, above the actual diagram. This might consist of a heading, description, or JavaScript.h jbVubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh j^Vubah#}(h%]h']h*]h,]h.]uh0jh j!Vhhh!h>h"Nubeh#}(h%]h']h*]h,]h.]j j uh0jh!h>h"Mh jThhubh`)}(huIf you want to provide a custom stylesheet using the ``head`` keyword, you can make use of the following CSS classes:h](h5If you want to provide a custom stylesheet using the }(h5If you want to provide a custom stylesheet using the h jVhhh!Nh"Nubj)}(h``head``h]hhead}(hhh jVubah#}(h%]h']h*]h,]h.]uh0jh jVubh8 keyword, you can make use of the following CSS classes:}(h8 keyword, you can make use of the following CSS classes:h jVhhh!Nh"Nubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jThhubj)}(hhh](j)}(hr``railroad-group``: A group containing everything relating to a given element group (ie something with a heading) h]h`)}(hq``railroad-group``: A group containing everything relating to a given element group (ie something with a heading)h](j)}(h``railroad-group``h]hrailroad-group}(hhh jVubah#}(h%]h']h*]h,]h.]uh0jh jVubh_: A group containing everything relating to a given element group (ie something with a heading)}(h_: A group containing everything relating to a given element group (ie something with a heading)h jVubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jVubah#}(h%]h']h*]h,]h.]uh0jh jVhhh!h>h"Nubj)}(h/``railroad-heading``: The title for each group h]h`)}(h.``railroad-heading``: The title for each grouph](j)}(h``railroad-heading``h]hrailroad-heading}(hhh jVubah#}(h%]h']h*]h,]h.]uh0jh jVubh: The title for each group}(h: The title for each grouph jVubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jVubah#}(h%]h']h*]h,]h.]uh0jh jVhhh!h>h"Nubj)}(hG``railroad-svg``: A div containing only the diagram SVG for each group h]h`)}(hF``railroad-svg``: A div containing only the diagram SVG for each grouph](j)}(h``railroad-svg``h]h railroad-svg}(hhh jWubah#}(h%]h']h*]h,]h.]uh0jh jWubh6: A div containing only the diagram SVG for each group}(h6: A div containing only the diagram SVG for each grouph jWubeh#}(h%]h']h*]h,]h.]uh0h_h!h>h"Mh jWubah#}(h%]h']h*]h,]h.]uh0jh jVhhh!h>h"Nubj)}(hI``railroad-description``: A div containing the group description (unused)h]h`)}(hj:Wh](j)}(h``railroad-description``h]hrailroad-description}(hhh j?Wubah#}(h%]h']h*]h,]h.]uh0jh jh"Mh j8Wubah#}(h%]h']h*]h,]h.]uh0jh jVhhh!h>h"Nubeh#}(h%]h']h*]h,]h.]j j uh0jh!h>h"Mh jThhubeh#}(h%]j<ah']h*] customizationah,]h.]uh0h h jRhhh!h>h"Mubeh#}(h%]jah']h*]generating railroad diagramsah,]h.]uh0h h h hhh!h>h"Mdubeh#}(h%]jah']h*]using the pyparsing moduleah,]h.]uh0h h hhhh!h>h"Kubah#}(h%]h']h*]h,]h.]sourceh>uh0hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksjMfootnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerjWerror_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh> _destinationN _config_files]pep_referencesN pep_base_url https://www.python.org/dev/peps/pep_file_url_templatepep-%04drfc_referencesN rfc_base_urlhttps://tools.ietf.org/html/ tab_widthKtrim_footnote_reference_spacefile_insertion_enabled raw_enabledKsyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xformembed_stylesheetcloak_email_addressesenvNubreporterNindirect_targets]substitution_defs}j`jTssubstitution_names}copyj`srefnames}( parseresults](jjjjjjEj 0j0j 1j1j33j3j;e operators]jaliteral](jS j-j:j6;j<e matchfirst](j j'j7j@eor](j jj,j'(j$7j}@eparseexception](jje fourfn.py](jj.eand](jjj5%j'j(j(j5j97j2Beset_parse_action]jEawhite]j{akeyword](jij!;eword](jj "eskipto](jn!j*eparse_with_tabs]j"aeach]jc(anotany]j)acaselessliteral]j:aurefids}(jU]j0aj\]jRajc ]jaj]jaj]jaj]jaj ]j aj]j!aj]j"aj ]jF$aj ]j$aj%]j %aj/']j%'aj]jc'aj]j.aj]j44ajA]jAaunameids}(jvWjjmjijjjjj%jjj0jj`jn jk j j j9jjijjKjUj`j\j"jjjc jjjjj jj!j j"jjq'j*jA$jj$j j%j j 'j%j^'j/'j+jj+jZj,jj-jj.jj4jj 4jj9jJj9jjRjjoCjjfCjAjFjjLjj~RjCjoWjjSjjTjj Tj TjTj jhWj<j UjUjUjUjUjUu nametypes}(jvWNjmNjjj%NjNjNjn j j9NjiNjKj`j"Njjjj j!j"jq'NjA$j$j%j 'j^'j+j+Nj,Nj-Nj.Nj4Nj 4j9Nj9jRNjoCNjfCjFNjLNj~RNjoWNjSNjTNj TjTNjhWNj UjUjUuh%}(jh jijjjjjjj;j0j$j`jjk je j j jj(jjEjUj:j\j]jjljc jjjjjjjj j jj!j*j"jj"j jP$j j$j%j%j/'j0'jjt'jZjt'jj+jj,jj-jj.jj.jJj4jj>4jj9jj9jAjAjjrCjjFjCjLjjRjjRjjSj TjTj j!Tj<jTjUjUjUjUjUjUh=jjjj*jjZjCjjjjjjj$j jTj=jjmjjjjjjjDj-jjijjjjj jj=j&jyjbjjjjjjj6ju footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}jWKsRparse_messages]transform_messages]h system_message)}(hhh]h`)}(hhh]h5Hyperlink target "originaltextfor" is not referenced.}(hhh j3Xubah#}(h%]h']h*]h,]h.]uh0h_h j0Xubah#}(h%]h']h*]h,]h.]levelKtypeINFOsourceh>lineMuh0j.Xuba transformerN decorationNhhub.