| Joachim Bingel | 6003b85 | 2014-12-18 14:20:55 +0000 | [diff] [blame^] | 1 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 2 | // // |
| 3 | // COSMAS II zeilenorientierten Suchanfragesprache (C2 plain syntax) // |
| 4 | // lokale Grammatik für #OV() und #OV(Options). // |
| 5 | // 17.12.12/FB // |
| 6 | // v-0.1 // |
| 7 | // // |
| 8 | // Opts nimmt eine oder mehrere, durch Kommata getrennte Optionen auf: // |
| 9 | // - Positionsoptionen (POS): L, R, F, FE, FI, X, -. // |
| 10 | // - Ausschließungsoptionen (EXCL): %, -. // |
| 11 | // - Gruppenbildungsoptionen (GROUP): min, max, -. // |
| 12 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 13 | |
| 14 | grammar c2ps_opOV; |
| 15 | |
| 16 | options {output=AST;} |
| 17 | tokens {OPOV; |
| 18 | POS; |
| 19 | EXCL; YES; |
| 20 | GROUP; MIN; MAX; } |
| 21 | @header {package de.ids_mannheim.korap.query.parse.cosmas;} |
| 22 | @lexer::header {package de.ids_mannheim.korap.query.parse.cosmas;} |
| 23 | |
| 24 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 25 | // |
| 26 | // Lexer |
| 27 | // |
| 28 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 29 | |
| 30 | WS : (' ')+ {skip();}; |
| 31 | |
| 32 | POSTYP : 'L'|'l'|'R'|'r'|'F'|'f'|'FE'|'fe'|'FI'|'fi'|'N'|'n'|'X'|'x' ; |
| 33 | |
| 34 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 35 | // |
| 36 | // Parser |
| 37 | // |
| 38 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 39 | |
| 40 | opOV : '#OV' -> ^(OPOV) |
| 41 | | '#OV(' opts? ')' -> ^(OPOV opts?); |
| 42 | |
| 43 | opts : opt (',' opt)* -> opt*; |
| 44 | |
| 45 | opt : (optPos | optExcl | optGrp); |
| 46 | |
| 47 | // Position: |
| 48 | optPos : POSTYP |
| 49 | |
| 50 | -> ^(POS POSTYP); |
| 51 | |
| 52 | optExcl : '%' |
| 53 | |
| 54 | -> ^(EXCL YES); |
| 55 | |
| 56 | optGrp : ('MIN' | 'min') -> ^(GROUP MIN) |
| 57 | | ('MAX' | 'max') -> ^(GROUP MAX) ; |
| 58 | |