<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/refs.basic.text.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'tr',
  ),
  'this' => 
  array (
    0 => 'book.parle.php',
    1 => 'Parle',
    2 => 'Parsing and lexing',
  ),
  'up' => 
  array (
    0 => 'refs.basic.text.php',
    1 => 'Metin İşleme',
  ),
  'prev' => 
  array (
    0 => 'function.commonmark-render-xml.php',
    1 => 'CommonMark\\Render\\XML',
  ),
  'next' => 
  array (
    0 => 'parle.setup.php',
    1 => 'Yapılandırma/Kurulum',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/parle/book.xml',
  ),
  'history' => 
  array (
  ),
  'extra_header_links' => 
  array (
    'rel' => 'alternate',
    'href' => '/manual/en/feeds/book.parle.atom',
    'type' => 'application/atom+xml',
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="book.parle" class="book">
 
 <h1 class="title">Parsing and lexing</h1>
 

 <div id="intro.parle" class="preface">
  <h1 class="title">Giriş</h1>
  <div class="warning"><strong class="warning">Uyarı</strong>
<p class="simpara">Bu eklenti <em>DENEYSELDİR</em>. Bu eklentinin davranışı,
işlev isimleri ve tüm belgeleri PHP&#039;nin sonraki sürümlerinde hiçbir duyuru
yapılmaksızın değiştirilebilir. Bu risk göze alınamayacaksa bu eklenti
kullanılmamalıdır.</p></div>
  <p class="para">
   The parle extension provides general purpose lexing and parsing facilities. The implementation is based on <a href="http://www.benhanson.net/" class="link external">&raquo;&nbsp;these libraries</a> and requires a <a href="http://en.cppreference.com/w/cpp/compiler_support" class="link external">&raquo;&nbsp;C++14</a> 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&#039;ve been finalized. Parle deals with parsing and lexing, the appropriate data structures representation and processing are the implementer&#039;s task. Serialization and code generation are not supported by the extension, yet.
  </p>
  <p class="para">
   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&#039;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&#039;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.
  </p>
  <p class="para">  
   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 <span class="methodname"><a href="parle-lexer.dump.php" class="methodname">Parle\Lexer::dump()</a></span> to inspect the generated state machine, or <span class="methodname"><a href="parle-parser.dump.php" class="methodname">Parle\Parser::dump()</a></span> to inspect the generated grammar, are useful. The method <span class="methodname"><a href="parle-parser.trace.php" class="methodname">Parle\Parser::trace()</a></span> can also be used to track the parsing operation.
  </p>
 </div>

 






 





 




 






 






 






 






 






 






 






 






 






 







<ul class="chunklist chunklist_book"><li><a href="parle.setup.php">Yapılandırma/Kurulum</a><ul class="chunklist chunklist_book chunklist_children"><li><a href="parle.requirements.php">Gereksinimler</a></li><li><a href="parle.installation.php">Kurulum</a></li></ul></li><li><a href="parle.constants.php">&Ouml;ntanımlı Sabitler</a></li><li><a href="parle.pattern.matching.php">Pattern matching</a> — Parle pattern matching</li><li><a href="parle.examples.php">&Ouml;rnekler</a><ul class="chunklist chunklist_book chunklist_children"><li><a href="parle.examples.lexer.php">Lexer examples</a></li><li><a href="parle.examples.parser.php">Parser examples</a></li></ul></li><li><a href="class.parle-lexer.php">Parle\Lexer</a> — The Parle\Lexer class<ul class="chunklist chunklist_book chunklist_children"><li><a href="parle-lexer.advance.php">Parle\Lexer::advance</a> — Process next lexer rule</li><li><a href="parle-lexer.build.php">Parle\Lexer::build</a> — Finalize the lexer rule set</li><li><a href="parle-lexer.callout.php">Parle\Lexer::callout</a> — Define token callback</li><li><a href="parle-lexer.consume.php">Parle\Lexer::consume</a> — Pass the data for processing</li><li><a href="parle-lexer.dump.php">Parle\Lexer::dump</a> — Dump the state machine</li><li><a href="parle-lexer.gettoken.php">Parle\Lexer::getToken</a> — Retrieve the current token</li><li><a href="parle-lexer.insertmacro.php">Parle\Lexer::insertMacro</a> — Insert regex macro</li><li><a href="parle-lexer.push.php">Parle\Lexer::push</a> — Add a lexer rule</li><li><a href="parle-lexer.reset.php">Parle\Lexer::reset</a> — Reset lexer</li></ul></li><li><a href="class.parle-rlexer.php">Parle\RLexer</a> — The Parle\RLexer class<ul class="chunklist chunklist_book chunklist_children"><li><a href="parle-rlexer.advance.php">Parle\RLexer::advance</a> — Process next lexer rule</li><li><a href="parle-rlexer.build.php">Parle\RLexer::build</a> — Finalize the lexer rule set</li><li><a href="parle-rlexer.callout.php">Parle\RLexer::callout</a> — Define token callback</li><li><a href="parle-rlexer.consume.php">Parle\RLexer::consume</a> — Pass the data for processing</li><li><a href="parle-rlexer.dump.php">Parle\RLexer::dump</a> — Dump the state machine</li><li><a href="parle-rlexer.gettoken.php">Parle\RLexer::getToken</a> — Retrieve the current token</li><li><a href="parle-rlexer.insertmacro.php">Parle\RLexer::insertMacro</a> — Insert regex macro</li><li><a href="parle-rlexer.push.php">Parle\RLexer::push</a> — Add a lexer rule</li><li><a href="parle-rlexer.pushstate.php">Parle\RLexer::pushState</a> — Push a new start state</li><li><a href="parle-rlexer.reset.php">Parle\RLexer::reset</a> — Reset lexer</li></ul></li><li><a href="class.parle-parser.php">Parle\Parser</a> — The Parle\Parser class<ul class="chunklist chunklist_book chunklist_children"><li><a href="parle-parser.advance.php">Parle\Parser::advance</a> — Process next parser rule</li><li><a href="parle-parser.build.php">Parle\Parser::build</a> — Finalize the grammar rules</li><li><a href="parle-parser.consume.php">Parle\Parser::consume</a> — Consume the data for processing</li><li><a href="parle-parser.dump.php">Parle\Parser::dump</a> — Dump the grammar</li><li><a href="parle-parser.errorinfo.php">Parle\Parser::errorInfo</a> — Retrieve the error information</li><li><a href="parle-parser.left.php">Parle\Parser::left</a> — Declare a token with left-associativity</li><li><a href="parle-parser.nonassoc.php">Parle\Parser::nonassoc</a> — Declare a token with no associativity</li><li><a href="parle-parser.precedence.php">Parle\Parser::precedence</a> — Declare a precedence rule</li><li><a href="parle-parser.push.php">Parle\Parser::push</a> — Add a grammar rule</li><li><a href="parle-parser.reset.php">Parle\Parser::reset</a> — Reset parser state</li><li><a href="parle-parser.right.php">Parle\Parser::right</a> — Declare a token with right-associativity</li><li><a href="parle-parser.sigil.php">Parle\Parser::sigil</a> — Retrieve a matching part of a rule</li><li><a href="parle-parser.sigilcount.php">Parle\Parser::sigilCount</a> — Number of elements in matched rule</li><li><a href="parle-parser.sigilname.php">Parle\Parser::sigilName</a> — Retrieve a rule or token name</li><li><a href="parle-parser.token.php">Parle\Parser::token</a> — Declare a token</li><li><a href="parle-parser.tokenid.php">Parle\Parser::tokenId</a> — Get token id</li><li><a href="parle-parser.trace.php">Parle\Parser::trace</a> — Trace the parser operation</li><li><a href="parle-parser.validate.php">Parle\Parser::validate</a> — Validate input</li></ul></li><li><a href="class.parle-rparser.php">Parle\RParser</a> — The Parle\RParser class<ul class="chunklist chunklist_book chunklist_children"><li><a href="parle-rparser.advance.php">Parle\RParser::advance</a> — Process next parser rule</li><li><a href="parle-rparser.build.php">Parle\RParser::build</a> — Finalize the grammar rules</li><li><a href="parle-rparser.consume.php">Parle\RParser::consume</a> — Consume the data for processing</li><li><a href="parle-rparser.dump.php">Parle\RParser::dump</a> — Dump the grammar</li><li><a href="parle-rparser.errorinfo.php">Parle\RParser::errorInfo</a> — Retrieve the error information</li><li><a href="parle-rparser.left.php">Parle\RParser::left</a> — Declare a token with left-associativity</li><li><a href="parle-rparser.nonassoc.php">Parle\RParser::nonassoc</a> — Declare a token with no associativity</li><li><a href="parle-rparser.precedence.php">Parle\RParser::precedence</a> — Declare a precedence rule</li><li><a href="parle-rparser.push.php">Parle\RParser::push</a> — Add a grammar rule</li><li><a href="parle-rparser.reset.php">Parle\RParser::reset</a> — Reset parser state</li><li><a href="parle-rparser.right.php">Parle\RParser::right</a> — Declare a token with right-associativity</li><li><a href="parle-rparser.sigil.php">Parle\RParser::sigil</a> — Retrieve a matching part of a rule</li><li><a href="parle-rparser.sigilcount.php">Parle\RParser::sigilCount</a> — Number of elements in matched rule</li><li><a href="parle-rparser.sigilname.php">Parle\RParser::sigilName</a> — Retrieve a rule or token name</li><li><a href="parle-rparser.token.php">Parle\RParser::token</a> — Declare a token</li><li><a href="parle-rparser.tokenid.php">Parle\RParser::tokenId</a> — Get token id</li><li><a href="parle-rparser.trace.php">Parle\RParser::trace</a> — Trace the parser operation</li><li><a href="parle-rparser.validate.php">Parle\RParser::validate</a> — Validate input</li></ul></li><li><a href="class.parle-stack.php">Parle\Stack</a> — The Parle\Stack class<ul class="chunklist chunklist_book chunklist_children"><li><a href="parle-stack.pop.php">Parle\Stack::pop</a> — Pop an item from the stack</li><li><a href="parle-stack.push.php">Parle\Stack::push</a> — Push an item into the stack</li></ul></li><li><a href="class.parle-token.php">Parle\Token</a> — The Parle\Token class</li><li><a href="class.parle-errorinfo.php">Parle\ErrorInfo</a> — The Parle\ErrorInfo class</li><li><a href="class.parle-lexerexception.php">Parle\LexerException</a> — The Parle\LexerException class</li><li><a href="class.parle-parserexception.php">Parle\ParserException</a> — The Parle\ParserException class</li></ul></div><?php manual_footer($setup); ?>