class

Noir::ScalaLexer

Inherits Noir::MaskedLexer < Reference < Object

ScalaLexer is a hand-rolled structural lexer for Scala source, modelled on Noir::PhpLexer / Noir::CSharpLexer. The Scala analyzers used to strip each line in isolation (strip_non_code_with_state(line, 0, false)), resetting the block-comment depth and multiline-string flag on every line, so route-shaped DSL inside a """…""" triple-quoted string or a multi-line /* … */ comment leaked as phantom endpoints. This lexer threads that state across the whole file once.

Two masked views are produced, both the same length as the source with newlines preserved:

  • masked (structural): strings, comments, triple-quotes and char literals are all blanked — used for brace/paren matching.
  • code: comments and triple-quoted bodies are blanked, but regular "…" string literals and char literals are PRESERVED, because Scala routes and CLI options are literals (path("users"), opt('p', ...)) that the analyzers read back.

Scala specifics handled: nested block comments (/* /* */ */), triple-quoted raw strings spanning lines, regular strings with \ escapes, and 'x' / '\n' char literals (left as code when it is actually a 'sym symbol).

Constructors

new(source : String)
Source

Instance methods

code
Source
code_lines

Code masked source split into lines (1:1 with String#lines). Comments and triple-quote bodies are blanked; regular strings and chars kept.

Source
masked_lines

Structural masked source split into lines (1:1 with String#lines).

Source