# A Case Study on the Design and Implementation of a Platform for Hand Rehabilitation
## 5 Results
### RehabHand Engineer Viewpoint
#### 5.2.1 Domain-Specific Syntax  
Domain-Specific Languages [38; 39] are languages tailored to a specific application domain [17; 40]. We often call them little languages [41], but it does not always have to be the case. DSL programs are expressive, short, and easy to maintain [42]. Several techniques exist for the implementation of a Domain-Specific Language [43]. Besides the embedded approach [44], the most commonly used approach is compiler/interpreter [19]. There are notable advantages with this approach [43]. The most important one is syntax, which can be prepared without any restrictions. The compiler generator approach is related to the compiler/interpreter approach. Here, some phases are generated automatically (lexical and syntax parts) using language development systems (compiler-compilers) (e.g., ANTRL [45], Lex/Yacc [46], LISA [47], YAJCo [48]). A similar approach to compiler generators is language workbenches (Xtext in Eclipse, or Jetbrains MPS in Intellij), a term coined by [PERSON] [22]. They contain a set of tools that support the development of a Domain-Specific Language. The most commonly used feature is to support an integrated development environment (IDE) for DSLs' end-users. RehabHand syntax was developed in the language workbench Xtext [49]. Xtext is implemented in Java and is available in the form of a plugin for the IDE Eclipse. To define a DSL, we first define a grammar in an EBNF-like syntax. Based on the grammar, the Eclipse plugin will then generate a compiler (using compiler generator ANTLR [45] beneath) and the language infrastructure support. This generation process, as well as the resulting tools, can be customized in numerous ways (constraints on the syntax tree are implemented by _validators_, syntax tree elements with _label providers_, etc.). Figure 4: Different exercises for hand rehabilitation. grammarferi.bsc.rm.MyRobotMovementwithorg.eclipse.xtext.common.Terminals generatemyRobotMovement\"[[http://www.bsc.feri/rm/MyRobotMovement](http://www.bsc.feri/rm/MyRobotMovement)]([http://www.bsc.feri/rm/MyRobotMovement](http://www.bsc.feri/rm/MyRobotMovement))\" Model: bt+Definecal-calibrationrep=Repetition? ; Define: 'hand'RobotType; RobotType: rt=('bionic'|'arduino'|'cyton'); Calibration: stmts+=(InitStmt)+; InitStmt: {InitializationStat} {ss=SpeedStmt|ss=GenStmt}; SpeedStmt:'speed'SpeedOption; SpeedOption: so=('slow'|'medium'|'fast'); GenStmt: {GenericStmt} (oo=OpenObj|co=CloseObj); OpenObj: 'open'MoveObj; CloseObj: 'close'MoveObj; MoveObject (('finger'firstObj=INT('-'lastObj=INT)? )|'hand'); Repetition:'repeat'(times=INT|wt=INT('.'dt=INT)?'s')? 'begin'ss+=(GenStmt/\"|SpecStmt\"/)+'end';  
A simplified version of RehabHand Xtext syntax is presented in Figure 5. There are various non-terminals derived from the starting non-terminal Model: Define, Calibration, and Repetition. Define is mandatory, Calibration and Repetition are optional. Non-terminal Define is further decribed by terminal hand and non-terminal RobotType. Non-terminal RobotType defines currently supported rehabilitation hands (terminals bionic, arduino, and cyton). Note that there is no hand definition (e.g., hand arduino) in the exercises in Figure 4. This is not part of the rehabilitation exercise. Therefore, we decided to omit any system configuration from the domain definition. This line is added in the preprocessing of exercises in Figure 4. If the Calibration is desired within a RehabHand program, initialization is performed (non-terminal InitStmt). Non-terminal InitStmt is defined with speed (non-terminal SpeedStmt) or hand initialization position (non-terminal GenStmt). Later is defined with the opening command (non-terminal OpenObj) or closing command (non-terminal CloseObj). Both non-terminals OpenObj and CloseObj are associated with non-terminal MoveObj, that basically provides the possibility to work with a finger or the whole hand. After calibration, the repetition process starts the rehabilitation exercise (non-terminal Repetition).