Create a gist now

Instantly share code, notes, and snippets.

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].
}.
@frankshearar

What's the host language? I thought at first it was Smalltalk (which wouldn't be surprising, given that that was Ometa's first host language), but Clause new: sym : args is not valid Smalltalk syntax. It would need to be something like Clause new: sym args: args (note the characters prior to the :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment