IO Operators
This commit is contained in:
parent
b9f419a59d
commit
82a8fccf87
22 changed files with 450 additions and 199 deletions
|
@ -1,9 +1,12 @@
|
|||
package parser
|
||||
|
||||
import com.github.h0tk3y.betterParse.grammar.Grammar
|
||||
import com.github.h0tk3y.betterParse.grammar.parseToEnd
|
||||
import parser.grammars.QueryGrammar
|
||||
import prolog.builtins.Query
|
||||
|
||||
class ReplParser: Parser {
|
||||
override fun parse(input: String): Query {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
class ReplParser : Parser {
|
||||
private val grammar: Grammar<Query> = QueryGrammar() as Grammar<Query>
|
||||
|
||||
override fun parse(input: String): Query = grammar.parseToEnd(input)
|
||||
}
|
16
src/parser/grammars/QueryGrammar.kt
Normal file
16
src/parser/grammars/QueryGrammar.kt
Normal file
|
@ -0,0 +1,16 @@
|
|||
package parser.grammars
|
||||
|
||||
import com.github.h0tk3y.betterParse.combinators.times
|
||||
import com.github.h0tk3y.betterParse.combinators.unaryMinus
|
||||
import com.github.h0tk3y.betterParse.combinators.use
|
||||
import com.github.h0tk3y.betterParse.parser.Parser
|
||||
import prolog.ast.logic.LogicOperand
|
||||
import prolog.builtins.Query
|
||||
|
||||
class QueryGrammar : TermsGrammar() {
|
||||
protected val query: Parser<Query> by (body * -dot) use {
|
||||
Query(this as LogicOperand)
|
||||
}
|
||||
|
||||
override val rootParser: Parser<Any> by query
|
||||
}
|
Reference in a new issue