Skip to content

Atoms

The atom is the atomic unit of chemistry (and of AsciiChem). An atom captures:

FieldSource positionExample
elementelement symbolC, He, Fe
isotopeprefix^14C
subscriptsuffix (after _)H_2
chargesuffixCa^2+
oxidation_statesuffixFe^(III)

A capital letter optionally followed by a lowercase letter.

H
H
He
He
Uue
Uu e

A subscript multiplicity follows _ directly. The subscript binds to the immediately preceding atom.

H_2
H 2
O_3
O 3
H_2O
H 2 O

For multi-character subscripts, use braces:

H_{2a}
H {2a}

Charges are suffix superscripts in IUPAC number-then-sign form:

Ca^2+
Ca 2 +
Cl^-
Cl -
SO_4^2-
S O 4 2 -

Oxidation states are Roman numerals wrapped in parens:

Fe^(II)
Fe II
Fe^(III)
Fe III
Mn^(VII)
Mn VII

The model captures these as Atom#oxidation_state (“II”, “III”, “VII”), distinct from a generic superscript.

The prefix isotope — the headline semantic fix

Section titled “The prefix isotope — the headline semantic fix”

The defining difference between AsciiChem and AsciiMath lives here.

^14C
C 14
^131I
I 131
^238U
U 238

In AsciiChem, the ^14 prefix binds to the following atom. The parse produces one Atom with isotope: "14". The MathML output is:

<msup><mi>C</mi><mn>14</mn></msup>

In AsciiMath, the same input would force a phantom carrier:

<msup><mi></mi><mn>14</mn></msup><mi>C</mi>

— an empty base followed by a sibling atom. The semantic binding (isotope 14 belongs to Carbon) is lost.

Leading digits on a molecule are the coefficient, distinct from the leading digit of a subscript. The grammar uses positive lookahead to disambiguate.

2H_2O
2 H 2 O
3H_2
3 H 2

The 2 in 2H_2O is the molecule’s coefficient; the 2 in H_2 is the atom’s subscript. Both are captured in the right place.