Location: PHPKode > projects > Harmony preview > harmony-preview/libraries/Harmony/Script/Context/Catch.php
<?php
/**
 * Harmony
 * Copyright (c) 2008 Maxime Bouroumeau-Fuseau
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 * @category Harmony
 * @package Harmony_Script
 * @subpackage Harmony_Script_Context
 * @author Maxime Bouroumeau-Fuseau
 * @copyright 2008 (c) Maxime Bouroumeau-Fuseau
 * @license http://www.opensource.org/licenses/mit-license.php
 * @link http://www.harmony-framework.com
 */

/** Harmony_Script_Context */
require_once 'Harmony/Script/Context.php';

/**
 * Handles catch
 * 
 * @category Harmony
 * @package Harmony_Script 
 * @subpackage Harmony_Script_Context
 * @copyright 2008 (c) Maxime Bouroumeau-Fuseau
 * @license http://www.opensource.org/licenses/mit-license.php
 */
class Harmony_Script_Context_Catch extends Harmony_Script_Context
{
	/**
	 * Exception type
	 */
	protected $_type;
	
	/**
	 * Variable name
	 */
	protected $_var;
	
	/**
	 * Gets the exception type
	 */
	public function tokenString($text)
	{
		$this->_type = $text;
	}
	
	/**
	 * Gets the variable name
	 */
	public function tokenVariable($text)
	{
		$this->_var = substr($text, 1);
	}
	
	/**
	 * Rewrites the catch instruction
	 */
	public function tokenCurlyBracesStart($text)
	{
		$this->_js = 'catch (' . $this->_var . ') {';
		$this->_js .= $this->getParser()->enterContext('Block');
		$this->_js .= '}';
		
		$this->exitContext($this->_js);
	}
}
Return current item: Harmony preview