jwrapper: deal with the optional "Compiled from" line in the grammar
[nit.git] / contrib / jwrapper / grammar / javap.sablecc
1 Grammar javap;
2
3 Lexer
4
5 identifier = ('a'..'z'|'A'..'Z'|'_'|'$') ('a'..'z'|'A'..'Z'|'_'|'$'|'0'..'9')*;
6 blank = (' '|'\n'|'\t'|'\r')+;
7 separator = ('.'|'/');
8
9 Parser
10 Ignored blank;
11
12 multi_files = compiled_from? class_or_interface;
13
14 class_or_interface = class_declaration | interface_declaration;
15
16 compiled_from = 'Compiled from "' identifier+ '.java"';
17
18 class_declaration = class_header '{' property_declaration* '}';
19
20 class_header = modifier* 'class' full_class_name extends_declaration?
21                            implements_declaration? throws_declaration?;
22 interface_declaration = modifier* 'interface' full_class_name extends_interface_declaration?
23                                                 '{' property_declaration* '}';
24
25 modifier = 'public'|'private'|'protected'|'static'|'final'|'native'|'synchronized'|'abstract'|'threadsafe'|'transient'|'volatile';
26 type = type_specifier '[]'*;
27 type_specifier = 'boolean'|'byte'|'char'|'short'|'int'|'float'|'long'|'double' | type_ref;
28
29 type_ref = full_class_name | generic_identifier 'extends' full_class_name | '?';
30 type_refs = {tail:} type_refs ',' type_ref | {head:} type_ref;
31
32 generic_param = '<' generic_parameter_list '>';
33 generic_parameter_list = {tail:} generic_parameter_list ',' parameter | {head:} parameter;
34 generic_identifier = full_class_name | '?';
35
36 full_class_name = full_class_name separator class_name | class_name;
37 class_name = identifier generic_param?;
38
39 interface_name = full_class_name;
40 interface_list = {tail:} interface_list ',' interface_name | {head:} interface_name;
41
42 parameter = type '...'?;
43 parameter_list_comp = {tail:} parameter_list_comp ',' parameter | {head:} parameter;
44 parameter_list = parameter_list_comp;
45
46 exception = type;
47 exception_list = exception_list ',' exception | exception;
48
49 statement = variable_declaration | statement_block | ';';
50 statement_block = '{' statement* '}';
51
52 variable_id = identifier '[]'*;
53 method_id = identifier;
54
55 property_declaration = method_declaration | constructor_declaration | variable_declaration | static_declaration | ';';
56 variable_declaration = modifier* type variable_id throws_declaration? ';';
57 method_declaration = modifier* generic_param? type method_id '(' parameter_list? ')' throws_declaration? ';';
58 constructor_declaration = modifier* full_class_name '(' parameter_list? ')' throws_declaration? ';';
59 implements_declaration = 'implements' interface_list*;
60 extends_interface_declaration = 'extends' interface_list*;
61 extends_declaration = 'extends' type;
62 static_declaration = modifier* '{' '}' ';';
63 throws_declaration = 'throws' exception_list?;