Skip to content

Commit

Permalink
Structure Definition
Browse files Browse the repository at this point in the history
* fixed incorrect attributed and non-attributed function definition list
  for structure definitions
* updated comments
* related to sealangdotorg/sea#35
  • Loading branch information
ppaulweber committed Jun 10, 2021
1 parent 9ceb1a3 commit 91c5835
Show file tree
Hide file tree
Showing 7 changed files with 10,206 additions and 9,909 deletions.
52 changes: 50 additions & 2 deletions src/GrammarParser.y
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ END 0 "end of file"
%type <InvariantDefinition::Ptr> InvariantDefinition
%type <ImportDefinition::Ptr> ImportDefinition
%type <StructureDefinition::Ptr> StructureDefinition
%type <FunctionDefinition::Ptr> StructureDefinitionElement
%type <FunctionDefinitions::Ptr> StructureDefinitionList
%type <FeatureDefinition::Ptr> FeatureDefinition
%type <Definition::Ptr> FeatureDeclarationOrDefinition
%type <Definitions::Ptr> FeatureDeclarationsAndDefinitions
Expand Down Expand Up @@ -551,6 +553,10 @@ InvariantDefinition
}
;

//
//
// StructureDefinition
//

ImportDefinition
: IMPORT IdentifierPath
Expand All @@ -565,14 +571,48 @@ ImportDefinition


StructureDefinition
: STRUCTURE Identifier EQUAL LCURPAREN FunctionDefinitions RCURPAREN
: STRUCTURE Identifier EQUAL LCURPAREN StructureDefinitionList RCURPAREN
{
// TODO: FIXME: @ppaulweber: handle AST keyword tokens $1, $3, $4, and $6
// $$ = Ast::make< StructureDefinition >( @$, $2, $5 );
}
;


StructureDefinitionElement
: LSQPAREN Attributes RSQPAREN FunctionDefinition
{
auto definition = $4;
definition->setAttributes( $2 );
$$ = definition;
}
| FunctionDefinition
{
$$ = $1;
}
;


StructureDefinitionList
: StructureDefinitionList StructureDefinitionElement
{
auto functions = $1;
functions->add( $2 );
$$ = functions;
}
| StructureDefinitionElement
{
auto functions = Ast::make< FunctionDefinitions >( @$ );
functions->add( $1 );
$$ = functions;
}
;

//
//
// FeatureDefinition
//

FeatureDefinition
: FEATURE Identifier EQUAL LCURPAREN FeatureDeclarationsAndDefinitions RCURPAREN
{
Expand Down Expand Up @@ -613,6 +653,10 @@ FeatureDeclarationsAndDefinitions
}
;

//
//
// ImplementationDefinition
//

ImplementationDefinition
: IMPLEMENTS IdentifierPath FOR Type EQUAL LCURPAREN ImplementationDefinitionDefinitions RCURPAREN
Expand Down Expand Up @@ -655,6 +699,10 @@ ImplementationDefinitionDefinitions
}
;

//
//
// DeclarationDefinition
//

DeclarationDefinition
: DERIVED Identifier COLON MaybeFunctionParameters MAPS Type
Expand All @@ -673,7 +721,7 @@ DeclarationDefinition
}
;


//
//
// Rules
//
Expand Down
32 changes: 21 additions & 11 deletions src/various/Grammar.org
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,6 @@ RuleDefinition ::= "rule" Identifier "=" Rule
#+html: {{page>.:grammar:RuleDefinition&noheader&nofooter}}


** FunctionDefinitions

#+begin_src
FunctionDefinitions ::= FunctionDefinitions FunctionDefinition
| FunctionDefinition
#+end_src

#+html: {{page>.:grammar:FunctionDefinitions&noheader&nofooter}}


** FunctionDefinition

#+begin_src
Expand Down Expand Up @@ -185,12 +175,32 @@ ImportDefinition ::= "import" IdentifierPath
** StructureDefinition

#+begin_src
StructureDefinition ::= "structure" Identifier "=" "{" FunctionDefinitions "}"
StructureDefinition ::= "structure" Identifier "=" "{" StructureDefinitionList "}"
#+end_src

#+html: {{page>.:grammar:StructureDefinition&noheader&nofooter}}


** StructureDefinitionElement

#+begin_src
StructureDefinitionElement ::= "[" Attributes "]" FunctionDefinition
| FunctionDefinition
#+end_src

#+html: {{page>.:grammar:StructureDefinitionElement&noheader&nofooter}}


** StructureDefinitionList

#+begin_src
StructureDefinitionList ::= StructureDefinitionList StructureDefinitionElement
| StructureDefinitionElement
#+end_src

#+html: {{page>.:grammar:StructureDefinitionList&noheader&nofooter}}


** FeatureDefinition

#+begin_src
Expand Down
Loading

0 comments on commit 91c5835

Please sign in to comment.