Say I am interested in creating a JVM-based implementation of Prolog. I would like to know if it is possible to use an existing JVM language for emulating the Prolog syntax, instead of relying on a Prolog parser that takes as an input a text file with Prolog code.
In Prolog you can define facts, rules, and the tricky part is that you can also define new operators at a very fine-grained level: you can specify the operator position, precedence and associativity.
Some simple examples below:
Facts:
father(john, peter).
mother(susan, peter).
male(john).
...
Rules:
parent(X, Y) :- father(X, Y).
parent(X, Y) :- mother(X, Y).
Operators:
op(100,xfx, is-father-of)
Rule using operator:
X is-father-of Y :- male(X), parent(X,Y).
I took a look to Groovy but it does not seem to allow to define new operators. To the best of my knowledge Scala allows to define operators but I do not think a statically-typed language will help me here. Is there a JVM language that could help me to do this?
Am I condemned to make use of a Prolog parser if I want to do this in the JVM?