JOVIAL2CTM Translator

The JOVIAL2C translator converts source code written in JOVIAL to functionally equivalent source code in C taking advantage of some GNU 3.0 extensions of C. The tool has been constructed using the DMS Software Reengineering Toolkit, the JOVIAL Front End, and a customization of the C Front End by GNU extensions for C used by the translator.

The JOVIAL2C translator has been used to modernize sophisticated embedded aircraft software, such as the mission software for the Northrop Grumman B-2.

The JOVIAL2C translator supports:

  • Source language: JOVIAL as defined by MIL-STD-1589C (USAF) or J73.
  • Target language: C with GNU extensions as provided by GCC 3.0.
    We have produced other C dialects for customers.
  • Translation of modules
    • Compool modules are translated to C header files containing compile time conditionals to deal with data initializers
    • Procedure modules are translated to C source files containing translation units
    • Main program modules are translated to C source files containing translation units
  • Translation of basic language features
    • Compool directives are translated to C includes of header files
    • Data items are translated to C declarations
    • Blocks are translated to C structures
    • Tables without dimensions are translated to C structures; tables with dimensions are translated to C arrays of structures
    • Procedures and functions are translated to C functions
    • Statements are translated one-to-one to corresponding C statements
    • Access to data items in blocks and tables is translated to C expressions using structure member access operators . and -> when necessary
    • Operators and predefined functions in formulas are translated to corresponding operators in C expressions or to predefined macros
    • Value-result parameter passing is translated to passing of C pointers with simulation of value-result behavior by the callee
  • Translation of advanced language features
    • Preset values specified for block and table entries are translated to C structure initializers
    • Specified tables without overlapping entries are translated to flat C structures (containing bit field members as necessary) specified tables with overlapping entries are translated to C unions of anonymous structures (containing bit field members as necessary)
    • Overlays are translated to nested anonymous C structures and unions (using a GCC 3.0 extension of C)
  • Translation of comments
    • Comments are preserved during translation with their representation being adapted as necessary
  • Preservation of well-structured macros
    • Well-structured macros in JOVIAL are translated to well-structured macros in C
    • Multiple macros in C may be created for a single macro in JOVIAL if necessary
    • If structure member access operators are added, token concatenation in macros for data items is propagated to token concatenation for the enclosing table or block name if possible.

Example

JOVIAL source code

    START

      %define records%
      TABLE tbl'one'grp W 1;
        BEGIN
          ITEM itm'one'A S 3 POS(3,0) = 1;
          ITEM itm'one'B S 3 POS(8,0) = 2;
        END;
      TABLE tbl'two'grp W 1;
        BEGIN
          ITEM itm'two'A S 3 POS(3,0) = 3;
          ITEM itm'two'B S 3 POS(8,0) = 4;
        END

      %access members of records%
      DEFINE get'A(G) "itm'!G'A";
      DEFINE get'B(G) "itm'!G'B";

      %test procedure%
      PROC test(:param) S;
        BEGIN
          ITEM param S;
          ITEM sumA S = get'A(one) + get'A(two);
          ITEM sumB S = get'B(one) + get'B(two);
          test = sumA + param + sumB;
          %perform sumA times%
          FOR I: 1 BY 1 WHILE I<= sumA;
            IF I < sumB;
              sumB = sumB + test(I);
            ELSE
              RETURN;
          param = param + sumB;
        END
    TERM

C source code produced by JOVIAL2C Translator

    #include "jovial.h"
    static struct
           {
             U(3) : 3 _align_to_bit;
             S(3) itm_one_a : 4 _align_to_bit;
             U(1) : 1 _align_to_bit;
             S(3) itm_one_b : 4 _align_to_bit;
             U(4) : 4 _align_to_bit;
           } tbl_one_grp = { .itm_one_a = 1,
                             .itm_one_b = 2 };
    static struct
           {
             U(3) : 3 _align_to_bit;
             S(3) itm_two_a : 4 _align_to_bit;
             U(1) : 1 _align_to_bit;
             S(3) itm_two_b : 4 _align_to_bit;
             U(4) : 4 _align_to_bit;
           } tbl_two_grp = { .itm_two_a = 3,
                             .itm_two_b = 4 };
    /* access members of records */
    #define GET_A(__g__) \
      tbl_##__g__##_grp.itm_##__g__##_a
    #define GET_B(__g__) \
      tbl_##__g__##_grp.itm_##__g__##_b
    static S test(S *ARG(param));
    /* test procedure */
    static S test(S *ARG(param))
      {
        __typeof__(*ARG(param)) param = *ARG(param);
        __typeof__(test(ARG(param))) RESULT(test);
        _main :
          {
            S suma = GET_A(one) + GET_A(two);
            S sumb = GET_B(one) + GET_B(two);
            RESULT(test) = suma + param + sumb;
            /* perform sumA times */
            {
              __typeof__(1) i;
              for (i = 1; i <= suma; i += 1)
                if (i < sumb)
                  sumb = sumb + test(i);
                else
                  goto _return;
            }
            param = param + sumb;
          }
        _return :
          {
            *ARG(param) = param;
            return RESULT(test);
          }
      }

Semantic Designs can provide cusomized tools and migration support to your organization.

For more information: info@semanticdesigns.com    Follow us at Twitter: @SemanticDesigns

JOVIAL2C
Translator