laughinghan/mathquill — pull request #102 by laughinghan (2012-07-14 17:23:27+00:00)
Title: split Parser::then into bind, then, pipe, and constResult, and explicitly call them

the old `Parser::then` conflated four things:

1. the monadic "binding operation", which takes in a function and
returns a parser that will call the original parser, pass the result
thereof to the function, expect the function to return a parser,
and continue parsing with the return value.

2. sequential parsing: `parser1.then(parser2)`, demands both parsers
match one after another, and throws away the result of `parser1` and
returns the result of `parser2`. E.g.:
`CharParser('x').then(CharParser('y'))` matches `'xy'` and returns `'y'`

3. piping the result so far through a function for processing, i.e.
doing a semantic action

4. throwing away the result so far and returning a fixed value

Notice that only `Parser::bind` is primitive and must be implemented by
constructing a new parsing function, the other 3 are all higher-level
combinators implemented with `bind`.

In addition to renaming, the Unit Tests were re-arranged so that `bind`
is tested before the other `then`-derivatives.

`latex.js` now explicitly calls whichever of these it actually meant.