Skip to content

Commit

Permalink
Function Definitions
Browse files Browse the repository at this point in the history
* removed invalid COMMA terminal
  - related to sealangdotorg/sea#35
  • Loading branch information
ppaulweber committed Jun 10, 2021
1 parent 86010cf commit 9ceb1a3
Show file tree
Hide file tree
Showing 7 changed files with 10,055 additions and 9,943 deletions.
25 changes: 21 additions & 4 deletions src/GrammarParser.y
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ END 0 "end of file"
%type <VariableDefinition::Ptr> Variable TypedVariable AttributedVariable TypedAttributedVariable
%type <VariableDefinitions::Ptr> TypedVariables
%type <FunctionDefinition::Ptr> FunctionDefinition
%type <FunctionDefinitions::Ptr> FunctionDefinitions
%type <DerivedDefinition::Ptr> DerivedDefinition
%type <RuleDefinition::Ptr> RuleDefinition
%type <EnumeratorDefinition::Ptr> EnumeratorDefinition
Expand Down Expand Up @@ -457,6 +458,22 @@ RuleDefinition
;


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


FunctionDefinition
: FUNCTION Identifier COLON MaybeFunctionParameters MAPS Type MaybeDefined MaybeInitially
{
Expand Down Expand Up @@ -548,7 +565,7 @@ ImportDefinition


StructureDefinition
: STRUCTURE Identifier EQUAL LCURPAREN FunctionDefinition RCURPAREN
: STRUCTURE Identifier EQUAL LCURPAREN FunctionDefinitions RCURPAREN
{
// TODO: FIXME: @ppaulweber: handle AST keyword tokens $1, $3, $4, and $6
// $$ = Ast::make< StructureDefinition >( @$, $2, $5 );
Expand Down Expand Up @@ -624,10 +641,10 @@ ImplementationDefinitionDefinition


ImplementationDefinitionDefinitions
: ImplementationDefinitionDefinitions ImplementationDefinitionDefinition
: ImplementationDefinitionDefinition ImplementationDefinitionDefinitions
{
auto definitions = $1;
definitions->add( $2 );
auto definitions = $2;
definitions->add( $1 );
$$ = definitions;
}
| ImplementationDefinitionDefinition
Expand Down
14 changes: 12 additions & 2 deletions src/various/Grammar.org
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ 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 @@ -175,7 +185,7 @@ ImportDefinition ::= "import" IdentifierPath
** StructureDefinition

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

#+html: {{page>.:grammar:StructureDefinition&noheader&nofooter}}
Expand Down Expand Up @@ -234,7 +244,7 @@ ImplementationDefinitionDefinition ::= DerivedDefinition
** ImplementationDefinitionDefinitions

#+begin_src
ImplementationDefinitionDefinitions ::= ImplementationDefinitionDefinitions ImplementationDefinitionDefinition
ImplementationDefinitionDefinitions ::= ImplementationDefinitionDefinition ImplementationDefinitionDefinitions
| ImplementationDefinitionDefinition
#+end_src

Expand Down
Loading

0 comments on commit 9ceb1a3

Please sign in to comment.