klyn.code.SourceTokenCursor.fromSource
method
public static fromSource(tokenizer as Tokenizer, source as String, skipTrivia as Boolean = true) as SourceTokenCursor
Description

Tokenizes source with tokenizer and returns a ready-to-use SourceTokenCursor.

Parameters
ParameterDescription
tokenizerLanguage tokenizer to apply.
sourceFull source code text.
skipTriviatrue to skip whitespace and comments.
Returns

New SourceTokenCursor instance.

Example
import klyn.code
import klyn.code.klyn

cursor = SourceTokenCursor.fromSource(KlynTokenizer(), "class User:\n    pass")
assert cursor.next().text == "class"
assert cursor.next().text == "User"