Preprocessing
This commit is contained in:
parent
82a8fccf87
commit
174855d7a3
5 changed files with 284 additions and 7 deletions
28
tests/parser/OperatorParserTests.kt
Normal file
28
tests/parser/OperatorParserTests.kt
Normal file
|
@ -0,0 +1,28 @@
|
|||
package parser
|
||||
|
||||
import com.github.h0tk3y.betterParse.grammar.Grammar
|
||||
import com.github.h0tk3y.betterParse.grammar.parseToEnd
|
||||
import com.github.h0tk3y.betterParse.parser.Parser
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Test
|
||||
import parser.grammars.TermsGrammar
|
||||
import prolog.ast.terms.Atom
|
||||
import prolog.ast.terms.Operator
|
||||
import prolog.ast.terms.Structure
|
||||
|
||||
class OperatorParserTests {
|
||||
class OperatorParser: TermsGrammar() {
|
||||
override val rootParser: Parser<Operator> by operator
|
||||
}
|
||||
|
||||
private var parser = OperatorParser() as Grammar<Operator>
|
||||
|
||||
@Test
|
||||
fun `parse conjunction`() {
|
||||
val input = "a, b"
|
||||
|
||||
val result = parser.parseToEnd(input)
|
||||
|
||||
assertEquals(Structure(Atom(","), listOf(Atom("a"), Atom("b"))), result, "Expected atom 'a, b'")
|
||||
}
|
||||
}
|
Reference in a new issue