Skip to content

Commit

Permalink
Implementation Definition
Browse files Browse the repository at this point in the history
* fixed syntax and definition for implementation
* related to ref sealangdotorg/sea#35
  • Loading branch information
ppaulweber committed Aug 1, 2017
1 parent cc64255 commit 6cb1155
Show file tree
Hide file tree
Showing 9 changed files with 4,841 additions and 4,882 deletions.
4 changes: 2 additions & 2 deletions src/GrammarParser.yy
Original file line number Diff line number Diff line change
Expand Up @@ -655,11 +655,11 @@ FeatureDefinitionList
//

ImplementationDefinition
: IMPLEMENTS IdentifierPath FOR Type EQUAL LCURPAREN ImplementationDefinitionList RCURPAREN
: IMPLEMENTS IdentifierPath FOR Identifier EQUAL LCURPAREN ImplementationDefinitionList RCURPAREN
{
$$ = Ast::make< ImplementationDefinition >( @$, $2, $4, $7 );
}
| IMPLEMENTS Type EQUAL LCURPAREN ImplementationDefinitionList RCURPAREN
| IMPLEMENTS Identifier EQUAL LCURPAREN ImplementationDefinitionList RCURPAREN
{
const auto name = Ast::make< Identifier >( @$, "" );
const auto path = asIdentifierPath( name );
Expand Down
18 changes: 6 additions & 12 deletions src/ast/Definition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,24 +357,18 @@ void FeatureDefinition::accept( Visitor& visitor )
//

ImplementationDefinition::ImplementationDefinition(
const IdentifierPath::Ptr& path,
const Type::Ptr& type,
const IdentifierPath::Ptr& feature,
const Identifier::Ptr& identifier,
const Definitions::Ptr& definitions )
: Definition( Node::ID::IMPLEMENTATION_DEFINITION, *path->identifiers()->end() )
, m_path( path )
, m_type( type )
: Definition( Node::ID::IMPLEMENTATION_DEFINITION, identifier )
, m_feature( feature )
, m_definitions( definitions )
{
}

const IdentifierPath::Ptr& ImplementationDefinition::path( void ) const
const IdentifierPath::Ptr& ImplementationDefinition::feature( void ) const
{
return m_path;
}

const Type::Ptr& ImplementationDefinition::type( void ) const
{
return m_type;
return m_feature;
}

const Definitions::Ptr& ImplementationDefinition::definitions( void ) const
Expand Down
11 changes: 4 additions & 7 deletions src/ast/Definition.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,21 +256,18 @@ namespace libcasm_fe
public:
using Ptr = std::shared_ptr< ImplementationDefinition >;

ImplementationDefinition( const IdentifierPath::Ptr& path,
const Type::Ptr& type,
ImplementationDefinition( const IdentifierPath::Ptr& feature,
const Identifier::Ptr& identifier,
const Definitions::Ptr& definitions );

const IdentifierPath::Ptr& path( void ) const;

const Type::Ptr& type( void ) const;
const IdentifierPath::Ptr& feature( void ) const;

const Definitions::Ptr& definitions( void ) const;

void accept( Visitor& visitor ) override final;

private:
const IdentifierPath::Ptr m_path;
const Type::Ptr m_type;
const IdentifierPath::Ptr m_feature;
const Definitions::Ptr m_definitions;
};

Expand Down
2 changes: 1 addition & 1 deletion src/ast/RecursiveVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void RecursiveVisitor::visit( FeatureDefinition& node )
void RecursiveVisitor::visit( ImplementationDefinition& node )
{
node.identifier()->accept( *this );
node.type()->accept( *this );
node.feature()->accept( *this );
node.definitions()->accept( *this );
node.attributes()->accept( *this );
}
Expand Down
6 changes: 3 additions & 3 deletions src/transform/AstDumpSourcePass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,12 +358,12 @@ void AstDumpSourceVisitor::visit( FeatureDefinition& node )
void AstDumpSourceVisitor::visit( ImplementationDefinition& node )
{
m_stream << "implements ";
if( node.identifier()->name() != "" )
if( node.feature()->path() != "" )
{
node.identifier()->accept( *this );
node.feature()->accept( *this );
m_stream << " for ";
}
node.type()->accept( *this );
node.identifier()->accept( *this );
m_stream << " =\n{";
const auto levelGuard = Indentation::NextLevel( m_indentation );
for( auto& e : *node.definitions() )
Expand Down
4 changes: 2 additions & 2 deletions src/various/Grammar.org
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ FeatureDefinitionList
| FeatureDefinitionElement

ImplementationDefinition
: IMPLEMENTS IdentifierPath FOR Type EQUAL LCURPAREN ImplementationDefinitionList RCURPAREN
| IMPLEMENTS Type EQUAL LCURPAREN ImplementationDefinitionList RCURPAREN
: IMPLEMENTS IdentifierPath FOR Identifier EQUAL LCURPAREN ImplementationDefinitionList RCURPAREN
| IMPLEMENTS Identifier EQUAL LCURPAREN ImplementationDefinitionList RCURPAREN

ImplementationDefinitionElement
: LSQPAREN Attributes RSQPAREN DerivedDefinition
Expand Down
914 changes: 451 additions & 463 deletions src/various/GrammarParser.cpp

Large diffs are not rendered by default.

Loading

0 comments on commit 6cb1155

Please sign in to comment.