Class TokenSpacer

java.lang.Object
org.ek9lang.compiler.formatter.TokenSpacer

final class TokenSpacer extends Object
Pass 3 of the EK9 source formatter: Token Spacing.

Re-tokenises the source, groups tokens by line, and rebuilds each line's content with canonical spacing while preserving the leading indent from Pass 1. The EK9 lexer discards whitespace, so all horizontal spacing must be reconstructed from token types.

  • Constructor Details

    • TokenSpacer

      TokenSpacer()
  • Method Details

    • space

      String space(String source)
      Apply canonical spacing to the given EK9 source.
      Parameters:
      source - The EK9 source code (already indented and reordered).
      Returns:
      The source with canonical spacing, or null if parsing fails.