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

Enhanced Query Parser using ANTLR grammar definition #50

Closed
shivasurya opened this issue Jul 6, 2024 · 1 comment · Fixed by #49
Closed

Enhanced Query Parser using ANTLR grammar definition #50

shivasurya opened this issue Jul 6, 2024 · 1 comment · Fixed by #49
Assignees
Labels
enhancement New feature or request

Comments

@shivasurya
Copy link
Owner

Using the ANTLR grammar, query parser can be enhanced and support more features including

  • More operators such as LIKE, BETWEEN, IN
  • ALIAS support with entities
  • METHOD chaining, Alias variable support
  • Complex condition AND, OR, NOT with brackets
grammar Query;

query           : 'FIND' select_list ('WHERE' expression)? ;
select_list     : select_item (',' select_item)* ;
select_item     : entity 'AS' alias ;
entity          : IDENTIFIER ;
alias           : IDENTIFIER ;
expression      : orExpression ;
orExpression    : andExpression ( 'OR' andExpression )* ;
andExpression   : notExpression ( 'AND' notExpression )* ;
notExpression   : 'NOT' notExpression
                | primary ;
primary         : condition
                | '(' expression ')' ;
condition       : alias '.' method_chain comparator value ;
method_chain    : method_or_variable ('.' method_or_variable)* ;
method_or_variable : method | variable ;
method          : IDENTIFIER '(' ')' ;
variable        : IDENTIFIER ;
comparator      : '=' | '!=' | '<' | '>' | '<=' | '>=' ;
value           : STRING | NUMBER ;
value_list      : value (',' value)* ;
STRING          : '"' ( ~('"' | '\\') | '\\' . )* '"' ;
NUMBER          : [0-9]+ ('.' [0-9]+)? ;
IDENTIFIER      : [a-zA-Z_][a-zA-Z0-9_]* ;
WS              : [ \t\r\n]+ -> skip ;

@shivasurya shivasurya added the enhancement New feature or request label Jul 6, 2024
@shivasurya shivasurya self-assigned this Jul 6, 2024
@shivasurya
Copy link
Owner Author

#49 should be starting point for this change

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

Successfully merging a pull request may close this issue.

1 participant