from raco import RACompiler
from raco.language import MyriaAlgebra
from raco.algebra import LogicalAlgebra

# A simple join
query = """
A(x,z) :- R(x,y), S(y,z)
"""

def comment(s):
  print "/*\n%s\n*/" % str(s)

# Create a cmpiler object
dlog = RACompiler()

# parse the query
dlog.fromDatalog(query)
print dlog.logicalplan

dlog.optimize(target=MyriaAlgebra, eliminate_common_subexpressions=False)

# generate code in the target language
code = dlog.compile()
print code


@@ -305,25 +305,185 @@
 int 
-dlog.logicalplan%0A
+%22************ LOGICAL PLAN *************%22%0Aprint dlog.logicalplan%0Aprint%0A%0A# Optimize the query, includes producing a physical plan%0Aprint %22************ PHYSICAL PLAN *************%22
 %0Adlo
@@ -552,16 +552,46 @@
 s=False)
+%0Aprint dlog.physicalplan%0Aprint
 %0A%0A# gene
@@ -645,16 +645,56 @@
 mpile()%0A
+print %22************ CODE *************%22%0A
 print co
@@ -696,9 +696,14 @@
 nt code%0A
+print
 %0A

make what it outputs obvious