ruler-core-1.0: examples/Internal.rul
{
{-# LANGUAGE BangPatterns #-}
module Internal where
import Control.Monad.Error
}
data D
con C
itf D
visit dispatch
inh ast :: D
syn x :: Int
syn z :: Int
{
foo =
sem foo : D monad IO
visit dispatch
clause C
internal bla -- internal clause: conditionally compute attributes
loc.p = 9
lhs.z = loc.p
clause other1
match False = True -- this clause will fail
loc.q = True
lhs.x = loc.p + const 3 lhs.ast
clause other2
lhs.x = 42 -- the result of this internal clause is returned
}
{
test :: D -> IO (Int, Int)
test d = do
let inh = Inh_D_dispatch { ast_Inh_D = d }
syn <- invoke_D_dispatch foo inh
let x = x_Syn_D syn
let z = z_Syn_D syn
return (x,z)
main :: IO ()
main = do let d = D_C
t <- test d
putStrLn $ show t
}