public isCodePosition(line as String, column as Long, initialState as LexicalState = null) as Boolean
Checks whether column in line is a code position (outside comments and string/character/regex literals).
| Parameter | Description |
|---|---|
line | Source line text. |
column | Zero-based column offset. |
initialState | Lexical state at the start of line. |
true when column is in executable code.
import klyn.code
p = LanguageProfile("klyn", "Klyn").withLineComments(["#"]).withStringDelimiters(["\""])
t = CodeTokenizer(p)
assert t.isCodePosition("x = \"hello\" # note", 2)
assert not t.isCodePosition("x = \"hello\" # note", 6)
assert not t.isCodePosition("x = \"hello\" # note", 15)