kesterel2lustre

compile Kernel Esterel to Lustre
git clone https://a3nm.net/git/kesterel2lustre/
Log | Files | Refs | README

esterel.hs (1113B)


      1 module Esterel where
      2 
      3 import qualified Data.Set as Set
      4 
      5 -- an Esterel module, polymorphic on the type of expression annotations
      6 data PModule e = Module Name [Sig] [Sig] (PExp e)
      7 -- the module name
      8 type Name = String
      9 
     10 -- the polymorphic expressions, with an annotation of type e
     11 data PExp e = Annotated (PExp2 e) e deriving (Show)
     12 -- the expressions themselves
     13 data PExp2 e = 
     14     Nothing
     15   | Emit Sig
     16   | Pause
     17   | Present Sig (PExp e) (PExp e)
     18   | Suspend (PExp e) Sig
     19   | Seq (PExp e) (PExp e)
     20   | Loop (PExp e)
     21   | Par (PExp e) (PExp e)
     22   | Trap Trap (PExp e)
     23   | Exit Trap
     24   | Signal Sig (PExp e)
     25   deriving (Show)
     26 
     27 -- the traps and signals
     28 type Sig = String
     29 type Trap = String
     30 
     31 -- expressions with no annotations
     32 type Exp = PExp ()
     33 
     34 -- a set of signals and traps that can be emitted or received
     35 type Scope = Set.Set Sig
     36 -- expressions annotated with their input and output signals (and traps)
     37 type ScopeExp = PExp (Scope, Scope)
     38 -- expressions further annotated with a unique identifier
     39 type ScopeLabelExp = PExp ((Scope, Scope), Int)
     40 
     41 -- the parsing environnement, which is unused
     42 data Environment = Empty
     43