Joachim Bingel | dbbde77 | 2014-05-12 15:26:10 +0000 | [diff] [blame^] | 1 | grammar CollectionQuery; |
| 2 | |
| 3 | @header {package de.ids_mannheim.korap.query.serialize.util;} |
| 4 | |
| 5 | /* |
| 6 | -- author: jbingel |
| 7 | -- date: 14-05-11 |
| 8 | */ |
| 9 | |
| 10 | /* |
| 11 | * LEXER SECTION |
| 12 | */ |
| 13 | |
| 14 | WS : ( ' ' | '\t' | '\r' | '\n' )+ -> skip ; |
| 15 | fragment FOCC : '{' WS* ( [0-9]* WS* ',' WS* [0-9]+ | [0-9]+ WS* ','? ) WS* '}'; |
| 16 | fragment NO_RE : ~[ \t\/]; |
| 17 | fragment ALPHABET : ~('\t' | ' ' | '/' | '*' | '?' | '+' | '{' | '}' | '[' | ']' |
| 18 | | '(' | ')' | '|' | '"' | ',' | ':' | '\'' | '\\' | '!' | '=' | '~' | '&' | '^' | '<' | '>' ); |
| 19 | NUMBER : [0-9]+; |
| 20 | |
| 21 | NL : [\r\n] -> skip; |
| 22 | ws : WS+; |
| 23 | |
| 24 | WORD : ALPHABET+; |
| 25 | LRB : '('; |
| 26 | RRB : ')'; |
| 27 | LT : '<'; |
| 28 | GT : '>'; |
| 29 | LEQ : '<='; |
| 30 | GEQ : '>='; |
| 31 | EQ : '='; |
| 32 | NE : '!='; |
| 33 | AND : '&'; |
| 34 | OR : '|'; |
| 35 | |
| 36 | /* |
| 37 | * PARSER SECTION |
| 38 | */ |
| 39 | |
| 40 | conj |
| 41 | : AND | OR; |
| 42 | |
| 43 | operator |
| 44 | : EQ | NE | LT | GT | LEQ | GEQ; |
| 45 | |
| 46 | expr |
| 47 | : field operator value |
| 48 | | value operator field operator value |
| 49 | ; |
| 50 | |
| 51 | field |
| 52 | : WORD; |
| 53 | |
| 54 | value |
| 55 | : WORD | NUMBER; |
| 56 | |
| 57 | andGroup |
| 58 | : (expr AND)* (LRB orGroup RRB)? (AND expr)* |
| 59 | | (expr AND)+ expr |
| 60 | ; |
| 61 | |
| 62 | orGroup |
| 63 | : (expr OR)* (LRB andGroup RRB)? (OR expr)* |
| 64 | | (expr OR)+ expr |
| 65 | ; |
| 66 | |
| 67 | exprGroup |
| 68 | : andGroup |
| 69 | | orGroup |
| 70 | ; |
| 71 | |
| 72 | start |
| 73 | : expr |
| 74 | | exprGroup |
| 75 | ; |