Created
April 20, 2015 19:18
-
-
Save flire/a5a2982216c7b1154c4e to your computer and use it in GitHub Desktop.
RQL grammar for Xtext
This file contains 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
grammar org.xtext.rql.RQL //with org.eclipse.xtext.common.Terminals | |
import "http://www.eclipse.org/emf/2002/Ecore" as ecore | |
generate rQL "http://www.xtext.org/rql/RQL" | |
//Model: | |
// greetings+=Greeting*; | |
// | |
//Greeting: | |
// 'Hello' name=ALPHA '!'; | |
Model: | |
operands+=Ho_operand ( (','|'&')* Ho_operand ) | |
; | |
And: Ho_operand ( '&' Ho_operand )+; | |
Or: Ho_operand ( (';'|'|') Ho_operand )+; | |
Ho_operand: | |
WSP* ( Higher_order_call | Call_operator | Predicate | Comparison | ( "(" (And | Or) ")" ) ) WSP* | |
; | |
Logical_op_aliases: ("or"|"and"|"not"); | |
Higher_order_call: | |
Logical_op_aliases WSP* '(' ( Ho_operand ( "," Ho_operand )* ) ')' | |
; | |
Binary_op_aliases: ("ne"|"eq"|"lt"|"le"|"gt"|"ge"|"like"); | |
Comp_ops : ("!="|"="|"<"|"<="|">"|">="); | |
Comparison : Strval WSP* ( ( '=' Binary_op_aliases '=' ) | Comp_ops ) Primary_expr; | |
Call_operator: | |
( Binary_op_aliases | Functions_tbl ) WSP* '(' ( Primary_expr ( "," Primary_expr )* )? ')' | |
; | |
Pred_tbl: ("select"|"sort"|"limit"|"implementing"|"composing"); | |
Predicate: Pred_tbl WSP* '(' ( Primary_expr ( ',' Primary_expr )* )? ')'; | |
Primary_expr: | |
WSP* ( ( Const_func_tbl WSP* '(' WSP* ')' ) | Array | Strval ) WSP* | |
; | |
Functions_tbl: ("isnull"|"in"|"out"); | |
Const_func_tbl : ("true"|"false"|"empty"|"null"); | |
Array: '(' WSP* Strval WSP* ("," WSP* Strval WSP* )* ')'; | |
Nchar: (ALPHA|DIGIT|'-'|'.'|'_'|'~'|'$'|':'|'*'|'+'|'?'|'/'|'@'); | |
Pct_encoded: '%' XDIGIT XDIGIT; | |
Strval: (Nchar|Pct_encoded)*; | |
terminal ALPHA: ('A'..'Z'|'a'..'z'); | |
terminal DIGIT: ('0'..'9'); | |
terminal XDIGIT: (DIGIT|'A'..'F'); | |
//terminal SP: ' '; | |
//terminal HTAB: '\t'; | |
terminal WSP: (' '|'\t'); | |
//DIGIT = %x30-39; | |
//XDIGIT = DIGIT / "A" / "B" / "C" / "D" / "E" / "F"; | |
//SP = %x20; | |
//HTAB = %x09; | |
//WSP = SP / HTAB; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment