Fixes the typeof operator along with data types in expressions.#6673
Merged
dlvenable merged 3 commits intoMar 25, 2026
Conversation
The typeof operator was not working because FunctionName came before it and it has a very broad matching rule. This means that ANTLR was resolving these as functions instead of their own tokens. Also there were no tests for the typeof operator. I have added some of these tests, first to verify the failure and fix, and second to ensure future changes do not break them. Signed-off-by: David Venable <dlv@amazon.com>
…ions and functionality. Signed-off-by: David Venable <dlv@amazon.com>
Member
Author
|
Looking at the example Java grammar for ANTLR, they clearly call out that the the |
…r future identifiers. Signed-off-by: David Venable <dlv@amazon.com>
kkondaka
approved these changes
Mar 25, 2026
sb2k16
approved these changes
Mar 25, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The function composition change (#6628) converted function from a single lexer rule (
Function) that matched the entirename(args)pattern into a parser rule that referenced a new standalone lexer ruleFunctionName. ThisFunctionNamerule was defined asJsonPointerCharacters, which matches[A-Za-z0-9_.@]+.This caused the
typeofoperator to stop working. This is because ANTLR was resolving our data type keywords (e.g.integer,map) asFunctionName. ANTLR did this becauseFunctionNamecame first in the grammar and is very broad. ANTLR resolves conflicts by choosing the rules defined first the grammar. So ANTLR was trying to resolve the data types as functions.The fix is to move the
FunctionNamebelow theDataTypes. Additionally, sinceFunctionNameis so broad, I renamed it toIdentifier. This means it can be a catch all for non-keywords that may be expanded in the expression language. This name should be clearer and allow it to be re-used so we don't hit this issue again with other identifiers.Also there were no tests for the
typeofoperator. I have added some of these tests, first to verify the failure and fix, and second to ensure future changes do not break them.This PR also adds additional test cases to ensure that existing features are working as expected. It corrects incorrect assertions related to tokens from #2692 that was attempting to verify that invalid floating point values are not parsed. It also adds new tests on the grammar for functions.
Issues Resolved
N/A
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.