# PyFlies: A Domain-Specific Language for Designing Experiments in Psychology
## 4 Language Abstract and Concrete Syntaxes
### Conditions Tables  
Condition tables are used to describe trial variable values in a compact form. Each column of a condition table specifies a variable available in each test trial. The heading row of the table defines trial variables, whereas the remaining rows specify variables' values and thus define the state of each trial. We could write a row for each trial with the exact values, thus defining the table in expanded form. Instead, we usually specify values using expressions that are evaluated during compilation yielding the fully expanded condition table. That brings more flexibility in extending the table, both column-wise and row-wise. Listing 3 gives the definition of a condition table concrete syntax in textX. Condition-sTable uses a noskipus rule modifier as we want to control whitespaces ourselves in this rule. The condition table can be specified in either Org Mode [38] or markdown table format ([[https://www.w3](https://www.w3) schools.io/file/markdown-table/]([https://www.w3](https://www.w3) schools.io/file/markdown-table/), accessed on 1 July 2021). Atthe beginning of the ConditionsTable rule (line 1), we have a match that consumes all whitespaces and comments (line 2) until the first pipe char (1) that starts the table. Line 3 defines the syntax of the table header with variable names. It starts with the pipe char, after which we have one or more (+=) variable name matched by the rule TableVarName. This variable assignment uses separator '|' textX repetition modifier during the matching (part ['|'] after TableVarName). Rules WSWithNL at line 8 and WSNoNL at line 9 match whitespaces with newline and whitespaces without a newline, respectively. The expression at line 4 consumes the header separator. The header separator is not preserved (i.e., no textX assignment is used). After the header, one or more condition specification is consumed (line 5) matched by the rule Condition (not given in the listing for brevity). ```
1 Conditionstable[noskigws];
2(/*a/Comment?/\(\backslash\)a/)*
3'|'variables+=TableVarName['|']WSNoNL'|'WSWithNL
4 WSNoNL/\(\backslash\)\(\backslash\)\(\backslash\)\(\backslash\)? (:7-:?\(\backslash\)\(\backslash\)\(\backslash\)||\(\



We describe PyFlies components using a built-in DSL for components description. The description consists of a component name, documentation, and a set of properties with names, types, default values, and their documentation. A component can inherit other components. A textX grammar for components definition is given in Listing 5. The optional abstract keyword (line 2) specifies components that can only be inherited but not referenced in tests. A component can inherit multiple other components. Inherited components are specified after the keyword extends (line 3). The component header is followed by its description after which the body is defined. The body of the component consists of zero or more parameters defined by the ParamType rule (line 6). The ParamType rule defines component parameters (line 10). It starts with the keyword param followed by the name attribute that is matched by the ID rule. The parameter type is specified after the colon and it can be a simple type or a list of types inside square brackets (line 12). Multiple types are used in a situation when the parameter may be one of several types (e.g., a symbol or a point, see Listing 6). The default parameter value is given after the char =. At the end of the definition, an optional description may be provided. ```
1 ComponentType:
2 abstract?='abstract''component'name=ID
3('extends'extends'=[ComponentType][','])? 4(description=Description)? 5'{'param_types==ParamType
7'}'}'
8'
9
10 ParanType:
11'param'name=ID':'
12(types=Type|'['types==Type[',']']')'='default= Expression
13(description=Description)? 14;
```
Listing 6 shows a definition of the rectangle component. This component inherits a visual component that describes common properties used by all visual components and adds property size which can be of either symbol or point type. The default value is point (20, 20).