Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix parser/lexer ambiguity for CONTAINS function #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

teunvanhemert
Copy link
Collaborator

@teunvanhemert teunvanhemert commented Jul 12, 2021

Currently, the grammar does not properly accept this scenario:

SELECT
    CONTAINS(o/data[at0001]/events[at0006]/data[at0003]/items[at0004]/value/sometext, 'test') AS containsValue
FROM
    EHR e CONTAINS COMPOSITION c[openEHR-EHR-COMPOSITION.encounter.v1]

This is caused by ANTLR recognizing the CONTAINS function call in the SELECT clause as a CONTAINS instead of a STRING_FUNCTION_ID, as CONTAINS is defined earlier in the lexer.

The 'reuse' of non-fragment lexer symbols in this way is not really supported by ANTLR without resorting to rather complicated solutions, so I suggest just extending the definition of the functionCall parser rule a little, as this PR does.

@sebastian-iancu
Copy link
Member

@teunvanhemert, oddly enough I just now noticed this PR.
Your change is good, I will merge it, but first I also need to document it properly in JIRA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants