1 Abstract syntax for Java subset that is the target of Mondrian.
2 The syntax has been taken from "The Java Language Specification".
4 (c) Erik Meijer & Arjan van IJzendoorn
13 %************************************************************************
15 \subsection{Java type declararations}
17 %************************************************************************
26 | Field [Modifier] Type Name (Maybe Expr)
27 | Constructor [Modifier] Name [Parameter] [Statement]
28 | Method [Modifier] Type Name [Parameter] [Statement]
30 | Interface [Modifier] Name [Name] [Decl]
31 | Class [Modifier] Name [Name] [Name] [Decl]
35 = Parameter [Modifier] Type Name
43 | Declaration Decl -- variable = inner Field, Class = innerclass
44 | IfThenElse [(Expr,Statement)] (Maybe Statement)
45 | Switch Expr [(Expr, [Statement])] (Maybe [Statement])
54 | InstanceOf Expr Type
55 | Call Expr Name [Expr]
57 | New Name [Expr] (Maybe [Decl]) -- anonymous innerclass
58 | NewArray Name [Expr]
67 = Public | Protected | Private
69 | Abstract | Final | Native | Synchronized | Transient | Volatile
70 deriving (Show, Eq, Ord)
76 | UIntLit Int -- Unboxed
77 | CharLit Char -- Boxed
78 | UCharLit Char -- Unboxed
82 addModifier :: Modifier -> Decl -> Decl
83 addModifier = \m -> \d ->
85 { Import n -> Import n
86 ; Field ms t n e -> Field (m:ms) t n e
87 ; Constructor ms n as ss -> Constructor (m:ms) n as ss
88 ; Method ms t n as ss -> Method (m:ms) t n as ss
89 ; Comment ss -> Comment ss
90 ; Interface ms n xs ds -> Interface (m:ms) n xs ds
91 ; Class ms n xs is ds -> Class (m:ms) n xs is ds
94 areSimple :: [Expr] -> Bool
95 areSimple = \es -> all isSimple es
97 isSimple :: Expr -> Bool
100 { Cast t e -> isSimple e
101 ; Access e n -> isSimple e
102 ; Assign l r -> isSimple l && isSimple r
103 ; InstanceOf e t -> isSimple e
104 ; Call e n es -> isSimple e && areSimple es
105 ; Op e1 o e2 -> False
106 ; New n es Nothing -> areSimple es
107 ; New n es (Just ds) -> False