Created
October 18, 2011 12:45
-
-
Save fogus/1295331 to your computer and use it in GitHub Desktop.
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]. | |
}. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 likeClause new: sym args: args
(note the characters prior to the:
).