klyn.code.Tokenizer.isCodePosition
method
public isCodePosition(line as String, column as Long, initialState as LexicalState = null) as Boolean
Description

Checks whether the zero-based column in line is a code position (outside comments and string/character/regex literals).

Parameters
ParameterDescription
lineSource line text.
columnZero-based column offset.
initialStateLexical state at the start of line.
Returns

true when column is in executable code.

Example
import klyn.code
import klyn.code.klyn

tokenizer = KlynTokenizer()
assert tokenizer.isCodePosition("x = 1 # comment", 2, LexicalState.NORMAL)
assert not tokenizer.isCodePosition("x = 1 # comment", 10, LexicalState.NORMAL)