klyn.code.CodeTokenizer.stripLineComments
method
public stripLineComments(line as String, initialState as LexicalState, out endState as LexicalState) as String
Description

Strips line and block comments from a single line while preserving string literals and updating endState for multi-line block comments or strings.

Parameters
ParameterDescription
lineSingle source line.
initialStateLexical state at the start of line.
endStateReceives the lexical state at the end of line.
Returns

Source line with comments removed.

Example
import klyn.code
import klyn.code.klyn

t = KlynTokenizer()
endState = LexicalState.NORMAL
cleaned = t.stripLineComments("x = 1 # comment", LexicalState.NORMAL, out endState)
assert cleaned.toTrim() == "x = 1"