Skip to content

Commit

Permalink
make all Jadescript code blocks optional
Browse files Browse the repository at this point in the history
  • Loading branch information
ParsleyJ committed Apr 21, 2023
1 parent 17259fc commit 54c8268
Show file tree
Hide file tree
Showing 26 changed files with 769 additions and 628 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,21 @@ TopElement:
*/
NamedElement:
{NamedElement}
name=Identifier;
name=Identifier
;

FeatureContainer returns NamedElement:
{FeatureContainer}
features+=Feature;
features+=Feature
;

Feature:
{Feature};

FeatureWithBody returns Feature:
{FeatureWithBody}
body=CodeBlock;
body=OptionalBlock
;



Expand Down Expand Up @@ -159,7 +162,7 @@ GlobalFunctionOrProcedure returns UsesOntologyElement: {GlobalFunctionOrProcedur
| ('ontologies' (ontologies+=JvmTypeReference (',' ontologies+=JvmTypeReference)*))
)
)?
'do' body=CodeBlock
'do' body=OptionalBlock
) | (
// Native Global Procedure
native?='native' procedure?='procedure' name=Identifier
Expand All @@ -182,7 +185,7 @@ GlobalFunctionOrProcedure returns UsesOntologyElement: {GlobalFunctionOrProcedur
| ('ontologies' (ontologies+=JvmTypeReference (',' ontologies+=JvmTypeReference)*))
)
)?
'do' body=CodeBlock
'do' body=OptionalBlock
)
);

Expand Down Expand Up @@ -249,77 +252,77 @@ FunctionOrProcedure returns ParameterizedFeature:
')')?
'as' type=TypeExpression
'do'
body=CodeBlock)
body=OptionalBlock)
|
(procedure?='procedure' name=Identifier
('with'
(parameters+=FormalParameter
(',' parameters+=FormalParameter)*)?)?
'do'
body=CodeBlock));
body=OptionalBlock));


OnMessageHandler returns FeatureWithBody:
{OnMessageHandler}(
'on' stale?='stale'? name='message' performative=Performative? pattern=Pattern?
('when' whenBody=WhenExpression)?
'do' (body=CodeBlock | nothing?='nothing')
'do' block=OptionalBlock
);


OnNativeEventHandler returns FeatureWithBody:
{OnNativeEventHandler}(
'on' stale?='stale'? name='native' pattern=Pattern?
('when' whenBody=WhenExpression)?
'do' (body=CodeBlock | nothing?='nothing')
'do' block=OptionalBlock
)
;

OnCreateHandler returns FeatureWithBody:
{OnCreateHandler}(
'on' name='create'
('with' parameters+=FormalParameter (',' parameters+=FormalParameter)*)?
'do' (body=CodeBlock | nothing?='nothing')
'do' block=OptionalBlock

)
;

OnDestroyHandler returns FeatureWithBody:
{OnDestroyHandler} (
'on' name='destroy' 'do' (body=CodeBlock | nothing?='nothing')
'on' name='destroy' 'do' body=OptionalBlock
)
;

OnActivateHandler returns FeatureWithBody:
{OnActivateHandler} (
'on' name='activate' 'do' (body=CodeBlock | nothing?='nothing')
'on' name='activate' 'do' body=OptionalBlock
)
;

OnDeactivateHandler returns FeatureWithBody:
{OnDeactivateHandler} (
'on' name='deactivate' 'do' (body=CodeBlock | nothing?='nothing')
'on' name='deactivate' 'do' body=OptionalBlock
)
;

OnExecuteHandler returns FeatureWithBody:
{OnExecuteHandler} (
'on' name='execute' 'do' (body=CodeBlock | nothing?='nothing')
'on' name='execute' 'do' body=OptionalBlock
)
;

OnExceptionHandler returns FeatureWithBody:
{OnExceptionHandler}(
'on' name='exception' pattern=Pattern?
('when' whenBody=WhenExpression)?
'do' (body=CodeBlock | nothing?='nothing')
'do' block=OptionalBlock
);

OnBehaviourFailureHandler returns FeatureWithBody:
{OnBehaviourFailureHandler}(
'on' name='behaviour' 'failure' pattern=Pattern?
('when' whenBody=WhenExpression)?
'do' (body=CodeBlock | nothing?='nothing')
'do' block=OptionalBlock
);

Concept returns FeatureWithSlots:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import it.unipr.ailab.jadescript.semantics.jadescripttypes.IJadescriptType;
import it.unipr.ailab.jadescript.semantics.jadescripttypes.index.BuiltinTypeProvider;
import it.unipr.ailab.jadescript.semantics.jadescripttypes.index.TypeSolver;
import it.unipr.ailab.jadescript.semantics.jadescripttypes.parameters.InvalidTypeInstantiatonException;
import it.unipr.ailab.jadescript.semantics.jadescripttypes.parameters.TypeArgument;
import it.unipr.ailab.jadescript.semantics.namespace.ImportedMembersNamespace;
import it.unipr.ailab.jadescript.semantics.namespace.NamespaceWithMembers;
Expand Down Expand Up @@ -94,13 +93,10 @@ public IJadescriptType getMessageType() {
typeHelper.unpackTuple(getMessageContentType())
);
final TypeSolver typeSolver = module.get(TypeSolver.class);
try {
return typeSolver.getMessageTypeSchemaForPerformative(
performative.toNullable()
).create(a);
} catch (InvalidTypeInstantiatonException e) {
e.printStackTrace();
}

return typeSolver.getMessageTypeSchemaForPerformative(
performative.toNullable()
).create(a);
}

final BuiltinTypeProvider builtins =
Expand Down
Loading

0 comments on commit 54c8268

Please sign in to comment.