Resolves #219.  Changed the way it counts "am I at the end" to handle

the square-bracket list index style (where there's a "]" token node after
the last index, unlike with the "#" syntax where the index is the last
node there is.).
I changed this to a switch statement for clarity