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

[BUG] literal token with DefaultTokenizer can't find a match - 'noneMatched' #56

Closed
xetra11 opened this issue Jul 25, 2022 · 1 comment

Comments

@xetra11
Copy link

xetra11 commented Jul 25, 2022

I a trying to figure out how this library works but I simply can't get passed the simple literal token example.
Here is my test code:

    @Test
    fun `should match foo`() {
        val literal = literalToken("foo")
        val tokenizer = DefaultTokenizer(listOf(literal))
        val sequence: TokenMatchesSequence = tokenizer.tokenize("my foo")

        assertThat(sequence.toList()).isNotEmpty() // success
        assertThat(sequence[0]!!.input).isEqualTo("my foo") // success
        assertThat(sequence[0]!!.type).isNotEqualTo(noneMatched) // failure
        assertThat(sequence[0]!!.text).isEqualTo("foo") // never reached
    }

This fails with assertThat(sequence[0]!!.type).isNotEqualTo(noneMatched) since there is no match for the simple input of my foo and the literal token looking for foo.

Any idea what I am doing wrong?

Infos:

implementation("com.github.h1tk3y.betterParse:better-parse:0.4.4")

Greetings!

@xetra11
Copy link
Author

xetra11 commented Jul 25, 2022

Sorry I just realized I need to call parse on the Token - not check the sequence for a result

@xetra11 xetra11 closed this as completed Jul 25, 2022
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

1 participant