model/model_viz: use OrderedTree[MConcern]
[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 // ---
19 // Class and properties
20
21 files = file+;
22 file = compiled_from? class_declaration;
23
24 class_declaration = modifier* class_or_interface full_class_name
25         extends_declaration? implements_declaration? throws_declaration?
26         '{' property_declaration* '}';
27
28 modifier
29         = 'public'|'private'|'protected'|'static'|'final'|'native'
30         |'synchronized'|'abstract'|'threadsafe'|'transient'|'volatile'|'strictfp';
31
32 class_or_interface = 'class'|'interface';
33
34 implements_declaration = 'implements' types;
35 extends_declaration = 'extends' types;
36 throws_declaration = 'throws' types?;
37
38 property_declaration
39         = {method:} modifier* generic_parameters? type identifier '(' types? ')' throws_declaration? ';'
40         | {constructor:} modifier* generic_parameters? full_class_name '(' types? ')' throws_declaration? ';'
41         | {attribute:} modifier* type identifier brackets* throws_declaration? ';'
42         | {static:} modifier* '{' '}' ';'
43         | ';';
44
45 // ---
46 // Types
47
48 type = base_type brackets* dots?;
49
50 types
51         = {tail:} types ',' type
52         | {head:} type;
53
54 base_type
55         = {primitive:} primitive_base_type
56         | {class:} full_class_name
57         | {extends:} generic_identifier 'extends' type_bound
58         | {super:} generic_identifier 'super' type_bound
59         | {wildcard:} wildcard
60         | {void:} 'void';
61
62 primitive_base_type = 'boolean'|'byte'|'char'|'short'|'int'|'float'|'long'|'double';
63
64 type_bound
65         = {tail:} type_bound '&' full_class_name
66         | {head:} full_class_name;
67
68 generic_identifier
69         = {class:} full_class_name
70         | {wildcard:} wildcard;
71
72 class_name = identifier generic_parameters?;
73
74 full_class_name
75         = {tail:} full_class_name separator class_name
76         | {head:} class_name;
77
78 generic_parameters = '<' types '>';