-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a script to test lexer on all the testing queries
- Loading branch information
Showing
2 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
// Throw exception if anything fails. | ||
set_error_handler(function ($severity, $message, $file, $line) { | ||
throw new ErrorException($message, 0, $severity, $file, $line); | ||
}); | ||
|
||
require_once __DIR__ . '/../../custom-parser/parser/DynamicRecursiveDescentParser.php'; | ||
require_once __DIR__ . '/../../custom-parser/parser/MySQLLexer.php'; | ||
|
||
$handle = fopen(__DIR__ . '/data/queries.csv', 'r'); | ||
|
||
$i = 1; | ||
$start = microtime(true); | ||
while (($query = fgetcsv($handle)) !== false) { | ||
$query = $query[0]; | ||
|
||
$tokens = tokenizeQuery($query); | ||
if (empty($tokens)) { | ||
throw new Exception('Failed to tokenize query: ' . $query); | ||
} | ||
$i++; | ||
} | ||
|
||
echo "Tokenized $i queries in ", microtime(true) - $start, 's', PHP_EOL; |
File renamed without changes.