rejig

Supported Program Formats
Login

Supported Program Formats

rejig got its name because it rejiggers programs between any input/output pairing of:

See the HP-11C, HP-12C, HP-15C, and HP-16C docs for details.

Additionally, rejig offers these output-only formats:

Unicode

The --from/to unicode/utf8 options described above assume R47 program text by default, with appropriate restrictions and stylings. However, these may be paired with the --validate and --syntax command line options respectively to cause rejig to expect/produce a more constrained RPN dialect.

The default output mode of rejig is to pretty-print in an R47 inspired format, but giving --syntax restricts its output to the limits and style of other machines. For instance, hp42s disallows R47-only ops and causes rejig to use HP-42S op name spellings, plus 42-isms like ST and IND markers. Further, it changes how --line-numbers operates to better match the style seen on-calculator and in the HP manuals.

These additional validation rule sets are available in rejig:

Some of these have associated program file formats listed above, but do not confuse these two schemes. Consider:

./rejig --to dm32     < program.p47
./rejig --syntax dm32 < program.p47

Both calls rely on the default --from p47 option by reading the input from a pipe, but with different output. The first overrides the default R47-inspired Unicode pretty-printing to produce a DM32 statefile instead. The second keeps the default output format but applies additional restrictions atop it to produce plaintext similar to what is found for the example programs printed in the DM32 manual.

Similar things occur on input with --from unicode except that the paired flag is --validate, which causes the Unicode plaintext parser to apply tighter validation rules than it normally would, overriding those for inputs presumed to be interpretable by an R47. Examples:

./rejig program.p47 --validate dm32
./rejig program.p47 --to dm32 > program.d32

The first command attempts to lower the R47 byte code given as input to Unicode pretty-printed form, using DM32 inspired op spellings, label and variable restrictions, and so forth. If it succeeds, the result should be suitable for presentation as a human-readable program listing for a DM32.

The second command does the same, but to a DM32 statefile. The explicit --to option is not needed here if you say instead:

./rejig program.p47 --output program.d32

…because it can then infer the output format from the given file name’s extension.

This takes us to…

Implied Formats

By default, rejig operates as if you gave -f p47 -t utf8, but the command line parser consults those defaults only when it cannot see a file name, as when using rejig in a pipeline:

rejig < input.p47 > output.p47u

This relies on rejig defaulting to stdin when no input file name is given and writing to stdout when no --output/o is given. This is convenient, but do be aware that using rejig in a pipeline like this prevents it from seeing the file names, defeating its ability to infer a machine type from that clue. Ironically, this can force simple commands like the above to become longer, as you now need to give flags like --syntax and --validate to supply details rejig could guess, if you directly gave it the file names with machine-specific extensions.

The following command is equivalent to the one immediately above:

rejig input.p47 -o output.p47u

The first command works because the file formats match the rejig defaults, avoiding the need for explicit --from/to options. The second works because this command form allows rejig to see the file name extensions and make suitable inferences.

You need not give --from/to options when doing non-default things provided you give rejig file names with extensions it knows about:

rejig input.utf8 -o output.p47

In needlessly verbose form, that can instead be expressed as:

rejig --from p47u input.utf8 --to p47 --output output.p47

Now consider this counterexample:

rejig -f utf8 -t p47 < input.p47u > output.p47

This is the overly-verbose example above recast using pipes, making the -f/t options fully justified because they override defaults we do not want to accept in this instance.

Format inferencing makes --from/to options largely redundant when not using rejig in a pipeline since you should be naming your RPN program files in accord with the conventions this program supports regardless.

The only thirty-series machine presently having a calculator-specific --from/to file format is the DM32 with its .d32 statefiles.

For all else, use file name extensions matching the --syntax/validate values when you wish to imply these options on Unicode I/O. Do realize, however, that the actual file format is --from/to unicode in these cases. Syntax and validator rules are a distinct concept to rejig.

(You may now wish to return to the rejig home page.)

License

This work is © 2026 by Warren Young and is licensed under CC BY-NC-SA 4.0


  1. ^ Although this mode is implied by a matching file name extension, be aware that VoyagerCalc’s “Export Listing as Text…” feature uses the generic .txt extension, which in rejig implies Free42 raw2txt style listings. (It wins on longstanding precedent.) All else but the LISTING section is ignored. There is no --to emu1?c partly because VoyagerCalc lacks a corresponding “Import” feature and partly because rejig lacks the ability to produce the non-LISTING sections.