<h1><i>PComb: a Parser Combinator library in

<div><font size="3">A collection of general and specific-purpose parsers that
can be composed with combinator functions to very powerful

<div><i><br>


<div><font size="3">A parser is a function that takes a <b>ParserInput</b>, a
<b>ParserOutput </b>and returns a

<div>
<ul>
<li><font size="3"><i>lit -- </i>match a literal string of characters,

<li><font size="3"><i>numeric -- </i>match any single numeric
<li><font size="3"><i>whitespace -- </i>match any single whitespace


<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">

<div>

<h4><i><font

<div>

<div><font size="3">A <b>ParseResult </b>is a three-element tuple with these


<div>

<div>
<ol>
<ol>
<li><font size="3">a <b>boolean </b>that indicates if the parser successfully
matched the
<li><font size="3">a copy of the <b>ParserInput </b>object that was passed in
with any matched test removed from the text
<li><font size="3">a copy of the <b>ParserOutput </b>object that was passed in
with any matched text appended to the matched
</ol>


<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">

<div>

<div>

<h4><i><font

<div>

<div><font size="3">The code that uses PComb must provide input to the library
with a class that implements the <b>ParserInput

<div>

<div><i><font face="Courier New" size="3">
<pre>export interface ParserInput {</pre>


<div>

<div><i><font face="Courier New" size="3">
<pre></pre>


<div>

<div><i><font face="Courier New" size="3">
<pre>&nbsp; &nbsp; /** What is the text that is being parsed?


<div>

<div><i><font face="Courier New" size="3">
<pre></pre>


<div>

<div><i><font face="Courier New" size="3">
<pre>&nbsp; &nbsp; text: string;</pre>


<div>

<div><i><font face="Courier New" size="3">
<pre></pre>


<div>

<div><i><font face="Courier New" size="3">
<pre>&nbsp; &nbsp; copy(): ParserInput;</pre>


<div>

<div><i><font face="Courier New" size="3">
<pre></pre>


<div>

<div><i><font size="3"><font face="Courier New"></font>
<pre><font face="Courier


<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">

<div>

<div><i><font size="3">


<div>

<div>

<div><font size="3">Similarly to <b>ParserInput</b>, a class that implements
<b>ParserOutput </b>is provided by the calling code to record the units of text
that have been matched by individual parser as well to record any state that is
specific to the particular

<div>

<div><i><font size="3">

<div>
<pre>export interface ParserOutput {</pre>


<div>

<div><i><font size="3">

<div>
<pre></pre>


<div>

<div><i><font size="3">

<div>
<pre>&nbsp; &nbsp; /** The text that was matched by the parser.


<div>

<div><i><font size="3">

<div>
<pre></pre>


<div>

<div><i><font size="3">

<div>
<pre>&nbsp; &nbsp; matched: Array&lt;string&gt;;</pre>


<div>

<div><i><font size="3">

<div>
<pre></pre>


<div>

<div><i><font size="3">

<div>
<pre>&nbsp; &nbsp; copy(): ParserOutput;</pre>


<div>

<div><i><font size="3">

<div>
<pre></pre>


<div>

<div><i><font size="3"></font>

<div>
<pre><font


<div>


<div><font size="3">A combinator is a higher-order function that takes one or
more <b>Parser </b>functions as input and produces a new function that wraps
and executes them in some particular

<div>
<ul>
<li><font size="3"><i>or -- </i>matches one of a list of parsers. After one
Parser matches the input, the <b>or </b>exits with a success
<li><font size="3"><i>and -- </i>match all of the listed parsers in order. If
one fails to match, the <b>and </b>exits with a failure
<li><font size="3"><i>opt -- </i>optionally match a parser; always produces a
success
<li><font size="3"><i>all -- </i>match the given single parser until matching
fails; return all matches as a single match. If the given Parser does not match
at least once, returns a failure
<li><font size="3"><i>any -- </i>collect all input as a single match up to the
point that the provided parser matches. Always
<li><font size="3"><i>exact -- </i>require that the given parser consume all
available input; otherwise, parsing
<li><font size="3"><i>apply -- </i>execute the given <b>ParserAction</b>&nbsp;if
the given parser


<div><font size="3">A <b>ParserAction </b>is a function that takes a string of
matched characters and a <b>ParserOutput </b>and returns a
<pre><i><font face="Courier New" size="3">export type ParserAction = (matchedText: string, output: ParserOutput) =&gt;

<p><font size="3">If such a function is provided to a <b>Parser</b>, it will be
executed on a successful match. The returned <b>ParserOutput </b>object then
becomes the return value for the <b>Parser</b>. This mechanism allows calling
code to have use-specific state that is recorded and mutated on parser


<p><font size="3"><br>


<p><font size="3">Interested? Check out the [Getting Started]