-
Notifications
You must be signed in to change notification settings - Fork 1
/
GrammaireSQL.g4
60 lines (46 loc) · 1.25 KB
/
GrammaireSQL.g4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
grammar GrammaireSQL;
requete:
((SELECT|COUNT)? (type_ = TYPE)?) ((MOT? ps = params) | (WHEN te = time_expression))*
;
params:
par1 = param (conj = CONJ par2 = param)*
;
param:
a = VAR
;
time_expression:
(year_ = year | month_year_ = month_year | date_interval_ = date_interval | date_ = date)
;
date_interval:
a = date CONJ_ET b = date
;
date:
(day_ = day DATE_SEPARATOR month_ = month DATE_SEPARATOR year_ = year) |
(day_ = day MONTH year_ = year)
;
month_year:
month_ = MONTH year_ = year
;
year:
digit1 = DIGIT digit2 = DIGIT digit3 = DIGIT digit4 = DIGIT
;
month:
digit1 = DIGIT digit2 = DIGIT
;
day:
digit1 = DIGIT digit2 = DIGIT
;
// Lexer rules
SELECT: 'vouloir';
COUNT: 'combien';
TYPE: 'article' | 'rubrique' | 'contact';
CONJ: 'et' | 'ou';
CONJ_ET: 'et';
MOT: 'mot' | 'contenir' | 'parler' | 'parlent';
WHEN: 'parution' | 'en';
DIGIT: [0-9];
DATE_SEPARATOR: ('/' | '-');
MONTH: 'janvier' | 'fevrier' | 'mars' | 'avril' | 'mai' | 'juin' | 'juillet' | 'aout' | 'septembre' | 'octobre' | 'novembre' | 'decembre';
// Don't change order as it might overide previous lexer rules
WS : (' ' |'\t' | '\r' | 'je' | 'qui' | 'dont') -> skip;
VAR : ('A'..'Z' | 'a'..'z') ('a'..'z')+;