(* main.rml *)
module Main:
  relation main: string list => ()
end

with "parse.rml"
with "static.rml"
with "flatten.rml"
with "fcemit.rml"

relation emit =
  rule	FCEmit.emit fcode
	----------------
	emit fcode

  rule	not FCEmit.emit fcode & print "FCEmit.emit failed\n"
	----------------
	emit fcode => fail
end

relation flatten =
  rule	Flatten.flatten tcode => fcode & emit fcode
	----------------
	flatten tcode

  rule	not Flatten.flatten tcode => _ & print "Flatten.flatten failed\n"
	----------------
	flatten tcode => fail
end

relation static =
  rule	Static.elaborate ast => tcode & flatten tcode
	----------------
	static ast

  rule	not Static.elaborate ast => _ & print "Static.elaborate failed\n"
	----------------
	static ast => fail
end

relation parse =
  rule	Parse.parse file => ast & static ast
	----------------
	parse file

  rule	not Parse.parse file => _ & print "Parse.parse failed\n"
	----------------
	parse file => fail
end

relation main =
  rule	parse file
	----------------
	main file::_
end
