class Noir::ScalaLexer

Overview

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:

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).

Defined in:

minilexers/scala_lexer.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(source : String) #

[View source]

Instance Method Detail

def code : Array(Char) #

[View source]
def code_lines : Array(String) #

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


[View source]
def in_code?(pos : Int32) : Bool #

[View source]
def masked : Array(Char) #

[View source]
def masked_lines : Array(String) #

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


[View source]
def matching_delimiter(open_pos : Int32) : Int32 | Nil #

[View source]
def skip_ranges : Array(Range(Int32, Int32)) #

[View source]
def statement_end(start_pos : Int32) : Int32 #

[View source]
def tokens : Array(ScalaToken) #

[View source]