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 Jun 10, 2021
1 parent 26ac06e commit 3dec7ac
Show file tree
Hide file tree
Showing 10 changed files with 12,832 additions and 12,961 deletions.
4 changes: 2 additions & 2 deletions src/GrammarParser.y
Original file line number Diff line number Diff line change
Expand Up @@ -677,11 +677,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: 7 additions & 11 deletions src/ast/Definition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -736,22 +736,18 @@ void FeatureDefinition::accept( Visitor& visitor )
//

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

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

const Type::Ptr& ImplementationDefinition::type( void ) const
const IdentifierPath::Ptr& ImplementationDefinition::feature( 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 @@ -466,21 +466,18 @@ namespace libcasm_fe
using Ptr = std::shared_ptr< ImplementationDefinition >;

ImplementationDefinition(
const IdentifierPath::Ptr& path,
const Type::Ptr& type,
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 @@ -226,7 +226,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
4 changes: 2 additions & 2 deletions src/various/Grammar.org
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ FeatureDefinitionList ::= FeatureDefinitionList FeatureDefinitionElement
** ImplementationDefinition

#+begin_src
ImplementationDefinition ::= "implements" IdentifierPath "for" Type "=" "{" ImplementationDefinitionList "}"
| "implements" Type "=" "{" ImplementationDefinitionList "}"
ImplementationDefinition ::= "implements" IdentifierPath "for" Identifier "=" "{" ImplementationDefinitionList "}"
| "implements" Identifier "=" "{" ImplementationDefinitionList "}"
#+end_src

#+html: {{page>.:grammar:ImplementationDefinition&noheader&nofooter}}
Expand Down
1,402 changes: 684 additions & 718 deletions src/various/GrammarParser.cpp

Large diffs are not rendered by default.

11,067 changes: 5,524 additions & 5,543 deletions src/various/GrammarParser.gv

Large diffs are not rendered by default.

Loading

0 comments on commit 3dec7ac

Please sign in to comment.