This repository really contains two things:
- extensive tables describing WL symbols, operators, and their properties
- a tokenizer or scanner portion for the Wolfram Language.
Concerning the first item, there are two commented YAML files that contain a full set of translations between:
- Wolfram Language named characters,
- Unicode/ASCII equivalents and Unicode and WL code-points,
- AMSLaTeX equivalent names,
- Operator name (if symbol is an operator),
- Operator arity (if an operator)
- Operator precedence (if an operator)
- Operator associativity (if an operator)
- Keyboard escape sequences for the symbol
The scanner and character tables are used inside Mathics3. However information can also be used by other programs for tokenizing and formatting Wolfram Language code.
For example, tables are used in mathics-pygments, a Pygments-based lexer and highlighter for Mathematica/Wolfram Language source code.
This library may be useful if you need to work with the Wolfram Language named character and convert it to various formats.
- For tokenizing and scanning Wolfram Language code, use the
mathics_scanner.tokenizer.Tokenizerclass. - To convert between Wolfram Language named characters and Unicode/ASCII, use
the
mathics_scanner.characters.replace_wl_with_plain_textandmathics_scanner.characters.replace_unicode_with_wlfunctions. - To convert between qualified names of named characters (such
FormalAfor\[FormalA]) and Wolfram's internal representation use them̀athics_scanner.characters.named_charactersdictionary.
To regenerate JSON-format tables, run:
$ mathics3-generate-json-table $ mathics3-generate-operator-json-table
Without options, mathics3-generate-json-table produces the maximum set of correspondences.
In most applications, though, you may need just a few of these. The
--field option can be used to narrow the list of entries to output in JSON. Run
mathics3-generate-json-table --help for a full list of fields.
There is a command-line utility, mathics3-tokens, for showing how
an input stream is tokenized. The --CodeTokenize or -C option
will try to show the token as it would appear using CodeTokenize. type
mathics3-tokens --help information on command-line options.
For notes on the implementation of the packages or details on the conversion scheme please read Implementation.
Please feel encouraged to contribute to this package or Mathics3! Create your own fork, make the desired changes, commit, and make a pull request.
Mathics3 is released under the GNU General Public License Version 3 (GPL3).