Merge: Functional api
[nit.git] / contrib / jwrapper / grammar / javap.sablecc
index 3f9318b..8d281ae 100644 (file)
@@ -3,18 +3,21 @@ Grammar javap;
 // ---
 Lexer
 
-identifier = ('a'..'z'|'A'..'Z'|'_'|'$') ('a'..'z'|'A'..'Z'|'_'|'$'|'0'..'9')*;
+identifier = ('a'..'z'|'A'..'Z'|'_'|'$') ('a'..'z'|'A'..'Z'|'_'|'-'|'$'|'0'..'9')*;
 blank = (' '|'\n'|'\t'|'\r')+;
 separator = ('.'|'/');
 brackets = '[]';
 wildcard = '?';
+compiled_from = 'Compiled from "' (Any-'"')* '"';
+dots = '...';
 
 // ---
 Parser
 Ignored blank;
 
+// ---
+// Class and properties
 
-compiled_from = 'Compiled from "' identifier+ '.java"';
 files = file+;
 file = compiled_from? class_declaration;
 
@@ -22,57 +25,54 @@ class_declaration = modifier* class_or_interface full_class_name
        extends_declaration? implements_declaration? throws_declaration?
        '{' property_declaration* '}';
 
-class_or_interface = 'class'|'interface';
-
 modifier
-       = 'public'|'private'|'protected'|'static'|'final'|'native'|'synchronized'|'abstract'|'threadsafe'|'transient'|'volatile';
-type = primitive_type brackets*;
-primitive_type
-       = 'boolean'|'byte'|'char'|'short'|'int'|'float'|'long'|'double'
-       | type_ref;
-
-type_ref
-       = full_class_name
-       | generic_identifier 'extends' full_class_name
-       | question_mark;
-
-generic_param = '<' generic_parameter_list '>';
-generic_parameter_list
-       = {tail:} generic_parameter_list ',' parameter
-       | {head:} parameter;
-generic_identifier
-       = full_class_name
-       | wildcard;
-
-full_class_name
-       = {tail:} full_class_name separator class_name
-       | {head:} class_name;
-class_name = identifier generic_param?;
+       = 'public'|'private'|'protected'|'static'|'final'|'native'
+       |'synchronized'|'abstract'|'threadsafe'|'transient'|'volatile'|'strictfp';
 
-parameter
-       = type '...'?
-       | {wildcard:} wildcard 'super' full_class_name ;
-parameter_list
-       = {tail:} parameter_list ',' parameter
-       | {head:} parameter;
+class_or_interface = 'class'|'interface';
 
-attribute_id = identifier brackets*;
-method_id = identifier;
+implements_declaration = 'implements' types;
+extends_declaration = 'extends' types;
+throws_declaration = 'throws' types?;
 
 property_declaration
-       = {method:} modifier* generic_param? type method_id '(' parameter_list? ')' throws_declaration? ';'
-       | {constructor:} modifier* full_class_name '(' parameter_list? ')' throws_declaration? ';'
-       | {attribute:} modifier* type attribute_id throws_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* '{' '}' ';'
        | ';';
 
-implements_declaration = 'implements' interface_list;
-extends_declaration = 'extends' interface_list;
-interface_list
-       = {tail:} interface_list ',' full_class_name
-       | {head:} full_class_name;
+// ---
+// Types
+
+type = base_type brackets* dots?;
 
-throws_declaration = 'throws' exception_list?;
-exception_list
-       = {tail:} exception_list ',' type
+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_identifier
+       = {class:} full_class_name
+       | {wildcard:} wildcard;
+
+class_name = identifier generic_parameters?;
+
+full_class_name
+       = {tail:} full_class_name separator class_name
+       | {head:} class_name;
+
+generic_parameters = '<' types '>';