-
Notifications
You must be signed in to change notification settings - Fork 0
/
Update.g
78 lines (61 loc) · 1.49 KB
/
Update.g
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
grammar Update;
options {
output = AST;
}
@parser::header {package mypackage.poly;
import javax.swing.JOptionPane;
}
@lexer::header {package mypackage.poly;
import javax.swing.JOptionPane;
}
@lexer::members
{
@Override
public void displayRecognitionError(String[] tokenNames, RecognitionException e) {
String hdr = getErrorHeader(e);
String msg = getErrorMessage(e, tokenNames);
throw new RuntimeException(hdr + ":" + msg);
}
}
@parser::members
{
@Override
public void displayRecognitionError(String[] tokenNames, RecognitionException e) {
String hdr = getErrorHeader(e);
String msg = getErrorMessage(e, tokenNames);
throw new RuntimeException(hdr + ":" + msg);
}
}
@rulecatch {
catch (Exception e) {
JOptionPane.showMessageDialog(null,e.toString());
System.exit(0);
}
}
root
: 'update' table_clause 'set' column_clause ;
table_clause
: folder_name '.' table_name ;
column_clause
: column_name | column_name statement ;
column_name
: column '=' value (',' column '=' value)*;
statement
: 'where' (column RELOP value LOGICOP)* (column RELOP value);
table_name
: ID;
folder_name
: ID;
column
: ID;
value
: STRING | NUMBER ;
RELOP
: '<' | '>' | '=' | '!=' | '<=' | '>=' ;
LOGICOP
: 'and' | 'or';
ID : ('a'..'z'|'A'..'Z'|'_')
('a'..'z'|'A'..'Z'|'_'|'0'..'9')* ;
STRING: ('"' ('a'..'z'|'A'..'Z'|'_'|'0'..'9'|' ')+ '"');
NUMBER: ('0'..'9')+;
WHITESPACE: (' '|'\t'|'\r'|'\n')+ {skip();};