Quoted atoms
This commit is contained in:
parent
1e087c8339
commit
43b364044e
5 changed files with 65 additions and 32 deletions
|
@ -7,7 +7,6 @@ import com.github.h0tk3y.betterParse.combinators.unaryMinus
|
|||
import com.github.h0tk3y.betterParse.combinators.use
|
||||
import com.github.h0tk3y.betterParse.grammar.parser
|
||||
import com.github.h0tk3y.betterParse.parser.Parser
|
||||
import prolog.ast.arithmetic.ArithmeticOperator
|
||||
import prolog.ast.arithmetic.Expression
|
||||
import prolog.ast.arithmetic.Float
|
||||
import prolog.ast.arithmetic.Integer
|
||||
|
@ -15,9 +14,16 @@ import prolog.ast.logic.LogicOperand
|
|||
import prolog.ast.terms.*
|
||||
|
||||
open class TermsGrammar : Tokens() {
|
||||
|
||||
// Basic named terms
|
||||
protected val variable: Parser<Variable> by variableToken use { Variable(text) }
|
||||
protected val atom: Parser<Atom> by nameToken use { Atom(text) }
|
||||
protected val simpleAtom: Parser<Atom> by nameToken use { Atom(text) }
|
||||
protected val quotedAtom: Parser<Atom> by (dummy
|
||||
or ticked
|
||||
or doubleTicked
|
||||
or backTicked
|
||||
) use { Atom(text.substring(1, text.length - 1)) }
|
||||
protected val atom: Parser<Atom> by (quotedAtom or simpleAtom)
|
||||
protected val compound: Parser<Structure> by (atom * -leftParenthesis * separated(
|
||||
parser(::term),
|
||||
comma,
|
||||
|
|
Reference in a new issue