Tokens are the basic atomic units of a grammar. In a typical programming language, tokens would include things like algebraic operators (+
, *
), statement separators ((
, {
, ;
), identifiers, numeric and string values, and reserved words.
The concept of a "token" is somewhat bound up with the way a grammar is written and parsed. Some parsing schemes don't involve the concept of tokenization (packrat parsers for PEGs). However, in this case the use of a railroad diagram implies a traditional BNF (or BNF-like) grammar, complete with a set of tokens.
edit — actually, looking at that other question, the discussion there is actually about a token grammar itself — the token grammar for JSON. I suppose you could consider the elements of the character set to be "tokens" for that purpose. Anyway it should be clear that in those cases — the rules for what numbers and strings look like — spaces can't appear in the middle of those constructs. That is, 23
and 2 3
are not the same.
Outside of the bizarre situations around automatic semicolon insertion, I can't think of places in the JavaScript grammar that disallows spaces between tokens.