Repository navigation
Changed
- The scanner and the parser are written by hand instead of being transliterated from cphalcon's re2c scanner and Lemon parser;
resources/files/parser.php, the globalphql_*functions and thec/sources are gone. Phalcon\Phql\Parser::parse()returns?array:nullfor a statement without any token (empty, blank, or starting with a NUL byte), as cphalcon does.Phalcon\Phql\Scanner\Scannerwas rewritten:new Scanner(string $phql),next(): Tokenandcursor(): intreplace theState-basedscanForToken()/getToken().Phalcon\Phql\Scanner\Tokenholds anintopcode (anOpcodevalue orToken::EOF/Token::SCAN_ERROR) and a value; itsOpcodetype and$lengthproperty are gone.Phalcon\Phql\Tokensisfinal, and its$namestable becameTokens::name().Phalcon\Phql\Scanner\Opcodeis unchanged.ext-mbstringis no longer required: the scanner works on bytes.- Parsing is linear in the statement's length: a 40,000-item
INlist parses in about 0.15 s instead of a minute.
Removed
Phalcon\Phql\Parser\Status,Phalcon\Phql\Scanner\StateandPhalcon\Phql\Scanner\ScannerStatus.
Added
- Parity tests against ext-phalcon: a statement corpus with goldens recorded from cphalcon (
tests/generate-golden.php),FixturesTest, andtests/differential.phpwith a seeded fuzzer, run in CI.
Fixed
Parsing now matches cphalcon exactly. Previously:
- an empty statement threw "PHQL statement cannot be NULL" and a blank one "Syntax error, unexpected EOF", where cphalcon returns no result;
- syntax errors quoted one character instead of the rest of the statement, never showed the token's value, and lacked the statement's length;
- scanning errors did not skip the offending byte, cut the excerpt at the wrong length, and counted characters instead of bytes;
- string literals kept their escape sequences (cphalcon resolves
\n,\r,\t,\\,\',\"); - deeply nested statements were accepted instead of failing with "Parsing failed, the PHQL statement is nested too deeply";
- parsing time grew quadratically with the length of the statement.