Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SourceLocation.toPreetyDoc acts wrong & add checks for tupleOf #1

Closed
duangsuse opened this issue Mar 1, 2020 · 4 comments
Closed
Labels
bug Something isn't working enhancement New feature or request

Comments

@duangsuse
Copy link
Contributor

duangsuse commented Mar 1, 2020

>>> elementIn('a'..'c').clam().read(input)
res111: kotlin.Char? = null
>>> es
res112: kotlin.collections.List<org.parserkt.pat.LocatedError /* = kotlin.Pair<org.parserkt.SourceLocation, org.parserkt.ErrorMessage /* = kotlin.String */> */> = [(<string>10#0, expecting [a-c])]
>>> tupleOf(::Point, 3, 4, 5)
java.lang.ArrayIndexOutOfBoundsException: Index 2 out of bounds for length 2
	at org.parserkt.util.Tuple.set(ArrangeModel.kt:48)
@duangsuse
Copy link
Contributor Author

Looks like the first error is introduced by a change to make operator fun PP.plus have lower memory allocation cost (flatten JoinBy list), that's a bug.

https://github.com/ParserKt/ParserKt/blob/master/src/commonMain/kotlin/org/parserkt/InputModel.kt#L23

@duangsuse duangsuse added bug Something isn't working enhancement New feature or request labels Mar 1, 2020
@duangsuse
Copy link
Contributor Author

val num = RepeatUn(asInt(), LexicalBasics.digitFor('0'..'9')) { it.toString().map { it-'0' } }
val timeUnit = PairedKeywordPattern<Int>().apply { mergeStrings("s" to 1, "min" to 60, "hr" to 60*60) }
val time = TrieNumUnit(num, timeUnit, IntOps)

Please also update this code example in the code

@duangsuse
Copy link
Contributor Author

🐛 Also, for NumUnit there's a bug cause joinUnitsInitial won't return whole chain, but does continue reading

@duangsuse
Copy link
Contributor Author

(3+1 issues fixed)

duangsuse added a commit that referenced this issue Mar 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant