fix: support Unicode comparison operators ≠ ≥ ≤ (#414) - #452
Open
chenjunwenhao wants to merge 1 commit into
Open
fix: support Unicode comparison operators ≠ ≥ ≤ (#414)#452chenjunwenhao wants to merge 1 commit into
chenjunwenhao wants to merge 1 commit into
Conversation
Add lexer support for Unicode comparison operators: - ≠ (U+2260, NOT EQUAL TO) as alias for != - ≥ (U+2265, GREATER-THAN OR EQUAL TO) as alias for >= - ≤ (U+2264, LESS-THAN OR EQUAL TO) as alias for <= Changes: - QLexer: recognize Unicode chars and emit NOEQ/GE/LE tokens - OperatorManager: register Unicode symbols as binary operator aliases - Add comprehensive test cases in test suite and Express4RunnerTest Closes alibaba#414
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.
Summary
OperatorManager, mapping them to the existing!=,>=,<=implementationsCloses #414
Problem Analysis
Issue #414 reported that custom Unicode symbols like ≠, ≥, ≤ were not recognized by QLExpress 4's parser, resulting in
QLSyntaxException. Users naturally expect these standard mathematical Unicode symbols to work as equivalents to their ASCII counterparts.The root cause was twofold:
QLexerdid not recognize these Unicode characters as valid operator tokens - they were falling through to theCATCH_ALLdefault caseOperatorManagerhad no operator entries for the Unicode symbols, so even if tokenized, the parser would not find matching binary operatorsFix
QLexer.java: Added three new
caseentries in thereadOperatorOrPunctuation()switch statement:'\u2260'(≠) → emitsNOEQtoken'\u2265'(≥) → emitsGEtoken'\u2264'(≤) → emitsLEtokenOperatorManager.java: Registered the Unicode strings as keys in
DEFAULT_BINARY_OPERATOR_MAP, pointing to the existing singleton operator instances:"≠"→UnequalOperator"≥"→GreaterEqualOperator"≤"→LessEqualOperatorTest plan
src/test/resources/testsuite/independent/operator/unicode_comparison.qlcovering:if/elseconditional blocksExpress4RunnerTest#unicodeComparisonOperatorsTestverifying the API-level behaviorFiles changed
src/main/java/com/alibaba/qlexpress4/aparser/QLexer.javasrc/main/java/com/alibaba/qlexpress4/runtime/operator/OperatorManager.javasrc/test/resources/testsuite/independent/operator/unicode_comparison.ql(new)src/test/java/com/alibaba/qlexpress4/Express4RunnerTest.java