<commit_before><?php
/**
 * Parser for Talus' TPL's templates scripts.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 *
 * @package Talus' Works
 * @author Baptiste "Talus" Clavié <<EMAIL>>
 * @copyright ©Talus, Talus' Works 2008+
 * @link http://www.talus-works.net Talus' Works
 * @license http://www.gnu.org/licenses/gpl.html GNU Public License 2+
 * @version $Id$
 */

// -- If PHP < 5.3, emulating E_USER_DEPRECATED
if (!defined('E_USER_DEPRECATED')) {
  define('E_USER_DEPRECATED', E_USER_NOTICE);
}

/**
 * Template's Parser
 *
 * This class handle the transformation from a Talus TPL code to an optimized
 * PHP code, which can be used by PHP.
 */
class Talus_TPL_Parser implements Talus_TPL_Parser_Interface {
  protected $_parameters = array();

  const
    SET = 1,
    FILTERS = 2,
    INCLUDES = 4,
    CONDITIONS = 8,
    CONSTANTS = 16,

    BASICS = 4,
    DEFAULTS = 30,
    ALL = 31,

    // -- Regex used
    REGEX_PHP_ID = '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*', // PHP Identifier
    REGEX_ARRAYS = '\[[^]]+?]'; // PHP Arrays

  /**
   * Initialisation
   *
   * @return void
   */
  public function __construct(){
    $this->parameter('parse', self::DEFAULTS);
    $this->parameter('set_compact', false);
    $this->parameter('namespace', '');
  }
<commit_msg>fixes #19 : multi-dimensional arrays are now properly recognized<commit_after><?php
/**
 * Parser for Talus' TPL's templates scripts.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 *
 * @package Talus' Works
 * @author Baptiste "Talus" Clavié <<EMAIL>>
 * @copyright ©Talus, Talus' Works 2008+
 * @link http://www.talus-works.net Talus' Works
 * @license http://www.gnu.org/licenses/gpl.html GNU Public License 2+
 * @version $Id$
 */

// -- If PHP < 5.3, emulating E_USER_DEPRECATED
if (!defined('E_USER_DEPRECATED')) {
  define('E_USER_DEPRECATED', E_USER_NOTICE);
}

/**
 * Template's Parser
 *
 * This class handle the transformation from a Talus TPL code to an optimized
 * PHP code, which can be used by PHP.
 */
class Talus_TPL_Parser implements Talus_TPL_Parser_Interface {
  protected $_parameters = array();

  const
    SET = 1,
    FILTERS = 2,
    INCLUDES = 4,
    CONDITIONS = 8,
    CONSTANTS = 16,

    BASICS = 4,
    DEFAULTS = 30,
    ALL = 31,

    // -- Regex used
    REGEX_PHP_ID = '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*', // PHP Identifier
    REGEX_ARRAYS = '(?:\[[^]]+?])+'; // PHP Arrays

  /**
   * Initialisation
   *
   * @return void
   */
  public function __construct(){
    $this->parameter('parse', self::DEFAULTS);
    $this->parameter('set_compact', false);
    $this->parameter('namespace', '');
  }

{'fraction_non_alphanumeric': 0.11947791164658635, 'fraction_numerical': 0.017570281124497992, 'mean_word_length': 3.359956236323851, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1315045', 'n_tokens_mistral': 1319, 'n_tokens_neox': 1242, 'n_words': 449}