contrib/jwrapper: big rewrite of the AST visitor
[nit.git] / contrib / jwrapper / grammar / javap.sablecc
1 Grammar javap;
2
3 // ---
4 Lexer
5
6 identifier = ('a'..'z'|'A'..'Z'|'_'|'$') ('a'..'z'|'A'..'Z'|'_'|'-'|'$'|'0'..'9')*;
7 blank = (' '|'\n'|'\t'|'\r')+;
8 separator = ('.'|'/');
9 brackets = '[]';
10 wildcard = '?';
11 compiled_from = 'Compiled from "' (Any-'"')* '"';
12 dots = '...';
13
14 // ---
15 Parser
16 Ignored blank;
17
18 files = file+;
19 file = compiled_from? class_declaration;
20
21 class_declaration = modifier* class_or_interface full_class_name
22         extends_declaration? implements_declaration? throws_declaration?
23         '{' property_declaration* '}';
24
25 class_or_interface = 'class'|'interface';
26
27 modifier
28         = 'public'|'private'|'protected'|'static'|'final'|'native'|'synchronized'|'abstract'|'threadsafe'|'transient'|'volatile'|'strictfp';
29
30 type = base_type brackets*;
31
32 base_type
33         = {primitive:} primitive_base_type
34         | {class:} full_class_name
35         | {extends:} generic_identifier 'extends' type_bound
36         | {super:} generic_identifier 'super' type_bound
37         | {wildcard:} wildcard
38         | {void:} 'void';
39
40 primitive_base_type = 'boolean'|'byte'|'char'|'short'|'int'|'float'|'long'|'double';
41
42 type_bound
43         = {tail:} type_bound '&' full_class_name
44         | {head:} full_class_name;
45
46 generic_identifier
47         = full_class_name
48         | wildcard;
49
50 full_class_name
51         = {tail:} full_class_name separator class_name
52         | {head:} class_name;
53 class_name = identifier generic_parameters?;
54
55 generic_parameters = '<' parameters '>';
56
57 parameter = type dots?;
58 parameters
59         = {tail:} parameters ',' parameter
60         | {head:} parameter;
61
62 property_declaration
63         = {method:} modifier* generic_parameters? type identifier '(' parameters? ')' throws_declaration? ';'
64         | {constructor:} modifier* generic_parameters? full_class_name '(' parameters? ')' throws_declaration? ';'
65         | {attribute:} modifier* type identifier brackets* throws_declaration? ';'
66         | {static:} modifier* '{' '}' ';'
67         | ';';
68
69 implements_declaration = 'implements' interface_list;
70 extends_declaration = 'extends' interface_list;
71 interface_list
72         = {tail:} interface_list ',' full_class_name
73         | {head:} full_class_name;
74
75 throws_declaration = 'throws' exception_list?;
76 exception_list
77         = {tail:} exception_list ',' type
78         | {head:} type;