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

Looks like bug in description #1

Closed
semoro opened this issue Jul 12, 2017 · 2 comments
Closed

Looks like bug in description #1

semoro opened this issue Jul 12, 2017 · 2 comments

Comments

@semoro
Copy link

semoro commented Jul 12, 2017

interface Item
class Number(val value: Int) : Item
class Variable(val name: String) : Item

object ItemsParser : Grammar<Item>() {
    val num by token("\\d+")
    val word by token("[A-Za-z]")
    val comma by token(",\\s+")

    val numParser = num use { Number(text.toInt()) }
    val varParser = word use { Variable(text) }

    override val <!PROPERTY_TYPE_MISMATCH_ON_OVERRIDE!>rootParser<!> = separatedTerms(numParser or varParser, comma)
}

val result: List<Item> = ItemsParser.<!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>parseToEnd("one, 2, three, 4, five")<!>

Some errors reported on code copied from README

@semoro
Copy link
Author

semoro commented Jul 12, 2017

I think, T for Grammar should be List<Item> here

@h0tk3y
Copy link
Owner

h0tk3y commented Jul 12, 2017

Fixed, thanks.

@h0tk3y h0tk3y closed this as completed Jul 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants