-- Haskel data types for the abstract syntax. -- Generated by the BNF converter. {-# LANGUAGE GeneralizedNewtypeDeriving #-} -- | The abstract syntax of language Java. module AbsJava where import qualified Prelude as T (Double, Integer, String) import qualified Prelude as C (Eq, Ord, Show, Read) import Data.String data ProgramFile = ProgF [Import] [TypeDeclaration] -- ^ ProgramFile ::= Import TypeDeclaration | Prpkg [Ident] [Semi] [Import] [TypeDeclaration] -- ^ ProgramFile ::= "package" Ident Semi Import TypeDeclaration deriving (C.Eq, C.Ord, C.Show, C.Read) data Import = ImportA [Ident] [Semi] -- ^ Import ::= "import" Ident ".*" Semi | ImportN [Ident] [Semi] -- ^ Import ::= "import" Ident Semi deriving (C.Eq, C.Ord, C.Show, C.Read) data TypeDeclaration = TypeDecl ClassHeader [FieldDeclaration] -- ^ TypeDeclaration ::= ClassHeader "{" FieldDeclaration "}" deriving (C.Eq, C.Ord, C.Show, C.Read) data ClassHeader = ClassDec [Modifier] Ident -- ^ ClassHeader ::= Modifier "class" Ident | ClassDecE [Modifier] Ident [TypeName] -- ^ ClassHeader ::= Modifier "class" Ident "extends" TypeName | ClassDecEI [Modifier] Ident [TypeName] [TypeName] -- ^ ClassHeader ::= Modifier "class" Ident "extends" TypeName "implements" TypeName | ClassDecI [Modifier] Ident [TypeName] -- ^ ClassHeader ::= Modifier "class" Ident "implements" TypeName | InterDec [Modifier] Ident -- ^ ClassHeader ::= Modifier "interface" Ident | InterDecE [Modifier] Ident [TypeName] -- ^ ClassHeader ::= Modifier "interface" Ident "extends" TypeName | InterDecEI [Modifier] Ident [TypeName] [TypeName] -- ^ ClassHeader ::= Modifier "interface" Ident "extends" TypeName "implements" TypeName | InterDecI [Modifier] Ident [TypeName] -- ^ ClassHeader ::= Modifier "interface" Ident "implements" TypeName deriving (C.Eq, C.Ord, C.Show, C.Read) data FieldDeclaration = Dblk Body -- ^ FieldDeclaration ::= Body | Dconst [Modifier] Ident [Parameter] Body -- ^ FieldDeclaration ::= Modifier Ident "(" Parameter ")" Body | Dconstt [Modifier] Ident [Parameter] [TypeName] Body -- ^ FieldDeclaration ::= Modifier Ident "(" Parameter ")" "throws" TypeName Body | Dinnerclass TypeDeclaration -- ^ FieldDeclaration ::= TypeDeclaration | Dmth [Modifier] TypeSpec MethodDecl MethodBody -- ^ FieldDeclaration ::= Modifier TypeSpec MethodDecl MethodBody | Dmthth [Modifier] TypeSpec MethodDecl [TypeName] MethodBody -- ^ FieldDeclaration ::= Modifier TypeSpec MethodDecl "throws" TypeName MethodBody | Dvar [Modifier] TypeSpec [VarDecl] -- ^ FieldDeclaration ::= Modifier TypeSpec VarDecl ";" deriving (C.Eq, C.Ord, C.Show, C.Read) data MethodBody = IBody -- ^ MethodBody ::= ";" | MBody Body -- ^ MethodBody ::= Body deriving (C.Eq, C.Ord, C.Show, C.Read) data LVarStatement = LVar TypeSpec [VarDecl] -- ^ LVarStatement ::= TypeSpec VarDecl ";" | LVarf TypeSpec [VarDecl] -- ^ LVarStatement ::= "final" TypeSpec VarDecl ";" | Statem Stm -- ^ LVarStatement ::= Stm deriving (C.Eq, C.Ord, C.Show, C.Read) data Body = BodyImpl [LVarStatement] -- ^ Body ::= "{" LVarStatement "}" deriving (C.Eq, C.Ord, C.Show, C.Read) data Stm = Case Exp -- ^ Stm ::= "case" Exp ":" | Dflt -- ^ Stm ::= "default" ":" | Exps Exp -- ^ Stm ::= Exp ";" | Grd GuardStm -- ^ Stm ::= GuardStm | Iter IterStm -- ^ Stm ::= IterStm | Jmp JumpStm -- ^ Stm ::= JumpStm | LV [LVarStatement] -- ^ Stm ::= "{" LVarStatement "}" | Lbl Ident -- ^ Stm ::= Ident ":" | Sel SelectionStm -- ^ Stm ::= SelectionStm | Sem -- ^ Stm ::= ";" deriving (C.Eq, C.Ord, C.Show, C.Read) data DeclaratorName = DeclArray Ident [BracketsOpt] -- ^ DeclaratorName ::= Ident BracketsOpt | DeclName Ident -- ^ DeclaratorName ::= Ident deriving (C.Eq, C.Ord, C.Show, C.Read) data VarDecl = VDecl Ident -- ^ VarDecl ::= Ident | VDeclAssign DeclaratorName VariableInits -- ^ VarDecl ::= DeclaratorName "=" VariableInits deriving (C.Eq, C.Ord, C.Show, C.Read) data VariableInits = IArri ArrayInits -- ^ VariableInits ::= "{" ArrayInits "}" | IEmpt -- ^ VariableInits ::= "{" "}" | IExp Exp -- ^ VariableInits ::= Exp deriving (C.Eq, C.Ord, C.Show, C.Read) data ArrayInits = Vai ArrayInits VariableInits -- ^ ArrayInits ::= ArrayInits "," VariableInits | Vainit VariableInits -- ^ ArrayInits ::= VariableInits | Vais ArrayInits -- ^ ArrayInits ::= ArrayInits "," deriving (C.Eq, C.Ord, C.Show, C.Read) data MethodDecl = Mth DeclaratorName [Parameter] -- ^ MethodDecl ::= DeclaratorName "(" Parameter ")" | MthdArr MethodDecl BracketsOpt -- ^ MethodDecl ::= MethodDecl BracketsOpt deriving (C.Eq, C.Ord, C.Show, C.Read) data Parameter = Param TypeSpec DeclaratorName -- ^ Parameter ::= TypeSpec DeclaratorName | Pfinal TypeSpec DeclaratorName -- ^ Parameter ::= "final" TypeSpec DeclaratorName deriving (C.Eq, C.Ord, C.Show, C.Read) data SelectionStm = If Exp Stm [ElseIfStm] Stm -- ^ SelectionStm ::= "if" "(" Exp ")" Stm ElseIfStm "else" Stm | Ifone Exp Stm [ElseIfStm] -- ^ SelectionStm ::= "if" "(" Exp ")" Stm ElseIfStm | Switch Exp Body -- ^ SelectionStm ::= "switch" "(" Exp ")" Body deriving (C.Eq, C.Ord, C.Show, C.Read) data ElseIfStm = Elseif Exp Stm -- ^ ElseIfStm ::= "else if" "(" Exp ")" Stm deriving (C.Eq, C.Ord, C.Show, C.Read) data JumpStm = Break -- ^ JumpStm ::= "break" ";" | Brlabel Ident -- ^ JumpStm ::= "break" Ident ";" | Continue -- ^ JumpStm ::= "continue" ";" | Continuelabel Ident -- ^ JumpStm ::= "continue" Ident ";" | Return -- ^ JumpStm ::= "return" ";" | ReturnExp Exp -- ^ JumpStm ::= "return" Exp ";" | Throw Exp -- ^ JumpStm ::= "throw" Exp ";" deriving (C.Eq, C.Ord, C.Show, C.Read) data GuardStm = Synchronized Exp Body -- ^ GuardStm ::= "synchronized" "(" Exp ")" Body | Try Body [Catch] -- ^ GuardStm ::= "try" Body Catch | Tryfinally Body [Catch] Body -- ^ GuardStm ::= "try" Body Catch "finally" Body deriving (C.Eq, C.Ord, C.Show, C.Read) data Catch = Catch1 TypeSpec Ident Body -- ^ Catch ::= "catch" "(" TypeSpec Ident ")" Body | Catch2 TypeSpec Body -- ^ Catch ::= "catch" "(" TypeSpec ")" Body deriving (C.Eq, C.Ord, C.Show, C.Read) data IterStm = Do Stm Exp -- ^ IterStm ::= "do" Stm "while" "(" Exp ")" | For ForInit [Exp] [Exp] Stm -- ^ IterStm ::= "for" "(" ForInit Exp ";" Exp ")" Stm | While Exp Stm -- ^ IterStm ::= "while" "(" Exp ")" Stm deriving (C.Eq, C.Ord, C.Show, C.Read) data ForInit = DeclVar TypeSpec [VarDecl] -- ^ ForInit ::= TypeSpec VarDecl ";" | DeclVarFinal TypeSpec [VarDecl] -- ^ ForInit ::= "final" TypeSpec VarDecl ";" | Exprs1 [Exp] -- ^ ForInit ::= Exp ";" deriving (C.Eq, C.Ord, C.Show, C.Read) data Modifier = Mabstract -- ^ Modifier ::= "abstract" | Mfinal -- ^ Modifier ::= "final" | Mnative -- ^ Modifier ::= "native" | Mprivate -- ^ Modifier ::= "private" | Mprotected -- ^ Modifier ::= "protected" | Mpublic -- ^ Modifier ::= "public" | Mstatic -- ^ Modifier ::= "static" | Msync -- ^ Modifier ::= "synchronized" | Mtransient -- ^ Modifier ::= "transient" | Mvolatile -- ^ Modifier ::= "volatile" deriving (C.Eq, C.Ord, C.Show, C.Read) data BasicType = Tboolean -- ^ BasicType ::= "boolean" | Tbyte -- ^ BasicType ::= "byte" | Tchar -- ^ BasicType ::= "char" | Tdouble -- ^ BasicType ::= "double" | Tfloat -- ^ BasicType ::= "float" | Tint -- ^ BasicType ::= "int" | Tlong -- ^ BasicType ::= "long" | Tshort -- ^ BasicType ::= "short" deriving (C.Eq, C.Ord, C.Show, C.Read) data TypeSpec = ArrayType TypeName [BracketsOpt] -- ^ TypeSpec ::= TypeName BracketsOpt | NamedType TypeName -- ^ TypeSpec ::= TypeName deriving (C.Eq, C.Ord, C.Show, C.Read) data TypeName = BuiltIn BasicType -- ^ TypeName ::= BasicType | ClassType [Ident] -- ^ TypeName ::= Ident deriving (C.Eq, C.Ord, C.Show, C.Read) data BracketsOpt = BracketsEmpty -- ^ BracketsOpt ::= "[]" deriving (C.Eq, C.Ord, C.Show, C.Read) data Exp = Earr ArrAcc -- ^ Exp ::= ArrAcc | Earrcoercion [Ident] [BracketsOpt] Exp -- ^ Exp ::= "(" Ident BracketsOpt ")" Exp13 | Eassign Exp Assignment_op Exp -- ^ Exp ::= Exp14 Assignment_op Exp | Ebcoercion BasicType Exp -- ^ Exp ::= "(" BasicType ")" Exp13 | Ebitand Exp Exp -- ^ Exp ::= Exp7 "&" Exp8 | Ebitexor Exp Exp -- ^ Exp ::= Exp6 "^" Exp7 | Ebitor Exp Exp -- ^ Exp ::= Exp5 "|" Exp6 | Econdition Exp Exp Exp -- ^ Exp ::= Exp3 "?" Exp ":" Exp2 | Econst Constant -- ^ Exp ::= Constant | Ediv Exp Exp -- ^ Exp ::= Exp12 "/" Exp13 | Eeq Exp Exp -- ^ Exp ::= Exp8 "==" Exp9 | Eexpcoercion Exp Exp -- ^ Exp ::= "(" Exp ")" Exp15 | Efld FieldAcc -- ^ Exp ::= FieldAcc | Ege Exp Exp -- ^ Exp ::= Exp9 ">=" Exp10 | Egrthen Exp Exp -- ^ Exp ::= Exp9 ">" Exp10 | Eland Exp Exp -- ^ Exp ::= Exp4 "&&" Exp5 | Ele Exp Exp -- ^ Exp ::= Exp9 "<=" Exp10 | Eleft Exp Exp -- ^ Exp ::= Exp10 "<<" Exp11 | Elor Exp Exp -- ^ Exp ::= Exp3 "||" Exp4 | Elthen Exp Exp -- ^ Exp ::= Exp9 "<" Exp10 | Eminus Exp Exp -- ^ Exp ::= Exp11 "-" Exp12 | Emod Exp Exp -- ^ Exp ::= Exp12 "%" Exp13 | Emth MthCall -- ^ Exp ::= MthCall | Eneq Exp Exp -- ^ Exp ::= Exp8 "!=" Exp9 | Enewalloc NewAlloc -- ^ Exp ::= NewAlloc | Eplus Exp Exp -- ^ Exp ::= Exp11 "+" Exp12 | Epostdec Exp -- ^ Exp ::= Exp15 "--" | Epostinc Exp -- ^ Exp ::= Exp15 "++" | Epredec Exp -- ^ Exp ::= "--" Exp14 | Epreinc Exp -- ^ Exp ::= "++" Exp14 | Epreop Unary_operator Exp -- ^ Exp ::= Unary_operator Exp13 | Eright Exp Exp -- ^ Exp ::= Exp10 ">>" Exp11 | Especname SpecName -- ^ Exp ::= SpecName | Estring T.String -- ^ Exp ::= String | Etimes Exp Exp -- ^ Exp ::= Exp12 "*" Exp13 | Etrip Exp Exp -- ^ Exp ::= Exp10 ">>>" Exp11 | Etype Exp TypeName -- ^ Exp ::= Exp14 "instanceof" TypeName | Evar [Ident] -- ^ Exp ::= Ident deriving (C.Eq, C.Ord, C.Show, C.Read) data SpecName = SSnull -- ^ SpecName ::= "null" | SSsuper -- ^ SpecName ::= "super" | SSthis -- ^ SpecName ::= "this" deriving (C.Eq, C.Ord, C.Show, C.Read) data NewAlloc = Anewarray TypeName [DimExpr] -- ^ NewAlloc ::= "new" TypeName DimExpr | Anewarriempty TypeName [DimExpr] -- ^ NewAlloc ::= "new" TypeName DimExpr "{" "}" | Anewarrinits TypeName [DimExpr] ArrayInits -- ^ NewAlloc ::= "new" TypeName DimExpr "{" ArrayInits "}" | Anewclass TypeName Args -- ^ NewAlloc ::= "new" TypeName Args | Anewinnerclass TypeName Args [FieldDeclaration] -- ^ NewAlloc ::= "new" TypeName Args "{" FieldDeclaration "}" deriving (C.Eq, C.Ord, C.Show, C.Read) data ArrAcc = Aarr [Ident] Exp -- ^ ArrAcc ::= Ident "[" Exp "]" | Aarr1 SpecExp Exp -- ^ ArrAcc ::= SpecExp "[" Exp "]" deriving (C.Eq, C.Ord, C.Show, C.Read) data SpecExp = Cep Exp -- ^ SpecExp ::= "(" Exp ")" | Cnp SpecExpNP -- ^ SpecExp ::= SpecExpNP | Cthis SpecName -- ^ SpecExp ::= SpecName deriving (C.Eq, C.Ord, C.Show, C.Read) data SpecExpNP = CNLit Constant -- ^ SpecExpNP ::= Constant | CNParr ArrAcc -- ^ SpecExpNP ::= ArrAcc | CNPfld FieldAcc -- ^ SpecExpNP ::= FieldAcc | CNPmth MthCall -- ^ SpecExpNP ::= MthCall deriving (C.Eq, C.Ord, C.Show, C.Read) data MthCall = Mmth [Ident] Args -- ^ MthCall ::= Ident Args | Mmth1 SpecExpNP Args -- ^ MthCall ::= SpecExpNP Args | Mmthspec SpecName Args -- ^ MthCall ::= SpecName Args deriving (C.Eq, C.Ord, C.Show, C.Read) data FieldAcc = Fclass [Ident] -- ^ FieldAcc ::= Ident ".class" | Ffclass2 BasicType -- ^ FieldAcc ::= BasicType ".class" | Ffthis [Ident] -- ^ FieldAcc ::= Ident ".this" | Ffvar SpecExp Ident -- ^ FieldAcc ::= SpecExp "." Ident | Ffvar1 NewAlloc Ident -- ^ FieldAcc ::= NewAlloc "." Ident deriving (C.Eq, C.Ord, C.Show, C.Read) data Args = ArgList [Exp] -- ^ Args ::= "(" Exp ")" deriving (C.Eq, C.Ord, C.Show, C.Read) data DimExpr = Dim Exp -- ^ DimExpr ::= "[" Exp "]" deriving (C.Eq, C.Ord, C.Show, C.Read) data Constant = Ecdouble JDouble -- ^ Constant ::= JDouble | Ecfloat JFloat -- ^ Constant ::= JFloat | Echar JChar -- ^ Constant ::= JChar | Eclongdouble JLongDouble -- ^ Constant ::= JLongDouble | Edouble T.Double -- ^ Constant ::= Double | Efalse -- ^ Constant ::= "false" | Efloat T.Double -- ^ Constant ::= Double | Ehexadec Hexadecimal -- ^ Constant ::= Hexadecimal | Ehexalong HexLong -- ^ Constant ::= HexLong | Ehexaunsign HexUnsigned -- ^ Constant ::= HexUnsigned | Ehexaunslong HexUnsLong -- ^ Constant ::= HexUnsLong | Eint T.Integer -- ^ Constant ::= Integer | Elong Long -- ^ Constant ::= Long | Elonger T.Integer -- ^ Constant ::= Integer | Eoctal Octal -- ^ Constant ::= Octal | Eoctallong OctalLong -- ^ Constant ::= OctalLong | Eoctalunsign OctalUnsigned -- ^ Constant ::= OctalUnsigned | Eoctalunslong OctalUnsLong -- ^ Constant ::= OctalUnsLong | Etrue -- ^ Constant ::= "true" | Eunicode UnicodeChar -- ^ Constant ::= UnicodeChar | Eunsigned Unsigned -- ^ Constant ::= Unsigned | Eunsignlong UnsignedLong -- ^ Constant ::= UnsignedLong deriving (C.Eq, C.Ord, C.Show, C.Read) data Unary_operator = Complement -- ^ Unary_operator ::= "~" | Logicalneg -- ^ Unary_operator ::= "!" | Negative -- ^ Unary_operator ::= "-" | Plus -- ^ Unary_operator ::= "+" deriving (C.Eq, C.Ord, C.Show, C.Read) data Assignment_op = Assign -- ^ Assignment_op ::= "=" | AssignAdd -- ^ Assignment_op ::= "+=" | AssignAnd -- ^ Assignment_op ::= "&=" | AssignDiv -- ^ Assignment_op ::= "/=" | AssignLeft -- ^ Assignment_op ::= "<<=" | AssignMod -- ^ Assignment_op ::= "%=" | AssignMul -- ^ Assignment_op ::= "*=" | AssignOr -- ^ Assignment_op ::= "|=" | AssignRight -- ^ Assignment_op ::= ">>=" | AssignSub -- ^ Assignment_op ::= "-=" | AssignTrip -- ^ Assignment_op ::= ">>>=" | AssignXor -- ^ Assignment_op ::= "^=" deriving (C.Eq, C.Ord, C.Show, C.Read) data Semi = Sem1 -- ^ Semi ::= ";" deriving (C.Eq, C.Ord, C.Show, C.Read) newtype Ident = Ident T.String deriving (C.Eq, C.Ord, C.Show, C.Read, Data.String.IsString) newtype Unsigned = Unsigned T.String deriving (C.Eq, C.Ord, C.Show, C.Read, Data.String.IsString) newtype Long = Long T.String deriving (C.Eq, C.Ord, C.Show, C.Read, Data.String.IsString) newtype UnsignedLong = UnsignedLong T.String deriving (C.Eq, C.Ord, C.Show, C.Read, Data.String.IsString) newtype Hexadecimal = Hexadecimal T.String deriving (C.Eq, C.Ord, C.Show, C.Read, Data.String.IsString) newtype HexUnsigned = HexUnsigned T.String deriving (C.Eq, C.Ord, C.Show, C.Read, Data.String.IsString) newtype HexLong = HexLong T.String deriving (C.Eq, C.Ord, C.Show, C.Read, Data.String.IsString) newtype HexUnsLong = HexUnsLong T.String deriving (C.Eq, C.Ord, C.Show, C.Read, Data.String.IsString) newtype Octal = Octal T.String deriving (C.Eq, C.Ord, C.Show, C.Read, Data.String.IsString) newtype OctalUnsigned = OctalUnsigned T.String deriving (C.Eq, C.Ord, C.Show, C.Read, Data.String.IsString) newtype OctalLong = OctalLong T.String deriving (C.Eq, C.Ord, C.Show, C.Read, Data.String.IsString) newtype OctalUnsLong = OctalUnsLong T.String deriving (C.Eq, C.Ord, C.Show, C.Read, Data.String.IsString) newtype JDouble = JDouble T.String deriving (C.Eq, C.Ord, C.Show, C.Read, Data.String.IsString) newtype JFloat = JFloat T.String deriving (C.Eq, C.Ord, C.Show, C.Read, Data.String.IsString) newtype JLongDouble = JLongDouble T.String deriving (C.Eq, C.Ord, C.Show, C.Read, Data.String.IsString) newtype UnicodeChar = UnicodeChar T.String deriving (C.Eq, C.Ord, C.Show, C.Read, Data.String.IsString) newtype JChar = JChar T.String deriving (C.Eq, C.Ord, C.Show, C.Read, Data.String.IsString)