Source for file TestLexer.php
Documentation is available at TestLexer.php
function __construct ($data)
private $_yy_stack = array ();
return $this->{'yylex' . $this->_yy_state}();
function yypushstate ($state)
$this->_yy_state = $state;
$this->_yy_state = array_pop($this->_yy_stack);
$this->_yy_state = $state;
if ($this->N >= strlen($this->data)) {
return false; // end of input
$yy_global_pattern = "/^(((@import\\s+[\"'`]([\\w:?=@&\/#._;-]+)[\"'`];)|(:\\s*url\\s*\\([\\s\"'`]*([\\w:?=@&\/#._;-]+)([\\s\"'`]*\\))|<[^>]*\\s+(src|href|url)=[\\s\"'`]*([\\w:?=@&\/#._;-]+)[\\s\"'`]*[^>]*>)))|^(#(test)\\11{1,2}(hi)\\12)|^([a-zA-Z]_[a-zA-Z]+([0-9])+)|^([a-zA-Z]_[a-zA-Z]+)|^([0-9][0-9]\\.([0-9])+)|^([ \t\n]+)|^(\\$)|^(a\\$)/";
if (preg_match($yy_global_pattern, substr($this->data, $this->N), $yymatches)) {
$yysubmatches = $yymatches;
$yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
if (!count($yymatches)) {
throw new Exception ('Error: lexing failed because a rule matched' .
'an empty string. Input "' . substr($this->data,
$this->N, 5 ) . '... state START');
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
if ($tokenMap[$this->token]) {
// extract sub-patterns for passing to lex function
$yysubmatches = array_slice($yysubmatches, $this->token + 1 ,
$tokenMap[$this->token]);
$this->value = current($yymatches); // token value
$r = $this->{'yy_r1_' . $this->token}($yysubmatches);
$this->N += strlen($this->value);
// process this token in the new state
} elseif ($r === false ) {
$this->N += strlen($this->value);
if ($this->N >= strlen($this->data)) {
return false; // end of input
} else { $yy_yymore_patterns = array (
1 => "^(#(test)\\11{1,2}(hi)\\12)|^([a-zA-Z]_[a-zA-Z]+([0-9])+)|^([a-zA-Z]_[a-zA-Z]+)|^([0-9][0-9]\\.([0-9])+)|^([ \t\n]+)|^(\\$)|^(a\\$)",
10 => "^([a-zA-Z]_[a-zA-Z]+([0-9])+)|^([a-zA-Z]_[a-zA-Z]+)|^([0-9][0-9]\\.([0-9])+)|^([ \t\n]+)|^(\\$)|^(a\\$)",
13 => "^([a-zA-Z]_[a-zA-Z]+)|^([0-9][0-9]\\.([0-9])+)|^([ \t\n]+)|^(\\$)|^(a\\$)",
15 => "^([0-9][0-9]\\.([0-9])+)|^([ \t\n]+)|^(\\$)|^(a\\$)",
16 => "^([ \t\n]+)|^(\\$)|^(a\\$)",
if (!strlen($yy_yymore_patterns[$this->token])) {
throw new Exception ('cannot do yymore for the last token');
substr($this->data, $this->N), $yymatches)) {
$yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
$this->value = current($yymatches); // token value
$r = $this->{'yy_r1_' . $this->token}();
} while ($r !== null || !$r);
// process this token in the new state
$this->N += strlen($this->value);
throw new Exception ('Unexpected input at line' . $this->line .
': ' . $this->data[$this->N]);
function yy_r1_1 ($yy_subpatterns)
echo " complex subpatterns: \n";
function yy_r1_10 ($yy_subpatterns)
echo " weirdo subpatterns: \n";
function yy_r1_13 ($yy_subpatterns)
echo " rule 1 subpatterns: \n";
$this->yypushstate (self ::TWO );
function yy_r1_15 ($yy_subpatterns)
echo " rule 2 subpatterns: \n";
$this->yybegin (self ::THREE );
function yy_r1_16 ($yy_subpatterns)
echo " rule 3 subpatterns: \n";
function yy_r1_18 ($yy_subpatterns)
echo " whitespace subpatterns: \n";
return false; // skip this token (do not return it)
function yy_r1_19 ($yy_subpatterns)
echo " blah subpatterns: \n";
function yy_r1_20 ($yy_subpatterns)
echo " blahblah subpatterns: \n";
if ($this->N >= strlen($this->data)) {
return false; // end of input
$yy_global_pattern = "/^([a-zA-Z][a-zA-Z])/";
if (preg_match($yy_global_pattern, substr($this->data, $this->N), $yymatches)) {
$yysubmatches = $yymatches;
$yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
if (!count($yymatches)) {
throw new Exception ('Error: lexing failed because a rule matched' .
'an empty string. Input "' . substr($this->data,
$this->N, 5 ) . '... state TWO');
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
if ($tokenMap[$this->token]) {
// extract sub-patterns for passing to lex function
$yysubmatches = array_slice($yysubmatches, $this->token + 1 ,
$tokenMap[$this->token]);
$this->value = current($yymatches); // token value
$r = $this->{'yy_r2_' . $this->token}($yysubmatches);
$this->N += strlen($this->value);
// process this token in the new state
} elseif ($r === false ) {
$this->N += strlen($this->value);
if ($this->N >= strlen($this->data)) {
return false; // end of input
} else { $yy_yymore_patterns = array (
if (!strlen($yy_yymore_patterns[$this->token])) {
throw new Exception ('cannot do yymore for the last token');
substr($this->data, $this->N), $yymatches)) {
$yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
$this->value = current($yymatches); // token value
$r = $this->{'yy_r2_' . $this->token}();
} while ($r !== null || !$r);
// process this token in the new state
$this->N += strlen($this->value);
throw new Exception ('Unexpected input at line' . $this->line .
': ' . $this->data[$this->N]);
function yy_r2_1 ($yy_subpatterns)
echo "alpha alpha (state TWO)\n";
if ($this->N >= strlen($this->data)) {
return false; // end of input
$yy_global_pattern = "/^(\\$[0-9])/";
if (preg_match($yy_global_pattern, substr($this->data, $this->N), $yymatches)) {
$yysubmatches = $yymatches;
$yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
if (!count($yymatches)) {
throw new Exception ('Error: lexing failed because a rule matched' .
'an empty string. Input "' . substr($this->data,
$this->N, 5 ) . '... state THREE');
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
if ($tokenMap[$this->token]) {
// extract sub-patterns for passing to lex function
$yysubmatches = array_slice($yysubmatches, $this->token + 1 ,
$tokenMap[$this->token]);
$this->value = current($yymatches); // token value
$r = $this->{'yy_r3_' . $this->token}($yysubmatches);
$this->N += strlen($this->value);
// process this token in the new state
} elseif ($r === false ) {
$this->N += strlen($this->value);
if ($this->N >= strlen($this->data)) {
return false; // end of input
} else { $yy_yymore_patterns = array (
if (!strlen($yy_yymore_patterns[$this->token])) {
throw new Exception ('cannot do yymore for the last token');
substr($this->data, $this->N), $yymatches)) {
$yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
$this->value = current($yymatches); // token value
$r = $this->{'yy_r3_' . $this->token}();
} while ($r !== null || !$r);
// process this token in the new state
$this->N += strlen($this->value);
throw new Exception ('Unexpected input at line' . $this->line .
': ' . $this->data[$this->N]);
function yy_r3_1 ($yy_subpatterns)
echo "number (state THREE)\n";
$this->yybegin (self ::START );
$a = new TestLexer ('a_AB1yk $09.1 a$B_b$1 #testtesthihi <a href="http://www.example.com/s/style.css">');
Documentation generated on Mon, 11 Mar 2019 15:40:45 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|