mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-3701: Questions regarding Parser::match and "identifier" EBNF #4543
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Apr 19, 2015).
Originally assigned to: @guilhermeblanco on GitHub.
Jira issue originally created by user mpdude:
I am currently investigating a problem where I am suspecting the DQL parser to wrongly transform a DQL statement to SQL. While I haven't yet found the exact reason (will open a new case for it), I have come across the following in the Parser::match() method:
The if-condition was changed a while ago in order to allow DQL terms like
WHEREto appear as identifiers.I think that the condition is wrong as it will *only* fail (create the syntax error) when the actual token does not match the expected type, we're not expecting an "identifier" and the next token is something special like punctuation that could not serve as an identifier.
So, for example when we're
match()ingaT*WITH, aT*WHEREwill be accepted as well. A correct check would probably not solve my actual problem, but it would probably have been spotted much earlier due to syntax errors issued.IMO this should actually read
That is, fail if the token does not match the expectation; and when the expectation is
T_IDENTIFIER, also accept every terminal string that can also be considered an "identifier".With this change, the tests almost pass. The only problem is when a
FROMclause expects an "identifier" and now a fully qualified class name starting with a backslash is no longer accepted.Unfortunately, I also did not manage to find an exact definition of "identifier" somewhere in the EBNF.
Lexer::getType()considers everything that starts with a character or underscore an identifier, but that does not match FQCNs.As there seems to be no special token for backslashes, I tried allowing the backslash as a starting character for identifiers as well (in the
Lexer), and it seems to work (all non-skipped tests pass).What do you think about it? Is that something we should fix and does my change make sense?