brackets = '[]';
wildcard = '?';
compiled_from = 'Compiled from "' (Any-'"')* '"';
+dots = '...';
// ---
Parser
Ignored blank;
+// ---
+// Class and properties
+
files = file+;
file = compiled_from? class_declaration;
extends_declaration? implements_declaration? throws_declaration?
'{' property_declaration* '}';
+modifier
+ = 'public'|'private'|'protected'|'static'|'final'|'native'
+ |'synchronized'|'abstract'|'threadsafe'|'transient'|'volatile'|'strictfp';
+
class_or_interface = 'class'|'interface';
-modifier
- = 'public'|'private'|'protected'|'static'|'final'|'native'|'synchronized'|'abstract'|'threadsafe'|'transient'|'volatile'|'strictfp';
-type = primitive_type brackets*;
-primitive_type
- = 'boolean'|'byte'|'char'|'short'|'int'|'float'|'long'|'double'
- | type_ref;
-
-type_ref
- = full_class_name
- | generic_identifier 'extends' type_bound
- | wildcard;
+implements_declaration = 'implements' types;
+extends_declaration = 'extends' types;
+throws_declaration = 'throws' types?;
+
+property_declaration
+ = {method:} modifier* generic_parameters? type identifier '(' types? ')' throws_declaration? ';'
+ | {constructor:} modifier* generic_parameters? full_class_name '(' types? ')' throws_declaration? ';'
+ | {attribute:} modifier* type identifier brackets* throws_declaration? ';'
+ | {static:} modifier* '{' '}' ';'
+ | ';';
+
+// ---
+// Types
+
+type = base_type brackets* dots?;
+
+types
+ = {tail:} types ',' type
+ | {head:} type;
+
+base_type
+ = {primitive:} primitive_base_type
+ | {class:} full_class_name
+ | {extends:} generic_identifier 'extends' type_bound
+ | {super:} generic_identifier 'super' type_bound
+ | {wildcard:} wildcard
+ | {void:} 'void';
+
+primitive_base_type = 'boolean'|'byte'|'char'|'short'|'int'|'float'|'long'|'double';
+
type_bound
= {tail:} type_bound '&' full_class_name
| {head:} full_class_name;
-generic_param = '<' generic_parameter_list '>';
-generic_parameter_list
- = {tail:} generic_parameter_list ',' parameter
- | {head:} parameter;
generic_identifier
- = full_class_name
- | wildcard;
+ = {class:} full_class_name
+ | {wildcard:} wildcard;
+
+class_name = identifier generic_parameters?;
full_class_name
= {tail:} full_class_name separator class_name
| {head:} class_name;
-class_name = identifier generic_param?;
-parameter
- = type '...'?
- | {wildcard:} wildcard 'super' full_class_name ;
-parameter_list
- = {tail:} parameter_list ',' parameter
- | {head:} parameter;
-
-attribute_id = identifier brackets*;
-method_id = identifier;
-
-property_declaration
- = {method:} modifier* generic_param? type method_id '(' parameter_list? ')' throws_declaration? ';'
- | {constructor:} modifier* generic_param? full_class_name '(' parameter_list? ')' throws_declaration? ';'
- | {attribute:} modifier* type attribute_id throws_declaration? ';'
- | {static:} modifier* '{' '}' ';'
- | ';';
-
-implements_declaration = 'implements' interface_list;
-extends_declaration = 'extends' interface_list;
-interface_list
- = {tail:} interface_list ',' full_class_name
- | {head:} full_class_name;
-
-throws_declaration = 'throws' exception_list?;
-exception_list
- = {tail:} exception_list ',' type
- | {head:} type;
+generic_parameters = '<' types '>';