parseAtom method

GreenNode? parseAtom(
  1. String? breakOnTokenText
)

Implementation

GreenNode? parseAtom(String? breakOnTokenText) {
  final base = this.parseGroup('atom',
      optional: false, greediness: null, breakOnTokenText: breakOnTokenText);

  if (this.mode == Mode.text) {
    return base;
  }

  final scriptsResult = parseScripts(
      allowLimits:
          base is EquationRowNode && base.overrideType == AtomType.op);

  if (!scriptsResult.empty) {
    if (scriptsResult.limits != true) {
      return MultiscriptsNode(
        base: base?.wrapWithEquationRow() ?? EquationRowNode.empty(),
        sub: scriptsResult.subscript,
        sup: scriptsResult.superscript,
      );
    } else {
      var res = scriptsResult.superscript != null
          ? OverNode(
              base: base?.wrapWithEquationRow() ?? EquationRowNode.empty(),
              above: scriptsResult.superscript!)
          : base;
      res = scriptsResult.subscript != null
          ? UnderNode(
              base: res?.wrapWithEquationRow() ?? EquationRowNode.empty(),
              below: scriptsResult.subscript!)
          : res;
      return res;
    }
  } else {
    return base;
  }
}