The RXU Rexx Preprocessor for Unicode


The RXU Rexx Preprocessor for Unicode

/******************************************************************************
 * This file is part of The Unicode Tools Of Rexx (TUTOR)                     *
 * See https://rexx.epbcn.com/TUTOR/                                          *
 *     and https://github.com/JosepMariaBlasco/TUTOR                          *
 * Copyright © 2023-2025 Josep Maria Blasco <josep.maria.blasco@epbcn.com>    *
 * License: Apache License 2.0 (https://www.apache.org/licenses/LICENSE-2.0)  *
 ******************************************************************************/

Description

The RXU Rexx Preprocessor for Unicode is implemented by a set of Rexx programs. The most visible one is a new command called rxu.rex.

RXU reads a .rxu program and attempts to translate it to standard .rex code (RXU needs the Unicode library, Unicode.cls, and will automatically use it). If no errors are found in the translation pass, the resulting .rex program is then executed, after which it is deleted. RXU programs can be written using an extended Rexx syntax that implements a set of Unicode and non-Unicode literals, several new BIFs and BIMs, and a system of polymorphic BIFs that allow the programmer to continue using the same concepts and BIFs that in Classic Rexx, and at the same time take advantage of the power and novelties of the Unicode world.

The RXU command

RXU filename converts a file named filename.ext (default extension: .rxu) into a .rex file, and then interprets this .rex file. By default, the .rex file is deleted at the end of the process-

Format:

[rexx] rxu [options] filename [arguments]

Options:

    -help, -h  : display help for the RXU command
    -keep, -k  : do not delete the generated .rex file
    -nokeep    : delete the generated .rex file (the default)
    -warnbif   : warn when using not-yet-migrated to Unicode BIFs
    -nowarnbif : don't warn when using not-yet-migrated to Unicode BIFs (the default)

Source file encoding

RXU source files should be encoded in UTF-8, without a byte order mark (BOM). There is currently no way to declare a different encoding for the source file.

  • No BOM. A UTF-8 byte order mark ("EF BB BF"X) at the beginning of the file is not accepted: it is reported as Syntax error 13 (Invalid character in program). This is the same behaviour that ooRexx shows when a .rex file starts with a BOM.
  • P, G and T strings are checked when the program is translated: if the contents of a "string"P, "string"G or "string"T literal are not well-formed UTF-8, RXU reports Syntax error 22 (Invalid character string).
  • U strings are always well-formed, because RXU itself generates the UTF-8 representation of their codepoints (see the section about U strings in New types of strings).
  • Y, X and B strings are BYTES strings, and their contents are not checked.
  • Unsuffixed strings are not checked when the program is translated. Their type is determined by OPTIONS DEFAULTSTRING (see New values for the OPTIONS instruction). When the default string type is BYTES, unsuffixed strings are BYTES strings, and their contents are not checked; when it is CODEPOINTS, GRAPHEMES or TEXT, an unsuffixed string that does not contain well-formed UTF-8 will raise a syntax error at run time, when the string is created.
  • Latin-1 bytes. Bytes in the "80"X.."C1"X range cannot start a UTF-8 sequence. The RXU parser accepts them, and handles them as Latin-1 characters (this allows, for example, "AC"X to be recognized as the "not" sign, "¬", when certain options are active). Bytes "C2"X and above are assumed to start a UTF-8 sequence. Mixing Latin-1 and UTF-8 characters in the same source file is bad practice and should be avoided.

What we do and what we don't do

RXU is a work-in-progress, not a finished product. Some parts of Rexx have been made to appear as "Unicode-ready", and some others have not. This can produce all kind of unexpected results. Use at your own risk!

The major focus of the translator is to implement Unicode-aware Classic Rexx: in this sense, priority is given, for example, to the implementation of Built-in Functions (BIFs) over Built-in Methods (BIMs). For instance, currently you will find a Unicode-aware implementation of several stream i/o BIFs, but no reimplementation of the Stream I/O classes.

Here is a list of what is currently implemented

Four new types of string

Revised built-in functions

New built-in functions

New classes

New values for the OPTIONS instruction