<commit_before><?php

use donatj\MySqlSchema\Columns;
use donatj\MySqlSchema\Table;

require('vendor/autoload.php');

$jql = file_get_contents('php://stdin');

/**
 * @param $jql
 * @throws \Exception
 * @throws \donatj\Misstep\Exceptions\ParseException
 * @throws \donatj\Misstep\Exceptions\StructureException
 */
function parse( $jql ) {
	$jql = preg_replace('%^//.*$%mx', '', $jql); //remove commented lines before parse
	$jql .= "\n";

	$totalMatch = '/\#\s(?P<declaration>.*)
		(?P<comment>\n(?::\s.*\n?)*)
		(?P<body>
		    (?:[-!?]\s.*\n
		    (?::\s.*\n)*)+
		)/x';


	checkForParseErrors($totalMatch, $jql);

	preg_match_all($totalMatch, $jql, $result, PREG_SET_ORDER);

	/**
	 * @var $tables \donatj\MySqlSchema\Table[]
	 */
	$foreignKeys = [ 'parents' => [ ], 'children' => [ ] ];
	$tables      = [ ];
	for( $i = 0; $i < count($result); $i++ ) {
		$body = $result[$i]['body'] . "\n";

		$table = new Table($result[$i]['declaration']);
		$table->setCharset('utf8');
		$table->setCollation('utf8_general_ci');

		if( trim($result[$i]['comment']) ) {
			$table->setComment(parseComment($result[$i]['comment']));
		}

		$bodyMatch = '/(?P<signal>[-?!])[ \t](?P<colName>\S+)
		[ \t]+(?P<nullable>\*)?(?P<signed>-)?(?P<colType>[a-z]+)(?P<colLength>\d+)?(?P<colDecimal>,\d+)?
		(?:(?P<hasDefault>=)(?:\'(?P<default1>(?:\'\'|[^\'])*)\'|(?P<default2>\S)))?
		(?P<pk>[ \t]\*?pk)?
		(?P<keys>(?:[ \t]+k\d+)*)
		(?P<uniques>(?:[ \t]+u\d+)*)
		(?P<comment>\n(?::[ \t].*\n?)*)/x';

		$tableKeys = [ ];

		checkForParseErrors($bodyMatch, $body);
		preg_match_all($bodyMatch, $body, $bodyResult, PREG_SET_ORDER);
		for( $j = 0; $j < count($bodyResult); $j++ ) {

			$colName = $bodyResult[$j]['colName'];
//		if( $colName == '_' ) {
//			$colName = $table->getName() . '_id';
//		}

			$col = null;<commit_msg>Allow multicharacter noquote defaults<commit_after><?php

use donatj\MySqlSchema\Columns;
use donatj\MySqlSchema\Table;

require('vendor/autoload.php');

$jql = file_get_contents('php://stdin');

/**
 * @param $jql
 * @throws \Exception
 * @throws \donatj\Misstep\Exceptions\ParseException
 * @throws \donatj\Misstep\Exceptions\StructureException
 */
function parse( $jql ) {
	$jql = preg_replace('%^//.*$%mx', '', $jql); //remove commented lines before parse
	$jql .= "\n";

	$totalMatch = '/\#\s(?P<declaration>.*)
		(?P<comment>\n(?::\s.*\n?)*)
		(?P<body>
		    (?:[-!?]\s.*\n
		    (?::\s.*\n)*)+
		)/x';


	checkForParseErrors($totalMatch, $jql);

	preg_match_all($totalMatch, $jql, $result, PREG_SET_ORDER);

	/**
	 * @var $tables \donatj\MySqlSchema\Table[]
	 */
	$foreignKeys = [ 'parents' => [ ], 'children' => [ ] ];
	$tables      = [ ];
	for( $i = 0; $i < count($result); $i++ ) {
		$body = $result[$i]['body'] . "\n";

		$table = new Table($result[$i]['declaration']);
		$table->setCharset('utf8');
		$table->setCollation('utf8_general_ci');

		if( trim($result[$i]['comment']) ) {
			$table->setComment(parseComment($result[$i]['comment']));
		}

		$bodyMatch = '/(?P<signal>[-?!])[ \t](?P<colName>\S+)
		[ \t]+(?P<nullable>\*)?(?P<signed>-)?(?P<colType>[a-z]+)(?P<colLength>\d+)?(?P<colDecimal>,\d+)?
		(?:(?P<hasDefault>=)(?:\'(?P<default1>(?:\'\'|[^\'])*)\'|(?P<default2>\S+)))?
		(?P<pk>[ \t]\*?pk)?
		(?P<keys>(?:[ \t]+k\d+)*)
		(?P<uniques>(?:[ \t]+u\d+)*)
		(?P<comment>\n(?::[ \t].*\n?)*)/x';

		$tableKeys = [ ];

		checkForParseErrors($bodyMatch, $body);
		preg_match_all($bodyMatch, $body, $bodyResult, PREG_SET_ORDER);
		for( $j = 0; $j < count($bodyResult); $j++ ) {

			$colName = $bodyResult[$j]['colName'];
//		if( $colName == '_' ) {
//			$colName = $table->getName() . '_id';
//		}

			$col = null;
{'fraction_non_alphanumeric': 0.29903713892709766, 'fraction_numerical': 0.003301237964236589, 'mean_word_length': 4.1647727272727275, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '1236533', 'n_tokens_mistral': 1653, 'n_tokens_neox': 1521, 'n_words': 204}