-- Haskel data types for the abstract syntax.
-- Generated by the BNF converter.

{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE PatternSynonyms #-}

-- | 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
  , Functor
  , Foldable
  , Traversable
  , Int, Maybe(..) )

import Data.String

type ProgramFile = ProgramFile' BNFC'Position
data ProgramFile' a
    = ProgF a [Import' a] [TypeDeclaration' a]
    -- ^ ProgramFile ::= Import TypeDeclaration
    | Prpkg a [Ident] [Semi' a] [Import' a] [TypeDeclaration' a]
    -- ^ ProgramFile ::= "package" Ident Semi Import TypeDeclaration
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type Import = Import' BNFC'Position
data Import' a
    = ImportA a [Ident] [Semi' a]
    -- ^ Import ::= "import" Ident ".*" Semi
    | ImportN a [Ident] [Semi' a]
    -- ^ Import ::= "import" Ident Semi
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type TypeDeclaration = TypeDeclaration' BNFC'Position
data TypeDeclaration' a
    = TypeDecl a (ClassHeader' a) [FieldDeclaration' a]
    -- ^ TypeDeclaration ::= ClassHeader "{" FieldDeclaration "}"
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type ClassHeader = ClassHeader' BNFC'Position
data ClassHeader' a
    = ClassDec a [Modifier' a] Ident
    -- ^ ClassHeader ::= Modifier "class" Ident
    | ClassDecE a [Modifier' a] Ident [TypeName' a]
    -- ^ ClassHeader ::= Modifier "class" Ident "extends" TypeName
    | ClassDecEI a [Modifier' a] Ident [TypeName' a] [TypeName' a]
    -- ^ ClassHeader ::= Modifier "class" Ident "extends" TypeName "implements" TypeName
    | ClassDecI a [Modifier' a] Ident [TypeName' a]
    -- ^ ClassHeader ::= Modifier "class" Ident "implements" TypeName
    | InterDec a [Modifier' a] Ident
    -- ^ ClassHeader ::= Modifier "interface" Ident
    | InterDecE a [Modifier' a] Ident [TypeName' a]
    -- ^ ClassHeader ::= Modifier "interface" Ident "extends" TypeName
    | InterDecEI a [Modifier' a] Ident [TypeName' a] [TypeName' a]
    -- ^ ClassHeader ::= Modifier "interface" Ident "extends" TypeName "implements" TypeName
    | InterDecI a [Modifier' a] Ident [TypeName' a]
    -- ^ ClassHeader ::= Modifier "interface" Ident "implements" TypeName
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type FieldDeclaration = FieldDeclaration' BNFC'Position
data FieldDeclaration' a
    = Dblk a (Body' a)
    -- ^ FieldDeclaration ::= Body
    | Dconst a [Modifier' a] Ident [Parameter' a] (Body' a)
    -- ^ FieldDeclaration ::= Modifier Ident "(" Parameter ")" Body
    | Dconstt a [Modifier' a] Ident [Parameter' a] [TypeName' a] (Body' a)
    -- ^ FieldDeclaration ::= Modifier Ident "(" Parameter ")" "throws" TypeName Body
    | Dinnerclass a (TypeDeclaration' a)
    -- ^ FieldDeclaration ::= TypeDeclaration
    | Dmth a [Modifier' a] (TypeSpec' a) (MethodDecl' a) (MethodBody' a)
    -- ^ FieldDeclaration ::= Modifier TypeSpec MethodDecl MethodBody
    | Dmthth a [Modifier' a] (TypeSpec' a) (MethodDecl' a) [TypeName' a] (MethodBody' a)
    -- ^ FieldDeclaration ::= Modifier TypeSpec MethodDecl "throws" TypeName MethodBody
    | Dvar a [Modifier' a] (TypeSpec' a) [VarDecl' a]
    -- ^ FieldDeclaration ::= Modifier TypeSpec VarDecl ";"
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type MethodBody = MethodBody' BNFC'Position
data MethodBody' a
    = IBody a
    -- ^ MethodBody ::= ";"
    | MBody a (Body' a)
    -- ^ MethodBody ::= Body
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type LVarStatement = LVarStatement' BNFC'Position
data LVarStatement' a
    = LVar a (TypeSpec' a) [VarDecl' a]
    -- ^ LVarStatement ::= TypeSpec VarDecl ";"
    | LVarf a (TypeSpec' a) [VarDecl' a]
    -- ^ LVarStatement ::= "final" TypeSpec VarDecl ";"
    | Statem a (Stm' a)
    -- ^ LVarStatement ::= Stm
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type Body = Body' BNFC'Position
data Body' a
    = BodyImpl a [LVarStatement' a]
    -- ^ Body ::= "{" LVarStatement "}"
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type Stm = Stm' BNFC'Position
data Stm' a
    = Case a (Exp' a)
    -- ^ Stm ::= "case" Exp ":"
    | Dflt a
    -- ^ Stm ::= "default" ":"
    | Exps a (Exp' a)
    -- ^ Stm ::= Exp ";"
    | Grd a (GuardStm' a)
    -- ^ Stm ::= GuardStm
    | Iter a (IterStm' a)
    -- ^ Stm ::= IterStm
    | Jmp a (JumpStm' a)
    -- ^ Stm ::= JumpStm
    | LV a [LVarStatement' a]
    -- ^ Stm ::= "{" LVarStatement "}"
    | Lbl a Ident
    -- ^ Stm ::= Ident ":"
    | Sel a (SelectionStm' a)
    -- ^ Stm ::= SelectionStm
    | Sem a
    -- ^ Stm ::= ";"
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type DeclaratorName = DeclaratorName' BNFC'Position
data DeclaratorName' a
    = DeclArray a Ident [BracketsOpt' a]
    -- ^ DeclaratorName ::= Ident BracketsOpt
    | DeclName a Ident
    -- ^ DeclaratorName ::= Ident
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type VarDecl = VarDecl' BNFC'Position
data VarDecl' a
    = VDecl a Ident
    -- ^ VarDecl ::= Ident
    | VDeclAssign a (DeclaratorName' a) (VariableInits' a)
    -- ^ VarDecl ::= DeclaratorName "=" VariableInits
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type VariableInits = VariableInits' BNFC'Position
data VariableInits' a
    = IArri a (ArrayInits' a)
    -- ^ VariableInits ::= "{" ArrayInits "}"
    | IEmpt a
    -- ^ VariableInits ::= "{" "}"
    | IExp a (Exp' a)
    -- ^ VariableInits ::= Exp
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type ArrayInits = ArrayInits' BNFC'Position
data ArrayInits' a
    = Vai a (ArrayInits' a) (VariableInits' a)
    -- ^ ArrayInits ::= ArrayInits "," VariableInits
    | Vainit a (VariableInits' a)
    -- ^ ArrayInits ::= VariableInits
    | Vais a (ArrayInits' a)
    -- ^ ArrayInits ::= ArrayInits ","
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type MethodDecl = MethodDecl' BNFC'Position
data MethodDecl' a
    = Mth a (DeclaratorName' a) [Parameter' a]
    -- ^ MethodDecl ::= DeclaratorName "(" Parameter ")"
    | MthdArr a (MethodDecl' a) (BracketsOpt' a)
    -- ^ MethodDecl ::= MethodDecl BracketsOpt
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type Parameter = Parameter' BNFC'Position
data Parameter' a
    = Param a (TypeSpec' a) (DeclaratorName' a)
    -- ^ Parameter ::= TypeSpec DeclaratorName
    | Pfinal a (TypeSpec' a) (DeclaratorName' a)
    -- ^ Parameter ::= "final" TypeSpec DeclaratorName
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type SelectionStm = SelectionStm' BNFC'Position
data SelectionStm' a
    = If a (Exp' a) (Stm' a) [ElseIfStm' a] (Stm' a)
    -- ^ SelectionStm ::= "if" "(" Exp ")" Stm ElseIfStm "else" Stm
    | Ifone a (Exp' a) (Stm' a) [ElseIfStm' a]
    -- ^ SelectionStm ::= "if" "(" Exp ")" Stm ElseIfStm
    | Switch a (Exp' a) (Body' a)
    -- ^ SelectionStm ::= "switch" "(" Exp ")" Body
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type ElseIfStm = ElseIfStm' BNFC'Position
data ElseIfStm' a
    = Elseif a (Exp' a) (Stm' a)
    -- ^ ElseIfStm ::= "else if" "(" Exp ")" Stm
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type JumpStm = JumpStm' BNFC'Position
data JumpStm' a
    = Break a
    -- ^ JumpStm ::= "break" ";"
    | Brlabel a Ident
    -- ^ JumpStm ::= "break" Ident ";"
    | Continue a
    -- ^ JumpStm ::= "continue" ";"
    | Continuelabel a Ident
    -- ^ JumpStm ::= "continue" Ident ";"
    | Return a
    -- ^ JumpStm ::= "return" ";"
    | ReturnExp a (Exp' a)
    -- ^ JumpStm ::= "return" Exp ";"
    | Throw a (Exp' a)
    -- ^ JumpStm ::= "throw" Exp ";"
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type GuardStm = GuardStm' BNFC'Position
data GuardStm' a
    = Synchronized a (Exp' a) (Body' a)
    -- ^ GuardStm ::= "synchronized" "(" Exp ")" Body
    | Try a (Body' a) [Catch' a]
    -- ^ GuardStm ::= "try" Body Catch
    | Tryfinally a (Body' a) [Catch' a] (Body' a)
    -- ^ GuardStm ::= "try" Body Catch "finally" Body
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type Catch = Catch' BNFC'Position
data Catch' a
    = Catch1 a (TypeSpec' a) Ident (Body' a)
    -- ^ Catch ::= "catch" "(" TypeSpec Ident ")" Body
    | Catch2 a (TypeSpec' a) (Body' a)
    -- ^ Catch ::= "catch" "(" TypeSpec ")" Body
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type IterStm = IterStm' BNFC'Position
data IterStm' a
    = Do a (Stm' a) (Exp' a)
    -- ^ IterStm ::= "do" Stm "while" "(" Exp ")"
    | For a (ForInit' a) [Exp' a] [Exp' a] (Stm' a)
    -- ^ IterStm ::= "for" "(" ForInit Exp ";" Exp ")" Stm
    | While a (Exp' a) (Stm' a)
    -- ^ IterStm ::= "while" "(" Exp ")" Stm
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type ForInit = ForInit' BNFC'Position
data ForInit' a
    = DeclVar a (TypeSpec' a) [VarDecl' a]
    -- ^ ForInit ::= TypeSpec VarDecl ";"
    | DeclVarFinal a (TypeSpec' a) [VarDecl' a]
    -- ^ ForInit ::= "final" TypeSpec VarDecl ";"
    | Exprs1 a [Exp' a]
    -- ^ ForInit ::= Exp ";"
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type Modifier = Modifier' BNFC'Position
data Modifier' a
    = Mabstract a
    -- ^ Modifier ::= "abstract"
    | Mfinal a
    -- ^ Modifier ::= "final"
    | Mnative a
    -- ^ Modifier ::= "native"
    | Mprivate a
    -- ^ Modifier ::= "private"
    | Mprotected a
    -- ^ Modifier ::= "protected"
    | Mpublic a
    -- ^ Modifier ::= "public"
    | Mstatic a
    -- ^ Modifier ::= "static"
    | Msync a
    -- ^ Modifier ::= "synchronized"
    | Mtransient a
    -- ^ Modifier ::= "transient"
    | Mvolatile a
    -- ^ Modifier ::= "volatile"
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type BasicType = BasicType' BNFC'Position
data BasicType' a
    = Tboolean a
    -- ^ BasicType ::= "boolean"
    | Tbyte a
    -- ^ BasicType ::= "byte"
    | Tchar a
    -- ^ BasicType ::= "char"
    | Tdouble a
    -- ^ BasicType ::= "double"
    | Tfloat a
    -- ^ BasicType ::= "float"
    | Tint a
    -- ^ BasicType ::= "int"
    | Tlong a
    -- ^ BasicType ::= "long"
    | Tshort a
    -- ^ BasicType ::= "short"
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type TypeSpec = TypeSpec' BNFC'Position
data TypeSpec' a
    = ArrayType a (TypeName' a) [BracketsOpt' a]
    -- ^ TypeSpec ::= TypeName BracketsOpt
    | NamedType a (TypeName' a)
    -- ^ TypeSpec ::= TypeName
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type TypeName = TypeName' BNFC'Position
data TypeName' a
    = BuiltIn a (BasicType' a)
    -- ^ TypeName ::= BasicType
    | ClassType a [Ident]
    -- ^ TypeName ::= Ident
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type BracketsOpt = BracketsOpt' BNFC'Position
data BracketsOpt' a
    = BracketsEmpty a
    -- ^ BracketsOpt ::= "[]"
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type Exp = Exp' BNFC'Position
data Exp' a
    = Earr a (ArrAcc' a)
    -- ^ Exp ::= ArrAcc
    | Earrcoercion a [Ident] [BracketsOpt' a] (Exp' a)
    -- ^ Exp ::= "(" Ident BracketsOpt ")" Exp13
    | Eassign a (Exp' a) (Assignment_op' a) (Exp' a)
    -- ^ Exp ::= Exp14 Assignment_op Exp
    | Ebcoercion a (BasicType' a) (Exp' a)
    -- ^ Exp ::= "(" BasicType ")" Exp13
    | Ebitand a (Exp' a) (Exp' a)
    -- ^ Exp ::= Exp7 "&" Exp8
    | Ebitexor a (Exp' a) (Exp' a)
    -- ^ Exp ::= Exp6 "^" Exp7
    | Ebitor a (Exp' a) (Exp' a)
    -- ^ Exp ::= Exp5 "|" Exp6
    | Econdition a (Exp' a) (Exp' a) (Exp' a)
    -- ^ Exp ::= Exp3 "?" Exp ":" Exp2
    | Econst a (Constant' a)
    -- ^ Exp ::= Constant
    | Ediv a (Exp' a) (Exp' a)
    -- ^ Exp ::= Exp12 "/" Exp13
    | Eeq a (Exp' a) (Exp' a)
    -- ^ Exp ::= Exp8 "==" Exp9
    | Eexpcoercion a (Exp' a) (Exp' a)
    -- ^ Exp ::= "(" Exp ")" Exp15
    | Efld a (FieldAcc' a)
    -- ^ Exp ::= FieldAcc
    | Ege a (Exp' a) (Exp' a)
    -- ^ Exp ::= Exp9 ">=" Exp10
    | Egrthen a (Exp' a) (Exp' a)
    -- ^ Exp ::= Exp9 ">" Exp10
    | Eland a (Exp' a) (Exp' a)
    -- ^ Exp ::= Exp4 "&&" Exp5
    | Ele a (Exp' a) (Exp' a)
    -- ^ Exp ::= Exp9 "<=" Exp10
    | Eleft a (Exp' a) (Exp' a)
    -- ^ Exp ::= Exp10 "<<" Exp11
    | Elor a (Exp' a) (Exp' a)
    -- ^ Exp ::= Exp3 "||" Exp4
    | Elthen a (Exp' a) (Exp' a)
    -- ^ Exp ::= Exp9 "<" Exp10
    | Eminus a (Exp' a) (Exp' a)
    -- ^ Exp ::= Exp11 "-" Exp12
    | Emod a (Exp' a) (Exp' a)
    -- ^ Exp ::= Exp12 "%" Exp13
    | Emth a (MthCall' a)
    -- ^ Exp ::= MthCall
    | Eneq a (Exp' a) (Exp' a)
    -- ^ Exp ::= Exp8 "!=" Exp9
    | Enewalloc a (NewAlloc' a)
    -- ^ Exp ::= NewAlloc
    | Eplus a (Exp' a) (Exp' a)
    -- ^ Exp ::= Exp11 "+" Exp12
    | Epostdec a (Exp' a)
    -- ^ Exp ::= Exp15 "--"
    | Epostinc a (Exp' a)
    -- ^ Exp ::= Exp15 "++"
    | Epredec a (Exp' a)
    -- ^ Exp ::= "--" Exp14
    | Epreinc a (Exp' a)
    -- ^ Exp ::= "++" Exp14
    | Epreop a (Unary_operator' a) (Exp' a)
    -- ^ Exp ::= Unary_operator Exp13
    | Eright a (Exp' a) (Exp' a)
    -- ^ Exp ::= Exp10 ">>" Exp11
    | Especname a (SpecName' a)
    -- ^ Exp ::= SpecName
    | Estring a T.String
    -- ^ Exp ::= String
    | Etimes a (Exp' a) (Exp' a)
    -- ^ Exp ::= Exp12 "*" Exp13
    | Etrip a (Exp' a) (Exp' a)
    -- ^ Exp ::= Exp10 ">>>" Exp11
    | Etype a (Exp' a) (TypeName' a)
    -- ^ Exp ::= Exp14 "instanceof" TypeName
    | Evar a [Ident]
    -- ^ Exp ::= Ident
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type SpecName = SpecName' BNFC'Position
data SpecName' a
    = SSnull a
    -- ^ SpecName ::= "null"
    | SSsuper a
    -- ^ SpecName ::= "super"
    | SSthis a
    -- ^ SpecName ::= "this"
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type NewAlloc = NewAlloc' BNFC'Position
data NewAlloc' a
    = Anewarray a (TypeName' a) [DimExpr' a]
    -- ^ NewAlloc ::= "new" TypeName DimExpr
    | Anewarriempty a (TypeName' a) [DimExpr' a]
    -- ^ NewAlloc ::= "new" TypeName DimExpr "{" "}"
    | Anewarrinits a (TypeName' a) [DimExpr' a] (ArrayInits' a)
    -- ^ NewAlloc ::= "new" TypeName DimExpr "{" ArrayInits "}"
    | Anewclass a (TypeName' a) (Args' a)
    -- ^ NewAlloc ::= "new" TypeName Args
    | Anewinnerclass a (TypeName' a) (Args' a) [FieldDeclaration' a]
    -- ^ NewAlloc ::= "new" TypeName Args "{" FieldDeclaration "}"
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type ArrAcc = ArrAcc' BNFC'Position
data ArrAcc' a
    = Aarr a [Ident] (Exp' a)
    -- ^ ArrAcc ::= Ident "[" Exp "]"
    | Aarr1 a (SpecExp' a) (Exp' a)
    -- ^ ArrAcc ::= SpecExp "[" Exp "]"
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type SpecExp = SpecExp' BNFC'Position
data SpecExp' a
    = Cep a (Exp' a)
    -- ^ SpecExp ::= "(" Exp ")"
    | Cnp a (SpecExpNP' a)
    -- ^ SpecExp ::= SpecExpNP
    | Cthis a (SpecName' a)
    -- ^ SpecExp ::= SpecName
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type SpecExpNP = SpecExpNP' BNFC'Position
data SpecExpNP' a
    = CNLit a (Constant' a)
    -- ^ SpecExpNP ::= Constant
    | CNParr a (ArrAcc' a)
    -- ^ SpecExpNP ::= ArrAcc
    | CNPfld a (FieldAcc' a)
    -- ^ SpecExpNP ::= FieldAcc
    | CNPmth a (MthCall' a)
    -- ^ SpecExpNP ::= MthCall
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type MthCall = MthCall' BNFC'Position
data MthCall' a
    = Mmth a [Ident] (Args' a)
    -- ^ MthCall ::= Ident Args
    | Mmth1 a (SpecExpNP' a) (Args' a)
    -- ^ MthCall ::= SpecExpNP Args
    | Mmthspec a (SpecName' a) (Args' a)
    -- ^ MthCall ::= SpecName Args
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type FieldAcc = FieldAcc' BNFC'Position
data FieldAcc' a
    = Fclass a [Ident]
    -- ^ FieldAcc ::= Ident ".class"
    | Ffclass2 a (BasicType' a)
    -- ^ FieldAcc ::= BasicType ".class"
    | Ffthis a [Ident]
    -- ^ FieldAcc ::= Ident ".this"
    | Ffvar a (SpecExp' a) Ident
    -- ^ FieldAcc ::= SpecExp "." Ident
    | Ffvar1 a (NewAlloc' a) Ident
    -- ^ FieldAcc ::= NewAlloc "." Ident
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type Args = Args' BNFC'Position
data Args' a
    = ArgList a [Exp' a]
    -- ^ Args ::= "(" Exp ")"
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type DimExpr = DimExpr' BNFC'Position
data DimExpr' a
    = Dim a (Exp' a)
    -- ^ DimExpr ::= "[" Exp "]"
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type Constant = Constant' BNFC'Position
data Constant' a
    = Ecdouble a JDouble
    -- ^ Constant ::= JDouble
    | Ecfloat a JFloat
    -- ^ Constant ::= JFloat
    | Echar a JChar
    -- ^ Constant ::= JChar
    | Eclongdouble a JLongDouble
    -- ^ Constant ::= JLongDouble
    | Edouble a T.Double
    -- ^ Constant ::= Double
    | Efalse a
    -- ^ Constant ::= "false"
    | Efloat a T.Double
    -- ^ Constant ::= Double
    | Ehexadec a Hexadecimal
    -- ^ Constant ::= Hexadecimal
    | Ehexalong a HexLong
    -- ^ Constant ::= HexLong
    | Ehexaunsign a HexUnsigned
    -- ^ Constant ::= HexUnsigned
    | Ehexaunslong a HexUnsLong
    -- ^ Constant ::= HexUnsLong
    | Eint a T.Integer
    -- ^ Constant ::= Integer
    | Elong a Long
    -- ^ Constant ::= Long
    | Elonger a T.Integer
    -- ^ Constant ::= Integer
    | Eoctal a Octal
    -- ^ Constant ::= Octal
    | Eoctallong a OctalLong
    -- ^ Constant ::= OctalLong
    | Eoctalunsign a OctalUnsigned
    -- ^ Constant ::= OctalUnsigned
    | Eoctalunslong a OctalUnsLong
    -- ^ Constant ::= OctalUnsLong
    | Etrue a
    -- ^ Constant ::= "true"
    | Eunicode a UnicodeChar
    -- ^ Constant ::= UnicodeChar
    | Eunsigned a Unsigned
    -- ^ Constant ::= Unsigned
    | Eunsignlong a UnsignedLong
    -- ^ Constant ::= UnsignedLong
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type Unary_operator = Unary_operator' BNFC'Position
data Unary_operator' a
    = Complement a
    -- ^ Unary_operator ::= "~"
    | Logicalneg a
    -- ^ Unary_operator ::= "!"
    | Negative a
    -- ^ Unary_operator ::= "-"
    | Plus a
    -- ^ Unary_operator ::= "+"
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type Assignment_op = Assignment_op' BNFC'Position
data Assignment_op' a
    = Assign a
    -- ^ Assignment_op ::= "="
    | AssignAdd a
    -- ^ Assignment_op ::= "+="
    | AssignAnd a
    -- ^ Assignment_op ::= "&="
    | AssignDiv a
    -- ^ Assignment_op ::= "/="
    | AssignLeft a
    -- ^ Assignment_op ::= "<<="
    | AssignMod a
    -- ^ Assignment_op ::= "%="
    | AssignMul a
    -- ^ Assignment_op ::= "*="
    | AssignOr a
    -- ^ Assignment_op ::= "|="
    | AssignRight a
    -- ^ Assignment_op ::= ">>="
    | AssignSub a
    -- ^ Assignment_op ::= "-="
    | AssignTrip a
    -- ^ Assignment_op ::= ">>>="
    | AssignXor a
    -- ^ Assignment_op ::= "^="
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

type Semi = Semi' BNFC'Position
data Semi' a
    = Sem1 a
    -- ^ Semi ::= ";"
  deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

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)

-- | Start position (line, column) of something.

type BNFC'Position = C.Maybe (C.Int, C.Int)

pattern BNFC'NoPosition :: BNFC'Position
pattern BNFC'NoPosition = C.Nothing

pattern BNFC'Position :: C.Int -> C.Int -> BNFC'Position
pattern BNFC'Position line col = C.Just (line, col)

-- | Get the start position of something.

class HasPosition a where
  hasPosition :: a -> BNFC'Position

instance HasPosition ProgramFile where
  hasPosition = \case
    ProgF p _ _ -> p
    Prpkg p _ _ _ _ -> p

instance HasPosition Import where
  hasPosition = \case
    ImportA p _ _ -> p
    ImportN p _ _ -> p

instance HasPosition TypeDeclaration where
  hasPosition = \case
    TypeDecl p _ _ -> p

instance HasPosition ClassHeader where
  hasPosition = \case
    ClassDec p _ _ -> p
    ClassDecE p _ _ _ -> p
    ClassDecEI p _ _ _ _ -> p
    ClassDecI p _ _ _ -> p
    InterDec p _ _ -> p
    InterDecE p _ _ _ -> p
    InterDecEI p _ _ _ _ -> p
    InterDecI p _ _ _ -> p

instance HasPosition FieldDeclaration where
  hasPosition = \case
    Dblk p _ -> p
    Dconst p _ _ _ _ -> p
    Dconstt p _ _ _ _ _ -> p
    Dinnerclass p _ -> p
    Dmth p _ _ _ _ -> p
    Dmthth p _ _ _ _ _ -> p
    Dvar p _ _ _ -> p

instance HasPosition MethodBody where
  hasPosition = \case
    IBody p -> p
    MBody p _ -> p

instance HasPosition LVarStatement where
  hasPosition = \case
    LVar p _ _ -> p
    LVarf p _ _ -> p
    Statem p _ -> p

instance HasPosition Body where
  hasPosition = \case
    BodyImpl p _ -> p

instance HasPosition Stm where
  hasPosition = \case
    Case p _ -> p
    Dflt p -> p
    Exps p _ -> p
    Grd p _ -> p
    Iter p _ -> p
    Jmp p _ -> p
    LV p _ -> p
    Lbl p _ -> p
    Sel p _ -> p
    Sem p -> p

instance HasPosition DeclaratorName where
  hasPosition = \case
    DeclArray p _ _ -> p
    DeclName p _ -> p

instance HasPosition VarDecl where
  hasPosition = \case
    VDecl p _ -> p
    VDeclAssign p _ _ -> p

instance HasPosition VariableInits where
  hasPosition = \case
    IArri p _ -> p
    IEmpt p -> p
    IExp p _ -> p

instance HasPosition ArrayInits where
  hasPosition = \case
    Vai p _ _ -> p
    Vainit p _ -> p
    Vais p _ -> p

instance HasPosition MethodDecl where
  hasPosition = \case
    Mth p _ _ -> p
    MthdArr p _ _ -> p

instance HasPosition Parameter where
  hasPosition = \case
    Param p _ _ -> p
    Pfinal p _ _ -> p

instance HasPosition SelectionStm where
  hasPosition = \case
    If p _ _ _ _ -> p
    Ifone p _ _ _ -> p
    Switch p _ _ -> p

instance HasPosition ElseIfStm where
  hasPosition = \case
    Elseif p _ _ -> p

instance HasPosition JumpStm where
  hasPosition = \case
    Break p -> p
    Brlabel p _ -> p
    Continue p -> p
    Continuelabel p _ -> p
    Return p -> p
    ReturnExp p _ -> p
    Throw p _ -> p

instance HasPosition GuardStm where
  hasPosition = \case
    Synchronized p _ _ -> p
    Try p _ _ -> p
    Tryfinally p _ _ _ -> p

instance HasPosition Catch where
  hasPosition = \case
    Catch1 p _ _ _ -> p
    Catch2 p _ _ -> p

instance HasPosition IterStm where
  hasPosition = \case
    Do p _ _ -> p
    For p _ _ _ _ -> p
    While p _ _ -> p

instance HasPosition ForInit where
  hasPosition = \case
    DeclVar p _ _ -> p
    DeclVarFinal p _ _ -> p
    Exprs1 p _ -> p

instance HasPosition Modifier where
  hasPosition = \case
    Mabstract p -> p
    Mfinal p -> p
    Mnative p -> p
    Mprivate p -> p
    Mprotected p -> p
    Mpublic p -> p
    Mstatic p -> p
    Msync p -> p
    Mtransient p -> p
    Mvolatile p -> p

instance HasPosition BasicType where
  hasPosition = \case
    Tboolean p -> p
    Tbyte p -> p
    Tchar p -> p
    Tdouble p -> p
    Tfloat p -> p
    Tint p -> p
    Tlong p -> p
    Tshort p -> p

instance HasPosition TypeSpec where
  hasPosition = \case
    ArrayType p _ _ -> p
    NamedType p _ -> p

instance HasPosition TypeName where
  hasPosition = \case
    BuiltIn p _ -> p
    ClassType p _ -> p

instance HasPosition BracketsOpt where
  hasPosition = \case
    BracketsEmpty p -> p

instance HasPosition Exp where
  hasPosition = \case
    Earr p _ -> p
    Earrcoercion p _ _ _ -> p
    Eassign p _ _ _ -> p
    Ebcoercion p _ _ -> p
    Ebitand p _ _ -> p
    Ebitexor p _ _ -> p
    Ebitor p _ _ -> p
    Econdition p _ _ _ -> p
    Econst p _ -> p
    Ediv p _ _ -> p
    Eeq p _ _ -> p
    Eexpcoercion p _ _ -> p
    Efld p _ -> p
    Ege p _ _ -> p
    Egrthen p _ _ -> p
    Eland p _ _ -> p
    Ele p _ _ -> p
    Eleft p _ _ -> p
    Elor p _ _ -> p
    Elthen p _ _ -> p
    Eminus p _ _ -> p
    Emod p _ _ -> p
    Emth p _ -> p
    Eneq p _ _ -> p
    Enewalloc p _ -> p
    Eplus p _ _ -> p
    Epostdec p _ -> p
    Epostinc p _ -> p
    Epredec p _ -> p
    Epreinc p _ -> p
    Epreop p _ _ -> p
    Eright p _ _ -> p
    Especname p _ -> p
    Estring p _ -> p
    Etimes p _ _ -> p
    Etrip p _ _ -> p
    Etype p _ _ -> p
    Evar p _ -> p

instance HasPosition SpecName where
  hasPosition = \case
    SSnull p -> p
    SSsuper p -> p
    SSthis p -> p

instance HasPosition NewAlloc where
  hasPosition = \case
    Anewarray p _ _ -> p
    Anewarriempty p _ _ -> p
    Anewarrinits p _ _ _ -> p
    Anewclass p _ _ -> p
    Anewinnerclass p _ _ _ -> p

instance HasPosition ArrAcc where
  hasPosition = \case
    Aarr p _ _ -> p
    Aarr1 p _ _ -> p

instance HasPosition SpecExp where
  hasPosition = \case
    Cep p _ -> p
    Cnp p _ -> p
    Cthis p _ -> p

instance HasPosition SpecExpNP where
  hasPosition = \case
    CNLit p _ -> p
    CNParr p _ -> p
    CNPfld p _ -> p
    CNPmth p _ -> p

instance HasPosition MthCall where
  hasPosition = \case
    Mmth p _ _ -> p
    Mmth1 p _ _ -> p
    Mmthspec p _ _ -> p

instance HasPosition FieldAcc where
  hasPosition = \case
    Fclass p _ -> p
    Ffclass2 p _ -> p
    Ffthis p _ -> p
    Ffvar p _ _ -> p
    Ffvar1 p _ _ -> p

instance HasPosition Args where
  hasPosition = \case
    ArgList p _ -> p

instance HasPosition DimExpr where
  hasPosition = \case
    Dim p _ -> p

instance HasPosition Constant where
  hasPosition = \case
    Ecdouble p _ -> p
    Ecfloat p _ -> p
    Echar p _ -> p
    Eclongdouble p _ -> p
    Edouble p _ -> p
    Efalse p -> p
    Efloat p _ -> p
    Ehexadec p _ -> p
    Ehexalong p _ -> p
    Ehexaunsign p _ -> p
    Ehexaunslong p _ -> p
    Eint p _ -> p
    Elong p _ -> p
    Elonger p _ -> p
    Eoctal p _ -> p
    Eoctallong p _ -> p
    Eoctalunsign p _ -> p
    Eoctalunslong p _ -> p
    Etrue p -> p
    Eunicode p _ -> p
    Eunsigned p _ -> p
    Eunsignlong p _ -> p

instance HasPosition Unary_operator where
  hasPosition = \case
    Complement p -> p
    Logicalneg p -> p
    Negative p -> p
    Plus p -> p

instance HasPosition Assignment_op where
  hasPosition = \case
    Assign p -> p
    AssignAdd p -> p
    AssignAnd p -> p
    AssignDiv p -> p
    AssignLeft p -> p
    AssignMod p -> p
    AssignMul p -> p
    AssignOr p -> p
    AssignRight p -> p
    AssignSub p -> p
    AssignTrip p -> p
    AssignXor p -> p

instance HasPosition Semi where
  hasPosition = \case
    Sem1 p -> p