Skip to content
Discussion options

You must be logged in to vote

It is not a special case anyone designed — it falls out of two rules that are each deliberate on their own, and the difference between your two examples is purely about which characters may continue an identifier.

A symbol starts on an alpha character and then keeps going while the next one is alpha or a digit:

if (parse.isAlpha(currentCharacter(state), prevCharacter(state), nextCharacter(state))) {
  while (parse.isAlpha(...) || parse.isDigit(currentCharacter(state))) {

A dot is neither, and isDigitDot puts it firmly on the number side instead:

parse.isDigitDot = function isDigitDot (c) {
  return ((c >= '0' && c <= '9') || c === '.')
}

So 2m6 tokenises as 2 followed by the single symbol m6

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@sandeepsengupta
Comment options

Answer selected by gwhitney
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants