This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ometa PrologTranslator : Parser { | |
variable ::= <spaces> <firstAndRest #upper #letterOrDigit>:name => [Var new: (name join: '')]. | |
symbol ::= <spaces> <firstAndRest #lower #letterOrDigit>:name => [Sym new: (name join: '')]. | |
clause ::= <symbol>:sym <token '('> <listOf #expr ','>:args <token ')'> => [Clause new: sym : args]. | |
expr ::= <clause> | <variable> | <symbol>. | |
clauses ::= <listOf #clause ','>. | |
rule ::= <clause>:head <token ':-'> <clauses>:body <token '.'> => [Rule new: head : body] | |
| <clause>:head <token '.'> => [Rule new: head : {}]. | |
rules ::= <rule>*:rs <spaces> <end> => [rs]. | |
query ::= <clause>:c <spaces> <end> => [c]. |