Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implement decl docs for enums
  • Loading branch information
hoelzro committed Aug 14, 2014
1 parent 7587005 commit e020d38
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/Perl6/Actions.nqp
Expand Up @@ -3425,6 +3425,14 @@ class Perl6::Actions is HLL::Actions does STDActions {
$*W.install_package($/, $longname.type_name_parts('enum name', :decl(1)),
($*SCOPE || 'our'), 'enum', $*PACKAGE, $*W.cur_lexpad(), $type_obj);

# Document it
Perl6::Pod::document($/, $type_obj, $*DOCEE, :leading);
if ~$*DOCEE ne '' {
$*DOCEE.set_docee($type_obj);
}
# Set it up for trailing declarations
$*PRECEDING_DECL := $type_obj;

# We evaluate to the enum type object.
make QAST::WVal.new( :value($type_obj) );
}
Expand Down
13 changes: 12 additions & 1 deletion src/Perl6/Grammar.nqp
Expand Up @@ -2816,9 +2816,20 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
proto token type_declarator { <...> }

token type_declarator:sym<enum> {
<sym> <.end_keyword> <.ws>
:my $*IN_DECL := 'enum';
:my $*DOC := $*DECLARATOR_DOCS;
{ $*DECLARATOR_DOCS := '' }
:my $*DOCEE;
:my $*DECLARAND;
<sym> <.end_keyword> <.ws>
{
my $line_no := HLL::Compiler.lineof(self.orig(), self.from(), :cache(1));
if $*PRECEDING_DECL_LINE < $line_no {
$*PRECEDING_DECL_LINE := $line_no;
$*PRECEDING_DECL := Mu; # actual declarand comes later, in Actions::type_declarator:sym<enum>
}
}
<.attach_docs>
[
| <longname>
{
Expand Down
1 change: 1 addition & 0 deletions src/Perl6/Metamodel/EnumHOW.nqp
Expand Up @@ -4,6 +4,7 @@
# one or two of which presumably provide the core enum-ish methods.
class Perl6::Metamodel::EnumHOW
does Perl6::Metamodel::Naming
does Perl6::Metamodel::Documenting
does Perl6::Metamodel::Stashing
does Perl6::Metamodel::AttributeContainer
does Perl6::Metamodel::MethodContainer
Expand Down

0 comments on commit e020d38

Please sign in to comment.