DollarMathCloser class

Finds the closing $ of single-dollar maths, for one text.

Maths first: a $ pairs with the next unescaped $ on its line, and the pair is maths unless it is provably two prices —

  • both dollars lead an amount: $5 and $10, $5-$10, $5M to $10M;
  • both dollars follow one: 5$ and 10$.

Everything else on one line is maths: $ x $, $2 + 3$, $1a \theta $2, $1 \theta $2a. A $ with no partner on its line, a pair with nothing but spaces between, and a $ next to another $ (half of a $$) open nothing. An escaped \$ is never a partner.

The second dollar of a price pair is spent: it does not open again, so in $5 and $10 then $x$ only x is maths.

The one rule the parser, the $ rewrite and the streaming reveal share. Openers must be asked about left to right, each at most once, so the spent dollars are known. Each search stops at the next $ or line break, so a whole text costs one pass.

Constructors

DollarMathCloser(String text)

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
text → String
final

Methods

find(int i) → int
The closer for the $ at i, or -1.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited