Audit + clean up token walking code in the R code model

This is an attempt to audit + clean up some of the token walking code we have in the R code model.

Quick outline -- there are a small number of 'very hot' code paths which other functions rely on. These are member functions of the `TokenCursor` object.

1. `moveToPreviousToken()`
2. `moveToNextToken()`
3. `bwdToMatchingToken()`
4. `fwdToMatchingToken()`

On success, they move the token cursor as named and return `true`; on failure they don't touch the token cursor and return `false`.

Most other functions are built on top of these 4 in the form of e.g. `while (cursor.moveToPreviousToken())`, so it is essential that they stop either at the start, or end, of the document.

The pre-existing code was a bit cluttered, so I've re-written and commented my steps here and I think it should at least be a step in the right direction.

@jmcphers, can we do a quick review of this?
not technically necessary--JavaScript doesn't have block variable scoping (IIRC anything inside a closure is scoped to the closure)