phpDocumentor PHP_LexerGenerator
[ class tree: PHP_LexerGenerator ] [ index: PHP_LexerGenerator ] [ all elements ]

File_ChessPGN lexer generated php code

  1. <?php
  2. //require_once 'File/ChessPGN/Parser.php';
  3. require_once dirname(__FILE__'/Parser.php';
  4.  
  5. class File_ChessPGN_Lexer
  6. {
  7.     const TAGOPEN File_ChessPGN_Parser::TAGOPEN// [
  8.         const TAGNAME File_ChessPGN_Parser::TAGNAME// ]
  9.         const TAGCLOSE File_ChessPGN_Parser::TAGCLOSE// ]
  10.         const STRING File_ChessPGN_Parser::STRING// ]
  11.         const NAG File_ChessPGN_Parser::NAG// $1 $2, etc.
  12.         const GAMEEND File_ChessPGN_Parser::GAMEEND// * 1-0 0-1
  13.         const PAWNMOVE File_ChessPGN_Parser::PAWNMOVE// e4, e8=Q, exd8=R
  14.         const PIECEMOVE File_ChessPGN_Parser::PIECEMOVE// Nf2, Nab2, N3d5, Qxe4, Qexe4, Q3xe4
  15.         const PLACEMENTMOVE File_ChessPGN_Parser::PLACEMENTMOVE// N@f2, P@d5
  16.         const CHECK File_ChessPGN_Parser::CHECK// +
  17.         const MATE File_ChessPGN_Parser::MATE// #
  18.         const DIGIT File_ChessPGN_Parser::DIGIT// 0-9
  19.         const MOVEANNOT File_ChessPGN_Parser::MOVEANNOT// ! ? !! ?? !? ?!
  20.         const RAVOPEN File_ChessPGN_Parser::RAVOPEN// (
  21.         const RAVCLOSE File_ChessPGN_Parser::RAVCLOSE// )
  22.         const PERIOD File_ChessPGN_Parser::PERIOD// .
  23.         const COMMENTOPEN File_ChessPGN_Parser::COMMENTOPEN// {
  24.         const COMMENTCLOSE File_ChessPGN_Parser::COMMENTCLOSE// }
  25.         const COMMENT File_ChessPGN_Parser::COMMENT// anything
  26.         const CASTLE File_ChessPGN_Parser::CASTLE// O-O O-O-O
  27.  
  28.     
  29.     private $input;
  30.     private $N;
  31.     public $token;
  32.     public $value;
  33.     public $line;
  34.     private $_string;
  35.     private $debug 0;
  36.     
  37.     function __construct($data)
  38.     {
  39.         $this->input str_replace("\r\n""\n"$data);
  40.         $this->0;
  41.     }
  42.  
  43.  
  44.     private $_yy_state 1;
  45.     private $_yy_stack array();
  46.  
  47.     function yylex()
  48.     {
  49.         return $this->{'yylex' $this->_yy_state}();
  50.     }
  51.  
  52.     function yypushstate($state)
  53.     {
  54.         array_push($this->_yy_stack$this->_yy_state);
  55.         $this->_yy_state $state;
  56.     }
  57.  
  58.     function yypopstate()
  59.     {
  60.         $this->_yy_state array_pop($this->_yy_stack);
  61.     }
  62.  
  63.     function yybegin($state)
  64.     {
  65.         $this->_yy_state $state;
  66.     }
  67.  
  68.  
  69.  
  70.     function yylex1()
  71.     {
  72.         $tokenMap array (
  73.               => 0,
  74.               => 0,
  75.               => 0,
  76.               => 0,
  77.               => 0,
  78.               => 0,
  79.               => 0,
  80.               => 0,
  81.               => 0,
  82.               10 => 0,
  83.             );
  84.         if ($this->>= strlen($this->input)) {
  85.             return false// end of input
  86.         }
  87.         $yy_global_pattern "/^(\\[)|^(\\()|^((?:1-0|0-1|1\2-1\2))|^([0-9]{1,3})|^(P?[a-h](?:[2-7]|[18]=(?:Q|R|B|N))|P?[a-h]x[a-h](?:[2-7]|[18]=(?:Q|R|B|N)))|^((?:Q|K|R|B|N)(?:[a-h]|[1-8])?[a-h][1-8]|(?:Q|K|R|B|N)(?:[a-h]|[1-8])?x[a-h][1-8])|^((?:P|K|Q|R|B|N)@[a-h][1-8])|^(\\{)|^(O-O-O|O-O)|^([ \n\t]+)/";
  88.  
  89.         do {
  90.             if (preg_match($yy_global_patternsubstr($this->input$this->N)$yymatches)) {
  91.                 $yysubmatches $yymatches;
  92.                 $yymatches array_filter($yymatches'strlen')// remove empty sub-patterns
  93.                 if (!count($yymatches)) {
  94.                     throw new Exception('Error: lexing failed because a rule matched' .
  95.                         'an empty string.  Input "' substr($this->input,
  96.                         $this->N5'... state YYINITIAL');
  97.                 }
  98.                 next($yymatches)// skip global match
  99.                 $this->token key($yymatches)// token number
  100.                 if ($tokenMap[$this->token]{
  101.                     // extract sub-patterns for passing to lex function
  102.                     $yysubmatches array_slice($yysubmatches$this->token 1,
  103.                         $tokenMap[$this->token]);
  104.                 else {
  105.                     $yysubmatches array();
  106.                 }
  107.                 $this->value current($yymatches)// token value
  108.                 $r $this->{'yy_r1_' $this->token}($yysubmatches);
  109.                 if ($r === null{
  110.                     $this->+= strlen($this->value);
  111.                     $this->line += substr_count("\n"$this->value);
  112.                     // accept this token
  113.                     return true;
  114.                 elseif ($r === true{
  115.                     // we have changed state
  116.                     // process this token in the new state
  117.                     return $this->yylex();
  118.                 elseif ($r === false{
  119.                     $this->+= strlen($this->value);
  120.                     $this->line += substr_count("\n"$this->value);
  121.                     if ($this->>= strlen($this->input)) {
  122.                         return false// end of input
  123.                     }
  124.                     // skip this token
  125.                     continue;
  126.                 else {                    $yy_yymore_patterns array(
  127.         => "^(\\()|^((?:1-0|0-1|1\2-1\2))|^([0-9]{1,3})|^(P?[a-h](?:[2-7]|[18]=(?:Q|R|B|N))|P?[a-h]x[a-h](?:[2-7]|[18]=(?:Q|R|B|N)))|^((?:Q|K|R|B|N)(?:[a-h]|[1-8])?[a-h][1-8]|(?:Q|K|R|B|N)(?:[a-h]|[1-8])?x[a-h][1-8])|^((?:P|K|Q|R|B|N)@[a-h][1-8])|^(\\{)|^(O-O-O|O-O)|^([ \n\t]+)",
  128.         => "^((?:1-0|0-1|1\2-1\2))|^([0-9]{1,3})|^(P?[a-h](?:[2-7]|[18]=(?:Q|R|B|N))|P?[a-h]x[a-h](?:[2-7]|[18]=(?:Q|R|B|N)))|^((?:Q|K|R|B|N)(?:[a-h]|[1-8])?[a-h][1-8]|(?:Q|K|R|B|N)(?:[a-h]|[1-8])?x[a-h][1-8])|^((?:P|K|Q|R|B|N)@[a-h][1-8])|^(\\{)|^(O-O-O|O-O)|^([ \n\t]+)",
  129.         => "^([0-9]{1,3})|^(P?[a-h](?:[2-7]|[18]=(?:Q|R|B|N))|P?[a-h]x[a-h](?:[2-7]|[18]=(?:Q|R|B|N)))|^((?:Q|K|R|B|N)(?:[a-h]|[1-8])?[a-h][1-8]|(?:Q|K|R|B|N)(?:[a-h]|[1-8])?x[a-h][1-8])|^((?:P|K|Q|R|B|N)@[a-h][1-8])|^(\\{)|^(O-O-O|O-O)|^([ \n\t]+)",
  130.         => "^(P?[a-h](?:[2-7]|[18]=(?:Q|R|B|N))|P?[a-h]x[a-h](?:[2-7]|[18]=(?:Q|R|B|N)))|^((?:Q|K|R|B|N)(?:[a-h]|[1-8])?[a-h][1-8]|(?:Q|K|R|B|N)(?:[a-h]|[1-8])?x[a-h][1-8])|^((?:P|K|Q|R|B|N)@[a-h][1-8])|^(\\{)|^(O-O-O|O-O)|^([ \n\t]+)",
  131.         => "^((?:Q|K|R|B|N)(?:[a-h]|[1-8])?[a-h][1-8]|(?:Q|K|R|B|N)(?:[a-h]|[1-8])?x[a-h][1-8])|^((?:P|K|Q|R|B|N)@[a-h][1-8])|^(\\{)|^(O-O-O|O-O)|^([ \n\t]+)",
  132.         => "^((?:P|K|Q|R|B|N)@[a-h][1-8])|^(\\{)|^(O-O-O|O-O)|^([ \n\t]+)",
  133.         => "^(\\{)|^(O-O-O|O-O)|^([ \n\t]+)",
  134.         => "^(O-O-O|O-O)|^([ \n\t]+)",
  135.         => "^([ \n\t]+)",
  136.         10 => "",
  137.     );
  138.  
  139.                     // yymore is needed
  140.                     do {
  141.                         if (!strlen($yy_yymore_patterns[$this->token])) {
  142.                             throw new Exception('cannot do yymore for the last token');
  143.                         }
  144.                         if (preg_match($yy_yymore_patterns[$this->token],
  145.                               substr($this->input$this->N)$yymatches)) {
  146.                             $yymatches array_filter($yymatches'strlen')// remove empty sub-patterns
  147.                             next($yymatches)// skip global match
  148.                             $this->token key($yymatches)// token number
  149.                             $this->value current($yymatches)// token value
  150.                             $this->line substr_count("\n"$this->value);
  151.                         }
  152.                     while ($this->{'yy_r1_' $this->token}(!== null);
  153.                     // accept
  154.                     $this->+= strlen($this->value);
  155.                     $this->line += substr_count("\n"$this->value);
  156.                     return true;
  157.                 }
  158.             else {
  159.                 throw new Exception('Unexpected input at line' $this->line .
  160.                     ': ' $this->input[$this->N]);
  161.             }
  162.             break;
  163.         while (true);
  164.     // end function
  165.  
  166.  
  167.     
  168.  
  169.  
  170.     const YYINITIAL 1;
  171.     function yy_r1_1($yy_subpatterns)
  172.     {
  173.  
  174.     if ($this->debugecho 'new tag ['.$this->value."]\n";
  175.     $this->token self::TAGOPEN;
  176.     $this->yybegin(self::INTAG);
  177.     }
  178.     function yy_r1_2($yy_subpatterns)
  179.     {
  180.  
  181.     $this->yybegin(self::INMOVES);
  182.     if ($this->debugecho '->found rav ['.$this->value."]\n";
  183.     $this->token self::RAVOPEN;
  184.     }
  185.     function yy_r1_3($yy_subpatterns)
  186.     {
  187.  
  188.     // end of game
  189.     if ($this->debugecho 'found game end ['.$this->value."]\n";
  190.     $this->token self::GAMEEND;
  191.     }
  192.     function yy_r1_4($yy_subpatterns)
  193.     {
  194.  
  195.     $this->yybegin(self::INMOVES);
  196.     if ($this->debugecho '->found digit ['.$this->value."]\n";
  197.     $this->token self::DIGIT;
  198.     }
  199.     function yy_r1_5($yy_subpatterns)
  200.     {
  201.  
  202.     $this->yybegin(self::INMOVES);
  203.     if ($this->debugecho '->found pawn move ['.$this->value."]\n";
  204.     $this->token self::PAWNMOVE;
  205.     }
  206.     function yy_r1_6($yy_subpatterns)
  207.     {
  208.  
  209.     $this->yybegin(self::INMOVES);
  210.     if ($this->debugecho '->found piece move ['.$this->value."]\n";
  211.     $this->token self::PIECEMOVE;
  212.     }
  213.     function yy_r1_7($yy_subpatterns)
  214.     {
  215.  
  216.     $this->yybegin(self::INMOVES);
  217.     if ($this->debugecho '->found placement move ['.$this->value."]\n";
  218.     $this->token self::PLACEMENTMOVE;
  219.     }
  220.     function yy_r1_8($yy_subpatterns)
  221.     {
  222.  
  223.     if ($this->debugecho 'new comment ['.$this->value."]\n";
  224.     $this->yypushstate(self::INCOMMENT);
  225.     $this->token self::COMMENTOPEN;
  226.     }
  227.     function yy_r1_9($yy_subpatterns)
  228.     {
  229.  
  230.     $this->yybegin(self::INMOVES);
  231.     if ($this->debugecho 'found castle move ['.$this->value."]\n";
  232.     $this->token self::CASTLE;
  233.     }
  234.     function yy_r1_10($yy_subpatterns)
  235.     {
  236.  
  237.     // cycle to next token
  238.     return false;
  239.     }
  240.  
  241.  
  242.     function yylex2()
  243.     {
  244.         $tokenMap array (
  245.               => 0,
  246.               => 0,
  247.               => 0,
  248.               => 0,
  249.               => 0,
  250.               => 0,
  251.               => 0,
  252.               => 0,
  253.               => 0,
  254.               10 => 0,
  255.               11 => 0,
  256.               12 => 0,
  257.               13 => 0,
  258.               14 => 0,
  259.               15 => 0,
  260.               16 => 0,
  261.             );
  262.         if ($this->>= strlen($this->input)) {
  263.             return false// end of input
  264.         }
  265.         $yy_global_pattern "/^(\\()|^((?:1-0|0-1|1\2-1\2))|^([0-9]{1,3})|^(P?[a-h](?:[2-7]|[18]=(?:Q|R|B|N))|P?[a-h]x[a-h](?:[2-7]|[18]=(?:Q|R|B|N)))|^((?:Q|K|R|B|N)(?:[a-h]|[1-8])?[a-h][1-8]|(?:Q|K|R|B|N)(?:[a-h]|[1-8])?x[a-h][1-8])|^((?:P|K|Q|R|B|N)@[a-h][1-8])|^(\\{)|^(O-O-O|O-O)|^([ \n\t]+)|^(\\$[0-9]+)|^(\\*)|^(\\.)|^(\\+)|^(#)|^(!|\\?|!!|\\?\\?|!\\?|\\?!)|^(\\))/";
  266.  
  267.         do {
  268.             if (preg_match($yy_global_patternsubstr($this->input$this->N)$yymatches)) {
  269.                 $yysubmatches $yymatches;
  270.                 $yymatches array_filter($yymatches'strlen')// remove empty sub-patterns
  271.                 if (!count($yymatches)) {
  272.                     throw new Exception('Error: lexing failed because a rule matched' .
  273.                         'an empty string.  Input "' substr($this->input,
  274.                         $this->N5'... state INMOVES');
  275.                 }
  276.                 next($yymatches)// skip global match
  277.                 $this->token key($yymatches)// token number
  278.                 if ($tokenMap[$this->token]{
  279.                     // extract sub-patterns for passing to lex function
  280.                     $yysubmatches array_slice($yysubmatches$this->token 1,
  281.                         $tokenMap[$this->token]);
  282.                 else {
  283.                     $yysubmatches array();
  284.                 }
  285.                 $this->value current($yymatches)// token value
  286.                 $r $this->{'yy_r2_' $this->token}($yysubmatches);
  287.                 if ($r === null{
  288.                     $this->+= strlen($this->value);
  289.                     $this->line += substr_count("\n"$this->value);
  290.                     // accept this token
  291.                     return true;
  292.                 elseif ($r === true{
  293.                     // we have changed state
  294.                     // process this token in the new state
  295.                     return $this->yylex();
  296.                 elseif ($r === false{
  297.                     $this->+= strlen($this->value);
  298.                     $this->line += substr_count("\n"$this->value);
  299.                     if ($this->>= strlen($this->input)) {
  300.                         return false// end of input
  301.                     }
  302.                     // skip this token
  303.                     continue;
  304.                 else {                    $yy_yymore_patterns array(
  305.         => "^((?:1-0|0-1|1\2-1\2))|^([0-9]{1,3})|^(P?[a-h](?:[2-7]|[18]=(?:Q|R|B|N))|P?[a-h]x[a-h](?:[2-7]|[18]=(?:Q|R|B|N)))|^((?:Q|K|R|B|N)(?:[a-h]|[1-8])?[a-h][1-8]|(?:Q|K|R|B|N)(?:[a-h]|[1-8])?x[a-h][1-8])|^((?:P|K|Q|R|B|N)@[a-h][1-8])|^(\\{)|^(O-O-O|O-O)|^([ \n\t]+)|^(\\$[0-9]+)|^(\\*)|^(\\.)|^(\\+)|^(#)|^(!|\\?|!!|\\?\\?|!\\?|\\?!)|^(\\))",
  306.         => "^([0-9]{1,3})|^(P?[a-h](?:[2-7]|[18]=(?:Q|R|B|N))|P?[a-h]x[a-h](?:[2-7]|[18]=(?:Q|R|B|N)))|^((?:Q|K|R|B|N)(?:[a-h]|[1-8])?[a-h][1-8]|(?:Q|K|R|B|N)(?:[a-h]|[1-8])?x[a-h][1-8])|^((?:P|K|Q|R|B|N)@[a-h][1-8])|^(\\{)|^(O-O-O|O-O)|^([ \n\t]+)|^(\\$[0-9]+)|^(\\*)|^(\\.)|^(\\+)|^(#)|^(!|\\?|!!|\\?\\?|!\\?|\\?!)|^(\\))",
  307.         => "^(P?[a-h](?:[2-7]|[18]=(?:Q|R|B|N))|P?[a-h]x[a-h](?:[2-7]|[18]=(?:Q|R|B|N)))|^((?:Q|K|R|B|N)(?:[a-h]|[1-8])?[a-h][1-8]|(?:Q|K|R|B|N)(?:[a-h]|[1-8])?x[a-h][1-8])|^((?:P|K|Q|R|B|N)@[a-h][1-8])|^(\\{)|^(O-O-O|O-O)|^([ \n\t]+)|^(\\$[0-9]+)|^(\\*)|^(\\.)|^(\\+)|^(#)|^(!|\\?|!!|\\?\\?|!\\?|\\?!)|^(\\))",
  308.         => "^((?:Q|K|R|B|N)(?:[a-h]|[1-8])?[a-h][1-8]|(?:Q|K|R|B|N)(?:[a-h]|[1-8])?x[a-h][1-8])|^((?:P|K|Q|R|B|N)@[a-h][1-8])|^(\\{)|^(O-O-O|O-O)|^([ \n\t]+)|^(\\$[0-9]+)|^(\\*)|^(\\.)|^(\\+)|^(#)|^(!|\\?|!!|\\?\\?|!\\?|\\?!)|^(\\))",
  309.         => "^((?:P|K|Q|R|B|N)@[a-h][1-8])|^(\\{)|^(O-O-O|O-O)|^([ \n\t]+)|^(\\$[0-9]+)|^(\\*)|^(\\.)|^(\\+)|^(#)|^(!|\\?|!!|\\?\\?|!\\?|\\?!)|^(\\))",
  310.         => "^(\\{)|^(O-O-O|O-O)|^([ \n\t]+)|^(\\$[0-9]+)|^(\\*)|^(\\.)|^(\\+)|^(#)|^(!|\\?|!!|\\?\\?|!\\?|\\?!)|^(\\))",
  311.         => "^(O-O-O|O-O)|^([ \n\t]+)|^(\\$[0-9]+)|^(\\*)|^(\\.)|^(\\+)|^(#)|^(!|\\?|!!|\\?\\?|!\\?|\\?!)|^(\\))",
  312.         => "^([ \n\t]+)|^(\\$[0-9]+)|^(\\*)|^(\\.)|^(\\+)|^(#)|^(!|\\?|!!|\\?\\?|!\\?|\\?!)|^(\\))",
  313.         => "^(\\$[0-9]+)|^(\\*)|^(\\.)|^(\\+)|^(#)|^(!|\\?|!!|\\?\\?|!\\?|\\?!)|^(\\))",
  314.         10 => "^(\\*)|^(\\.)|^(\\+)|^(#)|^(!|\\?|!!|\\?\\?|!\\?|\\?!)|^(\\))",
  315.         11 => "^(\\.)|^(\\+)|^(#)|^(!|\\?|!!|\\?\\?|!\\?|\\?!)|^(\\))",
  316.         12 => "^(\\+)|^(#)|^(!|\\?|!!|\\?\\?|!\\?|\\?!)|^(\\))",
  317.         13 => "^(#)|^(!|\\?|!!|\\?\\?|!\\?|\\?!)|^(\\))",
  318.         14 => "^(!|\\?|!!|\\?\\?|!\\?|\\?!)|^(\\))",
  319.         15 => "^(\\))",
  320.         16 => "",
  321.     );
  322.  
  323.                     // yymore is needed
  324.                     do {
  325.                         if (!strlen($yy_yymore_patterns[$this->token])) {
  326.                             throw new Exception('cannot do yymore for the last token');
  327.                         }
  328.                         if (preg_match($yy_yymore_patterns[$this->token],
  329.                               substr($this->input$this->N)$yymatches)) {
  330.                             $yymatches array_filter($yymatches'strlen')// remove empty sub-patterns
  331.                             next($yymatches)// skip global match
  332.                             $this->token key($yymatches)// token number
  333.                             $this->value current($yymatches)// token value
  334.                             $this->line substr_count("\n"$this->value);
  335.                         }
  336.                     while ($this->{'yy_r2_' $this->token}(!== null);
  337.                     // accept
  338.                     $this->+= strlen($this->value);
  339.                     $this->line += substr_count("\n"$this->value);
  340.                     return true;
  341.                 }
  342.             else {
  343.                 throw new Exception('Unexpected input at line' $this->line .
  344.                     ': ' $this->input[$this->N]);
  345.             }
  346.             break;
  347.         while (true);
  348.     // end function
  349.  
  350.  
  351.     
  352.  
  353.  
  354.     const INMOVES 2;
  355.     function yy_r2_1($yy_subpatterns)
  356.     {
  357.  
  358.     if ($this->debugecho '->found rav ['.$this->value."]\n";
  359.     $this->token self::RAVOPEN;
  360.     }
  361.     function yy_r2_2($yy_subpatterns)
  362.     {
  363.  
  364.     // end of game
  365.     $this->yybegin(self::YYINITIAL);
  366.     if ($this->debugecho 'found game end ['.$this->value."]\n";
  367.     $this->token self::GAMEEND;
  368.     }
  369.     function yy_r2_3($yy_subpatterns)
  370.     {
  371.  
  372.     if ($this->debugecho '->found digit ['.$this->value."]\n";
  373.     $this->token self::DIGIT;
  374.     }
  375.     function yy_r2_4($yy_subpatterns)
  376.     {
  377.  
  378.     if ($this->debugecho '->found pawn move ['.$this->value."]\n";
  379.     $this->token self::PAWNMOVE;
  380.     }
  381.     function yy_r2_5($yy_subpatterns)
  382.     {
  383.  
  384.     if ($this->debugecho '->found piece move ['.$this->value."]\n";
  385.     $this->token self::PIECEMOVE;
  386.     }
  387.     function yy_r2_6($yy_subpatterns)
  388.     {
  389.  
  390.     if ($this->debugecho '->found placement move ['.$this->value."]\n";
  391.     $this->token self::PLACEMENTMOVE;
  392.     }
  393.     function yy_r2_7($yy_subpatterns)
  394.     {
  395.  
  396.     if ($this->debugecho 'new comment ['.$this->value."]\n";
  397.     $this->yypushstate(self::INCOMMENT);
  398.     $this->token self::COMMENTOPEN;
  399.     }
  400.     function yy_r2_8($yy_subpatterns)
  401.     {
  402.  
  403.     if ($this->debugecho 'found castle move ['.$this->value."]\n";
  404.     $this->token self::CASTLE;
  405.     }
  406.     function yy_r2_9($yy_subpatterns)
  407.     {
  408.  
  409.     // cycle to next token
  410.     return false;
  411.     }
  412.     function yy_r2_10($yy_subpatterns)
  413.     {
  414.  
  415.     if ($this->debugecho 'found numeric annotation glyph ['.$this->value."]\n";
  416.     $this->token self::NAG;
  417.     }
  418.     function yy_r2_11($yy_subpatterns)
  419.     {
  420.  
  421.     // end of game
  422.     $this->yybegin(self::YYINITIAL);
  423.     if ($this->debugecho 'found unfinished game indicator ['.$this->value."]\n";
  424.     $this->token self::GAMEEND;
  425.     }
  426.     function yy_r2_12($yy_subpatterns)
  427.     {
  428.  
  429.     if ($this->debugecho 'found period ['.$this->value."]\n";
  430.     $this->token self::PERIOD;
  431.     }
  432.     function yy_r2_13($yy_subpatterns)
  433.     {
  434.  
  435.     if ($this->debugecho 'found check ['.$this->value."]\n";
  436.     $this->token self::CHECK;
  437.     }
  438.     function yy_r2_14($yy_subpatterns)
  439.     {
  440.  
  441.     if ($this->debugecho 'found mate ['.$this->value."]\n";
  442.     $this->token self::MATE;
  443.     }
  444.     function yy_r2_15($yy_subpatterns)
  445.     {
  446.  
  447.     if ($this->debugecho 'found move annotation ['.$this->value."]\n";
  448.     $this->token self::MOVEANNOT;
  449.     }
  450.     function yy_r2_16($yy_subpatterns)
  451.     {
  452.  
  453.     if ($this->debugecho 'found recursive annotation variation close ['.$this->value."]\n";
  454.     $this->token self::RAVCLOSE;
  455.     }
  456.  
  457.  
  458.     function yylex3()
  459.     {
  460.         $tokenMap array (
  461.               => 0,
  462.               => 0,
  463.               => 0,
  464.               => 0,
  465.             );
  466.         if ($this->>= strlen($this->input)) {
  467.             return false// end of input
  468.         }
  469.         $yy_global_pattern "/^(\")|^(\\])|^([^\\]\" ]+)|^( )/";
  470.  
  471.         do {
  472.             if (preg_match($yy_global_patternsubstr($this->input$this->N)$yymatches)) {
  473.                 $yysubmatches $yymatches;
  474.                 $yymatches array_filter($yymatches'strlen')// remove empty sub-patterns
  475.                 if (!count($yymatches)) {
  476.                     throw new Exception('Error: lexing failed because a rule matched' .
  477.                         'an empty string.  Input "' substr($this->input,
  478.                         $this->N5'... state INTAG');
  479.                 }
  480.                 next($yymatches)// skip global match
  481.                 $this->token key($yymatches)// token number
  482.                 if ($tokenMap[$this->token]{
  483.                     // extract sub-patterns for passing to lex function
  484.                     $yysubmatches array_slice($yysubmatches$this->token 1,
  485.                         $tokenMap[$this->token]);
  486.                 else {
  487.                     $yysubmatches array();
  488.                 }
  489.                 $this->value current($yymatches)// token value
  490.                 $r $this->{'yy_r3_' $this->token}($yysubmatches);
  491.                 if ($r === null{
  492.                     $this->+= strlen($this->value);
  493.                     $this->line += substr_count("\n"$this->value);
  494.                     // accept this token
  495.                     return true;
  496.                 elseif ($r === true{
  497.                     // we have changed state
  498.                     // process this token in the new state
  499.                     return $this->yylex();
  500.                 elseif ($r === false{
  501.                     $this->+= strlen($this->value);
  502.                     $this->line += substr_count("\n"$this->value);
  503.                     if ($this->>= strlen($this->input)) {
  504.                         return false// end of input
  505.                     }
  506.                     // skip this token
  507.                     continue;
  508.                 else {                    $yy_yymore_patterns array(
  509.         => "^(\\])|^([^\\]\" ]+)|^( )",
  510.         => "^([^\\]\" ]+)|^( )",
  511.         => "^( )",
  512.         => "",
  513.     );
  514.  
  515.                     // yymore is needed
  516.                     do {
  517.                         if (!strlen($yy_yymore_patterns[$this->token])) {
  518.                             throw new Exception('cannot do yymore for the last token');
  519.                         }
  520.                         if (preg_match($yy_yymore_patterns[$this->token],
  521.                               substr($this->input$this->N)$yymatches)) {
  522.                             $yymatches array_filter($yymatches'strlen')// remove empty sub-patterns
  523.                             next($yymatches)// skip global match
  524.                             $this->token key($yymatches)// token number
  525.                             $this->value current($yymatches)// token value
  526.                             $this->line substr_count("\n"$this->value);
  527.                         }
  528.                     while ($this->{'yy_r3_' $this->token}(!== null);
  529.                     // accept
  530.                     $this->+= strlen($this->value);
  531.                     $this->line += substr_count("\n"$this->value);
  532.                     return true;
  533.                 }
  534.             else {
  535.                 throw new Exception('Unexpected input at line' $this->line .
  536.                     ': ' $this->input[$this->N]);
  537.             }
  538.             break;
  539.         while (true);
  540.     // end function
  541.  
  542.  
  543.     
  544.  
  545.  
  546.     const INTAG 3;
  547.     function yy_r3_1($yy_subpatterns)
  548.     {
  549.  
  550.     if ($this->debugecho "starting string\n";
  551.     $this->yybegin(self::INSTRING);
  552.     $this->_string '';
  553.     $this->N++;
  554.     return true// cycle to next state
  555.     }
  556.     function yy_r3_2($yy_subpatterns)
  557.     {
  558.  
  559.     if ($this->debugecho "ending tag [".$this->value."]\n";
  560.     $this->yybegin(self::YYINITIAL);
  561.     $this->token self::TAGCLOSE;
  562.     }
  563.     function yy_r3_3($yy_subpatterns)
  564.     {
  565.  
  566.     if ($this->debugecho 'tag contents ['.$this->value."]\n";
  567.     $this->token self::TAGNAME;
  568.     }
  569.     function yy_r3_4($yy_subpatterns)
  570.     {
  571.  
  572.     // skip token
  573.     return false;
  574.     }
  575.  
  576.  
  577.     function yylex4()
  578.     {
  579.         $tokenMap array (
  580.               => 0,
  581.               => 0,
  582.               => 0,
  583.             );
  584.         if ($this->>= strlen($this->input)) {
  585.             return false// end of input
  586.         }
  587.         $yy_global_pattern "/^(\\\\)|^(\")|^([^[\"\\\\]+)/";
  588.  
  589.         do {
  590.             if (preg_match($yy_global_patternsubstr($this->input$this->N)$yymatches)) {
  591.                 $yysubmatches $yymatches;
  592.                 $yymatches array_filter($yymatches'strlen')// remove empty sub-patterns
  593.                 if (!count($yymatches)) {
  594.                     throw new Exception('Error: lexing failed because a rule matched' .
  595.                         'an empty string.  Input "' substr($this->input,
  596.                         $this->N5'... state INSTRING');
  597.                 }
  598.                 next($yymatches)// skip global match
  599.                 $this->token key($yymatches)// token number
  600.                 if ($tokenMap[$this->token]{
  601.                     // extract sub-patterns for passing to lex function
  602.                     $yysubmatches array_slice($yysubmatches$this->token 1,
  603.                         $tokenMap[$this->token]);
  604.                 else {
  605.                     $yysubmatches array();
  606.                 }
  607.                 $this->value current($yymatches)// token value
  608.                 $r $this->{'yy_r4_' $this->token}($yysubmatches);
  609.                 if ($r === null{
  610.                     $this->+= strlen($this->value);
  611.                     $this->line += substr_count("\n"$this->value);
  612.                     // accept this token
  613.                     return true;
  614.                 elseif ($r === true{
  615.                     // we have changed state
  616.                     // process this token in the new state
  617.                     return $this->yylex();
  618.                 elseif ($r === false{
  619.                     $this->+= strlen($this->value);
  620.                     $this->line += substr_count("\n"$this->value);
  621.                     if ($this->>= strlen($this->input)) {
  622.                         return false// end of input
  623.                     }
  624.                     // skip this token
  625.                     continue;
  626.                 else {                    $yy_yymore_patterns array(
  627.         => "^(\")|^([^[\"\\\\]+)",
  628.         => "^([^[\"\\\\]+)",
  629.         => "",
  630.     );
  631.  
  632.                     // yymore is needed
  633.                     do {
  634.                         if (!strlen($yy_yymore_patterns[$this->token])) {
  635.                             throw new Exception('cannot do yymore for the last token');
  636.                         }
  637.                         if (preg_match($yy_yymore_patterns[$this->token],
  638.                               substr($this->input$this->N)$yymatches)) {
  639.                             $yymatches array_filter($yymatches'strlen')// remove empty sub-patterns
  640.                             next($yymatches)// skip global match
  641.                             $this->token key($yymatches)// token number
  642.                             $this->value current($yymatches)// token value
  643.                             $this->line substr_count("\n"$this->value);
  644.                         }
  645.                     while ($this->{'yy_r4_' $this->token}(!== null);
  646.                     // accept
  647.                     $this->+= strlen($this->value);
  648.                     $this->line += substr_count("\n"$this->value);
  649.                     return true;
  650.                 }
  651.             else {
  652.                 throw new Exception('Unexpected input at line' $this->line .
  653.                     ': ' $this->input[$this->N]);
  654.             }
  655.             break;
  656.         while (true);
  657.     // end function
  658.  
  659.  
  660.     
  661.  
  662.  
  663.     const INSTRING 4;
  664.     function yy_r4_1($yy_subpatterns)
  665.     {
  666.  
  667.     if ($this->debugecho "string escape [\\]\n";
  668.     $this->yybegin(self::INESCAPE);
  669.     return true;
  670.     }
  671.     function yy_r4_2($yy_subpatterns)
  672.     {
  673.  
  674.     if ($this->debugecho "returning string [$this->_string]\n";
  675.     $this->yybegin(self::INTAG);
  676.     $this->value $this->_string;
  677.     $this->token self::STRING;
  678.     $this->-= strlen($this->_string1// make sure the counter is right
  679.     $this->_string '';
  680.     }
  681.     function yy_r4_3($yy_subpatterns)
  682.     {
  683.  
  684.     if ($this->debugecho "added to string [".$this->value."]\n";
  685.     $this->_string .= $this->value;
  686.     return false;
  687.     }
  688.  
  689.  
  690.     function yylex5()
  691.     {
  692.         $tokenMap array (
  693.               => 0,
  694.               => 0,
  695.             );
  696.         if ($this->>= strlen($this->input)) {
  697.             return false// end of input
  698.         }
  699.         $yy_global_pattern "/^(\"|\\\\)|^(.)/";
  700.  
  701.         do {
  702.             if (preg_match($yy_global_patternsubstr($this->input$this->N)$yymatches)) {
  703.                 $yysubmatches $yymatches;
  704.                 $yymatches array_filter($yymatches'strlen')// remove empty sub-patterns
  705.                 if (!count($yymatches)) {
  706.                     throw new Exception('Error: lexing failed because a rule matched' .
  707.                         'an empty string.  Input "' substr($this->input,
  708.                         $this->N5'... state INESCAPE');
  709.                 }
  710.                 next($yymatches)// skip global match
  711.                 $this->token key($yymatches)// token number
  712.                 if ($tokenMap[$this->token]{
  713.                     // extract sub-patterns for passing to lex function
  714.                     $yysubmatches array_slice($yysubmatches$this->token 1,
  715.                         $tokenMap[$this->token]);
  716.                 else {
  717.                     $yysubmatches array();
  718.                 }
  719.                 $this->value current($yymatches)// token value
  720.                 $r $this->{'yy_r5_' $this->token}($yysubmatches);
  721.                 if ($r === null{
  722.                     $this->+= strlen($this->value);
  723.                     $this->line += substr_count("\n"$this->value);
  724.                     // accept this token
  725.                     return true;
  726.                 elseif ($r === true{
  727.                     // we have changed state
  728.                     // process this token in the new state
  729.                     return $this->yylex();
  730.                 elseif ($r === false{
  731.                     $this->+= strlen($this->value);
  732.                     $this->line += substr_count("\n"$this->value);
  733.                     if ($this->>= strlen($this->input)) {
  734.                         return false// end of input
  735.                     }
  736.                     // skip this token
  737.                     continue;
  738.                 else {                    $yy_yymore_patterns array(
  739.         => "^(.)",
  740.         => "",
  741.     );
  742.  
  743.                     // yymore is needed
  744.                     do {
  745.                         if (!strlen($yy_yymore_patterns[$this->token])) {
  746.                             throw new Exception('cannot do yymore for the last token');
  747.                         }
  748.                         if (preg_match($yy_yymore_patterns[$this->token],
  749.                               substr($this->input$this->N)$yymatches)) {
  750.                             $yymatches array_filter($yymatches'strlen')// remove empty sub-patterns
  751.                             next($yymatches)// skip global match
  752.                             $this->token key($yymatches)// token number
  753.                             $this->value current($yymatches)// token value
  754.                             $this->line substr_count("\n"$this->value);
  755.                         }
  756.                     while ($this->{'yy_r5_' $this->token}(!== null);
  757.                     // accept
  758.                     $this->+= strlen($this->value);
  759.                     $this->line += substr_count("\n"$this->value);
  760.                     return true;
  761.                 }
  762.             else {
  763.                 throw new Exception('Unexpected input at line' $this->line .
  764.                     ': ' $this->input[$this->N]);
  765.             }
  766.             break;
  767.         while (true);
  768.     // end function
  769.  
  770.  
  771.     
  772.  
  773.  
  774.     const INESCAPE 5;
  775.     function yy_r5_1($yy_subpatterns)
  776.     {
  777.  
  778.     if ($this->debugecho "escape [".$this->value."]\n";
  779.     $this->yybegin(self::INSTRING);
  780.     $this->_string .= $this->value;
  781.     break;
  782.     }
  783.     function yy_r5_2($yy_subpatterns)
  784.     {
  785.  
  786.     if ($this->debugecho "non-escape [".$this->value."]\n";
  787.     $this->yybegin(self::INSTRING);
  788.     $this->_string .= $this->value;
  789.     return false;
  790.     }
  791.  
  792.  
  793.     function yylex6()
  794.     {
  795.         $tokenMap array (
  796.               => 0,
  797.               => 0,
  798.             );
  799.         if ($this->>= strlen($this->input)) {
  800.             return false// end of input
  801.         }
  802.         $yy_global_pattern "/^(\\})|^([^}]+)/";
  803.  
  804.         do {
  805.             if (preg_match($yy_global_patternsubstr($this->input$this->N)$yymatches)) {
  806.                 $yysubmatches $yymatches;
  807.                 $yymatches array_filter($yymatches'strlen')// remove empty sub-patterns
  808.                 if (!count($yymatches)) {
  809.                     throw new Exception('Error: lexing failed because a rule matched' .
  810.                         'an empty string.  Input "' substr($this->input,
  811.                         $this->N5'... state INCOMMENT');
  812.                 }
  813.                 next($yymatches)// skip global match
  814.                 $this->token key($yymatches)// token number
  815.                 if ($tokenMap[$this->token]{
  816.                     // extract sub-patterns for passing to lex function
  817.                     $yysubmatches array_slice($yysubmatches$this->token 1,
  818.                         $tokenMap[$this->token]);
  819.                 else {
  820.                     $yysubmatches array();
  821.                 }
  822.                 $this->value current($yymatches)// token value
  823.                 $r $this->{'yy_r6_' $this->token}($yysubmatches);
  824.                 if ($r === null{
  825.                     $this->+= strlen($this->value);
  826.                     $this->line += substr_count("\n"$this->value);
  827.                     // accept this token
  828.                     return true;
  829.                 elseif ($r === true{
  830.                     // we have changed state
  831.                     // process this token in the new state
  832.                     return $this->yylex();
  833.                 elseif ($r === false{
  834.                     $this->+= strlen($this->value);
  835.                     $this->line += substr_count("\n"$this->value);
  836.                     if ($this->>= strlen($this->input)) {
  837.                         return false// end of input
  838.                     }
  839.                     // skip this token
  840.                     continue;
  841.                 else {                    $yy_yymore_patterns array(
  842.         => "^([^}]+)",
  843.         => "",
  844.     );
  845.  
  846.                     // yymore is needed
  847.                     do {
  848.                         if (!strlen($yy_yymore_patterns[$this->token])) {
  849.                             throw new Exception('cannot do yymore for the last token');
  850.                         }
  851.                         if (preg_match($yy_yymore_patterns[$this->token],
  852.                               substr($this->input$this->N)$yymatches)) {
  853.                             $yymatches array_filter($yymatches'strlen')// remove empty sub-patterns
  854.                             next($yymatches)// skip global match
  855.                             $this->token key($yymatches)// token number
  856.                             $this->value current($yymatches)// token value
  857.                             $this->line substr_count("\n"$this->value);
  858.                         }
  859.                     while ($this->{'yy_r6_' $this->token}(!== null);
  860.                     // accept
  861.                     $this->+= strlen($this->value);
  862.                     $this->line += substr_count("\n"$this->value);
  863.                     return true;
  864.                 }
  865.             else {
  866.                 throw new Exception('Unexpected input at line' $this->line .
  867.                     ': ' $this->input[$this->N]);
  868.             }
  869.             break;
  870.         while (true);
  871.     // end function
  872.  
  873.  
  874.     
  875.  
  876.  
  877.     const INCOMMENT 6;
  878.     function yy_r6_1($yy_subpatterns)
  879.     {
  880.  
  881.     if ($this->debugecho 'close comment ['.$this->value."]\n";
  882.     $this->yypopstate();
  883.     $this->token self::COMMENTCLOSE;
  884.     }
  885.     function yy_r6_2($yy_subpatterns)
  886.     {
  887.  
  888.     if ($this->debugecho 'comment contents ['.$this->value."]\n";
  889.     $this->token self::COMMENT;
  890.     }
  891.  
  892.     /**
  893.      * return something useful, when a parse error occurs.
  894.      *
  895.      * used to build error messages if the parser fails, and needs to know the line number..
  896.      *
  897.      * @return   string 
  898.      * @access   public
  899.      */
  900.     function parseError(
  901.     {
  902.         return "Error at line {$this->yyline}";
  903.         
  904.     }

Documentation generated on Sun, 02 Jul 2006 08:51:29 -0400 by phpDocumentor 1.3.0