REJO implementation

REJO language is an extension of the Java language, i.e. Java programs may be compiled by the REJO compiler without problem (it must only have the rejo extention). Since REJO language is a superset of Java grammar its implementation was performed using a generator of compilers and the Java grammar described in the choosen generator. The most known generator of compilers is the pair YACC and LEX [19], however REJO implementation does not use them, it uses JavaCC[18]. We chose JavaCC because it uses, as native language, Java language and not C language (which is not as portable as Java) as in YACC/LEX and because the JavaCC grammar is easier than YACC grammar.

In this page we present a brief description of the REJO compiler implementation.


1 Description

The java grammar is mainly composed by 4 parts:

  1. The definition of the Tokens (lexical analysis), for instance, the definition of the keywords: if, for, class, int, break, etc.
  2. The production rules for defining the Structure of a Programme, for instance, the structure of classes, methodes, interfaces, variables' declaration, etc.
  3. The productions for defining Expressions", for instance, assignations, conditions, etc.
  4. The production rules for defining the Flow Control Structs, for example, the instructions if-else, while, for, do-while, switch, etc.

In order to implement REJO languaje, the java grammar was modified to:

  1. Add the notion of Reactive Method. For doing this the section two of the previous description was modified to insert a new production rule ( RMethodDeclaration ), in particular it was modified the class production rule.
  2. Add the set of production rules that define the structure of reactive methods in function of Reactive Instructions, Reactive Variables and Reactive Expressions.
  3. Avoid the redefinition of some java sentences that are reused in some reactive instructions. This is implemented using a java method action and a set of variables.

You may look an old version of REJO grammar (in html format) here.

2 Analysis

Statistics

The following table shows the number of production rules used by Java and REJO. As you can see REJO defines less than the half Java productions because it reuses Java productions. The only case where REJO has more productions rules is in the definition of Flow Control Structures; this is normal because REJO is richer describing behaviors.

The whole grammar has 131 rules.