You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have to say that this is the best parser library for Kotlin right now. One thing that's less-than-trivial to implement is a case-insensitive variant of string(), which kind of requires a copy-paste of the string() implementation:
fun ParserState.stringIgnoreCase(expected:String): String {
if (position + expected.length > input.length) {
fail("Expected '$expected', but got EOF.")
}
if (!input.regionMatches(position, expected, 0, expected.length, ignoreCase =true)) {
fail(
"Expected '$expected' (ignoring case), but got "+"'${input.substring(position, position + expected.length)}'."
)
}
position += expected.length
return expected
}
funstringIgnoreCase(expected:String): Parser<String> = parser { stringIgnoreCase(expected) }
As you can see, the only way this differs from string() is the addition of the ignoreCase argument to regionMatches. Would it make sense to add a parameter like ignoreCase = false to the existing string atom?
The text was updated successfully, but these errors were encountered:
I have to say that this is the best parser library for Kotlin right now. One thing that's less-than-trivial to implement is a case-insensitive variant of
string()
, which kind of requires a copy-paste of thestring()
implementation:As you can see, the only way this differs from
string()
is the addition of theignoreCase
argument toregionMatches
. Would it make sense to add a parameter likeignoreCase = false
to the existingstring
atom?The text was updated successfully, but these errors were encountered: