## 3 REX
### Fibonacci  
The goal here is to calculate the result of the application of the Fibonacci's function to an integer N or, in other words, to calculate the Nth element in the Fibonacci sequence. This example's REX text is shown in Listing 17. Mathematical arithmetic and comparison are verbose. This is another limitation of the current implementation. Nevertheless, nothing precludes including mathematical operators in function signatures (e.g., _an integer A > an integers B is a boolean_). The only thing that is needed is to treat those operators like any other alphanumeric character. Most of the text should be clear by now, however, conditions are introduced and these need some background. In REX, functions with signatures ending with _is a boolean_ can be used as conditions. We recognize this construction is a bit unexpected. It was chosen because it simplifies the implementation, but completely different approaches are possible. For example, the declaration _\"it_is_possible_that an integer X is_or_is_not_greater_than_or_equal_to an integer Y.\"_, because of the prefix _is_or_is_not_could imply a boolean return value, as well two different function signatures, namely: _\"...is_greater_than_or_equal_to_...\" and _\"...is_not_greater_than_or_equal_to_...\". It should also be noted that: _\"an integer X is an integer Y\"_ is expected to correspond and will be set to the assignment of Y's value to X. ```
**Listing 17**. REX text for the \"Fibonacci\" example. ```
there_are booleans (boolean). there_are integers (integer). it_is_possible_thatan integer X is an integer Y. it_is_possible_thatan integer X is_greater_than_or_equal_to an integer Y is a boolean B. it_is_possible the_addition_of an integer A with an integer B is an integer X. it_is_possible the_difference_between an integer A and an integer B is an integer X. it_is_possible_to output an integer X. if the_fibonacci_function_of an integer X is an integer Y, then if X is_greater_than_or_equal_to 3, then there_is_one integer N1, there_is_one integer N2, the_difference_between X and 1 is N1, the_difference_between X and 2 is N2, there_is_one integer A, there_is_one integer B, the_fibonacci_function_of N1 is A, the_fibonacci_function_of N2 is B, the_addition_of A with B is Y; else Y is 1. if launch application, then there_is_one integer A, there_is_one integer B, there_is_one integer C, the_fibonacci_function_of 1 is A, the_fibonacci_function_of 2 is B, the_fibonacci_function_of 10 is C, output A, output B, output C.
```

**Listing 17**. REX text for the \"Fibonacci\" example. In REX, the text in Listing 17 is compiled into the Ecore model shown in Figure 5. In Listing 18, the semantics of undefined functions are set, alongside a possible main method. public class FibApp extends_ops { public static void main(String[] args) {  FibApp fib = new FibApp();  fib.launch_application();  }  public void _integer_is_integer(_integer X, _integer Y) {  X.setValue(Y.getValue());;  }  public void _integer_is_greater_than_or_equal_to_integer_is_boolean( _integer_ X, _integer Y, _boolean B) {  B.setValue(X.getValue() >= Y.getValue());  }  public void the_addition_of_integer_with_integer_is_integer( _integer_ A, _integer B, _integer X) {  X.setValue(A.getValue() + B.getValue());  }  public void the_difference_between_integer_and_integer_is_integer( _integer A, _integer B, _integer X) {  X.setValue(A.getValue() - B.getValue());  }  public void output_integer(_integer X) {  System.out.println(X.getValue());  } } } ```

Listing 18: Java code entered manually for the \"Fibonacci\" example (simplified). ## 4 Implementation

In this section, the implementation of REX using the Eclipse IDE is described. Because REX has a small (but comprehensive) set of rules, and thus, a very simple grammar, its implementation is also quite straightforward. Using the tools provided by the Eclipse IDE, only two REX-specific translation units (or source files) are needed, namely, one grammar (44 rules, 113 lines of code, empty lines not included, approx.