contrib/jwrapper grammar: fix generic types parameters with bounds
[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
13 // ---
14 Parser
15 Ignored blank;
16
17 files = file+;
18 file = compiled_from? class_declaration;
19
20 class_declaration = modifier* class_or_interface full_class_name
21         extends_declaration? implements_declaration? throws_declaration?
22         '{' property_declaration* '}';
23
24 class_or_interface = 'class'|'interface';
25
26 modifier
27         = 'public'|'private'|'protected'|'static'|'final'|'native'|'synchronized'|'abstract'|'threadsafe'|'transient'|'volatile'|'strictfp';
28 type = primitive_type brackets*;
29 primitive_type
30         = 'boolean'|'byte'|'char'|'short'|'int'|'float'|'long'|'double'
31         | type_ref;
32
33 type_ref
34         = full_class_name
35         | generic_identifier 'extends' type_bound
36         | wildcard;
37 type_bound
38         = {tail:} type_bound '&' full_class_name
39         | {head:} full_class_name;
40
41 generic_param = '<' generic_parameter_list '>';
42 generic_parameter_list
43         = {tail:} generic_parameter_list ',' parameter
44         | {head:} parameter;
45 generic_identifier
46         = full_class_name
47         | wildcard;
48
49 full_class_name
50         = {tail:} full_class_name separator class_name
51         | {head:} class_name;
52 class_name = identifier generic_param?;
53
54 parameter
55         = type '...'?
56         | {wildcard:} wildcard 'super' full_class_name ;
57 parameter_list
58         = {tail:} parameter_list ',' parameter
59         | {head:} parameter;
60
61 attribute_id = identifier brackets*;
62 method_id = identifier;
63
64 property_declaration
65         = {method:} modifier* generic_param? type method_id '(' parameter_list? ')' throws_declaration? ';'
66         | {constructor:} modifier* generic_param? full_class_name '(' parameter_list? ')' throws_declaration? ';'
67         | {attribute:} modifier* type attribute_id throws_declaration? ';'
68         | {static:} modifier* '{' '}' ';'
69         | ';';
70
71 implements_declaration = 'implements' interface_list;
72 extends_declaration = 'extends' interface_list;
73 interface_list
74         = {tail:} interface_list ',' full_class_name
75         | {head:} full_class_name;
76
77 throws_declaration = 'throws' exception_list?;
78 exception_list
79         = {tail:} exception_list ',' type
80         | {head:} type;