Permalink
Browse files

parse javap -v output to get values of constant, use values in Perl6 …

…generator
  • Loading branch information...
1 parent fc78911 commit 2923cba9eea7c028d196995211553083c476a56e @philcrow philcrow committed with Aug 29, 2010
Showing with 26 additions and 5 deletions.
  1. +7 −1 lib/Java/Javap/Generator/Perl6.pm
  2. +19 −4 lib/Java/Javap/javap.grammar
@@ -341,7 +341,13 @@ method [% elem.name -%]
[% END %]
[% BLOCK constant_whole %]
- method [% elem.name %] (--> [% elem.type.perl_type_name %]) is export { ... }
+ method [% elem.name %] (--> [% elem.type.perl_type_name %]) is export { return [% IF elem.type.perl_type_name == 'Str'
+ %]'[% elem.value %]';[%
+ ELSIF elem.type.perl_type_name == 'Int' or
+ elem.type.perl_type_nmae == 'Num'
+ %][% elem.value %];[%
+ ELSE
+ %] ... [% END %] }
[% END %]
EO_Template
}
@@ -32,6 +32,7 @@ comp_unit_decl : ACCESS class_qualifier(s?)
CLASS_OR_INTERFACE qualified_name
extends_clause(?)
implements_clause(?)
+ verbose_class_details(?)
{
my $perl_qualified_name = $item{ qualified_name };
$perl_qualified_name =~ s/\./::/g;
@@ -46,7 +47,9 @@ comp_unit_decl : ACCESS class_qualifier(s?)
}
}
-class_qualifier : 'final' { 'final' }
+verbose_class_details : /[^{]*/
+
+class_qualifier : 'final' { 'final' }
| 'abstract' { 'status' }
extends_clause : 'extends' qualified_name { $item{ qualified_name } }
@@ -59,13 +62,15 @@ body_element : constant { $item[1] }
| method { $item[1] }
| variable { $item[1] }
-constant : ACCESS 'static' constant_modifier(s?) arg NAME ';' {
+constant : ACCESS 'static' constant_modifier(s?) arg NAME ';'
+ verbose_constant_details(?) {
{
body_element => 'constant',
access => $item{ ACCESS },
modifiers => $item{ 'constant_modifier(s?)' },
type => $item{ arg }[0],
name => $item{ NAME },
+ value => $item{ 'verbose_constant_details(?)' }[0],
}
}
| 'static' 'transient' arg NAME ';' {
@@ -76,11 +81,18 @@ constant : ACCESS 'static' constant_modifier(s?) arg NAME ';' {
}
}
+verbose_constant_details : 'Constant' 'value:' arg constant_value {
+ $item{ constant_value }
+}
+
+constant_value : /[^\n]*/
+
constant_modifier : 'final' | 'transient' | 'volatile'
method : ACCESS method_qualifier(s?)
arg NAME '(' arg_list(?) ')'
- throws_clause(?) ';' {
+ throws_clause(?) ';'
+ verbose_exceptions_details(?) {
$methods{ $item[4] }++;
{
body_element => 'method',
@@ -93,7 +105,8 @@ method : ACCESS method_qualifier(s?)
}
}
| ACCESS /(native)?/ qualified_name '(' arg_list(?) ')'
- throws_clause(?) ';' {
+ throws_clause(?) ';'
+ verbose_exceptions_details(?) {
$constructors++;
$methods{ 'new' }++;
{
@@ -112,6 +125,8 @@ method : ACCESS method_qualifier(s?)
}
}
+verbose_exceptions_details : 'Exceptions:' throws_clause
+
method_qualifier : 'abstract' { 'abstract' }
| 'native' { 'native' }
| 'static' { 'static' }

0 comments on commit 2923cba

Please sign in to comment.