Token Grouping

Chevrotain lexers support grouping Tokens Types separately from the main token vector in the lexing result. This is often useful to collect a specific set of Token Types for later processing, for example to collect comments tokens.

To group a Token Type simply specify the groupopen in new window property in its configuration. For example:

const Comment = createToken({
  name: "Comment",
  pattern: /\/\/.+/,
  group: "comments",

See executable exampleopen in new window for further details.