Lexer Building Options
import org.kiot.lexer.Lexer
val data = LexerData.buildSimple {
"\\d" action 1
"." action 2
}
/*
org.kiot.automaton.MarksConflictException:
FunctionMark(\d) conflicts with FunctionMark(.) under this pattern: [0..9]
*/import org.kiot.lexer.Lexer
val data = LexerData.buildSimple {
options.strict = false
"\\d" action 1
"." action 2
}
class SimpleLexer(chars: CharSequence) : Lexer<Nothing>(data, chars) {
override fun onAction(action: Int) {
when (action) {
1 -> println("a digit")
2 -> println("a char")
}
}
}
SimpleLexer("1").lex()
// output: a digit
SimpleLexer("2").lex()
// output: a charLast updated