package parser

import com.github.h0tk3y.betterParse.grammar.Grammar
import com.github.h0tk3y.betterParse.grammar.parseToEnd
import interpreter.Preprocessor
import io.Logger
import parser.grammars.LogicGrammar
import prolog.ast.logic.Clause

class ScriptParser: Parser {
    private val grammar: Grammar<List<Clause>> = LogicGrammar() as Grammar<List<Clause>>
    private val preprocessor = Preprocessor()

    override fun parse(input: String): List<Clause> {
        val raw = grammar.parseToEnd(input)
        return preprocessor.preprocess(raw)
    }
}