nitvm: Attributes access is fully functionnal with direct access when possible
[nit.git] / contrib / nitcc / examples / json.sablecc
1 Grammar json;
2
3 Lexer
4
5 number = int frac? exp?;
6 int = '-'? d+;
7 d = '0'..'9';
8 frac = '.' d+;
9 exp = e d+;
10 e = ('e'|'E') ('+'|'-')?;
11
12 string = '"' (Any-'\\'-'"' | '\\'Any)* '"';
13
14 blank = (' '|'\n'|'\t')+;
15
16 Parser
17 Ignored blank;
18
19 value =
20         {object:} '{' members? '}' |
21         {array:} '[' elements? ']' |
22         {number:} number |
23         {string:} string |
24         {true:} 'true' |
25         {false:} 'false' |
26         {null:} 'null' ;
27
28 members = {tail:} members ',' pair | {head:} pair ;
29 pair = string ':' value ;
30 elements = {tail:} elements ',' value | {head:} value ;