Skip to main content
Engineering LibreTexts

17.7: Chapter Summary

  • Page ID
    46450
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    This concludes our tutorial of PetitParser. We have reviewed the following points:

    • A parser is a composition of multiple smaller parsers combined with combinators.
    • To parse a string, use the method parse:.
    • To know if a string matches a grammar, use the method matches:.
    • The method flatten returns a String from the result of the parsing.
    • The method ==> performs the transformation given in the block given in parameter.
    • Compose parsers (and create a grammar) by subclassing PPCompositeParser.
    • Test your parser by subclassing PPCompositeParserTest.

    For a more extensive view of PetitParser, its concepts and implementation, the Moose book1 and Lukas Renggli’s PhD2 have both a dedicated chapter.


    1. http://www.themoosebook.org/book/internals/petit-parser
    2. http://scg.unibe.ch/archive/phd/renggli-phd.pdf

    This page titled 17.7: Chapter Summary is shared under a CC BY-SA 3.0 license and was authored, remixed, and/or curated by Alexandre Bergel, Damien Cassou, Stéphane Ducasse, Jannik Laval (Square Bracket Associates) via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.