\chapter{Introduction}
\label{chapt:Introduction}

Statecharts \cite{harel1987statecharts} are a domain-specific language (DSL) suitable for modeling reactive, discrete-event, autonomous, timed, complex and concurrent systems. Implementing such systems with the use of low-level primitives such as threads, locks and timers is a very difficult task. Statecharts hide these implementation details and allow the modeler to focus on the \emph{what}, instead of the \emph{how}.

However, the semantics of statecharts are not precisely defined, in many cases leaving room for choices to be made by implementors. Since their inception, several statechart implementations and standards have been developed with varying semantics.

The SCCD formalism \cite{VanMierlo2016} combines Class Diagrams with statecharts, supporting multi-statechart models with dynamic creation (and destruction) of instances. In the context of the SCCD project, a statechart compiler has to be developed. Given the semantic variability of existing statechart implementations, the most general solution is to support a range of semantics.

Big-Step Modeling Languages (BSML) \cite{sabzali2010deconstructing} are a family of DSLs, including various statecharts implementations, that have been mapped onto a common syntax, with their semantics decomposed into a set of precisely described variation points. This makes BSML a powerful framework for studying semantic variability in statecharts.

% \section{Contributions}

In this work, we have selected a subset of BSML semantic options that we think are applicable to statecharts. We have implemented these options in a statechart interpreter. (The reasons to develop an interpreter instead of a compiler will be motivated.) In accordance with BSML, we allow the modeler to choose the semantics on a by-model basis.


% To evaluate our solution, we compare it with YAKINDU \cite{yakindu}, a well-known open-source statechart IDE and code generator. We have studied YAKINDU's semantics and describe them as a BSML. We also show example models, implemented in both solutions, and discuss the semantic options chosen for these models.


\section{Technical remarks}

Since January 2020, Python 2 no longer receives (security) updates, so our solution solely targets Python 3, compatible with versions $\geq 3.6$, including the just-in-time compiler PyPy \footnote{https://www.pypy.org/}. Function and method signatures are extensively provided with type annotations, which can be statically checked for correctness, but primarily serve as a form of documentation. The implementation's dependencies on 3rd party libraries have been intentially kept small. The latest version of our implementation can be found in the `joeri'-branch of the SCCD project: \url{https://msdl.uantwerpen.be/git/simon/SCCD/src/joeri}

\section{Code fragments}

In this thesis, code fragments are sometimes used to illustrate hypothetical or actual implementations. We do not use a separate ``pseudocode'' syntax. Instead, Python's syntax is used everywhere, as it is clear and compact. The only exception is when we show code fragments of our action language, which has its own textual syntax.

\section{Outline}

The rest of this thesis is organized as follows: The first half of Chapter \ref{chapt:Background} introduces the statecharts formalism and already illustrates the non-precise semantics of the statecharts formalism.  The second half of \ref{chapt:Background} introduces the semantic options of BSML and discusses their applicability to statecharts. Chapter \ref{chapt:Implementation} describes the implementation of SCCD's statechart execution runtime. Chapter \ref{chapt:Evaluation} evaluates our solution by comparison with YAKINDU and the implementation of example models.