Skip to content

Instantly share code, notes, and snippets.

@pedrofurla
Created February 15, 2014 21:54
Show Gist options
  • Select an option

  • Save pedrofurla/9025691 to your computer and use it in GitHub Desktop.

Select an option

Save pedrofurla/9025691 to your computer and use it in GitHub Desktop.
A little model for a subset of WebIdl
{-# LANGUAGE ExistentialQuantification #-}
module WebIdl.Ast where
import WebIdl.Lex
type Ident = String
type ExtAttributes = String
type Default = Maybe Literal
type ReadOnly = Bool
type Inherit = Bool
type Nullable = Bool
type Array = Bool
-- |
data Type = Type Ident Nullable Array deriving (Show, Eq)
data Callback = Callback Ident ExtAttributes CbDef deriving (Show, Eq)
data CbDef = CbDef Type [FormalArg] deriving (Show, Eq)
data FormalArg = FormalArg Type Ident Default deriving (Show, Eq)
data TypeDef = TypeDef Ident Type deriving (Show, Eq)
data Const = Const Ident Type Literal deriving (Show, Eq)
data Interface = Interface Ident ExtAttributes (Maybe Type) [IMember] deriving (Show, Eq)
data IMember =
Attribute Ident Type ReadOnly Inherit |
Operation Ident Type [FormalArg] deriving (Show, Eq)
-- data Definition =
data WebIdl = WebIdl [Either Interface Callback] deriving (Show,Eq)
data Box = forall a. Show a => Box a
instance Show Box where
show (Box a) = "Box " ++ show a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment