[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/libraries/antlr/ -> AntlrParser.php (source)

   1  <?php
   2  
   3  /*
   4   [The "BSD licence"]
   5   Copyright (c) 2005-2008 Terence Parr
   6   All rights reserved.
   7  
   8   Redistribution and use in source and binary forms, with or without
   9   modification, are permitted provided that the following conditions
  10   are met:
  11   1. Redistributions of source code must retain the above copyright
  12      notice, this list of conditions and the following disclaimer.
  13   2. Redistributions in binary form must reproduce the above copyright
  14      notice, this list of conditions and the following disclaimer in the
  15      documentation and/or other materials provided with the distribution.
  16   3. The name of the author may not be used to endorse or promote products
  17      derived from this software without specific prior written permission.
  18  
  19   THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  20   IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  21   OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  22   IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  23   INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  24   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  26   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  28   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29  */
  30  
  31  /** A parser for TokenStreams.  "parser grammars" result in a subclass
  32   *  of this.
  33   */
  34  class AntlrParser extends BaseRecognizer {
  35      public $input;
  36  
  37  
  38  	public function __construct($input, $state = null) {
  39          parent::__construct($state); // share the state object with another parser
  40          $this->setTokenStream($input);
  41      }
  42  
  43  	public function reset() {
  44          parent::reset(); // reset all recognizer state variables
  45          if ( $this->input!=null ) {
  46              $this->input->seek(0); // rewind the input
  47          }
  48      }
  49  
  50  	protected function getCurrentInputSymbol($input) {
  51          return $this->input->LT(1);
  52      }
  53  
  54  	protected function getMissingSymbol($input, $e, $expectedTokenType, $follow)
  55      {
  56          $tokenText = null;
  57          if ( $expectedTokenType==TokenConst::$EOF ){ 
  58              $tokenText = "<missing EOF>";
  59          } else {
  60              $tokenNames = $this->getTokenNames();
  61              $tokenText = "<missing ".$tokenNames[$expectedTokenType].">";
  62          }
  63          $t = CommonToken::forTypeAndText($expectedTokenType, $tokenText);
  64          $current = $input->LT(1);
  65          if ( $current->getType() == TokenConst::$EOF ) {
  66              $current = $this->input->LT(-1);
  67          }
  68          $t->line = $current->getLine();
  69          $t->charPositionInLine = $current->getCharPositionInLine();
  70          $t->channel = $DEFAULT_TOKEN_CHANNEL;
  71          return $t;
  72      }
  73  
  74      /** Set the token stream and reset the parser */
  75  	public function setTokenStream($input) {
  76          $this->input = null;
  77          $this->reset();
  78          $this->input = $input;
  79      }
  80  
  81      public function getTokenStream() {
  82          return $this->input;
  83      }
  84  
  85  	public function getSourceName() {
  86          return $this->input->getSourceName();
  87      }
  88  
  89  	public function traceIn($ruleName, $ruleIndex)  {
  90          parent::traceIn($ruleName, $ruleIndex, $this->input->LT(1));
  91      }
  92  
  93  	public function traceOut($ruleName, $ruleIndex)  {
  94          parent::traceOut($ruleName, $ruleIndex, $this->input->LT(1));
  95      }
  96      
  97  
  98  }
  99  
 100  ?>


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1