Skip to content

Commit

Permalink
Implementation Definition
Browse files Browse the repository at this point in the history
* fixed syntax rules
* related to sealangdotorg/sea#35
  • Loading branch information
ppaulweber committed Jul 31, 2017
1 parent 41ff724 commit cc64255
Show file tree
Hide file tree
Showing 5 changed files with 3,125 additions and 3,015 deletions.
38 changes: 27 additions & 11 deletions src/GrammarParser.yy
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ END 0 "end of file"
%type <Definition::Ptr> FeatureDefinitionElement
%type <Definitions::Ptr> FeatureDefinitionList
%type <ImplementationDefinition::Ptr> ImplementationDefinition
%type <Definition::Ptr> ImplementationDefinitionDefinition
%type <Definitions::Ptr> ImplementationDefinitionDefinitions
%type <Definition::Ptr> ImplementationDefinitionElement
%type <Definitions::Ptr> ImplementationDefinitionList
%type <DeclarationDefinition::Ptr> Declaration

// expressions
Expand Down Expand Up @@ -649,13 +649,17 @@ FeatureDefinitionList
}
;

//
//
// ImplementationDefinition
//

ImplementationDefinition
: IMPLEMENTS IdentifierPath FOR Type EQUAL LCURPAREN ImplementationDefinitionDefinitions RCURPAREN
: IMPLEMENTS IdentifierPath FOR Type EQUAL LCURPAREN ImplementationDefinitionList RCURPAREN
{
$$ = Ast::make< ImplementationDefinition >( @$, $2, $4, $7 );
}
| IMPLEMENTS Type EQUAL LCURPAREN ImplementationDefinitionDefinitions RCURPAREN
| IMPLEMENTS Type EQUAL LCURPAREN ImplementationDefinitionList RCURPAREN
{
const auto name = Ast::make< Identifier >( @$, "" );
const auto path = asIdentifierPath( name );
Expand All @@ -664,26 +668,38 @@ ImplementationDefinition
;


ImplementationDefinitionDefinition
: DerivedDefinition
ImplementationDefinitionElement
: LSQPAREN Attributes RSQPAREN DerivedDefinition
{
auto definition = $4;
definition->setAttributes( $2 );
$$ = definition;
}
| DerivedDefinition
{
$$ = $1;
}
| LSQPAREN Attributes RSQPAREN RuleDefinition
{
auto definition = $4;
definition->setAttributes( $2 );
$$ = definition;
}
| RuleDefinition
{
$$ = $1;
}
;


ImplementationDefinitionDefinitions
: ImplementationDefinitionDefinition ImplementationDefinitionDefinitions
ImplementationDefinitionList
: ImplementationDefinitionList ImplementationDefinitionElement
{
auto definitions = $2;
definitions->add( $1 );
auto definitions = $1;
definitions->add( $2 );
$$ = definitions;
}
| ImplementationDefinitionDefinition
| ImplementationDefinitionElement
{
auto definitions = Ast::make< Definitions >( @$ );
definitions->add( $1 );
Expand Down
16 changes: 9 additions & 7 deletions src/various/Grammar.org
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,18 @@ FeatureDefinitionList
| FeatureDefinitionElement

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

ImplementationDefinitionDefinition
: DerivedDefinition
ImplementationDefinitionElement
: LSQPAREN Attributes RSQPAREN DerivedDefinition
| DerivedDefinition
| LSQPAREN Attributes RSQPAREN RuleDefinition
| RuleDefinition

ImplementationDefinitionDefinitions
: ImplementationDefinitionDefinition ImplementationDefinitionDefinitions
| ImplementationDefinitionDefinition
ImplementationDefinitionList
: ImplementationDefinitionList ImplementationDefinitionElement
| ImplementationDefinitionElement

Declaration
: DERIVED Identifier COLON MaybeFunctionParameters MAPS Type
Expand Down
Loading

0 comments on commit cc64255

Please sign in to comment.