Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions reference/parle/book.xml
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- State: experimental -->

<book xml:id="book.parle" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<book xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="book.parle">
<?phpdoc extension-membership="pecl" ?>
<title>Parsing and lexing</title>
<titleabbrev>Parle</titleabbrev>

<preface xml:id="intro.parle">
&reftitle.intro;
<para>
<simpara>
&warn.experimental;
The parle extension provides general purpose lexing and parsing facilities. The implementation is based on <link xlink:href="&url.parle.lib;">these libraries</link> and requires a <link xlink:href="&url.c14;">C++14</link> capable compiler. The lexer is based on the regex matching, the parser is LALR(1). Lexers and parsers are generated on the fly and can be used immediately after they've been finalized. Parle deals with parsing and lexing, the appropriate data structures representation and processing are the implementer's task. Serialization and code generation are not supported by the extension, yet.
</para>
<para>
</simpara>
<simpara>
Lexer analysis is a process of splitting a character sequence into a list of lexemes. The lexeme list can be then used for the syntax analysis against a formal grammar. These operations are also known as lexing and parsing. This documentation doesn't aim to provide an exhaustive information on lexing and parsing. Good information in this regard is available on the numerous resources on the net. Several usage examples are included, to show the functionality. The extension is useful for PHP programmers both willing to learn or to utilize parsing and lexing. State machines and grammar parsing don't have to be implemented manually, these complex tasks are taken away by parle. Thanks to that, the development can be focused on the actual problem solving.
</para>
<para>
</simpara>
<simpara>
The common use case for parle is, when a data format is too complex to be handled by the regex matching with PCRE. The practical application is herewith wide. Be it a specific data format, a behavior modification of existing functions, even an own programming language and beyond. The helper methods such as <methodname>Parle\Lexer::dump</methodname> to inspect the generated state machine, or <methodname>Parle\Parser::dump</methodname> to inspect the generated grammar, are useful. The method <methodname>Parle\Parser::trace</methodname> can also be used to track the parsing operation.
</para>
</simpara>
</preface>

&reference.parle.setup;
Expand All @@ -36,7 +35,6 @@
&reference.parle.parle.parserexception;

</book>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
Expand Down
11 changes: 4 additions & 7 deletions reference/parle/configure.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->

<section xml:id="parle.installation" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="parle.installation">
&reftitle.install;

<para>
<simpara>
&pecl.info;
<link xlink:href="&url.pecl.package;parle">&url.pecl.package;parle</link>
</para>


</section>
</simpara>


</section>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
Expand Down
18 changes: 8 additions & 10 deletions reference/parle/parle.errorinfo.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->

<reference xml:id="class.parle-errorinfo" role="class" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
<reference xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xml:id="class.parle-errorinfo" role="class">

<title>The Parle\ErrorInfo class</title>
<titleabbrev>Parle\ErrorInfo</titleabbrev>
Expand All @@ -11,9 +10,9 @@
<!-- {{{ Parle\ErrorInfo intro -->
<section xml:id="parle-errorinfo.intro">
&reftitle.intro;
<para>
<simpara>
The class represents detailed error information as supplied by <methodname>Parle\Parser::errorInfo</methodname>
</para>
</simpara>
</section>
<!-- }}} -->

Expand Down Expand Up @@ -48,7 +47,7 @@
<varname linkend="parle-errorinfo.props.token">token</varname>
</fieldsynopsis>


<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
<!-- Uncomment if there are some methods, same for the entities item down there. -->
<!--<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.parle-errorinfo')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])" />-->
Expand All @@ -57,27 +56,27 @@

</section>


<!-- {{{ Parle\ErrorInfo properties -->
<section xml:id="parle-errorinfo.props">
&reftitle.properties;
<variablelist>
<varlistentry xml:id="parle-errorinfo.props.id">
<term><varname>id</varname></term>
<listitem>
<para>Error id.</para>
<simpara>Error id.</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="parle-errorinfo.props.position">
<term><varname>position</varname></term>
<listitem>
<para>Position in the input, where the error occurred.</para>
<simpara>Position in the input, where the error occurred.</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="parle-errorinfo.props.token">
<term><varname>token</varname></term>
<listitem>
<para>If applicable - the <classname>Parle\Token</classname> related to the error, otherwise &null;.</para>
<simpara>If applicable - the <classname>Parle\Token</classname> related to the error, otherwise &null;.</simpara>
</listitem>
</varlistentry>
</variablelist>
Expand All @@ -90,7 +89,6 @@
<!--&reference.parle.entities.parle-errorinfo;-->

</reference>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
Expand Down
30 changes: 14 additions & 16 deletions reference/parle/parle.lexer.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->

<reference xml:id="class.parle-lexer" role="class" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
<reference xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xml:id="class.parle-lexer" role="class">

<title>The Parle\Lexer class</title>
<titleabbrev>Parle\Lexer</titleabbrev>
Expand All @@ -11,9 +10,9 @@
<!-- {{{ Parle\Lexer intro -->
<section xml:id="parle-lexer.intro">
&reftitle.intro;
<para>
<simpara>
Single state lexer class. Lexemes can be defined on the fly. If the particular lexer instance is meant to be used with <classname>Parle\Parser</classname>, the token IDs need to be taken from there. Otherwise, arbitrary token IDs can be supplied. This lexer can give a certain performance advantage over <classname>Parle\RLexer</classname>, if no multiple states are required. Note, that <classname>Parle\RParser</classname> is not compatible with this lexer.
</para>
</simpara>
</section>
<!-- }}} -->

Expand Down Expand Up @@ -96,7 +95,7 @@
</fieldsynopsis>

<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.parle-lexer')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])" />
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.parle-lexer')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])"/>
</classsynopsis>
<!-- }}} -->

Expand All @@ -110,35 +109,35 @@
<varlistentry xml:id="parle-lexer.constants.icase">
<term><constant>Parle\Lexer::ICASE</constant></term>
<listitem>
<para></para>
<simpara/>
</listitem>
</varlistentry>

<varlistentry xml:id="parle-lexer.constants.dot-not-lf">
<term><constant>Parle\Lexer::DOT_NOT_LF</constant></term>
<listitem>
<para></para>
<simpara/>
</listitem>
</varlistentry>

<varlistentry xml:id="parle-lexer.constants.dot-not-cr-lf">
<term><constant>Parle\Lexer::DOT_NOT_CRLF</constant></term>
<listitem>
<para></para>
<simpara/>
</listitem>
</varlistentry>

<varlistentry xml:id="parle-lexer.constants.skip-ws">
<term><constant>Parle\Lexer::SKIP_WS</constant></term>
<listitem>
<para></para>
<simpara/>
</listitem>
</varlistentry>

<varlistentry xml:id="parle-lexer.constants.match-zero-len">
<term><constant>Parle\Lexer::MATCH_ZERO_LEN</constant></term>
<listitem>
<para></para>
<simpara/>
</listitem>
</varlistentry>

Expand All @@ -153,31 +152,31 @@
<varlistentry xml:id="parle-lexer.props.bol">
<term><varname>bol</varname></term>
<listitem>
<para>Start of input flag.</para>
<simpara>Start of input flag.</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="parle-lexer.props.flags">
<term><varname>flags</varname></term>
<listitem>
<para>Lexer flags.</para>
<simpara>Lexer flags.</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="parle-lexer.props.state">
<term><varname>state</varname></term>
<listitem>
<para>Current lexer state, readonly.</para>
<simpara>Current lexer state, readonly.</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="parle-lexer.props.marker">
<term><varname>marker</varname></term>
<listitem>
<para>Position of the latest token match, readonly.</para>
<simpara>Position of the latest token match, readonly.</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="parle-lexer.props.cursor">
<term><varname>cursor</varname></term>
<listitem>
<para>Current input offset, readonly.</para>
<simpara>Current input offset, readonly.</simpara>
</listitem>
</varlistentry>
</variablelist>
Expand All @@ -190,7 +189,6 @@
&reference.parle.parle.entities.lexer;

</reference>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
Expand Down
20 changes: 9 additions & 11 deletions reference/parle/parle.lexerexception.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->

<reference xml:id="class.parle-lexerexception" role="class" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
<reference xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xml:id="class.parle-lexerexception" role="class">

<title>The Parle\LexerException class</title>
<titleabbrev>Parle\LexerException</titleabbrev>
Expand All @@ -11,9 +10,9 @@
<!-- {{{ Parle\LexerException intro -->
<section xml:id="parle-lexerexception.intro">
&reftitle.intro;
<para>
<simpara>

</para>
</simpara>
</section>
<!-- }}} -->

Expand All @@ -29,27 +28,27 @@
<ooclass>
<classname>Parle\LexerException</classname>
</ooclass>

<ooclass>
<modifier>extends</modifier>
<classname>Exception</classname>
</ooclass>

<oointerface>
<interfacename>Throwable</interfacename>
</oointerface>
</classsynopsisinfo>
<!-- }}} -->
<classsynopsisinfo role="comment">&InheritedProperties;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('exception.synopsis')/descendant::db:fieldsynopsis)" />
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('exception.synopsis')/descendant::db:fieldsynopsis)"/>



<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
<!-- Uncomment if there are some methods, same for the entities item down there. -->
<!--<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.parle-lexerexception')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])" />-->

<classsynopsisinfo role="comment">&InheritedMethods;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.exception')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])" />
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.exception')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])"/>

</classsynopsis>
<!-- }}} -->
Expand All @@ -63,7 +62,6 @@
-->

</reference>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
Expand Down
Loading
Loading