Skip to content

Instantly share code, notes, and snippets.

@fogus
Created October 18, 2011 12:45
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fogus/1295331 to your computer and use it in GitHub Desktop.
Save fogus/1295331 to your computer and use it in GitHub Desktop.
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
Copy link

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