hssqlppp (empty) → 0.0.4
raw patch · 13 files changed
+10867/−0 lines, 13 filesdep +HDBCdep +HDBC-postgresqldep +HUnitsetup-changed
Dependencies added: HDBC, HDBC-postgresql, HUnit, base, containers, directory, haskell98, mtl, parsec, pretty, regex-posix, test-framework, test-framework-hunit
Files
- Database/HsSqlPpp/Ast.hs +7767/−0
- Database/HsSqlPpp/Parser.lhs +1260/−0
- Database/HsSqlPpp/PrettyPrinter.lhs +538/−0
- HsSqlSystem.lhs +374/−0
- LICENSE +31/−0
- README +156/−0
- Setup.lhs +4/−0
- TODO +281/−0
- Tests.lhs +20/−0
- development +124/−0
- hssqlppp.cabal +51/−0
- questions +88/−0
- usage +173/−0
+ Database/HsSqlPpp/Ast.hs view
@@ -0,0 +1,7767 @@+++-- UUAGC 0.9.10 (Ast.ag)+module Database.HsSqlPpp.Ast(+ -- exports+ MySourcePos++ --ast nodes+ ,Statement (..)+ ,SelectExpression (..)+ ,FnBody (..)+ ,SetClause (..)+ ,TableRef (..)+ ,JoinExpression (..)+ ,JoinType (..)+ ,SelectList (..)+ ,SelectItem (..)+ ,CopySource (..)+ ,AttributeDef (..)+ ,RowConstraint (..)+ ,Constraint (..)+ ,TypeAttributeDef (..)+ ,ParamDef (..)+ ,VarDef (..)+ ,RaiseType (..)+ ,CombineType (..)+ ,Volatility (..)+ ,Language (..)+ ,TypeName (..)+ ,DropType (..)+ ,Cascade (..)+ ,Direction (..)+ ,Distinct (..)+ ,Natural (..)+ ,IfExists (..)+ ,RestartIdentity (..)+ ,Expression (..)+ ,OperatorType (..)+ ,getOperatorType+ ,InList (..)+ ,StatementList+ --checking stuff+ ,Message (..)+ ,MessageStuff (..)+ --types+ ,Type (..)+ ,PseudoType (..)+ ,TypeErrorInfo (..)+ ,StatementInfo (..)+ --scope+ ,Scope(..)+ ,defaultScope+ ,emptyScope+ --fns+ ,checkAst+ ,getExpressionType+ ,getStatementsType+ ,getStatementsTypeScope+ ,getStatementsInfo+ ,getStatementsInfoScope+ ,resetSps+ ,resetSp+ ,resetSp'+ ,resetSps'+ ,nsp+ --forward some defs+ ,typeSmallInt+ ,typeBigInt+ ,typeInt+ ,typeNumeric+ ,typeFloat4+ ,typeFloat8+ ,typeVarChar+ ,typeChar+ ,typeBool++) where++import Data.Maybe+import Data.List+import Debug.Trace+import Control.Monad.Error+import Control.Arrow++import Database.HsSqlPpp.TypeType+import Database.HsSqlPpp.AstUtils+import Database.HsSqlPpp.TypeConversion+import Database.HsSqlPpp.TypeCheckingH+import Database.HsSqlPpp.Scope+import Database.HsSqlPpp.DefaultScope+++checkAst :: StatementList -> [Message]+checkAst sts = let t = sem_Root (Root sts)+ in (messages_Syn_Root (wrap_Root t Inh_Root {scope_Inh_Root = defaultScope}))+{-+================================================================================++= Types++These are the utility functions which clients use to typecheck sql.++-}++getExpressionType :: Scope -> Expression -> Type+getExpressionType scope ex =+ let t = sem_ExpressionRoot (ExpressionRoot ex)+ in (nodeType_Syn_ExpressionRoot+ (wrap_ExpressionRoot t Inh_ExpressionRoot {scope_Inh_ExpressionRoot = combineScopes defaultScope scope}))+++getStatementsType :: StatementList -> [Type]+getStatementsType = getStatementsTypeScope emptyScope++getStatementsTypeScope :: Scope -> StatementList -> [Type]+getStatementsTypeScope scope st =+ let t = sem_Root (Root st)+ ta = wrap_Root t Inh_Root {scope_Inh_Root = combineScopes defaultScope scope}+ tl = nodeType_Syn_Root ta+ in (unwrapTypeList tl)++getStatementsInfo :: StatementList -> [StatementInfo]+getStatementsInfo = getStatementsInfoScope emptyScope++getStatementsInfoScope :: Scope -> StatementList -> [StatementInfo]+getStatementsInfoScope scope st =+ let t = sem_Root (Root st)+ ta = wrap_Root t Inh_Root {scope_Inh_Root = combineScopes defaultScope scope}+ t2 = statementInfo_Syn_Root ta+ in t2+++--hack job, often not interested in the source positions when testing+--the asts produced, so this function will reset all the source+--positions to empty ("", 0, 0) so we can compare them for equality, etc.+--without having to get the positions correct.++resetSps :: [Statement] -> [Statement]+resetSps = map resetSp++resetSp :: Statement -> Statement+resetSp (CreateFunction l n p r bq b v) = CreateFunction l n p r bq+ (case b of+ SqlFnBody stss -> SqlFnBody (map resetSp' stss)+ PlpgsqlFnBody vd stss -> PlpgsqlFnBody vd (map resetSp' stss))+ v+resetSp (ForSelectStatement v s stss) = ForSelectStatement v s (map resetSp' stss)+resetSp (ForIntegerStatement v f t stss) = ForIntegerStatement v f t (map resetSp' stss)+resetSp (CaseStatement v cs els) = CaseStatement v (map (second (map resetSp')) cs) (map resetSp' els)+resetSp (If cs els) = If (map (second (map resetSp')) cs) (map resetSp' els)+resetSp a = a++resetSp' :: SourcePosStatement -> SourcePosStatement+resetSp' (_,st) = (nsp,resetSp st)++resetSps' :: StatementList -> StatementList+resetSps' = map resetSp'++nsp :: MySourcePos+nsp = ("", 0,0)+++setUnknown :: Type -> Type -> Type+setUnknown _ _ = UnknownType++appendTypeList :: Type -> Type -> Type+appendTypeList t1 (TypeList ts) = TypeList (t1:ts)+appendTypeList t1 t2 = TypeList [t1,t2]+++data StatementInfo = DefaultStatementInfo Type+ | RelvarInfo CompositeDef+ | CreateFunctionInfo FunctionPrototype+ | SelectInfo Type+ | InsertInfo String Type+ | UpdateInfo String Type+ | DeleteInfo String+ | CreateDomainInfo String Type+ | DropInfo [(String,String)]+ | DropFunctionInfo [(String,[Type])]+ deriving (Eq,Show)+++--use this to make sure type errors are propagated into the statement+--infos, temporary++makeStatementInfo :: Type -> StatementInfo -> StatementInfo+makeStatementInfo ty st =+ if isError ty+ then DefaultStatementInfo ty+ else st+ where+ isError t = case t of+ TypeError _ _ -> True+ TypeList ts -> any isError ts+ _ -> False+++-- i think this should be alright, an identifier referenced in an+-- expression can only have zero or one dot in it.++splitIdentifier :: String -> (String,String)+splitIdentifier s = let (a,b) = span (/= '.') s+ in if b == ""+ then ("", a)+ else (a,tail b)+++--returns the type of the relation, and the system columns also+getRelationType :: Scope -> MySourcePos -> String -> (Type,Type)+getRelationType scope sp tbl =+ case getAttrs scope [TableComposite, ViewComposite] tbl of+ Just ((_,_,a@(UnnamedCompositeType _))+ ,(_,_,s@(UnnamedCompositeType _)) ) -> (a,s)+ _ -> (TypeError sp (UnrecognisedRelation tbl), TypeList [])++getFnType :: Scope -> MySourcePos -> String -> Expression -> Type -> Type+getFnType scope sp alias fnVal fnType =+ checkErrors [fnType] $ snd $ getFunIdens scope sp alias fnVal fnType++getFunIdens :: Scope -> MySourcePos -> String -> Expression -> Type -> (String, Type)+getFunIdens scope sp alias fnVal fnType =+ case fnVal of+ FunCall f _ ->+ let correlationName = if alias /= ""+ then alias+ else f+ in (correlationName, case fnType of+ SetOfType (CompositeType t) -> getCompositeType t+ SetOfType x -> UnnamedCompositeType [(correlationName,x)]+ y -> UnnamedCompositeType [(correlationName,y)])+ x -> ("", TypeError sp (ContextError "FunCall"))+ where+ getCompositeType t =+ case getAttrs scope [Composite+ ,TableComposite+ ,ViewComposite] t of+ Just ((_,_,a@(UnnamedCompositeType _)), _) -> a+ _ -> UnnamedCompositeType []++commonFieldNames t1 t2 =+ intersect (fn t1) (fn t2)+ where+ fn (UnnamedCompositeType s) = map fst s+ fn _ = []++both :: (a->b) -> (a,a) -> (b,b)+both fn (x,y) = (fn x, fn y)++++fixedValue :: a -> a -> a -> a+fixedValue a _ _ = a+++checkTableExists :: Scope -> MySourcePos -> String -> Type+checkTableExists scope sp tbl =+ case getAttrs scope [TableComposite, ViewComposite] tbl of+ Just _ -> TypeList []+ _ -> TypeError sp (UnrecognisedRelation tbl)++checkColumnConsistency :: Scope -> MySourcePos -> String -> [String] -> [(String,Type)] -> Type+checkColumnConsistency scope sp tbl cols' insNameTypePairs =+ let --todo: check the cols have no duplicates+ --todo: check the missing target cols have defaults+ targetTableType = fst $ getRelationType scope sp tbl+ targetTableCols = unwrapComposite targetTableType+ --check the num cols in the insdata match the number of cols+ cols = if null cols'+ then map fst targetTableCols+ else cols'+ wrongLengthError = if length insNameTypePairs /= length cols+ then TypeError sp WrongNumberOfColumns+ else TypeList []+ --check the target cols appear in the target table and get their types+ nonMatchingColumns = cols \\ map fst targetTableCols+ nonMatchingErrors = case length nonMatchingColumns of+ 0 -> TypeList []+ 1 -> makeUnknownColumnError $ head nonMatchingColumns+ _ -> TypeList $ map makeUnknownColumnError nonMatchingColumns+ targetNameTypePairs = map (\l -> (l, fromJust $ lookup l targetTableCols)) cols+ --check the types of the insdata match the column targets+ --name datatype columntype+ typeTriples = map (\((a,b),c) -> (a,b,c)) $ zip targetNameTypePairs $ map snd insNameTypePairs+ matchingTypeErrors = map (\(_,b,c) -> checkAssignmentValid scope sp c b) typeTriples+ in checkErrors [targetTableType+ ,wrongLengthError+ ,nonMatchingErrors+ ,TypeList matchingTypeErrors] $ TypeList []+ where+ makeUnknownColumnError = TypeError sp . UnrecognisedIdentifier++getColumnTypes :: Scope -> MySourcePos -> String -> [String] -> [(String,Type)]+getColumnTypes scope sp tbl cols' =+ let targetTableType = fst $ getRelationType scope sp tbl+ targetTableCols = unwrapComposite targetTableType+ cols = if null cols'+ then map fst targetTableCols+ else cols'+ nonMatchingColumns = cols \\ map fst targetTableCols+ nonMatchingErrors = case length nonMatchingColumns of+ 0 -> TypeList []+ 1 -> makeUnknownColumnError $ head nonMatchingColumns+ _ -> TypeList $ map makeUnknownColumnError nonMatchingColumns+ in map (\l -> (l, fromJust $ lookup l targetTableCols)) cols+ where+ makeUnknownColumnError = TypeError sp . UnrecognisedIdentifier+++getRowTypes :: Type -> [Type]+getRowTypes (TypeList [(RowCtor ts)]) = ts+getRowTypes (TypeList ts) = ts+getRowTypes x = error $ "cannot get row types from " ++ show x+-- AttributeDef ------------------------------------------------+data AttributeDef = AttributeDef (String) (TypeName) (Maybe Expression) (RowConstraintList) + deriving ( Eq,Show)+-- cata+sem_AttributeDef :: AttributeDef ->+ T_AttributeDef +sem_AttributeDef (AttributeDef _name _typ _check _cons ) =+ (sem_AttributeDef_AttributeDef _name (sem_TypeName _typ ) _check (sem_RowConstraintList _cons ) )+-- semantic domain+type T_AttributeDef = Bool ->+ Scope ->+ MySourcePos ->+ ( AttributeDef,String,([Message]),Type)+data Inh_AttributeDef = Inh_AttributeDef {inLoop_Inh_AttributeDef :: Bool,scope_Inh_AttributeDef :: Scope,sourcePos_Inh_AttributeDef :: MySourcePos}+data Syn_AttributeDef = Syn_AttributeDef {actualValue_Syn_AttributeDef :: AttributeDef,attrName_Syn_AttributeDef :: String,messages_Syn_AttributeDef :: [Message],nodeType_Syn_AttributeDef :: Type}+wrap_AttributeDef :: T_AttributeDef ->+ Inh_AttributeDef ->+ Syn_AttributeDef +wrap_AttributeDef sem (Inh_AttributeDef _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOattrName,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_AttributeDef _lhsOactualValue _lhsOattrName _lhsOmessages _lhsOnodeType ))+sem_AttributeDef_AttributeDef :: String ->+ T_TypeName ->+ (Maybe Expression) ->+ T_RowConstraintList ->+ T_AttributeDef +sem_AttributeDef_AttributeDef name_ typ_ check_ cons_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOattrName :: String+ _lhsOnodeType :: Type+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: AttributeDef+ _typOinLoop :: Bool+ _typOscope :: Scope+ _typOsourcePos :: MySourcePos+ _consOinLoop :: Bool+ _consOscope :: Scope+ _consOsourcePos :: MySourcePos+ _typIactualValue :: TypeName+ _typImessages :: ([Message])+ _typInodeType :: Type+ _consIactualValue :: RowConstraintList+ _consImessages :: ([Message])+ _consInodeType :: Type+ _lhsOattrName =+ name_+ _lhsOnodeType =+ _typInodeType+ _lhsOmessages =+ _typImessages ++ _consImessages+ _actualValue =+ AttributeDef name_ _typIactualValue check_ _consIactualValue+ _lhsOactualValue =+ _actualValue+ _typOinLoop =+ _lhsIinLoop+ _typOscope =+ _lhsIscope+ _typOsourcePos =+ _lhsIsourcePos+ _consOinLoop =+ _lhsIinLoop+ _consOscope =+ _lhsIscope+ _consOsourcePos =+ _lhsIsourcePos+ ( _typIactualValue,_typImessages,_typInodeType) =+ (typ_ _typOinLoop _typOscope _typOsourcePos )+ ( _consIactualValue,_consImessages,_consInodeType) =+ (cons_ _consOinLoop _consOscope _consOsourcePos )+ in ( _lhsOactualValue,_lhsOattrName,_lhsOmessages,_lhsOnodeType)))+-- AttributeDefList --------------------------------------------+type AttributeDefList = [(AttributeDef)]+-- cata+sem_AttributeDefList :: AttributeDefList ->+ T_AttributeDefList +sem_AttributeDefList list =+ (Prelude.foldr sem_AttributeDefList_Cons sem_AttributeDefList_Nil (Prelude.map sem_AttributeDef list) )+-- semantic domain+type T_AttributeDefList = Bool ->+ Scope ->+ MySourcePos ->+ ( AttributeDefList,([Message]),Type)+data Inh_AttributeDefList = Inh_AttributeDefList {inLoop_Inh_AttributeDefList :: Bool,scope_Inh_AttributeDefList :: Scope,sourcePos_Inh_AttributeDefList :: MySourcePos}+data Syn_AttributeDefList = Syn_AttributeDefList {actualValue_Syn_AttributeDefList :: AttributeDefList,messages_Syn_AttributeDefList :: [Message],nodeType_Syn_AttributeDefList :: Type}+wrap_AttributeDefList :: T_AttributeDefList ->+ Inh_AttributeDefList ->+ Syn_AttributeDefList +wrap_AttributeDefList sem (Inh_AttributeDefList _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_AttributeDefList _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_AttributeDefList_Cons :: T_AttributeDef ->+ T_AttributeDefList ->+ T_AttributeDefList +sem_AttributeDefList_Cons hd_ tl_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: AttributeDefList+ _hdOinLoop :: Bool+ _hdOscope :: Scope+ _hdOsourcePos :: MySourcePos+ _tlOinLoop :: Bool+ _tlOscope :: Scope+ _tlOsourcePos :: MySourcePos+ _hdIactualValue :: AttributeDef+ _hdIattrName :: String+ _hdImessages :: ([Message])+ _hdInodeType :: Type+ _tlIactualValue :: AttributeDefList+ _tlImessages :: ([Message])+ _tlInodeType :: Type+ _lhsOnodeType =+ checkErrors [_tlInodeType, _hdInodeType] $+ consComposite (_hdIattrName, _hdInodeType) _tlInodeType+ _lhsOmessages =+ _hdImessages ++ _tlImessages+ _actualValue =+ (:) _hdIactualValue _tlIactualValue+ _lhsOactualValue =+ _actualValue+ _hdOinLoop =+ _lhsIinLoop+ _hdOscope =+ _lhsIscope+ _hdOsourcePos =+ _lhsIsourcePos+ _tlOinLoop =+ _lhsIinLoop+ _tlOscope =+ _lhsIscope+ _tlOsourcePos =+ _lhsIsourcePos+ ( _hdIactualValue,_hdIattrName,_hdImessages,_hdInodeType) =+ (hd_ _hdOinLoop _hdOscope _hdOsourcePos )+ ( _tlIactualValue,_tlImessages,_tlInodeType) =+ (tl_ _tlOinLoop _tlOscope _tlOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_AttributeDefList_Nil :: T_AttributeDefList +sem_AttributeDefList_Nil =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: AttributeDefList+ _lhsOnodeType =+ UnnamedCompositeType []+ _lhsOmessages =+ []+ _actualValue =+ []+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- Cascade -----------------------------------------------------+data Cascade = Cascade + | Restrict + deriving ( Eq,Show)+-- cata+sem_Cascade :: Cascade ->+ T_Cascade +sem_Cascade (Cascade ) =+ (sem_Cascade_Cascade )+sem_Cascade (Restrict ) =+ (sem_Cascade_Restrict )+-- semantic domain+type T_Cascade = Bool ->+ Scope ->+ MySourcePos ->+ ( Cascade,([Message]),Type)+data Inh_Cascade = Inh_Cascade {inLoop_Inh_Cascade :: Bool,scope_Inh_Cascade :: Scope,sourcePos_Inh_Cascade :: MySourcePos}+data Syn_Cascade = Syn_Cascade {actualValue_Syn_Cascade :: Cascade,messages_Syn_Cascade :: [Message],nodeType_Syn_Cascade :: Type}+wrap_Cascade :: T_Cascade ->+ Inh_Cascade ->+ Syn_Cascade +wrap_Cascade sem (Inh_Cascade _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_Cascade _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_Cascade_Cascade :: T_Cascade +sem_Cascade_Cascade =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Cascade+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ Cascade+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_Cascade_Restrict :: T_Cascade +sem_Cascade_Restrict =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Cascade+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ Restrict+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- CaseExpressionList ------------------------------------------+type CaseExpressionList = [(Expression)]+-- cata+sem_CaseExpressionList :: CaseExpressionList ->+ T_CaseExpressionList +sem_CaseExpressionList list =+ (Prelude.foldr sem_CaseExpressionList_Cons sem_CaseExpressionList_Nil (Prelude.map sem_Expression list) )+-- semantic domain+type T_CaseExpressionList = Bool ->+ Scope ->+ MySourcePos ->+ ( CaseExpressionList,([Message]),Type)+data Inh_CaseExpressionList = Inh_CaseExpressionList {inLoop_Inh_CaseExpressionList :: Bool,scope_Inh_CaseExpressionList :: Scope,sourcePos_Inh_CaseExpressionList :: MySourcePos}+data Syn_CaseExpressionList = Syn_CaseExpressionList {actualValue_Syn_CaseExpressionList :: CaseExpressionList,messages_Syn_CaseExpressionList :: [Message],nodeType_Syn_CaseExpressionList :: Type}+wrap_CaseExpressionList :: T_CaseExpressionList ->+ Inh_CaseExpressionList ->+ Syn_CaseExpressionList +wrap_CaseExpressionList sem (Inh_CaseExpressionList _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_CaseExpressionList _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_CaseExpressionList_Cons :: T_Expression ->+ T_CaseExpressionList ->+ T_CaseExpressionList +sem_CaseExpressionList_Cons hd_ tl_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: CaseExpressionList+ _hdOinLoop :: Bool+ _hdOscope :: Scope+ _hdOsourcePos :: MySourcePos+ _tlOinLoop :: Bool+ _tlOscope :: Scope+ _tlOsourcePos :: MySourcePos+ _hdIactualValue :: Expression+ _hdIliftedColumnName :: String+ _hdImessages :: ([Message])+ _hdInodeType :: Type+ _tlIactualValue :: CaseExpressionList+ _tlImessages :: ([Message])+ _tlInodeType :: Type+ _lhsOmessages =+ _hdImessages ++ _tlImessages+ _lhsOnodeType =+ _hdInodeType `appendTypeList` _tlInodeType+ _actualValue =+ (:) _hdIactualValue _tlIactualValue+ _lhsOactualValue =+ _actualValue+ _hdOinLoop =+ _lhsIinLoop+ _hdOscope =+ _lhsIscope+ _hdOsourcePos =+ _lhsIsourcePos+ _tlOinLoop =+ _lhsIinLoop+ _tlOscope =+ _lhsIscope+ _tlOsourcePos =+ _lhsIsourcePos+ ( _hdIactualValue,_hdIliftedColumnName,_hdImessages,_hdInodeType) =+ (hd_ _hdOinLoop _hdOscope _hdOsourcePos )+ ( _tlIactualValue,_tlImessages,_tlInodeType) =+ (tl_ _tlOinLoop _tlOscope _tlOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_CaseExpressionList_Nil :: T_CaseExpressionList +sem_CaseExpressionList_Nil =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: CaseExpressionList+ _lhsOmessages =+ []+ _lhsOnodeType =+ TypeList []+ _actualValue =+ []+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- CaseExpressionListExpressionPair ----------------------------+type CaseExpressionListExpressionPair = ( (CaseExpressionList),(Expression))+-- cata+sem_CaseExpressionListExpressionPair :: CaseExpressionListExpressionPair ->+ T_CaseExpressionListExpressionPair +sem_CaseExpressionListExpressionPair ( x1,x2) =+ (sem_CaseExpressionListExpressionPair_Tuple (sem_CaseExpressionList x1 ) (sem_Expression x2 ) )+-- semantic domain+type T_CaseExpressionListExpressionPair = Bool ->+ Scope ->+ MySourcePos ->+ ( CaseExpressionListExpressionPair,([Message]),Type)+data Inh_CaseExpressionListExpressionPair = Inh_CaseExpressionListExpressionPair {inLoop_Inh_CaseExpressionListExpressionPair :: Bool,scope_Inh_CaseExpressionListExpressionPair :: Scope,sourcePos_Inh_CaseExpressionListExpressionPair :: MySourcePos}+data Syn_CaseExpressionListExpressionPair = Syn_CaseExpressionListExpressionPair {actualValue_Syn_CaseExpressionListExpressionPair :: CaseExpressionListExpressionPair,messages_Syn_CaseExpressionListExpressionPair :: [Message],nodeType_Syn_CaseExpressionListExpressionPair :: Type}+wrap_CaseExpressionListExpressionPair :: T_CaseExpressionListExpressionPair ->+ Inh_CaseExpressionListExpressionPair ->+ Syn_CaseExpressionListExpressionPair +wrap_CaseExpressionListExpressionPair sem (Inh_CaseExpressionListExpressionPair _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_CaseExpressionListExpressionPair _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_CaseExpressionListExpressionPair_Tuple :: T_CaseExpressionList ->+ T_Expression ->+ T_CaseExpressionListExpressionPair +sem_CaseExpressionListExpressionPair_Tuple x1_ x2_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: CaseExpressionListExpressionPair+ _x1OinLoop :: Bool+ _x1Oscope :: Scope+ _x1OsourcePos :: MySourcePos+ _x2OinLoop :: Bool+ _x2Oscope :: Scope+ _x2OsourcePos :: MySourcePos+ _x1IactualValue :: CaseExpressionList+ _x1Imessages :: ([Message])+ _x1InodeType :: Type+ _x2IactualValue :: Expression+ _x2IliftedColumnName :: String+ _x2Imessages :: ([Message])+ _x2InodeType :: Type+ _lhsOmessages =+ _x1Imessages ++ _x2Imessages+ _lhsOnodeType =+ _x1InodeType `appendTypeList` _x2InodeType+ _actualValue =+ (_x1IactualValue,_x2IactualValue)+ _lhsOactualValue =+ _actualValue+ _x1OinLoop =+ _lhsIinLoop+ _x1Oscope =+ _lhsIscope+ _x1OsourcePos =+ _lhsIsourcePos+ _x2OinLoop =+ _lhsIinLoop+ _x2Oscope =+ _lhsIscope+ _x2OsourcePos =+ _lhsIsourcePos+ ( _x1IactualValue,_x1Imessages,_x1InodeType) =+ (x1_ _x1OinLoop _x1Oscope _x1OsourcePos )+ ( _x2IactualValue,_x2IliftedColumnName,_x2Imessages,_x2InodeType) =+ (x2_ _x2OinLoop _x2Oscope _x2OsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- CaseExpressionListExpressionPairList ------------------------+type CaseExpressionListExpressionPairList = [(CaseExpressionListExpressionPair)]+-- cata+sem_CaseExpressionListExpressionPairList :: CaseExpressionListExpressionPairList ->+ T_CaseExpressionListExpressionPairList +sem_CaseExpressionListExpressionPairList list =+ (Prelude.foldr sem_CaseExpressionListExpressionPairList_Cons sem_CaseExpressionListExpressionPairList_Nil (Prelude.map sem_CaseExpressionListExpressionPair list) )+-- semantic domain+type T_CaseExpressionListExpressionPairList = Bool ->+ Scope ->+ MySourcePos ->+ ( CaseExpressionListExpressionPairList,([Message]),Type)+data Inh_CaseExpressionListExpressionPairList = Inh_CaseExpressionListExpressionPairList {inLoop_Inh_CaseExpressionListExpressionPairList :: Bool,scope_Inh_CaseExpressionListExpressionPairList :: Scope,sourcePos_Inh_CaseExpressionListExpressionPairList :: MySourcePos}+data Syn_CaseExpressionListExpressionPairList = Syn_CaseExpressionListExpressionPairList {actualValue_Syn_CaseExpressionListExpressionPairList :: CaseExpressionListExpressionPairList,messages_Syn_CaseExpressionListExpressionPairList :: [Message],nodeType_Syn_CaseExpressionListExpressionPairList :: Type}+wrap_CaseExpressionListExpressionPairList :: T_CaseExpressionListExpressionPairList ->+ Inh_CaseExpressionListExpressionPairList ->+ Syn_CaseExpressionListExpressionPairList +wrap_CaseExpressionListExpressionPairList sem (Inh_CaseExpressionListExpressionPairList _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_CaseExpressionListExpressionPairList _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_CaseExpressionListExpressionPairList_Cons :: T_CaseExpressionListExpressionPair ->+ T_CaseExpressionListExpressionPairList ->+ T_CaseExpressionListExpressionPairList +sem_CaseExpressionListExpressionPairList_Cons hd_ tl_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: CaseExpressionListExpressionPairList+ _hdOinLoop :: Bool+ _hdOscope :: Scope+ _hdOsourcePos :: MySourcePos+ _tlOinLoop :: Bool+ _tlOscope :: Scope+ _tlOsourcePos :: MySourcePos+ _hdIactualValue :: CaseExpressionListExpressionPair+ _hdImessages :: ([Message])+ _hdInodeType :: Type+ _tlIactualValue :: CaseExpressionListExpressionPairList+ _tlImessages :: ([Message])+ _tlInodeType :: Type+ _lhsOmessages =+ _hdImessages ++ _tlImessages+ _lhsOnodeType =+ _hdInodeType `appendTypeList` _tlInodeType+ _actualValue =+ (:) _hdIactualValue _tlIactualValue+ _lhsOactualValue =+ _actualValue+ _hdOinLoop =+ _lhsIinLoop+ _hdOscope =+ _lhsIscope+ _hdOsourcePos =+ _lhsIsourcePos+ _tlOinLoop =+ _lhsIinLoop+ _tlOscope =+ _lhsIscope+ _tlOsourcePos =+ _lhsIsourcePos+ ( _hdIactualValue,_hdImessages,_hdInodeType) =+ (hd_ _hdOinLoop _hdOscope _hdOsourcePos )+ ( _tlIactualValue,_tlImessages,_tlInodeType) =+ (tl_ _tlOinLoop _tlOscope _tlOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_CaseExpressionListExpressionPairList_Nil :: T_CaseExpressionListExpressionPairList +sem_CaseExpressionListExpressionPairList_Nil =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: CaseExpressionListExpressionPairList+ _lhsOmessages =+ []+ _lhsOnodeType =+ TypeList []+ _actualValue =+ []+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- CombineType -------------------------------------------------+data CombineType = Except + | Intersect + | Union + | UnionAll + deriving ( Eq,Show)+-- cata+sem_CombineType :: CombineType ->+ T_CombineType +sem_CombineType (Except ) =+ (sem_CombineType_Except )+sem_CombineType (Intersect ) =+ (sem_CombineType_Intersect )+sem_CombineType (Union ) =+ (sem_CombineType_Union )+sem_CombineType (UnionAll ) =+ (sem_CombineType_UnionAll )+-- semantic domain+type T_CombineType = Bool ->+ Scope ->+ MySourcePos ->+ ( CombineType,([Message]),Type)+data Inh_CombineType = Inh_CombineType {inLoop_Inh_CombineType :: Bool,scope_Inh_CombineType :: Scope,sourcePos_Inh_CombineType :: MySourcePos}+data Syn_CombineType = Syn_CombineType {actualValue_Syn_CombineType :: CombineType,messages_Syn_CombineType :: [Message],nodeType_Syn_CombineType :: Type}+wrap_CombineType :: T_CombineType ->+ Inh_CombineType ->+ Syn_CombineType +wrap_CombineType sem (Inh_CombineType _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_CombineType _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_CombineType_Except :: T_CombineType +sem_CombineType_Except =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: CombineType+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ Except+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_CombineType_Intersect :: T_CombineType +sem_CombineType_Intersect =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: CombineType+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ Intersect+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_CombineType_Union :: T_CombineType +sem_CombineType_Union =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: CombineType+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ Union+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_CombineType_UnionAll :: T_CombineType +sem_CombineType_UnionAll =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: CombineType+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ UnionAll+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- Constraint --------------------------------------------------+data Constraint = CheckConstraint (Expression) + | PrimaryKeyConstraint (StringList) + | ReferenceConstraint (StringList) (String) (StringList) (Cascade) (Cascade) + | UniqueConstraint (StringList) + deriving ( Eq,Show)+-- cata+sem_Constraint :: Constraint ->+ T_Constraint +sem_Constraint (CheckConstraint _expression ) =+ (sem_Constraint_CheckConstraint (sem_Expression _expression ) )+sem_Constraint (PrimaryKeyConstraint _stringList ) =+ (sem_Constraint_PrimaryKeyConstraint (sem_StringList _stringList ) )+sem_Constraint (ReferenceConstraint _atts _table _tableAtts _onUpdate _onDelete ) =+ (sem_Constraint_ReferenceConstraint (sem_StringList _atts ) _table (sem_StringList _tableAtts ) (sem_Cascade _onUpdate ) (sem_Cascade _onDelete ) )+sem_Constraint (UniqueConstraint _stringList ) =+ (sem_Constraint_UniqueConstraint (sem_StringList _stringList ) )+-- semantic domain+type T_Constraint = Bool ->+ Scope ->+ MySourcePos ->+ ( Constraint,([Message]),Type)+data Inh_Constraint = Inh_Constraint {inLoop_Inh_Constraint :: Bool,scope_Inh_Constraint :: Scope,sourcePos_Inh_Constraint :: MySourcePos}+data Syn_Constraint = Syn_Constraint {actualValue_Syn_Constraint :: Constraint,messages_Syn_Constraint :: [Message],nodeType_Syn_Constraint :: Type}+wrap_Constraint :: T_Constraint ->+ Inh_Constraint ->+ Syn_Constraint +wrap_Constraint sem (Inh_Constraint _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_Constraint _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_Constraint_CheckConstraint :: T_Expression ->+ T_Constraint +sem_Constraint_CheckConstraint expression_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Constraint+ _expressionOinLoop :: Bool+ _expressionOscope :: Scope+ _expressionOsourcePos :: MySourcePos+ _expressionIactualValue :: Expression+ _expressionIliftedColumnName :: String+ _expressionImessages :: ([Message])+ _expressionInodeType :: Type+ _lhsOmessages =+ _expressionImessages+ _lhsOnodeType =+ _expressionInodeType+ _actualValue =+ CheckConstraint _expressionIactualValue+ _lhsOactualValue =+ _actualValue+ _expressionOinLoop =+ _lhsIinLoop+ _expressionOscope =+ _lhsIscope+ _expressionOsourcePos =+ _lhsIsourcePos+ ( _expressionIactualValue,_expressionIliftedColumnName,_expressionImessages,_expressionInodeType) =+ (expression_ _expressionOinLoop _expressionOscope _expressionOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_Constraint_PrimaryKeyConstraint :: T_StringList ->+ T_Constraint +sem_Constraint_PrimaryKeyConstraint stringList_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Constraint+ _stringListOinLoop :: Bool+ _stringListOscope :: Scope+ _stringListOsourcePos :: MySourcePos+ _stringListIactualValue :: StringList+ _stringListImessages :: ([Message])+ _stringListInodeType :: Type+ _stringListIstrings :: ([String])+ _lhsOmessages =+ _stringListImessages+ _lhsOnodeType =+ _stringListInodeType+ _actualValue =+ PrimaryKeyConstraint _stringListIactualValue+ _lhsOactualValue =+ _actualValue+ _stringListOinLoop =+ _lhsIinLoop+ _stringListOscope =+ _lhsIscope+ _stringListOsourcePos =+ _lhsIsourcePos+ ( _stringListIactualValue,_stringListImessages,_stringListInodeType,_stringListIstrings) =+ (stringList_ _stringListOinLoop _stringListOscope _stringListOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_Constraint_ReferenceConstraint :: T_StringList ->+ String ->+ T_StringList ->+ T_Cascade ->+ T_Cascade ->+ T_Constraint +sem_Constraint_ReferenceConstraint atts_ table_ tableAtts_ onUpdate_ onDelete_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Constraint+ _attsOinLoop :: Bool+ _attsOscope :: Scope+ _attsOsourcePos :: MySourcePos+ _tableAttsOinLoop :: Bool+ _tableAttsOscope :: Scope+ _tableAttsOsourcePos :: MySourcePos+ _onUpdateOinLoop :: Bool+ _onUpdateOscope :: Scope+ _onUpdateOsourcePos :: MySourcePos+ _onDeleteOinLoop :: Bool+ _onDeleteOscope :: Scope+ _onDeleteOsourcePos :: MySourcePos+ _attsIactualValue :: StringList+ _attsImessages :: ([Message])+ _attsInodeType :: Type+ _attsIstrings :: ([String])+ _tableAttsIactualValue :: StringList+ _tableAttsImessages :: ([Message])+ _tableAttsInodeType :: Type+ _tableAttsIstrings :: ([String])+ _onUpdateIactualValue :: Cascade+ _onUpdateImessages :: ([Message])+ _onUpdateInodeType :: Type+ _onDeleteIactualValue :: Cascade+ _onDeleteImessages :: ([Message])+ _onDeleteInodeType :: Type+ _lhsOmessages =+ _attsImessages ++ _tableAttsImessages ++ _onUpdateImessages ++ _onDeleteImessages+ _lhsOnodeType =+ _attsInodeType `setUnknown` _tableAttsInodeType `setUnknown` _onUpdateInodeType `setUnknown` _onDeleteInodeType+ _actualValue =+ ReferenceConstraint _attsIactualValue table_ _tableAttsIactualValue _onUpdateIactualValue _onDeleteIactualValue+ _lhsOactualValue =+ _actualValue+ _attsOinLoop =+ _lhsIinLoop+ _attsOscope =+ _lhsIscope+ _attsOsourcePos =+ _lhsIsourcePos+ _tableAttsOinLoop =+ _lhsIinLoop+ _tableAttsOscope =+ _lhsIscope+ _tableAttsOsourcePos =+ _lhsIsourcePos+ _onUpdateOinLoop =+ _lhsIinLoop+ _onUpdateOscope =+ _lhsIscope+ _onUpdateOsourcePos =+ _lhsIsourcePos+ _onDeleteOinLoop =+ _lhsIinLoop+ _onDeleteOscope =+ _lhsIscope+ _onDeleteOsourcePos =+ _lhsIsourcePos+ ( _attsIactualValue,_attsImessages,_attsInodeType,_attsIstrings) =+ (atts_ _attsOinLoop _attsOscope _attsOsourcePos )+ ( _tableAttsIactualValue,_tableAttsImessages,_tableAttsInodeType,_tableAttsIstrings) =+ (tableAtts_ _tableAttsOinLoop _tableAttsOscope _tableAttsOsourcePos )+ ( _onUpdateIactualValue,_onUpdateImessages,_onUpdateInodeType) =+ (onUpdate_ _onUpdateOinLoop _onUpdateOscope _onUpdateOsourcePos )+ ( _onDeleteIactualValue,_onDeleteImessages,_onDeleteInodeType) =+ (onDelete_ _onDeleteOinLoop _onDeleteOscope _onDeleteOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_Constraint_UniqueConstraint :: T_StringList ->+ T_Constraint +sem_Constraint_UniqueConstraint stringList_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Constraint+ _stringListOinLoop :: Bool+ _stringListOscope :: Scope+ _stringListOsourcePos :: MySourcePos+ _stringListIactualValue :: StringList+ _stringListImessages :: ([Message])+ _stringListInodeType :: Type+ _stringListIstrings :: ([String])+ _lhsOmessages =+ _stringListImessages+ _lhsOnodeType =+ _stringListInodeType+ _actualValue =+ UniqueConstraint _stringListIactualValue+ _lhsOactualValue =+ _actualValue+ _stringListOinLoop =+ _lhsIinLoop+ _stringListOscope =+ _lhsIscope+ _stringListOsourcePos =+ _lhsIsourcePos+ ( _stringListIactualValue,_stringListImessages,_stringListInodeType,_stringListIstrings) =+ (stringList_ _stringListOinLoop _stringListOscope _stringListOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- ConstraintList ----------------------------------------------+type ConstraintList = [(Constraint)]+-- cata+sem_ConstraintList :: ConstraintList ->+ T_ConstraintList +sem_ConstraintList list =+ (Prelude.foldr sem_ConstraintList_Cons sem_ConstraintList_Nil (Prelude.map sem_Constraint list) )+-- semantic domain+type T_ConstraintList = Bool ->+ Scope ->+ MySourcePos ->+ ( ConstraintList,([Message]),Type)+data Inh_ConstraintList = Inh_ConstraintList {inLoop_Inh_ConstraintList :: Bool,scope_Inh_ConstraintList :: Scope,sourcePos_Inh_ConstraintList :: MySourcePos}+data Syn_ConstraintList = Syn_ConstraintList {actualValue_Syn_ConstraintList :: ConstraintList,messages_Syn_ConstraintList :: [Message],nodeType_Syn_ConstraintList :: Type}+wrap_ConstraintList :: T_ConstraintList ->+ Inh_ConstraintList ->+ Syn_ConstraintList +wrap_ConstraintList sem (Inh_ConstraintList _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_ConstraintList _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_ConstraintList_Cons :: T_Constraint ->+ T_ConstraintList ->+ T_ConstraintList +sem_ConstraintList_Cons hd_ tl_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: ConstraintList+ _hdOinLoop :: Bool+ _hdOscope :: Scope+ _hdOsourcePos :: MySourcePos+ _tlOinLoop :: Bool+ _tlOscope :: Scope+ _tlOsourcePos :: MySourcePos+ _hdIactualValue :: Constraint+ _hdImessages :: ([Message])+ _hdInodeType :: Type+ _tlIactualValue :: ConstraintList+ _tlImessages :: ([Message])+ _tlInodeType :: Type+ _lhsOmessages =+ _hdImessages ++ _tlImessages+ _lhsOnodeType =+ _hdInodeType `appendTypeList` _tlInodeType+ _actualValue =+ (:) _hdIactualValue _tlIactualValue+ _lhsOactualValue =+ _actualValue+ _hdOinLoop =+ _lhsIinLoop+ _hdOscope =+ _lhsIscope+ _hdOsourcePos =+ _lhsIsourcePos+ _tlOinLoop =+ _lhsIinLoop+ _tlOscope =+ _lhsIscope+ _tlOsourcePos =+ _lhsIsourcePos+ ( _hdIactualValue,_hdImessages,_hdInodeType) =+ (hd_ _hdOinLoop _hdOscope _hdOsourcePos )+ ( _tlIactualValue,_tlImessages,_tlInodeType) =+ (tl_ _tlOinLoop _tlOscope _tlOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_ConstraintList_Nil :: T_ConstraintList +sem_ConstraintList_Nil =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: ConstraintList+ _lhsOmessages =+ []+ _lhsOnodeType =+ TypeList []+ _actualValue =+ []+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- CopySource --------------------------------------------------+data CopySource = CopyFilename (String) + | Stdin + deriving ( Eq,Show)+-- cata+sem_CopySource :: CopySource ->+ T_CopySource +sem_CopySource (CopyFilename _string ) =+ (sem_CopySource_CopyFilename _string )+sem_CopySource (Stdin ) =+ (sem_CopySource_Stdin )+-- semantic domain+type T_CopySource = Bool ->+ Scope ->+ MySourcePos ->+ ( CopySource,([Message]),Type)+data Inh_CopySource = Inh_CopySource {inLoop_Inh_CopySource :: Bool,scope_Inh_CopySource :: Scope,sourcePos_Inh_CopySource :: MySourcePos}+data Syn_CopySource = Syn_CopySource {actualValue_Syn_CopySource :: CopySource,messages_Syn_CopySource :: [Message],nodeType_Syn_CopySource :: Type}+wrap_CopySource :: T_CopySource ->+ Inh_CopySource ->+ Syn_CopySource +wrap_CopySource sem (Inh_CopySource _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_CopySource _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_CopySource_CopyFilename :: String ->+ T_CopySource +sem_CopySource_CopyFilename string_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: CopySource+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ CopyFilename string_+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_CopySource_Stdin :: T_CopySource +sem_CopySource_Stdin =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: CopySource+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ Stdin+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- Direction ---------------------------------------------------+data Direction = Asc + | Desc + deriving ( Eq,Show)+-- cata+sem_Direction :: Direction ->+ T_Direction +sem_Direction (Asc ) =+ (sem_Direction_Asc )+sem_Direction (Desc ) =+ (sem_Direction_Desc )+-- semantic domain+type T_Direction = Bool ->+ Scope ->+ MySourcePos ->+ ( Direction,([Message]),Type)+data Inh_Direction = Inh_Direction {inLoop_Inh_Direction :: Bool,scope_Inh_Direction :: Scope,sourcePos_Inh_Direction :: MySourcePos}+data Syn_Direction = Syn_Direction {actualValue_Syn_Direction :: Direction,messages_Syn_Direction :: [Message],nodeType_Syn_Direction :: Type}+wrap_Direction :: T_Direction ->+ Inh_Direction ->+ Syn_Direction +wrap_Direction sem (Inh_Direction _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_Direction _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_Direction_Asc :: T_Direction +sem_Direction_Asc =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Direction+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ Asc+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_Direction_Desc :: T_Direction +sem_Direction_Desc =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Direction+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ Desc+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- Distinct ----------------------------------------------------+data Distinct = Distinct + | Dupes + deriving ( Eq,Show)+-- cata+sem_Distinct :: Distinct ->+ T_Distinct +sem_Distinct (Distinct ) =+ (sem_Distinct_Distinct )+sem_Distinct (Dupes ) =+ (sem_Distinct_Dupes )+-- semantic domain+type T_Distinct = Bool ->+ Scope ->+ MySourcePos ->+ ( Distinct,([Message]),Type)+data Inh_Distinct = Inh_Distinct {inLoop_Inh_Distinct :: Bool,scope_Inh_Distinct :: Scope,sourcePos_Inh_Distinct :: MySourcePos}+data Syn_Distinct = Syn_Distinct {actualValue_Syn_Distinct :: Distinct,messages_Syn_Distinct :: [Message],nodeType_Syn_Distinct :: Type}+wrap_Distinct :: T_Distinct ->+ Inh_Distinct ->+ Syn_Distinct +wrap_Distinct sem (Inh_Distinct _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_Distinct _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_Distinct_Distinct :: T_Distinct +sem_Distinct_Distinct =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Distinct+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ Distinct+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_Distinct_Dupes :: T_Distinct +sem_Distinct_Dupes =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Distinct+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ Dupes+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- DropType ----------------------------------------------------+data DropType = Domain + | Table + | Type + | View + deriving ( Eq,Show)+-- cata+sem_DropType :: DropType ->+ T_DropType +sem_DropType (Domain ) =+ (sem_DropType_Domain )+sem_DropType (Table ) =+ (sem_DropType_Table )+sem_DropType (Type ) =+ (sem_DropType_Type )+sem_DropType (View ) =+ (sem_DropType_View )+-- semantic domain+type T_DropType = Bool ->+ Scope ->+ MySourcePos ->+ ( DropType,([Message]),Type)+data Inh_DropType = Inh_DropType {inLoop_Inh_DropType :: Bool,scope_Inh_DropType :: Scope,sourcePos_Inh_DropType :: MySourcePos}+data Syn_DropType = Syn_DropType {actualValue_Syn_DropType :: DropType,messages_Syn_DropType :: [Message],nodeType_Syn_DropType :: Type}+wrap_DropType :: T_DropType ->+ Inh_DropType ->+ Syn_DropType +wrap_DropType sem (Inh_DropType _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_DropType _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_DropType_Domain :: T_DropType +sem_DropType_Domain =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: DropType+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ Domain+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_DropType_Table :: T_DropType +sem_DropType_Table =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: DropType+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ Table+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_DropType_Type :: T_DropType +sem_DropType_Type =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: DropType+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ Type+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_DropType_View :: T_DropType +sem_DropType_View =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: DropType+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ View+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- Expression --------------------------------------------------+data Expression = BooleanLit (Bool) + | Case (CaseExpressionListExpressionPairList) (MaybeExpression) + | CaseSimple (Expression) (CaseExpressionListExpressionPairList) (MaybeExpression) + | Cast (Expression) (TypeName) + | Exists (SelectExpression) + | FloatLit (Double) + | FunCall (String) (ExpressionList) + | Identifier (String) + | InPredicate (Expression) (Bool) (InList) + | IntegerLit (Integer) + | NullLit + | PositionalArg (Integer) + | ScalarSubQuery (SelectExpression) + | StringLit (String) (String) + | WindowFn (Expression) (ExpressionList) (ExpressionList) (Direction) + deriving ( Eq,Show)+-- cata+sem_Expression :: Expression ->+ T_Expression +sem_Expression (BooleanLit _bool ) =+ (sem_Expression_BooleanLit _bool )+sem_Expression (Case _cases _els ) =+ (sem_Expression_Case (sem_CaseExpressionListExpressionPairList _cases ) (sem_MaybeExpression _els ) )+sem_Expression (CaseSimple _value _cases _els ) =+ (sem_Expression_CaseSimple (sem_Expression _value ) (sem_CaseExpressionListExpressionPairList _cases ) (sem_MaybeExpression _els ) )+sem_Expression (Cast _expr _tn ) =+ (sem_Expression_Cast (sem_Expression _expr ) (sem_TypeName _tn ) )+sem_Expression (Exists _sel ) =+ (sem_Expression_Exists (sem_SelectExpression _sel ) )+sem_Expression (FloatLit _double ) =+ (sem_Expression_FloatLit _double )+sem_Expression (FunCall _funName _args ) =+ (sem_Expression_FunCall _funName (sem_ExpressionList _args ) )+sem_Expression (Identifier _i ) =+ (sem_Expression_Identifier _i )+sem_Expression (InPredicate _expr _i _list ) =+ (sem_Expression_InPredicate (sem_Expression _expr ) _i (sem_InList _list ) )+sem_Expression (IntegerLit _integer ) =+ (sem_Expression_IntegerLit _integer )+sem_Expression (NullLit ) =+ (sem_Expression_NullLit )+sem_Expression (PositionalArg _integer ) =+ (sem_Expression_PositionalArg _integer )+sem_Expression (ScalarSubQuery _sel ) =+ (sem_Expression_ScalarSubQuery (sem_SelectExpression _sel ) )+sem_Expression (StringLit _quote _value ) =+ (sem_Expression_StringLit _quote _value )+sem_Expression (WindowFn _fn _partitionBy _orderBy _dir ) =+ (sem_Expression_WindowFn (sem_Expression _fn ) (sem_ExpressionList _partitionBy ) (sem_ExpressionList _orderBy ) (sem_Direction _dir ) )+-- semantic domain+type T_Expression = Bool ->+ Scope ->+ MySourcePos ->+ ( Expression,String,([Message]),Type)+data Inh_Expression = Inh_Expression {inLoop_Inh_Expression :: Bool,scope_Inh_Expression :: Scope,sourcePos_Inh_Expression :: MySourcePos}+data Syn_Expression = Syn_Expression {actualValue_Syn_Expression :: Expression,liftedColumnName_Syn_Expression :: String,messages_Syn_Expression :: [Message],nodeType_Syn_Expression :: Type}+wrap_Expression :: T_Expression ->+ Inh_Expression ->+ Syn_Expression +wrap_Expression sem (Inh_Expression _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOliftedColumnName,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_Expression _lhsOactualValue _lhsOliftedColumnName _lhsOmessages _lhsOnodeType ))+sem_Expression_BooleanLit :: Bool ->+ T_Expression +sem_Expression_BooleanLit bool_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOliftedColumnName :: String+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: Expression+ _lhsOnodeType =+ typeBool+ _lhsOliftedColumnName =+ ""+ _lhsOmessages =+ []+ _actualValue =+ BooleanLit bool_+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOliftedColumnName,_lhsOmessages,_lhsOnodeType)))+sem_Expression_Case :: T_CaseExpressionListExpressionPairList ->+ T_MaybeExpression ->+ T_Expression +sem_Expression_Case cases_ els_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOliftedColumnName :: String+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: Expression+ _casesOinLoop :: Bool+ _casesOscope :: Scope+ _casesOsourcePos :: MySourcePos+ _elsOinLoop :: Bool+ _elsOscope :: Scope+ _elsOsourcePos :: MySourcePos+ _casesIactualValue :: CaseExpressionListExpressionPairList+ _casesImessages :: ([Message])+ _casesInodeType :: Type+ _elsIactualValue :: MaybeExpression+ _elsImessages :: ([Message])+ _elsInodeType :: Type+ _lhsOnodeType =+ let elseThen =+ case _elsInodeType of+ TypeList [] -> []+ t -> [t]+ unwrappedLists = map unwrapTypeList $ unwrapTypeList _casesInodeType+ whenTypes :: [Type]+ whenTypes = concat $ map unwrapTypeList $ map head unwrappedLists+ thenTypes :: [Type]+ thenTypes = map (head . tail) unwrappedLists ++ elseThen+ whensAllBool :: Type+ whensAllBool = if any (/= typeBool) whenTypes+ then TypeError _lhsIsourcePos+ (WrongTypes typeBool whenTypes)+ else TypeList []+ in checkErrors (whenTypes ++ thenTypes ++ [whensAllBool]) $+ resolveResultSetType+ _lhsIscope+ _lhsIsourcePos+ thenTypes+ _lhsOliftedColumnName =+ ""+ _lhsOmessages =+ _casesImessages ++ _elsImessages+ _actualValue =+ Case _casesIactualValue _elsIactualValue+ _lhsOactualValue =+ _actualValue+ _casesOinLoop =+ _lhsIinLoop+ _casesOscope =+ _lhsIscope+ _casesOsourcePos =+ _lhsIsourcePos+ _elsOinLoop =+ _lhsIinLoop+ _elsOscope =+ _lhsIscope+ _elsOsourcePos =+ _lhsIsourcePos+ ( _casesIactualValue,_casesImessages,_casesInodeType) =+ (cases_ _casesOinLoop _casesOscope _casesOsourcePos )+ ( _elsIactualValue,_elsImessages,_elsInodeType) =+ (els_ _elsOinLoop _elsOscope _elsOsourcePos )+ in ( _lhsOactualValue,_lhsOliftedColumnName,_lhsOmessages,_lhsOnodeType)))+sem_Expression_CaseSimple :: T_Expression ->+ T_CaseExpressionListExpressionPairList ->+ T_MaybeExpression ->+ T_Expression +sem_Expression_CaseSimple value_ cases_ els_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOliftedColumnName :: String+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: Expression+ _valueOinLoop :: Bool+ _valueOscope :: Scope+ _valueOsourcePos :: MySourcePos+ _casesOinLoop :: Bool+ _casesOscope :: Scope+ _casesOsourcePos :: MySourcePos+ _elsOinLoop :: Bool+ _elsOscope :: Scope+ _elsOsourcePos :: MySourcePos+ _valueIactualValue :: Expression+ _valueIliftedColumnName :: String+ _valueImessages :: ([Message])+ _valueInodeType :: Type+ _casesIactualValue :: CaseExpressionListExpressionPairList+ _casesImessages :: ([Message])+ _casesInodeType :: Type+ _elsIactualValue :: MaybeExpression+ _elsImessages :: ([Message])+ _elsInodeType :: Type+ _lhsOnodeType =+ let elseThen =+ case _elsInodeType of+ TypeList [] -> []+ t -> [t]+ unwrappedLists = map unwrapTypeList $ unwrapTypeList _casesInodeType+ whenTypes :: [Type]+ whenTypes = concat $ map unwrapTypeList $ map head unwrappedLists+ thenTypes :: [Type]+ thenTypes = map (head . tail) unwrappedLists ++ elseThen+ checkWhenTypes = resolveResultSetType+ _lhsIscope+ _lhsIsourcePos+ (_valueInodeType:whenTypes)+ in checkErrors (whenTypes ++ thenTypes ++ [checkWhenTypes]) $+ resolveResultSetType+ _lhsIscope+ _lhsIsourcePos+ thenTypes+ _lhsOliftedColumnName =+ _valueIliftedColumnName+ _lhsOmessages =+ _valueImessages ++ _casesImessages ++ _elsImessages+ _actualValue =+ CaseSimple _valueIactualValue _casesIactualValue _elsIactualValue+ _lhsOactualValue =+ _actualValue+ _valueOinLoop =+ _lhsIinLoop+ _valueOscope =+ _lhsIscope+ _valueOsourcePos =+ _lhsIsourcePos+ _casesOinLoop =+ _lhsIinLoop+ _casesOscope =+ _lhsIscope+ _casesOsourcePos =+ _lhsIsourcePos+ _elsOinLoop =+ _lhsIinLoop+ _elsOscope =+ _lhsIscope+ _elsOsourcePos =+ _lhsIsourcePos+ ( _valueIactualValue,_valueIliftedColumnName,_valueImessages,_valueInodeType) =+ (value_ _valueOinLoop _valueOscope _valueOsourcePos )+ ( _casesIactualValue,_casesImessages,_casesInodeType) =+ (cases_ _casesOinLoop _casesOscope _casesOsourcePos )+ ( _elsIactualValue,_elsImessages,_elsInodeType) =+ (els_ _elsOinLoop _elsOscope _elsOsourcePos )+ in ( _lhsOactualValue,_lhsOliftedColumnName,_lhsOmessages,_lhsOnodeType)))+sem_Expression_Cast :: T_Expression ->+ T_TypeName ->+ T_Expression +sem_Expression_Cast expr_ tn_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOliftedColumnName :: String+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: Expression+ _exprOinLoop :: Bool+ _exprOscope :: Scope+ _exprOsourcePos :: MySourcePos+ _tnOinLoop :: Bool+ _tnOscope :: Scope+ _tnOsourcePos :: MySourcePos+ _exprIactualValue :: Expression+ _exprIliftedColumnName :: String+ _exprImessages :: ([Message])+ _exprInodeType :: Type+ _tnIactualValue :: TypeName+ _tnImessages :: ([Message])+ _tnInodeType :: Type+ _lhsOnodeType =+ checkErrors [_exprInodeType]+ _tnInodeType+ _lhsOliftedColumnName =+ case _tnIactualValue of+ SimpleTypeName tn -> tn+ _ -> ""+ _lhsOmessages =+ _exprImessages ++ _tnImessages+ _actualValue =+ Cast _exprIactualValue _tnIactualValue+ _lhsOactualValue =+ _actualValue+ _exprOinLoop =+ _lhsIinLoop+ _exprOscope =+ _lhsIscope+ _exprOsourcePos =+ _lhsIsourcePos+ _tnOinLoop =+ _lhsIinLoop+ _tnOscope =+ _lhsIscope+ _tnOsourcePos =+ _lhsIsourcePos+ ( _exprIactualValue,_exprIliftedColumnName,_exprImessages,_exprInodeType) =+ (expr_ _exprOinLoop _exprOscope _exprOsourcePos )+ ( _tnIactualValue,_tnImessages,_tnInodeType) =+ (tn_ _tnOinLoop _tnOscope _tnOsourcePos )+ in ( _lhsOactualValue,_lhsOliftedColumnName,_lhsOmessages,_lhsOnodeType)))+sem_Expression_Exists :: T_SelectExpression ->+ T_Expression +sem_Expression_Exists sel_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOliftedColumnName :: String+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: Expression+ _selOinLoop :: Bool+ _selOscope :: Scope+ _selOsourcePos :: MySourcePos+ _selIactualValue :: SelectExpression+ _selImessages :: ([Message])+ _selInodeType :: Type+ _lhsOnodeType =+ checkErrors [_selInodeType] typeBool+ _lhsOliftedColumnName =+ ""+ _lhsOmessages =+ _selImessages+ _actualValue =+ Exists _selIactualValue+ _lhsOactualValue =+ _actualValue+ _selOinLoop =+ _lhsIinLoop+ _selOscope =+ _lhsIscope+ _selOsourcePos =+ _lhsIsourcePos+ ( _selIactualValue,_selImessages,_selInodeType) =+ (sel_ _selOinLoop _selOscope _selOsourcePos )+ in ( _lhsOactualValue,_lhsOliftedColumnName,_lhsOmessages,_lhsOnodeType)))+sem_Expression_FloatLit :: Double ->+ T_Expression +sem_Expression_FloatLit double_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOliftedColumnName :: String+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: Expression+ _lhsOnodeType =+ typeNumeric+ _lhsOliftedColumnName =+ ""+ _lhsOmessages =+ []+ _actualValue =+ FloatLit double_+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOliftedColumnName,_lhsOmessages,_lhsOnodeType)))+sem_Expression_FunCall :: String ->+ T_ExpressionList ->+ T_Expression +sem_Expression_FunCall funName_ args_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOliftedColumnName :: String+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: Expression+ _argsOinLoop :: Bool+ _argsOscope :: Scope+ _argsOsourcePos :: MySourcePos+ _argsIactualValue :: ExpressionList+ _argsImessages :: ([Message])+ _argsInodeType :: Type+ _lhsOnodeType =+ checkErrors [_argsInodeType] $+ typeCheckFunCall+ _lhsIscope+ _lhsIsourcePos+ funName_+ _argsInodeType+ _lhsOliftedColumnName =+ if isOperator funName_+ then ""+ else funName_+ _lhsOmessages =+ _argsImessages+ _actualValue =+ FunCall funName_ _argsIactualValue+ _lhsOactualValue =+ _actualValue+ _argsOinLoop =+ _lhsIinLoop+ _argsOscope =+ _lhsIscope+ _argsOsourcePos =+ _lhsIsourcePos+ ( _argsIactualValue,_argsImessages,_argsInodeType) =+ (args_ _argsOinLoop _argsOscope _argsOsourcePos )+ in ( _lhsOactualValue,_lhsOliftedColumnName,_lhsOmessages,_lhsOnodeType)))+sem_Expression_Identifier :: String ->+ T_Expression +sem_Expression_Identifier i_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOliftedColumnName :: String+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: Expression+ _lhsOnodeType =+ let (correlationName,iden) = splitIdentifier i_+ in scopeLookupID _lhsIscope _lhsIsourcePos correlationName iden+ _lhsOliftedColumnName =+ i_+ _lhsOmessages =+ []+ _actualValue =+ Identifier i_+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOliftedColumnName,_lhsOmessages,_lhsOnodeType)))+sem_Expression_InPredicate :: T_Expression ->+ Bool ->+ T_InList ->+ T_Expression +sem_Expression_InPredicate expr_ i_ list_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOliftedColumnName :: String+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: Expression+ _exprOinLoop :: Bool+ _exprOscope :: Scope+ _exprOsourcePos :: MySourcePos+ _listOinLoop :: Bool+ _listOscope :: Scope+ _listOsourcePos :: MySourcePos+ _exprIactualValue :: Expression+ _exprIliftedColumnName :: String+ _exprImessages :: ([Message])+ _exprInodeType :: Type+ _listIactualValue :: InList+ _listImessages :: ([Message])+ _listInodeType :: Type+ _lhsOnodeType =+ let er = resolveResultSetType+ _lhsIscope+ _lhsIsourcePos+ [_exprInodeType, _listInodeType]+ in checkErrors [er] typeBool+ _lhsOliftedColumnName =+ _exprIliftedColumnName+ _lhsOmessages =+ _exprImessages ++ _listImessages+ _actualValue =+ InPredicate _exprIactualValue i_ _listIactualValue+ _lhsOactualValue =+ _actualValue+ _exprOinLoop =+ _lhsIinLoop+ _exprOscope =+ _lhsIscope+ _exprOsourcePos =+ _lhsIsourcePos+ _listOinLoop =+ _lhsIinLoop+ _listOscope =+ _lhsIscope+ _listOsourcePos =+ _lhsIsourcePos+ ( _exprIactualValue,_exprIliftedColumnName,_exprImessages,_exprInodeType) =+ (expr_ _exprOinLoop _exprOscope _exprOsourcePos )+ ( _listIactualValue,_listImessages,_listInodeType) =+ (list_ _listOinLoop _listOscope _listOsourcePos )+ in ( _lhsOactualValue,_lhsOliftedColumnName,_lhsOmessages,_lhsOnodeType)))+sem_Expression_IntegerLit :: Integer ->+ T_Expression +sem_Expression_IntegerLit integer_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOliftedColumnName :: String+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: Expression+ _lhsOnodeType =+ typeInt+ _lhsOliftedColumnName =+ ""+ _lhsOmessages =+ []+ _actualValue =+ IntegerLit integer_+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOliftedColumnName,_lhsOmessages,_lhsOnodeType)))+sem_Expression_NullLit :: T_Expression +sem_Expression_NullLit =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOliftedColumnName :: String+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: Expression+ _lhsOnodeType =+ UnknownStringLit+ _lhsOliftedColumnName =+ ""+ _lhsOmessages =+ []+ _actualValue =+ NullLit+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOliftedColumnName,_lhsOmessages,_lhsOnodeType)))+sem_Expression_PositionalArg :: Integer ->+ T_Expression +sem_Expression_PositionalArg integer_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOliftedColumnName :: String+ _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Expression+ _lhsOliftedColumnName =+ ""+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ PositionalArg integer_+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOliftedColumnName,_lhsOmessages,_lhsOnodeType)))+sem_Expression_ScalarSubQuery :: T_SelectExpression ->+ T_Expression +sem_Expression_ScalarSubQuery sel_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOliftedColumnName :: String+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: Expression+ _selOinLoop :: Bool+ _selOscope :: Scope+ _selOsourcePos :: MySourcePos+ _selIactualValue :: SelectExpression+ _selImessages :: ([Message])+ _selInodeType :: Type+ _lhsOnodeType =+ let f = map snd $ unwrapComposite $ unwrapSetOf _selInodeType+ in checkErrors [_selInodeType] $+ case length f of+ 0 -> error "internal error: no columns in scalar subquery?"+ 1 -> head f+ _ -> RowCtor f+ _lhsOliftedColumnName =+ ""+ _lhsOmessages =+ _selImessages+ _actualValue =+ ScalarSubQuery _selIactualValue+ _lhsOactualValue =+ _actualValue+ _selOinLoop =+ _lhsIinLoop+ _selOscope =+ _lhsIscope+ _selOsourcePos =+ _lhsIsourcePos+ ( _selIactualValue,_selImessages,_selInodeType) =+ (sel_ _selOinLoop _selOscope _selOsourcePos )+ in ( _lhsOactualValue,_lhsOliftedColumnName,_lhsOmessages,_lhsOnodeType)))+sem_Expression_StringLit :: String ->+ String ->+ T_Expression +sem_Expression_StringLit quote_ value_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOliftedColumnName :: String+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: Expression+ _lhsOnodeType =+ UnknownStringLit+ _lhsOliftedColumnName =+ ""+ _lhsOmessages =+ []+ _actualValue =+ StringLit quote_ value_+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOliftedColumnName,_lhsOmessages,_lhsOnodeType)))+sem_Expression_WindowFn :: T_Expression ->+ T_ExpressionList ->+ T_ExpressionList ->+ T_Direction ->+ T_Expression +sem_Expression_WindowFn fn_ partitionBy_ orderBy_ dir_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOliftedColumnName :: String+ _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Expression+ _fnOinLoop :: Bool+ _fnOscope :: Scope+ _fnOsourcePos :: MySourcePos+ _partitionByOinLoop :: Bool+ _partitionByOscope :: Scope+ _partitionByOsourcePos :: MySourcePos+ _orderByOinLoop :: Bool+ _orderByOscope :: Scope+ _orderByOsourcePos :: MySourcePos+ _dirOinLoop :: Bool+ _dirOscope :: Scope+ _dirOsourcePos :: MySourcePos+ _fnIactualValue :: Expression+ _fnIliftedColumnName :: String+ _fnImessages :: ([Message])+ _fnInodeType :: Type+ _partitionByIactualValue :: ExpressionList+ _partitionByImessages :: ([Message])+ _partitionByInodeType :: Type+ _orderByIactualValue :: ExpressionList+ _orderByImessages :: ([Message])+ _orderByInodeType :: Type+ _dirIactualValue :: Direction+ _dirImessages :: ([Message])+ _dirInodeType :: Type+ _lhsOliftedColumnName =+ _fnIliftedColumnName+ _lhsOmessages =+ _fnImessages ++ _partitionByImessages ++ _orderByImessages ++ _dirImessages+ _lhsOnodeType =+ _fnInodeType `setUnknown` _partitionByInodeType `setUnknown` _orderByInodeType `setUnknown` _dirInodeType+ _actualValue =+ WindowFn _fnIactualValue _partitionByIactualValue _orderByIactualValue _dirIactualValue+ _lhsOactualValue =+ _actualValue+ _fnOinLoop =+ _lhsIinLoop+ _fnOscope =+ _lhsIscope+ _fnOsourcePos =+ _lhsIsourcePos+ _partitionByOinLoop =+ _lhsIinLoop+ _partitionByOscope =+ _lhsIscope+ _partitionByOsourcePos =+ _lhsIsourcePos+ _orderByOinLoop =+ _lhsIinLoop+ _orderByOscope =+ _lhsIscope+ _orderByOsourcePos =+ _lhsIsourcePos+ _dirOinLoop =+ _lhsIinLoop+ _dirOscope =+ _lhsIscope+ _dirOsourcePos =+ _lhsIsourcePos+ ( _fnIactualValue,_fnIliftedColumnName,_fnImessages,_fnInodeType) =+ (fn_ _fnOinLoop _fnOscope _fnOsourcePos )+ ( _partitionByIactualValue,_partitionByImessages,_partitionByInodeType) =+ (partitionBy_ _partitionByOinLoop _partitionByOscope _partitionByOsourcePos )+ ( _orderByIactualValue,_orderByImessages,_orderByInodeType) =+ (orderBy_ _orderByOinLoop _orderByOscope _orderByOsourcePos )+ ( _dirIactualValue,_dirImessages,_dirInodeType) =+ (dir_ _dirOinLoop _dirOscope _dirOsourcePos )+ in ( _lhsOactualValue,_lhsOliftedColumnName,_lhsOmessages,_lhsOnodeType)))+-- ExpressionList ----------------------------------------------+type ExpressionList = [(Expression)]+-- cata+sem_ExpressionList :: ExpressionList ->+ T_ExpressionList +sem_ExpressionList list =+ (Prelude.foldr sem_ExpressionList_Cons sem_ExpressionList_Nil (Prelude.map sem_Expression list) )+-- semantic domain+type T_ExpressionList = Bool ->+ Scope ->+ MySourcePos ->+ ( ExpressionList,([Message]),Type)+data Inh_ExpressionList = Inh_ExpressionList {inLoop_Inh_ExpressionList :: Bool,scope_Inh_ExpressionList :: Scope,sourcePos_Inh_ExpressionList :: MySourcePos}+data Syn_ExpressionList = Syn_ExpressionList {actualValue_Syn_ExpressionList :: ExpressionList,messages_Syn_ExpressionList :: [Message],nodeType_Syn_ExpressionList :: Type}+wrap_ExpressionList :: T_ExpressionList ->+ Inh_ExpressionList ->+ Syn_ExpressionList +wrap_ExpressionList sem (Inh_ExpressionList _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_ExpressionList _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_ExpressionList_Cons :: T_Expression ->+ T_ExpressionList ->+ T_ExpressionList +sem_ExpressionList_Cons hd_ tl_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: ExpressionList+ _hdOinLoop :: Bool+ _hdOscope :: Scope+ _hdOsourcePos :: MySourcePos+ _tlOinLoop :: Bool+ _tlOscope :: Scope+ _tlOsourcePos :: MySourcePos+ _hdIactualValue :: Expression+ _hdIliftedColumnName :: String+ _hdImessages :: ([Message])+ _hdInodeType :: Type+ _tlIactualValue :: ExpressionList+ _tlImessages :: ([Message])+ _tlInodeType :: Type+ _lhsOmessages =+ _hdImessages ++ _tlImessages+ _lhsOnodeType =+ _hdInodeType `appendTypeList` _tlInodeType+ _actualValue =+ (:) _hdIactualValue _tlIactualValue+ _lhsOactualValue =+ _actualValue+ _hdOinLoop =+ _lhsIinLoop+ _hdOscope =+ _lhsIscope+ _hdOsourcePos =+ _lhsIsourcePos+ _tlOinLoop =+ _lhsIinLoop+ _tlOscope =+ _lhsIscope+ _tlOsourcePos =+ _lhsIsourcePos+ ( _hdIactualValue,_hdIliftedColumnName,_hdImessages,_hdInodeType) =+ (hd_ _hdOinLoop _hdOscope _hdOsourcePos )+ ( _tlIactualValue,_tlImessages,_tlInodeType) =+ (tl_ _tlOinLoop _tlOscope _tlOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_ExpressionList_Nil :: T_ExpressionList +sem_ExpressionList_Nil =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: ExpressionList+ _lhsOmessages =+ []+ _lhsOnodeType =+ TypeList []+ _actualValue =+ []+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- ExpressionListList ------------------------------------------+type ExpressionListList = [(ExpressionList)]+-- cata+sem_ExpressionListList :: ExpressionListList ->+ T_ExpressionListList +sem_ExpressionListList list =+ (Prelude.foldr sem_ExpressionListList_Cons sem_ExpressionListList_Nil (Prelude.map sem_ExpressionList list) )+-- semantic domain+type T_ExpressionListList = Bool ->+ Scope ->+ MySourcePos ->+ ( ExpressionListList,([Message]),Type)+data Inh_ExpressionListList = Inh_ExpressionListList {inLoop_Inh_ExpressionListList :: Bool,scope_Inh_ExpressionListList :: Scope,sourcePos_Inh_ExpressionListList :: MySourcePos}+data Syn_ExpressionListList = Syn_ExpressionListList {actualValue_Syn_ExpressionListList :: ExpressionListList,messages_Syn_ExpressionListList :: [Message],nodeType_Syn_ExpressionListList :: Type}+wrap_ExpressionListList :: T_ExpressionListList ->+ Inh_ExpressionListList ->+ Syn_ExpressionListList +wrap_ExpressionListList sem (Inh_ExpressionListList _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_ExpressionListList _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_ExpressionListList_Cons :: T_ExpressionList ->+ T_ExpressionListList ->+ T_ExpressionListList +sem_ExpressionListList_Cons hd_ tl_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: ExpressionListList+ _hdOinLoop :: Bool+ _hdOscope :: Scope+ _hdOsourcePos :: MySourcePos+ _tlOinLoop :: Bool+ _tlOscope :: Scope+ _tlOsourcePos :: MySourcePos+ _hdIactualValue :: ExpressionList+ _hdImessages :: ([Message])+ _hdInodeType :: Type+ _tlIactualValue :: ExpressionListList+ _tlImessages :: ([Message])+ _tlInodeType :: Type+ _lhsOmessages =+ _hdImessages ++ _tlImessages+ _lhsOnodeType =+ _hdInodeType `appendTypeList` _tlInodeType+ _actualValue =+ (:) _hdIactualValue _tlIactualValue+ _lhsOactualValue =+ _actualValue+ _hdOinLoop =+ _lhsIinLoop+ _hdOscope =+ _lhsIscope+ _hdOsourcePos =+ _lhsIsourcePos+ _tlOinLoop =+ _lhsIinLoop+ _tlOscope =+ _lhsIscope+ _tlOsourcePos =+ _lhsIsourcePos+ ( _hdIactualValue,_hdImessages,_hdInodeType) =+ (hd_ _hdOinLoop _hdOscope _hdOsourcePos )+ ( _tlIactualValue,_tlImessages,_tlInodeType) =+ (tl_ _tlOinLoop _tlOscope _tlOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_ExpressionListList_Nil :: T_ExpressionListList +sem_ExpressionListList_Nil =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: ExpressionListList+ _lhsOmessages =+ []+ _lhsOnodeType =+ TypeList []+ _actualValue =+ []+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- ExpressionListStatementListPair -----------------------------+type ExpressionListStatementListPair = ( (ExpressionList),(StatementList))+-- cata+sem_ExpressionListStatementListPair :: ExpressionListStatementListPair ->+ T_ExpressionListStatementListPair +sem_ExpressionListStatementListPair ( x1,x2) =+ (sem_ExpressionListStatementListPair_Tuple (sem_ExpressionList x1 ) (sem_StatementList x2 ) )+-- semantic domain+type T_ExpressionListStatementListPair = Bool ->+ Scope ->+ MySourcePos ->+ ( ExpressionListStatementListPair,([Message]),Type)+data Inh_ExpressionListStatementListPair = Inh_ExpressionListStatementListPair {inLoop_Inh_ExpressionListStatementListPair :: Bool,scope_Inh_ExpressionListStatementListPair :: Scope,sourcePos_Inh_ExpressionListStatementListPair :: MySourcePos}+data Syn_ExpressionListStatementListPair = Syn_ExpressionListStatementListPair {actualValue_Syn_ExpressionListStatementListPair :: ExpressionListStatementListPair,messages_Syn_ExpressionListStatementListPair :: [Message],nodeType_Syn_ExpressionListStatementListPair :: Type}+wrap_ExpressionListStatementListPair :: T_ExpressionListStatementListPair ->+ Inh_ExpressionListStatementListPair ->+ Syn_ExpressionListStatementListPair +wrap_ExpressionListStatementListPair sem (Inh_ExpressionListStatementListPair _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_ExpressionListStatementListPair _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_ExpressionListStatementListPair_Tuple :: T_ExpressionList ->+ T_StatementList ->+ T_ExpressionListStatementListPair +sem_ExpressionListStatementListPair_Tuple x1_ x2_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: ExpressionListStatementListPair+ _x1OinLoop :: Bool+ _x1Oscope :: Scope+ _x1OsourcePos :: MySourcePos+ _x2OinLoop :: Bool+ _x2Oscope :: Scope+ _x2OsourcePos :: MySourcePos+ _x1IactualValue :: ExpressionList+ _x1Imessages :: ([Message])+ _x1InodeType :: Type+ _x2IactualValue :: StatementList+ _x2Imessages :: ([Message])+ _x2InodeType :: Type+ _x2IstatementInfo :: ([StatementInfo])+ _lhsOmessages =+ _x1Imessages ++ _x2Imessages+ _lhsOnodeType =+ _x1InodeType `setUnknown` _x2InodeType+ _actualValue =+ (_x1IactualValue,_x2IactualValue)+ _lhsOactualValue =+ _actualValue+ _x1OinLoop =+ _lhsIinLoop+ _x1Oscope =+ _lhsIscope+ _x1OsourcePos =+ _lhsIsourcePos+ _x2OinLoop =+ _lhsIinLoop+ _x2Oscope =+ _lhsIscope+ _x2OsourcePos =+ _lhsIsourcePos+ ( _x1IactualValue,_x1Imessages,_x1InodeType) =+ (x1_ _x1OinLoop _x1Oscope _x1OsourcePos )+ ( _x2IactualValue,_x2Imessages,_x2InodeType,_x2IstatementInfo) =+ (x2_ _x2OinLoop _x2Oscope _x2OsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- ExpressionListStatementListPairList -------------------------+type ExpressionListStatementListPairList = [(ExpressionListStatementListPair)]+-- cata+sem_ExpressionListStatementListPairList :: ExpressionListStatementListPairList ->+ T_ExpressionListStatementListPairList +sem_ExpressionListStatementListPairList list =+ (Prelude.foldr sem_ExpressionListStatementListPairList_Cons sem_ExpressionListStatementListPairList_Nil (Prelude.map sem_ExpressionListStatementListPair list) )+-- semantic domain+type T_ExpressionListStatementListPairList = Bool ->+ Scope ->+ MySourcePos ->+ ( ExpressionListStatementListPairList,([Message]),Type)+data Inh_ExpressionListStatementListPairList = Inh_ExpressionListStatementListPairList {inLoop_Inh_ExpressionListStatementListPairList :: Bool,scope_Inh_ExpressionListStatementListPairList :: Scope,sourcePos_Inh_ExpressionListStatementListPairList :: MySourcePos}+data Syn_ExpressionListStatementListPairList = Syn_ExpressionListStatementListPairList {actualValue_Syn_ExpressionListStatementListPairList :: ExpressionListStatementListPairList,messages_Syn_ExpressionListStatementListPairList :: [Message],nodeType_Syn_ExpressionListStatementListPairList :: Type}+wrap_ExpressionListStatementListPairList :: T_ExpressionListStatementListPairList ->+ Inh_ExpressionListStatementListPairList ->+ Syn_ExpressionListStatementListPairList +wrap_ExpressionListStatementListPairList sem (Inh_ExpressionListStatementListPairList _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_ExpressionListStatementListPairList _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_ExpressionListStatementListPairList_Cons :: T_ExpressionListStatementListPair ->+ T_ExpressionListStatementListPairList ->+ T_ExpressionListStatementListPairList +sem_ExpressionListStatementListPairList_Cons hd_ tl_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: ExpressionListStatementListPairList+ _hdOinLoop :: Bool+ _hdOscope :: Scope+ _hdOsourcePos :: MySourcePos+ _tlOinLoop :: Bool+ _tlOscope :: Scope+ _tlOsourcePos :: MySourcePos+ _hdIactualValue :: ExpressionListStatementListPair+ _hdImessages :: ([Message])+ _hdInodeType :: Type+ _tlIactualValue :: ExpressionListStatementListPairList+ _tlImessages :: ([Message])+ _tlInodeType :: Type+ _lhsOmessages =+ _hdImessages ++ _tlImessages+ _lhsOnodeType =+ _hdInodeType `appendTypeList` _tlInodeType+ _actualValue =+ (:) _hdIactualValue _tlIactualValue+ _lhsOactualValue =+ _actualValue+ _hdOinLoop =+ _lhsIinLoop+ _hdOscope =+ _lhsIscope+ _hdOsourcePos =+ _lhsIsourcePos+ _tlOinLoop =+ _lhsIinLoop+ _tlOscope =+ _lhsIscope+ _tlOsourcePos =+ _lhsIsourcePos+ ( _hdIactualValue,_hdImessages,_hdInodeType) =+ (hd_ _hdOinLoop _hdOscope _hdOsourcePos )+ ( _tlIactualValue,_tlImessages,_tlInodeType) =+ (tl_ _tlOinLoop _tlOscope _tlOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_ExpressionListStatementListPairList_Nil :: T_ExpressionListStatementListPairList +sem_ExpressionListStatementListPairList_Nil =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: ExpressionListStatementListPairList+ _lhsOmessages =+ []+ _lhsOnodeType =+ TypeList []+ _actualValue =+ []+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- ExpressionRoot ----------------------------------------------+data ExpressionRoot = ExpressionRoot (Expression) + deriving ( Show)+-- cata+sem_ExpressionRoot :: ExpressionRoot ->+ T_ExpressionRoot +sem_ExpressionRoot (ExpressionRoot _expr ) =+ (sem_ExpressionRoot_ExpressionRoot (sem_Expression _expr ) )+-- semantic domain+type T_ExpressionRoot = Scope ->+ ( ExpressionRoot,([Message]),Type)+data Inh_ExpressionRoot = Inh_ExpressionRoot {scope_Inh_ExpressionRoot :: Scope}+data Syn_ExpressionRoot = Syn_ExpressionRoot {actualValue_Syn_ExpressionRoot :: ExpressionRoot,messages_Syn_ExpressionRoot :: [Message],nodeType_Syn_ExpressionRoot :: Type}+wrap_ExpressionRoot :: T_ExpressionRoot ->+ Inh_ExpressionRoot ->+ Syn_ExpressionRoot +wrap_ExpressionRoot sem (Inh_ExpressionRoot _lhsIscope ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIscope )+ in (Syn_ExpressionRoot _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_ExpressionRoot_ExpressionRoot :: T_Expression ->+ T_ExpressionRoot +sem_ExpressionRoot_ExpressionRoot expr_ =+ (\ _lhsIscope ->+ (let _exprOsourcePos :: MySourcePos+ _exprOinLoop :: Bool+ _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: ExpressionRoot+ _exprOscope :: Scope+ _exprIactualValue :: Expression+ _exprIliftedColumnName :: String+ _exprImessages :: ([Message])+ _exprInodeType :: Type+ _exprOsourcePos =+ ("",0,0)+ _exprOinLoop =+ False+ _lhsOmessages =+ _exprImessages+ _lhsOnodeType =+ _exprInodeType+ _actualValue =+ ExpressionRoot _exprIactualValue+ _lhsOactualValue =+ _actualValue+ _exprOscope =+ _lhsIscope+ ( _exprIactualValue,_exprIliftedColumnName,_exprImessages,_exprInodeType) =+ (expr_ _exprOinLoop _exprOscope _exprOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- ExpressionStatementListPair ---------------------------------+type ExpressionStatementListPair = ( (Expression),(StatementList))+-- cata+sem_ExpressionStatementListPair :: ExpressionStatementListPair ->+ T_ExpressionStatementListPair +sem_ExpressionStatementListPair ( x1,x2) =+ (sem_ExpressionStatementListPair_Tuple (sem_Expression x1 ) (sem_StatementList x2 ) )+-- semantic domain+type T_ExpressionStatementListPair = Bool ->+ Scope ->+ MySourcePos ->+ ( ExpressionStatementListPair,([Message]),Type)+data Inh_ExpressionStatementListPair = Inh_ExpressionStatementListPair {inLoop_Inh_ExpressionStatementListPair :: Bool,scope_Inh_ExpressionStatementListPair :: Scope,sourcePos_Inh_ExpressionStatementListPair :: MySourcePos}+data Syn_ExpressionStatementListPair = Syn_ExpressionStatementListPair {actualValue_Syn_ExpressionStatementListPair :: ExpressionStatementListPair,messages_Syn_ExpressionStatementListPair :: [Message],nodeType_Syn_ExpressionStatementListPair :: Type}+wrap_ExpressionStatementListPair :: T_ExpressionStatementListPair ->+ Inh_ExpressionStatementListPair ->+ Syn_ExpressionStatementListPair +wrap_ExpressionStatementListPair sem (Inh_ExpressionStatementListPair _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_ExpressionStatementListPair _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_ExpressionStatementListPair_Tuple :: T_Expression ->+ T_StatementList ->+ T_ExpressionStatementListPair +sem_ExpressionStatementListPair_Tuple x1_ x2_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: ExpressionStatementListPair+ _x1OinLoop :: Bool+ _x1Oscope :: Scope+ _x1OsourcePos :: MySourcePos+ _x2OinLoop :: Bool+ _x2Oscope :: Scope+ _x2OsourcePos :: MySourcePos+ _x1IactualValue :: Expression+ _x1IliftedColumnName :: String+ _x1Imessages :: ([Message])+ _x1InodeType :: Type+ _x2IactualValue :: StatementList+ _x2Imessages :: ([Message])+ _x2InodeType :: Type+ _x2IstatementInfo :: ([StatementInfo])+ _lhsOmessages =+ _x1Imessages ++ _x2Imessages+ _lhsOnodeType =+ _x1InodeType `setUnknown` _x2InodeType+ _actualValue =+ (_x1IactualValue,_x2IactualValue)+ _lhsOactualValue =+ _actualValue+ _x1OinLoop =+ _lhsIinLoop+ _x1Oscope =+ _lhsIscope+ _x1OsourcePos =+ _lhsIsourcePos+ _x2OinLoop =+ _lhsIinLoop+ _x2Oscope =+ _lhsIscope+ _x2OsourcePos =+ _lhsIsourcePos+ ( _x1IactualValue,_x1IliftedColumnName,_x1Imessages,_x1InodeType) =+ (x1_ _x1OinLoop _x1Oscope _x1OsourcePos )+ ( _x2IactualValue,_x2Imessages,_x2InodeType,_x2IstatementInfo) =+ (x2_ _x2OinLoop _x2Oscope _x2OsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- ExpressionStatementListPairList -----------------------------+type ExpressionStatementListPairList = [(ExpressionStatementListPair)]+-- cata+sem_ExpressionStatementListPairList :: ExpressionStatementListPairList ->+ T_ExpressionStatementListPairList +sem_ExpressionStatementListPairList list =+ (Prelude.foldr sem_ExpressionStatementListPairList_Cons sem_ExpressionStatementListPairList_Nil (Prelude.map sem_ExpressionStatementListPair list) )+-- semantic domain+type T_ExpressionStatementListPairList = Bool ->+ Scope ->+ MySourcePos ->+ ( ExpressionStatementListPairList,([Message]),Type)+data Inh_ExpressionStatementListPairList = Inh_ExpressionStatementListPairList {inLoop_Inh_ExpressionStatementListPairList :: Bool,scope_Inh_ExpressionStatementListPairList :: Scope,sourcePos_Inh_ExpressionStatementListPairList :: MySourcePos}+data Syn_ExpressionStatementListPairList = Syn_ExpressionStatementListPairList {actualValue_Syn_ExpressionStatementListPairList :: ExpressionStatementListPairList,messages_Syn_ExpressionStatementListPairList :: [Message],nodeType_Syn_ExpressionStatementListPairList :: Type}+wrap_ExpressionStatementListPairList :: T_ExpressionStatementListPairList ->+ Inh_ExpressionStatementListPairList ->+ Syn_ExpressionStatementListPairList +wrap_ExpressionStatementListPairList sem (Inh_ExpressionStatementListPairList _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_ExpressionStatementListPairList _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_ExpressionStatementListPairList_Cons :: T_ExpressionStatementListPair ->+ T_ExpressionStatementListPairList ->+ T_ExpressionStatementListPairList +sem_ExpressionStatementListPairList_Cons hd_ tl_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: ExpressionStatementListPairList+ _hdOinLoop :: Bool+ _hdOscope :: Scope+ _hdOsourcePos :: MySourcePos+ _tlOinLoop :: Bool+ _tlOscope :: Scope+ _tlOsourcePos :: MySourcePos+ _hdIactualValue :: ExpressionStatementListPair+ _hdImessages :: ([Message])+ _hdInodeType :: Type+ _tlIactualValue :: ExpressionStatementListPairList+ _tlImessages :: ([Message])+ _tlInodeType :: Type+ _lhsOmessages =+ _hdImessages ++ _tlImessages+ _lhsOnodeType =+ _hdInodeType `appendTypeList` _tlInodeType+ _actualValue =+ (:) _hdIactualValue _tlIactualValue+ _lhsOactualValue =+ _actualValue+ _hdOinLoop =+ _lhsIinLoop+ _hdOscope =+ _lhsIscope+ _hdOsourcePos =+ _lhsIsourcePos+ _tlOinLoop =+ _lhsIinLoop+ _tlOscope =+ _lhsIscope+ _tlOsourcePos =+ _lhsIsourcePos+ ( _hdIactualValue,_hdImessages,_hdInodeType) =+ (hd_ _hdOinLoop _hdOscope _hdOsourcePos )+ ( _tlIactualValue,_tlImessages,_tlInodeType) =+ (tl_ _tlOinLoop _tlOscope _tlOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_ExpressionStatementListPairList_Nil :: T_ExpressionStatementListPairList +sem_ExpressionStatementListPairList_Nil =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: ExpressionStatementListPairList+ _lhsOmessages =+ []+ _lhsOnodeType =+ TypeList []+ _actualValue =+ []+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- FnBody ------------------------------------------------------+data FnBody = PlpgsqlFnBody (VarDefList) (StatementList) + | SqlFnBody (StatementList) + deriving ( Eq,Show)+-- cata+sem_FnBody :: FnBody ->+ T_FnBody +sem_FnBody (PlpgsqlFnBody _varDefList _sts ) =+ (sem_FnBody_PlpgsqlFnBody (sem_VarDefList _varDefList ) (sem_StatementList _sts ) )+sem_FnBody (SqlFnBody _sts ) =+ (sem_FnBody_SqlFnBody (sem_StatementList _sts ) )+-- semantic domain+type T_FnBody = Bool ->+ Scope ->+ MySourcePos ->+ ( FnBody,([Message]),Type)+data Inh_FnBody = Inh_FnBody {inLoop_Inh_FnBody :: Bool,scope_Inh_FnBody :: Scope,sourcePos_Inh_FnBody :: MySourcePos}+data Syn_FnBody = Syn_FnBody {actualValue_Syn_FnBody :: FnBody,messages_Syn_FnBody :: [Message],nodeType_Syn_FnBody :: Type}+wrap_FnBody :: T_FnBody ->+ Inh_FnBody ->+ Syn_FnBody +wrap_FnBody sem (Inh_FnBody _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_FnBody _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_FnBody_PlpgsqlFnBody :: T_VarDefList ->+ T_StatementList ->+ T_FnBody +sem_FnBody_PlpgsqlFnBody varDefList_ sts_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: FnBody+ _varDefListOinLoop :: Bool+ _varDefListOscope :: Scope+ _varDefListOsourcePos :: MySourcePos+ _stsOinLoop :: Bool+ _stsOscope :: Scope+ _stsOsourcePos :: MySourcePos+ _varDefListIactualValue :: VarDefList+ _varDefListImessages :: ([Message])+ _varDefListInodeType :: Type+ _stsIactualValue :: StatementList+ _stsImessages :: ([Message])+ _stsInodeType :: Type+ _stsIstatementInfo :: ([StatementInfo])+ _lhsOmessages =+ _varDefListImessages ++ _stsImessages+ _lhsOnodeType =+ _varDefListInodeType `setUnknown` _stsInodeType+ _actualValue =+ PlpgsqlFnBody _varDefListIactualValue _stsIactualValue+ _lhsOactualValue =+ _actualValue+ _varDefListOinLoop =+ _lhsIinLoop+ _varDefListOscope =+ _lhsIscope+ _varDefListOsourcePos =+ _lhsIsourcePos+ _stsOinLoop =+ _lhsIinLoop+ _stsOscope =+ _lhsIscope+ _stsOsourcePos =+ _lhsIsourcePos+ ( _varDefListIactualValue,_varDefListImessages,_varDefListInodeType) =+ (varDefList_ _varDefListOinLoop _varDefListOscope _varDefListOsourcePos )+ ( _stsIactualValue,_stsImessages,_stsInodeType,_stsIstatementInfo) =+ (sts_ _stsOinLoop _stsOscope _stsOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_FnBody_SqlFnBody :: T_StatementList ->+ T_FnBody +sem_FnBody_SqlFnBody sts_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: FnBody+ _stsOinLoop :: Bool+ _stsOscope :: Scope+ _stsOsourcePos :: MySourcePos+ _stsIactualValue :: StatementList+ _stsImessages :: ([Message])+ _stsInodeType :: Type+ _stsIstatementInfo :: ([StatementInfo])+ _lhsOmessages =+ _stsImessages+ _lhsOnodeType =+ _stsInodeType+ _actualValue =+ SqlFnBody _stsIactualValue+ _lhsOactualValue =+ _actualValue+ _stsOinLoop =+ _lhsIinLoop+ _stsOscope =+ _lhsIscope+ _stsOsourcePos =+ _lhsIsourcePos+ ( _stsIactualValue,_stsImessages,_stsInodeType,_stsIstatementInfo) =+ (sts_ _stsOinLoop _stsOscope _stsOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- IfExists ----------------------------------------------------+data IfExists = IfExists + | Require + deriving ( Eq,Show)+-- cata+sem_IfExists :: IfExists ->+ T_IfExists +sem_IfExists (IfExists ) =+ (sem_IfExists_IfExists )+sem_IfExists (Require ) =+ (sem_IfExists_Require )+-- semantic domain+type T_IfExists = Bool ->+ Scope ->+ MySourcePos ->+ ( IfExists,([Message]),Type)+data Inh_IfExists = Inh_IfExists {inLoop_Inh_IfExists :: Bool,scope_Inh_IfExists :: Scope,sourcePos_Inh_IfExists :: MySourcePos}+data Syn_IfExists = Syn_IfExists {actualValue_Syn_IfExists :: IfExists,messages_Syn_IfExists :: [Message],nodeType_Syn_IfExists :: Type}+wrap_IfExists :: T_IfExists ->+ Inh_IfExists ->+ Syn_IfExists +wrap_IfExists sem (Inh_IfExists _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_IfExists _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_IfExists_IfExists :: T_IfExists +sem_IfExists_IfExists =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: IfExists+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ IfExists+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_IfExists_Require :: T_IfExists +sem_IfExists_Require =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: IfExists+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ Require+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- InList ------------------------------------------------------+data InList = InList (ExpressionList) + | InSelect (SelectExpression) + deriving ( Eq,Show)+-- cata+sem_InList :: InList ->+ T_InList +sem_InList (InList _exprs ) =+ (sem_InList_InList (sem_ExpressionList _exprs ) )+sem_InList (InSelect _sel ) =+ (sem_InList_InSelect (sem_SelectExpression _sel ) )+-- semantic domain+type T_InList = Bool ->+ Scope ->+ MySourcePos ->+ ( InList,([Message]),Type)+data Inh_InList = Inh_InList {inLoop_Inh_InList :: Bool,scope_Inh_InList :: Scope,sourcePos_Inh_InList :: MySourcePos}+data Syn_InList = Syn_InList {actualValue_Syn_InList :: InList,messages_Syn_InList :: [Message],nodeType_Syn_InList :: Type}+wrap_InList :: T_InList ->+ Inh_InList ->+ Syn_InList +wrap_InList sem (Inh_InList _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_InList _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_InList_InList :: T_ExpressionList ->+ T_InList +sem_InList_InList exprs_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: InList+ _exprsOinLoop :: Bool+ _exprsOscope :: Scope+ _exprsOsourcePos :: MySourcePos+ _exprsIactualValue :: ExpressionList+ _exprsImessages :: ([Message])+ _exprsInodeType :: Type+ _lhsOnodeType =+ resolveResultSetType+ _lhsIscope+ _lhsIsourcePos+ $ unwrapTypeList _exprsInodeType+ _lhsOmessages =+ _exprsImessages+ _actualValue =+ InList _exprsIactualValue+ _lhsOactualValue =+ _actualValue+ _exprsOinLoop =+ _lhsIinLoop+ _exprsOscope =+ _lhsIscope+ _exprsOsourcePos =+ _lhsIsourcePos+ ( _exprsIactualValue,_exprsImessages,_exprsInodeType) =+ (exprs_ _exprsOinLoop _exprsOscope _exprsOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_InList_InSelect :: T_SelectExpression ->+ T_InList +sem_InList_InSelect sel_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: InList+ _selOinLoop :: Bool+ _selOscope :: Scope+ _selOsourcePos :: MySourcePos+ _selIactualValue :: SelectExpression+ _selImessages :: ([Message])+ _selInodeType :: Type+ _lhsOnodeType =+ let attrs = map snd $ unwrapComposite $ unwrapSetOf $ _selInodeType+ in case length attrs of+ 0 -> error "internal error - got subquery with no columns? in inselect"+ 1 -> head attrs+ _ -> RowCtor attrs+ _lhsOmessages =+ _selImessages+ _actualValue =+ InSelect _selIactualValue+ _lhsOactualValue =+ _actualValue+ _selOinLoop =+ _lhsIinLoop+ _selOscope =+ _lhsIscope+ _selOsourcePos =+ _lhsIsourcePos+ ( _selIactualValue,_selImessages,_selInodeType) =+ (sel_ _selOinLoop _selOscope _selOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- JoinExpression ----------------------------------------------+data JoinExpression = JoinOn (Expression) + | JoinUsing (StringList) + deriving ( Eq,Show)+-- cata+sem_JoinExpression :: JoinExpression ->+ T_JoinExpression +sem_JoinExpression (JoinOn _expression ) =+ (sem_JoinExpression_JoinOn (sem_Expression _expression ) )+sem_JoinExpression (JoinUsing _stringList ) =+ (sem_JoinExpression_JoinUsing (sem_StringList _stringList ) )+-- semantic domain+type T_JoinExpression = Bool ->+ Scope ->+ MySourcePos ->+ ( JoinExpression,([Message]),Type)+data Inh_JoinExpression = Inh_JoinExpression {inLoop_Inh_JoinExpression :: Bool,scope_Inh_JoinExpression :: Scope,sourcePos_Inh_JoinExpression :: MySourcePos}+data Syn_JoinExpression = Syn_JoinExpression {actualValue_Syn_JoinExpression :: JoinExpression,messages_Syn_JoinExpression :: [Message],nodeType_Syn_JoinExpression :: Type}+wrap_JoinExpression :: T_JoinExpression ->+ Inh_JoinExpression ->+ Syn_JoinExpression +wrap_JoinExpression sem (Inh_JoinExpression _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_JoinExpression _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_JoinExpression_JoinOn :: T_Expression ->+ T_JoinExpression +sem_JoinExpression_JoinOn expression_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: JoinExpression+ _expressionOinLoop :: Bool+ _expressionOscope :: Scope+ _expressionOsourcePos :: MySourcePos+ _expressionIactualValue :: Expression+ _expressionIliftedColumnName :: String+ _expressionImessages :: ([Message])+ _expressionInodeType :: Type+ _lhsOmessages =+ _expressionImessages+ _lhsOnodeType =+ _expressionInodeType+ _actualValue =+ JoinOn _expressionIactualValue+ _lhsOactualValue =+ _actualValue+ _expressionOinLoop =+ _lhsIinLoop+ _expressionOscope =+ _lhsIscope+ _expressionOsourcePos =+ _lhsIsourcePos+ ( _expressionIactualValue,_expressionIliftedColumnName,_expressionImessages,_expressionInodeType) =+ (expression_ _expressionOinLoop _expressionOscope _expressionOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_JoinExpression_JoinUsing :: T_StringList ->+ T_JoinExpression +sem_JoinExpression_JoinUsing stringList_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: JoinExpression+ _stringListOinLoop :: Bool+ _stringListOscope :: Scope+ _stringListOsourcePos :: MySourcePos+ _stringListIactualValue :: StringList+ _stringListImessages :: ([Message])+ _stringListInodeType :: Type+ _stringListIstrings :: ([String])+ _lhsOmessages =+ _stringListImessages+ _lhsOnodeType =+ _stringListInodeType+ _actualValue =+ JoinUsing _stringListIactualValue+ _lhsOactualValue =+ _actualValue+ _stringListOinLoop =+ _lhsIinLoop+ _stringListOscope =+ _lhsIscope+ _stringListOsourcePos =+ _lhsIsourcePos+ ( _stringListIactualValue,_stringListImessages,_stringListInodeType,_stringListIstrings) =+ (stringList_ _stringListOinLoop _stringListOscope _stringListOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- JoinType ----------------------------------------------------+data JoinType = Cross + | FullOuter + | Inner + | LeftOuter + | RightOuter + deriving ( Eq,Show)+-- cata+sem_JoinType :: JoinType ->+ T_JoinType +sem_JoinType (Cross ) =+ (sem_JoinType_Cross )+sem_JoinType (FullOuter ) =+ (sem_JoinType_FullOuter )+sem_JoinType (Inner ) =+ (sem_JoinType_Inner )+sem_JoinType (LeftOuter ) =+ (sem_JoinType_LeftOuter )+sem_JoinType (RightOuter ) =+ (sem_JoinType_RightOuter )+-- semantic domain+type T_JoinType = Bool ->+ Scope ->+ MySourcePos ->+ ( JoinType,([Message]),Type)+data Inh_JoinType = Inh_JoinType {inLoop_Inh_JoinType :: Bool,scope_Inh_JoinType :: Scope,sourcePos_Inh_JoinType :: MySourcePos}+data Syn_JoinType = Syn_JoinType {actualValue_Syn_JoinType :: JoinType,messages_Syn_JoinType :: [Message],nodeType_Syn_JoinType :: Type}+wrap_JoinType :: T_JoinType ->+ Inh_JoinType ->+ Syn_JoinType +wrap_JoinType sem (Inh_JoinType _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_JoinType _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_JoinType_Cross :: T_JoinType +sem_JoinType_Cross =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: JoinType+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ Cross+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_JoinType_FullOuter :: T_JoinType +sem_JoinType_FullOuter =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: JoinType+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ FullOuter+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_JoinType_Inner :: T_JoinType +sem_JoinType_Inner =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: JoinType+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ Inner+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_JoinType_LeftOuter :: T_JoinType +sem_JoinType_LeftOuter =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: JoinType+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ LeftOuter+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_JoinType_RightOuter :: T_JoinType +sem_JoinType_RightOuter =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: JoinType+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ RightOuter+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- Language ----------------------------------------------------+data Language = Plpgsql + | Sql + deriving ( Eq,Show)+-- cata+sem_Language :: Language ->+ T_Language +sem_Language (Plpgsql ) =+ (sem_Language_Plpgsql )+sem_Language (Sql ) =+ (sem_Language_Sql )+-- semantic domain+type T_Language = Bool ->+ Scope ->+ MySourcePos ->+ ( Language,([Message]),Type)+data Inh_Language = Inh_Language {inLoop_Inh_Language :: Bool,scope_Inh_Language :: Scope,sourcePos_Inh_Language :: MySourcePos}+data Syn_Language = Syn_Language {actualValue_Syn_Language :: Language,messages_Syn_Language :: [Message],nodeType_Syn_Language :: Type}+wrap_Language :: T_Language ->+ Inh_Language ->+ Syn_Language +wrap_Language sem (Inh_Language _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_Language _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_Language_Plpgsql :: T_Language +sem_Language_Plpgsql =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Language+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ Plpgsql+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_Language_Sql :: T_Language +sem_Language_Sql =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Language+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ Sql+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- MTableRef ---------------------------------------------------+type MTableRef = (Maybe (TableRef))+-- cata+sem_MTableRef :: MTableRef ->+ T_MTableRef +sem_MTableRef (Prelude.Just x ) =+ (sem_MTableRef_Just (sem_TableRef x ) )+sem_MTableRef Prelude.Nothing =+ sem_MTableRef_Nothing+-- semantic domain+type T_MTableRef = Bool ->+ Scope ->+ MySourcePos ->+ ( MTableRef,([QualifiedScope]),([String]),([Message]),Type)+data Inh_MTableRef = Inh_MTableRef {inLoop_Inh_MTableRef :: Bool,scope_Inh_MTableRef :: Scope,sourcePos_Inh_MTableRef :: MySourcePos}+data Syn_MTableRef = Syn_MTableRef {actualValue_Syn_MTableRef :: MTableRef,idens_Syn_MTableRef :: [QualifiedScope],joinIdens_Syn_MTableRef :: [String],messages_Syn_MTableRef :: [Message],nodeType_Syn_MTableRef :: Type}+wrap_MTableRef :: T_MTableRef ->+ Inh_MTableRef ->+ Syn_MTableRef +wrap_MTableRef sem (Inh_MTableRef _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOidens,_lhsOjoinIdens,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_MTableRef _lhsOactualValue _lhsOidens _lhsOjoinIdens _lhsOmessages _lhsOnodeType ))+sem_MTableRef_Just :: T_TableRef ->+ T_MTableRef +sem_MTableRef_Just just_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: MTableRef+ _lhsOidens :: ([QualifiedScope])+ _lhsOjoinIdens :: ([String])+ _justOinLoop :: Bool+ _justOscope :: Scope+ _justOsourcePos :: MySourcePos+ _justIactualValue :: TableRef+ _justIidens :: ([QualifiedScope])+ _justIjoinIdens :: ([String])+ _justImessages :: ([Message])+ _justInodeType :: Type+ _lhsOnodeType =+ _justInodeType+ _lhsOmessages =+ _justImessages+ _actualValue =+ Just _justIactualValue+ _lhsOactualValue =+ _actualValue+ _lhsOidens =+ _justIidens+ _lhsOjoinIdens =+ _justIjoinIdens+ _justOinLoop =+ _lhsIinLoop+ _justOscope =+ _lhsIscope+ _justOsourcePos =+ _lhsIsourcePos+ ( _justIactualValue,_justIidens,_justIjoinIdens,_justImessages,_justInodeType) =+ (just_ _justOinLoop _justOscope _justOsourcePos )+ in ( _lhsOactualValue,_lhsOidens,_lhsOjoinIdens,_lhsOmessages,_lhsOnodeType)))+sem_MTableRef_Nothing :: T_MTableRef +sem_MTableRef_Nothing =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOidens :: ([QualifiedScope])+ _lhsOjoinIdens :: ([String])+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: MTableRef+ _lhsOnodeType =+ TypeList []+ _lhsOidens =+ []+ _lhsOjoinIdens =+ []+ _lhsOmessages =+ []+ _actualValue =+ Nothing+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOidens,_lhsOjoinIdens,_lhsOmessages,_lhsOnodeType)))+-- MaybeExpression ---------------------------------------------+type MaybeExpression = (Maybe (Expression))+-- cata+sem_MaybeExpression :: MaybeExpression ->+ T_MaybeExpression +sem_MaybeExpression (Prelude.Just x ) =+ (sem_MaybeExpression_Just (sem_Expression x ) )+sem_MaybeExpression Prelude.Nothing =+ sem_MaybeExpression_Nothing+-- semantic domain+type T_MaybeExpression = Bool ->+ Scope ->+ MySourcePos ->+ ( MaybeExpression,([Message]),Type)+data Inh_MaybeExpression = Inh_MaybeExpression {inLoop_Inh_MaybeExpression :: Bool,scope_Inh_MaybeExpression :: Scope,sourcePos_Inh_MaybeExpression :: MySourcePos}+data Syn_MaybeExpression = Syn_MaybeExpression {actualValue_Syn_MaybeExpression :: MaybeExpression,messages_Syn_MaybeExpression :: [Message],nodeType_Syn_MaybeExpression :: Type}+wrap_MaybeExpression :: T_MaybeExpression ->+ Inh_MaybeExpression ->+ Syn_MaybeExpression +wrap_MaybeExpression sem (Inh_MaybeExpression _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_MaybeExpression _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_MaybeExpression_Just :: T_Expression ->+ T_MaybeExpression +sem_MaybeExpression_Just just_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: MaybeExpression+ _justOinLoop :: Bool+ _justOscope :: Scope+ _justOsourcePos :: MySourcePos+ _justIactualValue :: Expression+ _justIliftedColumnName :: String+ _justImessages :: ([Message])+ _justInodeType :: Type+ _lhsOnodeType =+ _justInodeType+ _lhsOmessages =+ _justImessages+ _actualValue =+ Just _justIactualValue+ _lhsOactualValue =+ _actualValue+ _justOinLoop =+ _lhsIinLoop+ _justOscope =+ _lhsIscope+ _justOsourcePos =+ _lhsIsourcePos+ ( _justIactualValue,_justIliftedColumnName,_justImessages,_justInodeType) =+ (just_ _justOinLoop _justOscope _justOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_MaybeExpression_Nothing :: T_MaybeExpression +sem_MaybeExpression_Nothing =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: MaybeExpression+ _lhsOnodeType =+ TypeList []+ _lhsOmessages =+ []+ _actualValue =+ Nothing+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- Natural -----------------------------------------------------+data Natural = Natural + | Unnatural + deriving ( Eq,Show)+-- cata+sem_Natural :: Natural ->+ T_Natural +sem_Natural (Natural ) =+ (sem_Natural_Natural )+sem_Natural (Unnatural ) =+ (sem_Natural_Unnatural )+-- semantic domain+type T_Natural = Bool ->+ Scope ->+ MySourcePos ->+ ( Natural,([Message]),Type)+data Inh_Natural = Inh_Natural {inLoop_Inh_Natural :: Bool,scope_Inh_Natural :: Scope,sourcePos_Inh_Natural :: MySourcePos}+data Syn_Natural = Syn_Natural {actualValue_Syn_Natural :: Natural,messages_Syn_Natural :: [Message],nodeType_Syn_Natural :: Type}+wrap_Natural :: T_Natural ->+ Inh_Natural ->+ Syn_Natural +wrap_Natural sem (Inh_Natural _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_Natural _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_Natural_Natural :: T_Natural +sem_Natural_Natural =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Natural+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ Natural+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_Natural_Unnatural :: T_Natural +sem_Natural_Unnatural =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Natural+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ Unnatural+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- OnExpr ------------------------------------------------------+type OnExpr = (Maybe (JoinExpression))+-- cata+sem_OnExpr :: OnExpr ->+ T_OnExpr +sem_OnExpr (Prelude.Just x ) =+ (sem_OnExpr_Just (sem_JoinExpression x ) )+sem_OnExpr Prelude.Nothing =+ sem_OnExpr_Nothing+-- semantic domain+type T_OnExpr = Bool ->+ Scope ->+ MySourcePos ->+ ( OnExpr,([Message]),Type)+data Inh_OnExpr = Inh_OnExpr {inLoop_Inh_OnExpr :: Bool,scope_Inh_OnExpr :: Scope,sourcePos_Inh_OnExpr :: MySourcePos}+data Syn_OnExpr = Syn_OnExpr {actualValue_Syn_OnExpr :: OnExpr,messages_Syn_OnExpr :: [Message],nodeType_Syn_OnExpr :: Type}+wrap_OnExpr :: T_OnExpr ->+ Inh_OnExpr ->+ Syn_OnExpr +wrap_OnExpr sem (Inh_OnExpr _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_OnExpr _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_OnExpr_Just :: T_JoinExpression ->+ T_OnExpr +sem_OnExpr_Just just_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: OnExpr+ _justOinLoop :: Bool+ _justOscope :: Scope+ _justOsourcePos :: MySourcePos+ _justIactualValue :: JoinExpression+ _justImessages :: ([Message])+ _justInodeType :: Type+ _lhsOmessages =+ _justImessages+ _lhsOnodeType =+ _justInodeType+ _actualValue =+ Just _justIactualValue+ _lhsOactualValue =+ _actualValue+ _justOinLoop =+ _lhsIinLoop+ _justOscope =+ _lhsIscope+ _justOsourcePos =+ _lhsIsourcePos+ ( _justIactualValue,_justImessages,_justInodeType) =+ (just_ _justOinLoop _justOscope _justOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_OnExpr_Nothing :: T_OnExpr +sem_OnExpr_Nothing =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: OnExpr+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ Nothing+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- ParamDef ----------------------------------------------------+data ParamDef = ParamDef (String) (TypeName) + | ParamDefTp (TypeName) + deriving ( Eq,Show)+-- cata+sem_ParamDef :: ParamDef ->+ T_ParamDef +sem_ParamDef (ParamDef _name _typ ) =+ (sem_ParamDef_ParamDef _name (sem_TypeName _typ ) )+sem_ParamDef (ParamDefTp _typ ) =+ (sem_ParamDef_ParamDefTp (sem_TypeName _typ ) )+-- semantic domain+type T_ParamDef = Bool ->+ Scope ->+ MySourcePos ->+ ( ParamDef,([Message]),Type,String)+data Inh_ParamDef = Inh_ParamDef {inLoop_Inh_ParamDef :: Bool,scope_Inh_ParamDef :: Scope,sourcePos_Inh_ParamDef :: MySourcePos}+data Syn_ParamDef = Syn_ParamDef {actualValue_Syn_ParamDef :: ParamDef,messages_Syn_ParamDef :: [Message],nodeType_Syn_ParamDef :: Type,paramName_Syn_ParamDef :: String}+wrap_ParamDef :: T_ParamDef ->+ Inh_ParamDef ->+ Syn_ParamDef +wrap_ParamDef sem (Inh_ParamDef _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType,_lhsOparamName) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_ParamDef _lhsOactualValue _lhsOmessages _lhsOnodeType _lhsOparamName ))+sem_ParamDef_ParamDef :: String ->+ T_TypeName ->+ T_ParamDef +sem_ParamDef_ParamDef name_ typ_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOparamName :: String+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: ParamDef+ _typOinLoop :: Bool+ _typOscope :: Scope+ _typOsourcePos :: MySourcePos+ _typIactualValue :: TypeName+ _typImessages :: ([Message])+ _typInodeType :: Type+ _lhsOnodeType =+ _typInodeType+ _lhsOparamName =+ name_+ _lhsOmessages =+ _typImessages+ _actualValue =+ ParamDef name_ _typIactualValue+ _lhsOactualValue =+ _actualValue+ _typOinLoop =+ _lhsIinLoop+ _typOscope =+ _lhsIscope+ _typOsourcePos =+ _lhsIsourcePos+ ( _typIactualValue,_typImessages,_typInodeType) =+ (typ_ _typOinLoop _typOscope _typOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType,_lhsOparamName)))+sem_ParamDef_ParamDefTp :: T_TypeName ->+ T_ParamDef +sem_ParamDef_ParamDefTp typ_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOparamName :: String+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: ParamDef+ _typOinLoop :: Bool+ _typOscope :: Scope+ _typOsourcePos :: MySourcePos+ _typIactualValue :: TypeName+ _typImessages :: ([Message])+ _typInodeType :: Type+ _lhsOnodeType =+ _typInodeType+ _lhsOparamName =+ ""+ _lhsOmessages =+ _typImessages+ _actualValue =+ ParamDefTp _typIactualValue+ _lhsOactualValue =+ _actualValue+ _typOinLoop =+ _lhsIinLoop+ _typOscope =+ _lhsIscope+ _typOsourcePos =+ _lhsIsourcePos+ ( _typIactualValue,_typImessages,_typInodeType) =+ (typ_ _typOinLoop _typOscope _typOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType,_lhsOparamName)))+-- ParamDefList ------------------------------------------------+type ParamDefList = [(ParamDef)]+-- cata+sem_ParamDefList :: ParamDefList ->+ T_ParamDefList +sem_ParamDefList list =+ (Prelude.foldr sem_ParamDefList_Cons sem_ParamDefList_Nil (Prelude.map sem_ParamDef list) )+-- semantic domain+type T_ParamDefList = Bool ->+ Scope ->+ MySourcePos ->+ ( ParamDefList,([Message]),Type,([(String,Type)]))+data Inh_ParamDefList = Inh_ParamDefList {inLoop_Inh_ParamDefList :: Bool,scope_Inh_ParamDefList :: Scope,sourcePos_Inh_ParamDefList :: MySourcePos}+data Syn_ParamDefList = Syn_ParamDefList {actualValue_Syn_ParamDefList :: ParamDefList,messages_Syn_ParamDefList :: [Message],nodeType_Syn_ParamDefList :: Type,params_Syn_ParamDefList :: [(String,Type)]}+wrap_ParamDefList :: T_ParamDefList ->+ Inh_ParamDefList ->+ Syn_ParamDefList +wrap_ParamDefList sem (Inh_ParamDefList _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType,_lhsOparams) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_ParamDefList _lhsOactualValue _lhsOmessages _lhsOnodeType _lhsOparams ))+sem_ParamDefList_Cons :: T_ParamDef ->+ T_ParamDefList ->+ T_ParamDefList +sem_ParamDefList_Cons hd_ tl_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOparams :: ([(String,Type)])+ _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: ParamDefList+ _hdOinLoop :: Bool+ _hdOscope :: Scope+ _hdOsourcePos :: MySourcePos+ _tlOinLoop :: Bool+ _tlOscope :: Scope+ _tlOsourcePos :: MySourcePos+ _hdIactualValue :: ParamDef+ _hdImessages :: ([Message])+ _hdInodeType :: Type+ _hdIparamName :: String+ _tlIactualValue :: ParamDefList+ _tlImessages :: ([Message])+ _tlInodeType :: Type+ _tlIparams :: ([(String,Type)])+ _lhsOparams =+ ((_hdIparamName, _hdInodeType) : _tlIparams)+ _lhsOmessages =+ _hdImessages ++ _tlImessages+ _lhsOnodeType =+ _hdInodeType `appendTypeList` _tlInodeType+ _actualValue =+ (:) _hdIactualValue _tlIactualValue+ _lhsOactualValue =+ _actualValue+ _hdOinLoop =+ _lhsIinLoop+ _hdOscope =+ _lhsIscope+ _hdOsourcePos =+ _lhsIsourcePos+ _tlOinLoop =+ _lhsIinLoop+ _tlOscope =+ _lhsIscope+ _tlOsourcePos =+ _lhsIsourcePos+ ( _hdIactualValue,_hdImessages,_hdInodeType,_hdIparamName) =+ (hd_ _hdOinLoop _hdOscope _hdOsourcePos )+ ( _tlIactualValue,_tlImessages,_tlInodeType,_tlIparams) =+ (tl_ _tlOinLoop _tlOscope _tlOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType,_lhsOparams)))+sem_ParamDefList_Nil :: T_ParamDefList +sem_ParamDefList_Nil =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOparams :: ([(String,Type)])+ _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: ParamDefList+ _lhsOparams =+ []+ _lhsOmessages =+ []+ _lhsOnodeType =+ TypeList []+ _actualValue =+ []+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType,_lhsOparams)))+-- RaiseType ---------------------------------------------------+data RaiseType = RError + | RException + | RNotice + deriving ( Eq,Show)+-- cata+sem_RaiseType :: RaiseType ->+ T_RaiseType +sem_RaiseType (RError ) =+ (sem_RaiseType_RError )+sem_RaiseType (RException ) =+ (sem_RaiseType_RException )+sem_RaiseType (RNotice ) =+ (sem_RaiseType_RNotice )+-- semantic domain+type T_RaiseType = Bool ->+ Scope ->+ MySourcePos ->+ ( RaiseType,([Message]),Type)+data Inh_RaiseType = Inh_RaiseType {inLoop_Inh_RaiseType :: Bool,scope_Inh_RaiseType :: Scope,sourcePos_Inh_RaiseType :: MySourcePos}+data Syn_RaiseType = Syn_RaiseType {actualValue_Syn_RaiseType :: RaiseType,messages_Syn_RaiseType :: [Message],nodeType_Syn_RaiseType :: Type}+wrap_RaiseType :: T_RaiseType ->+ Inh_RaiseType ->+ Syn_RaiseType +wrap_RaiseType sem (Inh_RaiseType _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_RaiseType _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_RaiseType_RError :: T_RaiseType +sem_RaiseType_RError =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: RaiseType+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ RError+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_RaiseType_RException :: T_RaiseType +sem_RaiseType_RException =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: RaiseType+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ RException+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_RaiseType_RNotice :: T_RaiseType +sem_RaiseType_RNotice =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: RaiseType+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ RNotice+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- RestartIdentity ---------------------------------------------+data RestartIdentity = ContinueIdentity + | RestartIdentity + deriving ( Eq,Show)+-- cata+sem_RestartIdentity :: RestartIdentity ->+ T_RestartIdentity +sem_RestartIdentity (ContinueIdentity ) =+ (sem_RestartIdentity_ContinueIdentity )+sem_RestartIdentity (RestartIdentity ) =+ (sem_RestartIdentity_RestartIdentity )+-- semantic domain+type T_RestartIdentity = Bool ->+ Scope ->+ MySourcePos ->+ ( RestartIdentity,([Message]),Type)+data Inh_RestartIdentity = Inh_RestartIdentity {inLoop_Inh_RestartIdentity :: Bool,scope_Inh_RestartIdentity :: Scope,sourcePos_Inh_RestartIdentity :: MySourcePos}+data Syn_RestartIdentity = Syn_RestartIdentity {actualValue_Syn_RestartIdentity :: RestartIdentity,messages_Syn_RestartIdentity :: [Message],nodeType_Syn_RestartIdentity :: Type}+wrap_RestartIdentity :: T_RestartIdentity ->+ Inh_RestartIdentity ->+ Syn_RestartIdentity +wrap_RestartIdentity sem (Inh_RestartIdentity _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_RestartIdentity _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_RestartIdentity_ContinueIdentity :: T_RestartIdentity +sem_RestartIdentity_ContinueIdentity =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: RestartIdentity+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ ContinueIdentity+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_RestartIdentity_RestartIdentity :: T_RestartIdentity +sem_RestartIdentity_RestartIdentity =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: RestartIdentity+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ RestartIdentity+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- Root --------------------------------------------------------+data Root = Root (StatementList) + deriving ( Show)+-- cata+sem_Root :: Root ->+ T_Root +sem_Root (Root _statements ) =+ (sem_Root_Root (sem_StatementList _statements ) )+-- semantic domain+type T_Root = Scope ->+ ( Root,([Message]),Type,([StatementInfo]))+data Inh_Root = Inh_Root {scope_Inh_Root :: Scope}+data Syn_Root = Syn_Root {actualValue_Syn_Root :: Root,messages_Syn_Root :: [Message],nodeType_Syn_Root :: Type,statementInfo_Syn_Root :: [StatementInfo]}+wrap_Root :: T_Root ->+ Inh_Root ->+ Syn_Root +wrap_Root sem (Inh_Root _lhsIscope ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType,_lhsOstatementInfo) =+ (sem _lhsIscope )+ in (Syn_Root _lhsOactualValue _lhsOmessages _lhsOnodeType _lhsOstatementInfo ))+sem_Root_Root :: T_StatementList ->+ T_Root +sem_Root_Root statements_ =+ (\ _lhsIscope ->+ (let _statementsOsourcePos :: MySourcePos+ _statementsOinLoop :: Bool+ _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Root+ _lhsOstatementInfo :: ([StatementInfo])+ _statementsOscope :: Scope+ _statementsIactualValue :: StatementList+ _statementsImessages :: ([Message])+ _statementsInodeType :: Type+ _statementsIstatementInfo :: ([StatementInfo])+ _statementsOsourcePos =+ ("",0,0)+ _statementsOinLoop =+ False+ _lhsOmessages =+ _statementsImessages+ _lhsOnodeType =+ _statementsInodeType+ _actualValue =+ Root _statementsIactualValue+ _lhsOactualValue =+ _actualValue+ _lhsOstatementInfo =+ _statementsIstatementInfo+ _statementsOscope =+ _lhsIscope+ ( _statementsIactualValue,_statementsImessages,_statementsInodeType,_statementsIstatementInfo) =+ (statements_ _statementsOinLoop _statementsOscope _statementsOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType,_lhsOstatementInfo)))+-- RowConstraint -----------------------------------------------+data RowConstraint = NotNullConstraint + | NullConstraint + | RowCheckConstraint (Expression) + | RowPrimaryKeyConstraint + | RowReferenceConstraint (String) (Maybe String) (Cascade) (Cascade) + | RowUniqueConstraint + deriving ( Eq,Show)+-- cata+sem_RowConstraint :: RowConstraint ->+ T_RowConstraint +sem_RowConstraint (NotNullConstraint ) =+ (sem_RowConstraint_NotNullConstraint )+sem_RowConstraint (NullConstraint ) =+ (sem_RowConstraint_NullConstraint )+sem_RowConstraint (RowCheckConstraint _expression ) =+ (sem_RowConstraint_RowCheckConstraint (sem_Expression _expression ) )+sem_RowConstraint (RowPrimaryKeyConstraint ) =+ (sem_RowConstraint_RowPrimaryKeyConstraint )+sem_RowConstraint (RowReferenceConstraint _table _att _onUpdate _onDelete ) =+ (sem_RowConstraint_RowReferenceConstraint _table _att (sem_Cascade _onUpdate ) (sem_Cascade _onDelete ) )+sem_RowConstraint (RowUniqueConstraint ) =+ (sem_RowConstraint_RowUniqueConstraint )+-- semantic domain+type T_RowConstraint = Bool ->+ Scope ->+ MySourcePos ->+ ( RowConstraint,([Message]),Type)+data Inh_RowConstraint = Inh_RowConstraint {inLoop_Inh_RowConstraint :: Bool,scope_Inh_RowConstraint :: Scope,sourcePos_Inh_RowConstraint :: MySourcePos}+data Syn_RowConstraint = Syn_RowConstraint {actualValue_Syn_RowConstraint :: RowConstraint,messages_Syn_RowConstraint :: [Message],nodeType_Syn_RowConstraint :: Type}+wrap_RowConstraint :: T_RowConstraint ->+ Inh_RowConstraint ->+ Syn_RowConstraint +wrap_RowConstraint sem (Inh_RowConstraint _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_RowConstraint _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_RowConstraint_NotNullConstraint :: T_RowConstraint +sem_RowConstraint_NotNullConstraint =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: RowConstraint+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ NotNullConstraint+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_RowConstraint_NullConstraint :: T_RowConstraint +sem_RowConstraint_NullConstraint =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: RowConstraint+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ NullConstraint+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_RowConstraint_RowCheckConstraint :: T_Expression ->+ T_RowConstraint +sem_RowConstraint_RowCheckConstraint expression_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: RowConstraint+ _expressionOinLoop :: Bool+ _expressionOscope :: Scope+ _expressionOsourcePos :: MySourcePos+ _expressionIactualValue :: Expression+ _expressionIliftedColumnName :: String+ _expressionImessages :: ([Message])+ _expressionInodeType :: Type+ _lhsOmessages =+ _expressionImessages+ _lhsOnodeType =+ _expressionInodeType+ _actualValue =+ RowCheckConstraint _expressionIactualValue+ _lhsOactualValue =+ _actualValue+ _expressionOinLoop =+ _lhsIinLoop+ _expressionOscope =+ _lhsIscope+ _expressionOsourcePos =+ _lhsIsourcePos+ ( _expressionIactualValue,_expressionIliftedColumnName,_expressionImessages,_expressionInodeType) =+ (expression_ _expressionOinLoop _expressionOscope _expressionOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_RowConstraint_RowPrimaryKeyConstraint :: T_RowConstraint +sem_RowConstraint_RowPrimaryKeyConstraint =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: RowConstraint+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ RowPrimaryKeyConstraint+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_RowConstraint_RowReferenceConstraint :: String ->+ (Maybe String) ->+ T_Cascade ->+ T_Cascade ->+ T_RowConstraint +sem_RowConstraint_RowReferenceConstraint table_ att_ onUpdate_ onDelete_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: RowConstraint+ _onUpdateOinLoop :: Bool+ _onUpdateOscope :: Scope+ _onUpdateOsourcePos :: MySourcePos+ _onDeleteOinLoop :: Bool+ _onDeleteOscope :: Scope+ _onDeleteOsourcePos :: MySourcePos+ _onUpdateIactualValue :: Cascade+ _onUpdateImessages :: ([Message])+ _onUpdateInodeType :: Type+ _onDeleteIactualValue :: Cascade+ _onDeleteImessages :: ([Message])+ _onDeleteInodeType :: Type+ _lhsOmessages =+ _onUpdateImessages ++ _onDeleteImessages+ _lhsOnodeType =+ _onUpdateInodeType `setUnknown` _onDeleteInodeType+ _actualValue =+ RowReferenceConstraint table_ att_ _onUpdateIactualValue _onDeleteIactualValue+ _lhsOactualValue =+ _actualValue+ _onUpdateOinLoop =+ _lhsIinLoop+ _onUpdateOscope =+ _lhsIscope+ _onUpdateOsourcePos =+ _lhsIsourcePos+ _onDeleteOinLoop =+ _lhsIinLoop+ _onDeleteOscope =+ _lhsIscope+ _onDeleteOsourcePos =+ _lhsIsourcePos+ ( _onUpdateIactualValue,_onUpdateImessages,_onUpdateInodeType) =+ (onUpdate_ _onUpdateOinLoop _onUpdateOscope _onUpdateOsourcePos )+ ( _onDeleteIactualValue,_onDeleteImessages,_onDeleteInodeType) =+ (onDelete_ _onDeleteOinLoop _onDeleteOscope _onDeleteOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_RowConstraint_RowUniqueConstraint :: T_RowConstraint +sem_RowConstraint_RowUniqueConstraint =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: RowConstraint+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ RowUniqueConstraint+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- RowConstraintList -------------------------------------------+type RowConstraintList = [(RowConstraint)]+-- cata+sem_RowConstraintList :: RowConstraintList ->+ T_RowConstraintList +sem_RowConstraintList list =+ (Prelude.foldr sem_RowConstraintList_Cons sem_RowConstraintList_Nil (Prelude.map sem_RowConstraint list) )+-- semantic domain+type T_RowConstraintList = Bool ->+ Scope ->+ MySourcePos ->+ ( RowConstraintList,([Message]),Type)+data Inh_RowConstraintList = Inh_RowConstraintList {inLoop_Inh_RowConstraintList :: Bool,scope_Inh_RowConstraintList :: Scope,sourcePos_Inh_RowConstraintList :: MySourcePos}+data Syn_RowConstraintList = Syn_RowConstraintList {actualValue_Syn_RowConstraintList :: RowConstraintList,messages_Syn_RowConstraintList :: [Message],nodeType_Syn_RowConstraintList :: Type}+wrap_RowConstraintList :: T_RowConstraintList ->+ Inh_RowConstraintList ->+ Syn_RowConstraintList +wrap_RowConstraintList sem (Inh_RowConstraintList _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_RowConstraintList _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_RowConstraintList_Cons :: T_RowConstraint ->+ T_RowConstraintList ->+ T_RowConstraintList +sem_RowConstraintList_Cons hd_ tl_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: RowConstraintList+ _hdOinLoop :: Bool+ _hdOscope :: Scope+ _hdOsourcePos :: MySourcePos+ _tlOinLoop :: Bool+ _tlOscope :: Scope+ _tlOsourcePos :: MySourcePos+ _hdIactualValue :: RowConstraint+ _hdImessages :: ([Message])+ _hdInodeType :: Type+ _tlIactualValue :: RowConstraintList+ _tlImessages :: ([Message])+ _tlInodeType :: Type+ _lhsOmessages =+ _hdImessages ++ _tlImessages+ _lhsOnodeType =+ _hdInodeType `appendTypeList` _tlInodeType+ _actualValue =+ (:) _hdIactualValue _tlIactualValue+ _lhsOactualValue =+ _actualValue+ _hdOinLoop =+ _lhsIinLoop+ _hdOscope =+ _lhsIscope+ _hdOsourcePos =+ _lhsIsourcePos+ _tlOinLoop =+ _lhsIinLoop+ _tlOscope =+ _lhsIscope+ _tlOsourcePos =+ _lhsIsourcePos+ ( _hdIactualValue,_hdImessages,_hdInodeType) =+ (hd_ _hdOinLoop _hdOscope _hdOsourcePos )+ ( _tlIactualValue,_tlImessages,_tlInodeType) =+ (tl_ _tlOinLoop _tlOscope _tlOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_RowConstraintList_Nil :: T_RowConstraintList +sem_RowConstraintList_Nil =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: RowConstraintList+ _lhsOmessages =+ []+ _lhsOnodeType =+ TypeList []+ _actualValue =+ []+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- SelectExpression --------------------------------------------+data SelectExpression = CombineSelect (CombineType) (SelectExpression) (SelectExpression) + | Select (Distinct) (SelectList) (MTableRef) (Where) (ExpressionList) (Maybe Expression) (ExpressionList) (Direction) (Maybe Expression) (Maybe Expression) + | Values (ExpressionListList) + deriving ( Eq,Show)+-- cata+sem_SelectExpression :: SelectExpression ->+ T_SelectExpression +sem_SelectExpression (CombineSelect _ctype _sel1 _sel2 ) =+ (sem_SelectExpression_CombineSelect (sem_CombineType _ctype ) (sem_SelectExpression _sel1 ) (sem_SelectExpression _sel2 ) )+sem_SelectExpression (Select _selDistinct _selSelectList _selTref _selWhere _selGroupBy _selHaving _selOrderBy _selDir _selLimit _selOffset ) =+ (sem_SelectExpression_Select (sem_Distinct _selDistinct ) (sem_SelectList _selSelectList ) (sem_MTableRef _selTref ) (sem_Where _selWhere ) (sem_ExpressionList _selGroupBy ) _selHaving (sem_ExpressionList _selOrderBy ) (sem_Direction _selDir ) _selLimit _selOffset )+sem_SelectExpression (Values _vll ) =+ (sem_SelectExpression_Values (sem_ExpressionListList _vll ) )+-- semantic domain+type T_SelectExpression = Bool ->+ Scope ->+ MySourcePos ->+ ( SelectExpression,([Message]),Type)+data Inh_SelectExpression = Inh_SelectExpression {inLoop_Inh_SelectExpression :: Bool,scope_Inh_SelectExpression :: Scope,sourcePos_Inh_SelectExpression :: MySourcePos}+data Syn_SelectExpression = Syn_SelectExpression {actualValue_Syn_SelectExpression :: SelectExpression,messages_Syn_SelectExpression :: [Message],nodeType_Syn_SelectExpression :: Type}+wrap_SelectExpression :: T_SelectExpression ->+ Inh_SelectExpression ->+ Syn_SelectExpression +wrap_SelectExpression sem (Inh_SelectExpression _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_SelectExpression _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_SelectExpression_CombineSelect :: T_CombineType ->+ T_SelectExpression ->+ T_SelectExpression ->+ T_SelectExpression +sem_SelectExpression_CombineSelect ctype_ sel1_ sel2_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: SelectExpression+ _ctypeOinLoop :: Bool+ _ctypeOscope :: Scope+ _ctypeOsourcePos :: MySourcePos+ _sel1OinLoop :: Bool+ _sel1Oscope :: Scope+ _sel1OsourcePos :: MySourcePos+ _sel2OinLoop :: Bool+ _sel2Oscope :: Scope+ _sel2OsourcePos :: MySourcePos+ _ctypeIactualValue :: CombineType+ _ctypeImessages :: ([Message])+ _ctypeInodeType :: Type+ _sel1IactualValue :: SelectExpression+ _sel1Imessages :: ([Message])+ _sel1InodeType :: Type+ _sel2IactualValue :: SelectExpression+ _sel2Imessages :: ([Message])+ _sel2InodeType :: Type+ _lhsOnodeType =+ checkErrors [_sel1InodeType,_sel2InodeType] $+ typeCheckCombineSelect+ _lhsIscope+ _lhsIsourcePos+ _sel1InodeType+ _sel2InodeType+ _lhsOmessages =+ _ctypeImessages ++ _sel1Imessages ++ _sel2Imessages+ _actualValue =+ CombineSelect _ctypeIactualValue _sel1IactualValue _sel2IactualValue+ _lhsOactualValue =+ _actualValue+ _ctypeOinLoop =+ _lhsIinLoop+ _ctypeOscope =+ _lhsIscope+ _ctypeOsourcePos =+ _lhsIsourcePos+ _sel1OinLoop =+ _lhsIinLoop+ _sel1Oscope =+ _lhsIscope+ _sel1OsourcePos =+ _lhsIsourcePos+ _sel2OinLoop =+ _lhsIinLoop+ _sel2Oscope =+ _lhsIscope+ _sel2OsourcePos =+ _lhsIsourcePos+ ( _ctypeIactualValue,_ctypeImessages,_ctypeInodeType) =+ (ctype_ _ctypeOinLoop _ctypeOscope _ctypeOsourcePos )+ ( _sel1IactualValue,_sel1Imessages,_sel1InodeType) =+ (sel1_ _sel1OinLoop _sel1Oscope _sel1OsourcePos )+ ( _sel2IactualValue,_sel2Imessages,_sel2InodeType) =+ (sel2_ _sel2OinLoop _sel2Oscope _sel2OsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_SelectExpression_Select :: T_Distinct ->+ T_SelectList ->+ T_MTableRef ->+ T_Where ->+ T_ExpressionList ->+ (Maybe Expression) ->+ T_ExpressionList ->+ T_Direction ->+ (Maybe Expression) ->+ (Maybe Expression) ->+ T_SelectExpression +sem_SelectExpression_Select selDistinct_ selSelectList_ selTref_ selWhere_ selGroupBy_ selHaving_ selOrderBy_ selDir_ selLimit_ selOffset_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _selSelectListOscope :: Scope+ _selWhereOscope :: Scope+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: SelectExpression+ _selDistinctOinLoop :: Bool+ _selDistinctOscope :: Scope+ _selDistinctOsourcePos :: MySourcePos+ _selSelectListOinLoop :: Bool+ _selSelectListOsourcePos :: MySourcePos+ _selTrefOinLoop :: Bool+ _selTrefOscope :: Scope+ _selTrefOsourcePos :: MySourcePos+ _selWhereOinLoop :: Bool+ _selWhereOsourcePos :: MySourcePos+ _selGroupByOinLoop :: Bool+ _selGroupByOscope :: Scope+ _selGroupByOsourcePos :: MySourcePos+ _selOrderByOinLoop :: Bool+ _selOrderByOscope :: Scope+ _selOrderByOsourcePos :: MySourcePos+ _selDirOinLoop :: Bool+ _selDirOscope :: Scope+ _selDirOsourcePos :: MySourcePos+ _selDistinctIactualValue :: Distinct+ _selDistinctImessages :: ([Message])+ _selDistinctInodeType :: Type+ _selSelectListIactualValue :: SelectList+ _selSelectListImessages :: ([Message])+ _selSelectListInodeType :: Type+ _selTrefIactualValue :: MTableRef+ _selTrefIidens :: ([QualifiedScope])+ _selTrefIjoinIdens :: ([String])+ _selTrefImessages :: ([Message])+ _selTrefInodeType :: Type+ _selWhereIactualValue :: Where+ _selWhereImessages :: ([Message])+ _selWhereInodeType :: Type+ _selGroupByIactualValue :: ExpressionList+ _selGroupByImessages :: ([Message])+ _selGroupByInodeType :: Type+ _selOrderByIactualValue :: ExpressionList+ _selOrderByImessages :: ([Message])+ _selOrderByInodeType :: Type+ _selDirIactualValue :: Direction+ _selDirImessages :: ([Message])+ _selDirInodeType :: Type+ _lhsOnodeType =+ checkErrors+ [_selTrefInodeType+ ,_selSelectListInodeType+ ,_selWhereInodeType]+ (let t = _selSelectListInodeType+ in case t of+ UnnamedCompositeType [(_,Pseudo Void)] -> Pseudo Void+ _ -> SetOfType _selSelectListInodeType)+ _selSelectListOscope =+ scopeReplaceIds _lhsIscope _selTrefIidens _selTrefIjoinIdens+ _selWhereOscope =+ scopeReplaceIds _lhsIscope _selTrefIidens _selTrefIjoinIdens+ _lhsOmessages =+ _selDistinctImessages ++ _selSelectListImessages ++ _selTrefImessages ++ _selWhereImessages ++ _selGroupByImessages ++ _selOrderByImessages ++ _selDirImessages+ _actualValue =+ Select _selDistinctIactualValue _selSelectListIactualValue _selTrefIactualValue _selWhereIactualValue _selGroupByIactualValue selHaving_ _selOrderByIactualValue _selDirIactualValue selLimit_ selOffset_+ _lhsOactualValue =+ _actualValue+ _selDistinctOinLoop =+ _lhsIinLoop+ _selDistinctOscope =+ _lhsIscope+ _selDistinctOsourcePos =+ _lhsIsourcePos+ _selSelectListOinLoop =+ _lhsIinLoop+ _selSelectListOsourcePos =+ _lhsIsourcePos+ _selTrefOinLoop =+ _lhsIinLoop+ _selTrefOscope =+ _lhsIscope+ _selTrefOsourcePos =+ _lhsIsourcePos+ _selWhereOinLoop =+ _lhsIinLoop+ _selWhereOsourcePos =+ _lhsIsourcePos+ _selGroupByOinLoop =+ _lhsIinLoop+ _selGroupByOscope =+ _lhsIscope+ _selGroupByOsourcePos =+ _lhsIsourcePos+ _selOrderByOinLoop =+ _lhsIinLoop+ _selOrderByOscope =+ _lhsIscope+ _selOrderByOsourcePos =+ _lhsIsourcePos+ _selDirOinLoop =+ _lhsIinLoop+ _selDirOscope =+ _lhsIscope+ _selDirOsourcePos =+ _lhsIsourcePos+ ( _selDistinctIactualValue,_selDistinctImessages,_selDistinctInodeType) =+ (selDistinct_ _selDistinctOinLoop _selDistinctOscope _selDistinctOsourcePos )+ ( _selSelectListIactualValue,_selSelectListImessages,_selSelectListInodeType) =+ (selSelectList_ _selSelectListOinLoop _selSelectListOscope _selSelectListOsourcePos )+ ( _selTrefIactualValue,_selTrefIidens,_selTrefIjoinIdens,_selTrefImessages,_selTrefInodeType) =+ (selTref_ _selTrefOinLoop _selTrefOscope _selTrefOsourcePos )+ ( _selWhereIactualValue,_selWhereImessages,_selWhereInodeType) =+ (selWhere_ _selWhereOinLoop _selWhereOscope _selWhereOsourcePos )+ ( _selGroupByIactualValue,_selGroupByImessages,_selGroupByInodeType) =+ (selGroupBy_ _selGroupByOinLoop _selGroupByOscope _selGroupByOsourcePos )+ ( _selOrderByIactualValue,_selOrderByImessages,_selOrderByInodeType) =+ (selOrderBy_ _selOrderByOinLoop _selOrderByOscope _selOrderByOsourcePos )+ ( _selDirIactualValue,_selDirImessages,_selDirInodeType) =+ (selDir_ _selDirOinLoop _selDirOscope _selDirOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_SelectExpression_Values :: T_ExpressionListList ->+ T_SelectExpression +sem_SelectExpression_Values vll_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: SelectExpression+ _vllOinLoop :: Bool+ _vllOscope :: Scope+ _vllOsourcePos :: MySourcePos+ _vllIactualValue :: ExpressionListList+ _vllImessages :: ([Message])+ _vllInodeType :: Type+ _lhsOnodeType =+ checkErrors [_vllInodeType] $+ typeCheckValuesExpr+ _lhsIscope+ _lhsIsourcePos+ _vllInodeType+ _lhsOmessages =+ _vllImessages+ _actualValue =+ Values _vllIactualValue+ _lhsOactualValue =+ _actualValue+ _vllOinLoop =+ _lhsIinLoop+ _vllOscope =+ _lhsIscope+ _vllOsourcePos =+ _lhsIsourcePos+ ( _vllIactualValue,_vllImessages,_vllInodeType) =+ (vll_ _vllOinLoop _vllOscope _vllOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- SelectItem --------------------------------------------------+data SelectItem = SelExp (Expression) + | SelectItem (Expression) (String) + deriving ( Eq,Show)+-- cata+sem_SelectItem :: SelectItem ->+ T_SelectItem +sem_SelectItem (SelExp _ex ) =+ (sem_SelectItem_SelExp (sem_Expression _ex ) )+sem_SelectItem (SelectItem _ex _name ) =+ (sem_SelectItem_SelectItem (sem_Expression _ex ) _name )+-- semantic domain+type T_SelectItem = Bool ->+ Scope ->+ MySourcePos ->+ ( SelectItem,String,([Message]),Type)+data Inh_SelectItem = Inh_SelectItem {inLoop_Inh_SelectItem :: Bool,scope_Inh_SelectItem :: Scope,sourcePos_Inh_SelectItem :: MySourcePos}+data Syn_SelectItem = Syn_SelectItem {actualValue_Syn_SelectItem :: SelectItem,columnName_Syn_SelectItem :: String,messages_Syn_SelectItem :: [Message],nodeType_Syn_SelectItem :: Type}+wrap_SelectItem :: T_SelectItem ->+ Inh_SelectItem ->+ Syn_SelectItem +wrap_SelectItem sem (Inh_SelectItem _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOcolumnName,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_SelectItem _lhsOactualValue _lhsOcolumnName _lhsOmessages _lhsOnodeType ))+sem_SelectItem_SelExp :: T_Expression ->+ T_SelectItem +sem_SelectItem_SelExp ex_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOcolumnName :: String+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: SelectItem+ _exOinLoop :: Bool+ _exOscope :: Scope+ _exOsourcePos :: MySourcePos+ _exIactualValue :: Expression+ _exIliftedColumnName :: String+ _exImessages :: ([Message])+ _exInodeType :: Type+ _lhsOnodeType =+ _exInodeType+ _lhsOcolumnName =+ case _exIliftedColumnName of+ "" -> "?column?"+ s -> s+ _lhsOmessages =+ _exImessages+ _actualValue =+ SelExp _exIactualValue+ _lhsOactualValue =+ _actualValue+ _exOinLoop =+ _lhsIinLoop+ _exOscope =+ _lhsIscope+ _exOsourcePos =+ _lhsIsourcePos+ ( _exIactualValue,_exIliftedColumnName,_exImessages,_exInodeType) =+ (ex_ _exOinLoop _exOscope _exOsourcePos )+ in ( _lhsOactualValue,_lhsOcolumnName,_lhsOmessages,_lhsOnodeType)))+sem_SelectItem_SelectItem :: T_Expression ->+ String ->+ T_SelectItem +sem_SelectItem_SelectItem ex_ name_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOcolumnName :: String+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: SelectItem+ _exOinLoop :: Bool+ _exOscope :: Scope+ _exOsourcePos :: MySourcePos+ _exIactualValue :: Expression+ _exIliftedColumnName :: String+ _exImessages :: ([Message])+ _exInodeType :: Type+ _lhsOnodeType =+ _exInodeType+ _lhsOcolumnName =+ name_+ _lhsOmessages =+ _exImessages+ _actualValue =+ SelectItem _exIactualValue name_+ _lhsOactualValue =+ _actualValue+ _exOinLoop =+ _lhsIinLoop+ _exOscope =+ _lhsIscope+ _exOsourcePos =+ _lhsIsourcePos+ ( _exIactualValue,_exIliftedColumnName,_exImessages,_exInodeType) =+ (ex_ _exOinLoop _exOscope _exOsourcePos )+ in ( _lhsOactualValue,_lhsOcolumnName,_lhsOmessages,_lhsOnodeType)))+-- SelectItemList ----------------------------------------------+type SelectItemList = [(SelectItem)]+-- cata+sem_SelectItemList :: SelectItemList ->+ T_SelectItemList +sem_SelectItemList list =+ (Prelude.foldr sem_SelectItemList_Cons sem_SelectItemList_Nil (Prelude.map sem_SelectItem list) )+-- semantic domain+type T_SelectItemList = Bool ->+ Scope ->+ MySourcePos ->+ ( SelectItemList,([Message]),Type)+data Inh_SelectItemList = Inh_SelectItemList {inLoop_Inh_SelectItemList :: Bool,scope_Inh_SelectItemList :: Scope,sourcePos_Inh_SelectItemList :: MySourcePos}+data Syn_SelectItemList = Syn_SelectItemList {actualValue_Syn_SelectItemList :: SelectItemList,messages_Syn_SelectItemList :: [Message],nodeType_Syn_SelectItemList :: Type}+wrap_SelectItemList :: T_SelectItemList ->+ Inh_SelectItemList ->+ Syn_SelectItemList +wrap_SelectItemList sem (Inh_SelectItemList _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_SelectItemList _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_SelectItemList_Cons :: T_SelectItem ->+ T_SelectItemList ->+ T_SelectItemList +sem_SelectItemList_Cons hd_ tl_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: SelectItemList+ _hdOinLoop :: Bool+ _hdOscope :: Scope+ _hdOsourcePos :: MySourcePos+ _tlOinLoop :: Bool+ _tlOscope :: Scope+ _tlOsourcePos :: MySourcePos+ _hdIactualValue :: SelectItem+ _hdIcolumnName :: String+ _hdImessages :: ([Message])+ _hdInodeType :: Type+ _tlIactualValue :: SelectItemList+ _tlImessages :: ([Message])+ _tlInodeType :: Type+ _lhsOnodeType =+ foldr consComposite _tlInodeType+ (let (correlationName,iden) = splitIdentifier _hdIcolumnName+ in if iden == "*"+ then scopeExpandStar _lhsIscope _lhsIsourcePos correlationName+ else [(iden, _hdInodeType)])+ _lhsOmessages =+ _hdImessages ++ _tlImessages+ _actualValue =+ (:) _hdIactualValue _tlIactualValue+ _lhsOactualValue =+ _actualValue+ _hdOinLoop =+ _lhsIinLoop+ _hdOscope =+ _lhsIscope+ _hdOsourcePos =+ _lhsIsourcePos+ _tlOinLoop =+ _lhsIinLoop+ _tlOscope =+ _lhsIscope+ _tlOsourcePos =+ _lhsIsourcePos+ ( _hdIactualValue,_hdIcolumnName,_hdImessages,_hdInodeType) =+ (hd_ _hdOinLoop _hdOscope _hdOsourcePos )+ ( _tlIactualValue,_tlImessages,_tlInodeType) =+ (tl_ _tlOinLoop _tlOscope _tlOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_SelectItemList_Nil :: T_SelectItemList +sem_SelectItemList_Nil =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: SelectItemList+ _lhsOnodeType =+ UnnamedCompositeType []+ _lhsOmessages =+ []+ _actualValue =+ []+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- SelectList --------------------------------------------------+data SelectList = SelectList (SelectItemList) (StringList) + deriving ( Eq,Show)+-- cata+sem_SelectList :: SelectList ->+ T_SelectList +sem_SelectList (SelectList _items _stringList ) =+ (sem_SelectList_SelectList (sem_SelectItemList _items ) (sem_StringList _stringList ) )+-- semantic domain+type T_SelectList = Bool ->+ Scope ->+ MySourcePos ->+ ( SelectList,([Message]),Type)+data Inh_SelectList = Inh_SelectList {inLoop_Inh_SelectList :: Bool,scope_Inh_SelectList :: Scope,sourcePos_Inh_SelectList :: MySourcePos}+data Syn_SelectList = Syn_SelectList {actualValue_Syn_SelectList :: SelectList,messages_Syn_SelectList :: [Message],nodeType_Syn_SelectList :: Type}+wrap_SelectList :: T_SelectList ->+ Inh_SelectList ->+ Syn_SelectList +wrap_SelectList sem (Inh_SelectList _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_SelectList _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_SelectList_SelectList :: T_SelectItemList ->+ T_StringList ->+ T_SelectList +sem_SelectList_SelectList items_ stringList_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: SelectList+ _itemsOinLoop :: Bool+ _itemsOscope :: Scope+ _itemsOsourcePos :: MySourcePos+ _stringListOinLoop :: Bool+ _stringListOscope :: Scope+ _stringListOsourcePos :: MySourcePos+ _itemsIactualValue :: SelectItemList+ _itemsImessages :: ([Message])+ _itemsInodeType :: Type+ _stringListIactualValue :: StringList+ _stringListImessages :: ([Message])+ _stringListInodeType :: Type+ _stringListIstrings :: ([String])+ _lhsOnodeType =+ _itemsInodeType+ _lhsOmessages =+ _itemsImessages ++ _stringListImessages+ _actualValue =+ SelectList _itemsIactualValue _stringListIactualValue+ _lhsOactualValue =+ _actualValue+ _itemsOinLoop =+ _lhsIinLoop+ _itemsOscope =+ _lhsIscope+ _itemsOsourcePos =+ _lhsIsourcePos+ _stringListOinLoop =+ _lhsIinLoop+ _stringListOscope =+ _lhsIscope+ _stringListOsourcePos =+ _lhsIsourcePos+ ( _itemsIactualValue,_itemsImessages,_itemsInodeType) =+ (items_ _itemsOinLoop _itemsOscope _itemsOsourcePos )+ ( _stringListIactualValue,_stringListImessages,_stringListInodeType,_stringListIstrings) =+ (stringList_ _stringListOinLoop _stringListOscope _stringListOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- SetClause ---------------------------------------------------+data SetClause = RowSetClause (StringList) (ExpressionList) + | SetClause (String) (Expression) + deriving ( Eq,Show)+-- cata+sem_SetClause :: SetClause ->+ T_SetClause +sem_SetClause (RowSetClause _atts _vals ) =+ (sem_SetClause_RowSetClause (sem_StringList _atts ) (sem_ExpressionList _vals ) )+sem_SetClause (SetClause _att _val ) =+ (sem_SetClause_SetClause _att (sem_Expression _val ) )+-- semantic domain+type T_SetClause = Bool ->+ Scope ->+ MySourcePos ->+ ( SetClause,([Message]),Type,([(String,Type)]))+data Inh_SetClause = Inh_SetClause {inLoop_Inh_SetClause :: Bool,scope_Inh_SetClause :: Scope,sourcePos_Inh_SetClause :: MySourcePos}+data Syn_SetClause = Syn_SetClause {actualValue_Syn_SetClause :: SetClause,messages_Syn_SetClause :: [Message],nodeType_Syn_SetClause :: Type,pairs_Syn_SetClause :: [(String,Type)]}+wrap_SetClause :: T_SetClause ->+ Inh_SetClause ->+ Syn_SetClause +wrap_SetClause sem (Inh_SetClause _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType,_lhsOpairs) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_SetClause _lhsOactualValue _lhsOmessages _lhsOnodeType _lhsOpairs ))+sem_SetClause_RowSetClause :: T_StringList ->+ T_ExpressionList ->+ T_SetClause +sem_SetClause_RowSetClause atts_ vals_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOpairs :: ([(String,Type)])+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: SetClause+ _attsOinLoop :: Bool+ _attsOscope :: Scope+ _attsOsourcePos :: MySourcePos+ _valsOinLoop :: Bool+ _valsOscope :: Scope+ _valsOsourcePos :: MySourcePos+ _attsIactualValue :: StringList+ _attsImessages :: ([Message])+ _attsInodeType :: Type+ _attsIstrings :: ([String])+ _valsIactualValue :: ExpressionList+ _valsImessages :: ([Message])+ _valsInodeType :: Type+ _lhsOnodeType =+ let atts = _attsIstrings+ types = getRowTypes _valsInodeType+ lengthError = if length atts /= length types+ then TypeError _lhsIsourcePos WrongNumberOfColumns+ else TypeList []+ in checkErrors [lengthError] $ TypeList []+ _lhsOpairs =+ zip _attsIstrings $ getRowTypes _valsInodeType+ _lhsOmessages =+ _attsImessages ++ _valsImessages+ _actualValue =+ RowSetClause _attsIactualValue _valsIactualValue+ _lhsOactualValue =+ _actualValue+ _attsOinLoop =+ _lhsIinLoop+ _attsOscope =+ _lhsIscope+ _attsOsourcePos =+ _lhsIsourcePos+ _valsOinLoop =+ _lhsIinLoop+ _valsOscope =+ _lhsIscope+ _valsOsourcePos =+ _lhsIsourcePos+ ( _attsIactualValue,_attsImessages,_attsInodeType,_attsIstrings) =+ (atts_ _attsOinLoop _attsOscope _attsOsourcePos )+ ( _valsIactualValue,_valsImessages,_valsInodeType) =+ (vals_ _valsOinLoop _valsOscope _valsOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType,_lhsOpairs)))+sem_SetClause_SetClause :: String ->+ T_Expression ->+ T_SetClause +sem_SetClause_SetClause att_ val_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOpairs :: ([(String,Type)])+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: SetClause+ _valOinLoop :: Bool+ _valOscope :: Scope+ _valOsourcePos :: MySourcePos+ _valIactualValue :: Expression+ _valIliftedColumnName :: String+ _valImessages :: ([Message])+ _valInodeType :: Type+ _lhsOnodeType =+ checkErrors [_valInodeType] $ TypeList []+ _lhsOpairs =+ [(att_, _valInodeType)]+ _lhsOmessages =+ _valImessages+ _actualValue =+ SetClause att_ _valIactualValue+ _lhsOactualValue =+ _actualValue+ _valOinLoop =+ _lhsIinLoop+ _valOscope =+ _lhsIscope+ _valOsourcePos =+ _lhsIsourcePos+ ( _valIactualValue,_valIliftedColumnName,_valImessages,_valInodeType) =+ (val_ _valOinLoop _valOscope _valOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType,_lhsOpairs)))+-- SetClauseList -----------------------------------------------+type SetClauseList = [(SetClause)]+-- cata+sem_SetClauseList :: SetClauseList ->+ T_SetClauseList +sem_SetClauseList list =+ (Prelude.foldr sem_SetClauseList_Cons sem_SetClauseList_Nil (Prelude.map sem_SetClause list) )+-- semantic domain+type T_SetClauseList = Bool ->+ Scope ->+ MySourcePos ->+ ( SetClauseList,([Message]),Type,([(String,Type)]))+data Inh_SetClauseList = Inh_SetClauseList {inLoop_Inh_SetClauseList :: Bool,scope_Inh_SetClauseList :: Scope,sourcePos_Inh_SetClauseList :: MySourcePos}+data Syn_SetClauseList = Syn_SetClauseList {actualValue_Syn_SetClauseList :: SetClauseList,messages_Syn_SetClauseList :: [Message],nodeType_Syn_SetClauseList :: Type,pairs_Syn_SetClauseList :: [(String,Type)]}+wrap_SetClauseList :: T_SetClauseList ->+ Inh_SetClauseList ->+ Syn_SetClauseList +wrap_SetClauseList sem (Inh_SetClauseList _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType,_lhsOpairs) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_SetClauseList _lhsOactualValue _lhsOmessages _lhsOnodeType _lhsOpairs ))+sem_SetClauseList_Cons :: T_SetClause ->+ T_SetClauseList ->+ T_SetClauseList +sem_SetClauseList_Cons hd_ tl_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOpairs :: ([(String,Type)])+ _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: SetClauseList+ _hdOinLoop :: Bool+ _hdOscope :: Scope+ _hdOsourcePos :: MySourcePos+ _tlOinLoop :: Bool+ _tlOscope :: Scope+ _tlOsourcePos :: MySourcePos+ _hdIactualValue :: SetClause+ _hdImessages :: ([Message])+ _hdInodeType :: Type+ _hdIpairs :: ([(String,Type)])+ _tlIactualValue :: SetClauseList+ _tlImessages :: ([Message])+ _tlInodeType :: Type+ _tlIpairs :: ([(String,Type)])+ _lhsOpairs =+ _hdIpairs ++ _tlIpairs+ _lhsOmessages =+ _hdImessages ++ _tlImessages+ _lhsOnodeType =+ _hdInodeType `appendTypeList` _tlInodeType+ _actualValue =+ (:) _hdIactualValue _tlIactualValue+ _lhsOactualValue =+ _actualValue+ _hdOinLoop =+ _lhsIinLoop+ _hdOscope =+ _lhsIscope+ _hdOsourcePos =+ _lhsIsourcePos+ _tlOinLoop =+ _lhsIinLoop+ _tlOscope =+ _lhsIscope+ _tlOsourcePos =+ _lhsIsourcePos+ ( _hdIactualValue,_hdImessages,_hdInodeType,_hdIpairs) =+ (hd_ _hdOinLoop _hdOscope _hdOsourcePos )+ ( _tlIactualValue,_tlImessages,_tlInodeType,_tlIpairs) =+ (tl_ _tlOinLoop _tlOscope _tlOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType,_lhsOpairs)))+sem_SetClauseList_Nil :: T_SetClauseList +sem_SetClauseList_Nil =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOpairs :: ([(String,Type)])+ _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: SetClauseList+ _lhsOpairs =+ []+ _lhsOmessages =+ []+ _lhsOnodeType =+ TypeList []+ _actualValue =+ []+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType,_lhsOpairs)))+-- SourcePosStatement ------------------------------------------+type SourcePosStatement = ( (MySourcePos),(Statement))+-- cata+sem_SourcePosStatement :: SourcePosStatement ->+ T_SourcePosStatement +sem_SourcePosStatement ( x1,x2) =+ (sem_SourcePosStatement_Tuple x1 (sem_Statement x2 ) )+-- semantic domain+type T_SourcePosStatement = Bool ->+ Scope ->+ MySourcePos ->+ ( SourcePosStatement,([Message]),Type,StatementInfo)+data Inh_SourcePosStatement = Inh_SourcePosStatement {inLoop_Inh_SourcePosStatement :: Bool,scope_Inh_SourcePosStatement :: Scope,sourcePos_Inh_SourcePosStatement :: MySourcePos}+data Syn_SourcePosStatement = Syn_SourcePosStatement {actualValue_Syn_SourcePosStatement :: SourcePosStatement,messages_Syn_SourcePosStatement :: [Message],nodeType_Syn_SourcePosStatement :: Type,statementInfo_Syn_SourcePosStatement :: StatementInfo}+wrap_SourcePosStatement :: T_SourcePosStatement ->+ Inh_SourcePosStatement ->+ Syn_SourcePosStatement +wrap_SourcePosStatement sem (Inh_SourcePosStatement _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType,_lhsOstatementInfo) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_SourcePosStatement _lhsOactualValue _lhsOmessages _lhsOnodeType _lhsOstatementInfo ))+sem_SourcePosStatement_Tuple :: MySourcePos ->+ T_Statement ->+ T_SourcePosStatement +sem_SourcePosStatement_Tuple x1_ x2_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _x2ObackType :: Type+ _x2OsourcePos :: MySourcePos+ _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: SourcePosStatement+ _lhsOstatementInfo :: StatementInfo+ _x2OinLoop :: Bool+ _x2Oscope :: Scope+ _x2IactualValue :: Statement+ _x2IbackType :: Type+ _x2Imessages :: ([Message])+ _x2InodeType :: Type+ _x2IstatementInfo :: StatementInfo+ _x2ObackType =+ _x2InodeType+ _x2OsourcePos =+ x1_+ _lhsOmessages =+ _x2Imessages+ _lhsOnodeType =+ _x2InodeType+ _actualValue =+ (x1_,_x2IactualValue)+ _lhsOactualValue =+ _actualValue+ _lhsOstatementInfo =+ _x2IstatementInfo+ _x2OinLoop =+ _lhsIinLoop+ _x2Oscope =+ _lhsIscope+ ( _x2IactualValue,_x2IbackType,_x2Imessages,_x2InodeType,_x2IstatementInfo) =+ (x2_ _x2ObackType _x2OinLoop _x2Oscope _x2OsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType,_lhsOstatementInfo)))+-- Statement ---------------------------------------------------+data Statement = Assignment (String) (Expression) + | CaseStatement (Expression) (ExpressionListStatementListPairList) (StatementList) + | ContinueStatement + | Copy (String) (StringList) (CopySource) + | CopyData (String) + | CreateDomain (String) (TypeName) (Maybe Expression) + | CreateFunction (Language) (String) (ParamDefList) (TypeName) (String) (FnBody) (Volatility) + | CreateTable (String) (AttributeDefList) (ConstraintList) + | CreateTableAs (String) (SelectExpression) + | CreateType (String) (TypeAttributeDefList) + | CreateView (String) (SelectExpression) + | Delete (String) (Where) (Maybe SelectList) + | DropFunction (IfExists) (StringStringListPairList) (Cascade) + | DropSomething (DropType) (IfExists) (StringList) (Cascade) + | Execute (Expression) + | ExecuteInto (Expression) (StringList) + | ForIntegerStatement (String) (Expression) (Expression) (StatementList) + | ForSelectStatement (String) (SelectExpression) (StatementList) + | If (ExpressionStatementListPairList) (StatementList) + | Insert (String) (StringList) (SelectExpression) (Maybe SelectList) + | NullStatement + | Perform (Expression) + | Raise (RaiseType) (String) (ExpressionList) + | Return (Maybe Expression) + | ReturnNext (Expression) + | ReturnQuery (SelectExpression) + | SelectStatement (SelectExpression) + | Truncate (StringList) (RestartIdentity) (Cascade) + | Update (String) (SetClauseList) (Where) (Maybe SelectList) + | WhileStatement (Expression) (StatementList) + deriving ( Eq,Show)+-- cata+sem_Statement :: Statement ->+ T_Statement +sem_Statement (Assignment _target _value ) =+ (sem_Statement_Assignment _target (sem_Expression _value ) )+sem_Statement (CaseStatement _val _cases _els ) =+ (sem_Statement_CaseStatement (sem_Expression _val ) (sem_ExpressionListStatementListPairList _cases ) (sem_StatementList _els ) )+sem_Statement (ContinueStatement ) =+ (sem_Statement_ContinueStatement )+sem_Statement (Copy _table _targetCols _source ) =+ (sem_Statement_Copy _table (sem_StringList _targetCols ) (sem_CopySource _source ) )+sem_Statement (CopyData _insData ) =+ (sem_Statement_CopyData _insData )+sem_Statement (CreateDomain _name _typ _check ) =+ (sem_Statement_CreateDomain _name (sem_TypeName _typ ) _check )+sem_Statement (CreateFunction _lang _name _params _rettype _bodyQuote _body _vol ) =+ (sem_Statement_CreateFunction (sem_Language _lang ) _name (sem_ParamDefList _params ) (sem_TypeName _rettype ) _bodyQuote (sem_FnBody _body ) (sem_Volatility _vol ) )+sem_Statement (CreateTable _name _atts _cons ) =+ (sem_Statement_CreateTable _name (sem_AttributeDefList _atts ) (sem_ConstraintList _cons ) )+sem_Statement (CreateTableAs _name _expr ) =+ (sem_Statement_CreateTableAs _name (sem_SelectExpression _expr ) )+sem_Statement (CreateType _name _atts ) =+ (sem_Statement_CreateType _name (sem_TypeAttributeDefList _atts ) )+sem_Statement (CreateView _name _expr ) =+ (sem_Statement_CreateView _name (sem_SelectExpression _expr ) )+sem_Statement (Delete _table _whr _returning ) =+ (sem_Statement_Delete _table (sem_Where _whr ) _returning )+sem_Statement (DropFunction _ifE _sigs _cascade ) =+ (sem_Statement_DropFunction (sem_IfExists _ifE ) (sem_StringStringListPairList _sigs ) (sem_Cascade _cascade ) )+sem_Statement (DropSomething _dropType _ifE _names _cascade ) =+ (sem_Statement_DropSomething (sem_DropType _dropType ) (sem_IfExists _ifE ) (sem_StringList _names ) (sem_Cascade _cascade ) )+sem_Statement (Execute _expr ) =+ (sem_Statement_Execute (sem_Expression _expr ) )+sem_Statement (ExecuteInto _expr _targets ) =+ (sem_Statement_ExecuteInto (sem_Expression _expr ) (sem_StringList _targets ) )+sem_Statement (ForIntegerStatement _var _from _to _sts ) =+ (sem_Statement_ForIntegerStatement _var (sem_Expression _from ) (sem_Expression _to ) (sem_StatementList _sts ) )+sem_Statement (ForSelectStatement _var _sel _sts ) =+ (sem_Statement_ForSelectStatement _var (sem_SelectExpression _sel ) (sem_StatementList _sts ) )+sem_Statement (If _cases _els ) =+ (sem_Statement_If (sem_ExpressionStatementListPairList _cases ) (sem_StatementList _els ) )+sem_Statement (Insert _table _targetCols _insData _returning ) =+ (sem_Statement_Insert _table (sem_StringList _targetCols ) (sem_SelectExpression _insData ) _returning )+sem_Statement (NullStatement ) =+ (sem_Statement_NullStatement )+sem_Statement (Perform _expr ) =+ (sem_Statement_Perform (sem_Expression _expr ) )+sem_Statement (Raise _level _message _args ) =+ (sem_Statement_Raise (sem_RaiseType _level ) _message (sem_ExpressionList _args ) )+sem_Statement (Return _value ) =+ (sem_Statement_Return _value )+sem_Statement (ReturnNext _expr ) =+ (sem_Statement_ReturnNext (sem_Expression _expr ) )+sem_Statement (ReturnQuery _sel ) =+ (sem_Statement_ReturnQuery (sem_SelectExpression _sel ) )+sem_Statement (SelectStatement _ex ) =+ (sem_Statement_SelectStatement (sem_SelectExpression _ex ) )+sem_Statement (Truncate _tables _restartIdentity _cascade ) =+ (sem_Statement_Truncate (sem_StringList _tables ) (sem_RestartIdentity _restartIdentity ) (sem_Cascade _cascade ) )+sem_Statement (Update _table _assigns _whr _returning ) =+ (sem_Statement_Update _table (sem_SetClauseList _assigns ) (sem_Where _whr ) _returning )+sem_Statement (WhileStatement _expr _sts ) =+ (sem_Statement_WhileStatement (sem_Expression _expr ) (sem_StatementList _sts ) )+-- semantic domain+type T_Statement = Type ->+ Bool ->+ Scope ->+ MySourcePos ->+ ( Statement,Type,([Message]),Type,StatementInfo)+data Inh_Statement = Inh_Statement {backType_Inh_Statement :: Type,inLoop_Inh_Statement :: Bool,scope_Inh_Statement :: Scope,sourcePos_Inh_Statement :: MySourcePos}+data Syn_Statement = Syn_Statement {actualValue_Syn_Statement :: Statement,backType_Syn_Statement :: Type,messages_Syn_Statement :: [Message],nodeType_Syn_Statement :: Type,statementInfo_Syn_Statement :: StatementInfo}+wrap_Statement :: T_Statement ->+ Inh_Statement ->+ Syn_Statement +wrap_Statement sem (Inh_Statement _lhsIbackType _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsObackType,_lhsOmessages,_lhsOnodeType,_lhsOstatementInfo) =+ (sem _lhsIbackType _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_Statement _lhsOactualValue _lhsObackType _lhsOmessages _lhsOnodeType _lhsOstatementInfo ))+sem_Statement_Assignment :: String ->+ T_Expression ->+ T_Statement +sem_Statement_Assignment target_ value_ =+ (\ _lhsIbackType+ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOstatementInfo :: StatementInfo+ _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Statement+ _lhsObackType :: Type+ _valueOinLoop :: Bool+ _valueOscope :: Scope+ _valueOsourcePos :: MySourcePos+ _valueIactualValue :: Expression+ _valueIliftedColumnName :: String+ _valueImessages :: ([Message])+ _valueInodeType :: Type+ _lhsOstatementInfo =+ DefaultStatementInfo _lhsIbackType+ _lhsOmessages =+ _valueImessages+ _lhsOnodeType =+ _valueInodeType+ _actualValue =+ Assignment target_ _valueIactualValue+ _lhsOactualValue =+ _actualValue+ _lhsObackType =+ _lhsIbackType+ _valueOinLoop =+ _lhsIinLoop+ _valueOscope =+ _lhsIscope+ _valueOsourcePos =+ _lhsIsourcePos+ ( _valueIactualValue,_valueIliftedColumnName,_valueImessages,_valueInodeType) =+ (value_ _valueOinLoop _valueOscope _valueOsourcePos )+ in ( _lhsOactualValue,_lhsObackType,_lhsOmessages,_lhsOnodeType,_lhsOstatementInfo)))+sem_Statement_CaseStatement :: T_Expression ->+ T_ExpressionListStatementListPairList ->+ T_StatementList ->+ T_Statement +sem_Statement_CaseStatement val_ cases_ els_ =+ (\ _lhsIbackType+ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOstatementInfo :: StatementInfo+ _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Statement+ _lhsObackType :: Type+ _valOinLoop :: Bool+ _valOscope :: Scope+ _valOsourcePos :: MySourcePos+ _casesOinLoop :: Bool+ _casesOscope :: Scope+ _casesOsourcePos :: MySourcePos+ _elsOinLoop :: Bool+ _elsOscope :: Scope+ _elsOsourcePos :: MySourcePos+ _valIactualValue :: Expression+ _valIliftedColumnName :: String+ _valImessages :: ([Message])+ _valInodeType :: Type+ _casesIactualValue :: ExpressionListStatementListPairList+ _casesImessages :: ([Message])+ _casesInodeType :: Type+ _elsIactualValue :: StatementList+ _elsImessages :: ([Message])+ _elsInodeType :: Type+ _elsIstatementInfo :: ([StatementInfo])+ _lhsOstatementInfo =+ DefaultStatementInfo _lhsIbackType+ _lhsOmessages =+ _valImessages ++ _casesImessages ++ _elsImessages+ _lhsOnodeType =+ _valInodeType `setUnknown` _casesInodeType `setUnknown` _elsInodeType+ _actualValue =+ CaseStatement _valIactualValue _casesIactualValue _elsIactualValue+ _lhsOactualValue =+ _actualValue+ _lhsObackType =+ _lhsIbackType+ _valOinLoop =+ _lhsIinLoop+ _valOscope =+ _lhsIscope+ _valOsourcePos =+ _lhsIsourcePos+ _casesOinLoop =+ _lhsIinLoop+ _casesOscope =+ _lhsIscope+ _casesOsourcePos =+ _lhsIsourcePos+ _elsOinLoop =+ _lhsIinLoop+ _elsOscope =+ _lhsIscope+ _elsOsourcePos =+ _lhsIsourcePos+ ( _valIactualValue,_valIliftedColumnName,_valImessages,_valInodeType) =+ (val_ _valOinLoop _valOscope _valOsourcePos )+ ( _casesIactualValue,_casesImessages,_casesInodeType) =+ (cases_ _casesOinLoop _casesOscope _casesOsourcePos )+ ( _elsIactualValue,_elsImessages,_elsInodeType,_elsIstatementInfo) =+ (els_ _elsOinLoop _elsOscope _elsOsourcePos )+ in ( _lhsOactualValue,_lhsObackType,_lhsOmessages,_lhsOnodeType,_lhsOstatementInfo)))+sem_Statement_ContinueStatement :: T_Statement +sem_Statement_ContinueStatement =+ (\ _lhsIbackType+ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOstatementInfo :: StatementInfo+ _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Statement+ _lhsObackType :: Type+ _lhsOstatementInfo =+ DefaultStatementInfo _lhsIbackType+ _lhsOmessages =+ if not _lhsIinLoop+ then [Error _lhsIsourcePos ContinueNotInLoop]+ else []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ ContinueStatement+ _lhsOactualValue =+ _actualValue+ _lhsObackType =+ _lhsIbackType+ in ( _lhsOactualValue,_lhsObackType,_lhsOmessages,_lhsOnodeType,_lhsOstatementInfo)))+sem_Statement_Copy :: String ->+ T_StringList ->+ T_CopySource ->+ T_Statement +sem_Statement_Copy table_ targetCols_ source_ =+ (\ _lhsIbackType+ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOstatementInfo :: StatementInfo+ _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Statement+ _lhsObackType :: Type+ _targetColsOinLoop :: Bool+ _targetColsOscope :: Scope+ _targetColsOsourcePos :: MySourcePos+ _sourceOinLoop :: Bool+ _sourceOscope :: Scope+ _sourceOsourcePos :: MySourcePos+ _targetColsIactualValue :: StringList+ _targetColsImessages :: ([Message])+ _targetColsInodeType :: Type+ _targetColsIstrings :: ([String])+ _sourceIactualValue :: CopySource+ _sourceImessages :: ([Message])+ _sourceInodeType :: Type+ _lhsOstatementInfo =+ DefaultStatementInfo _lhsIbackType+ _lhsOmessages =+ _targetColsImessages ++ _sourceImessages+ _lhsOnodeType =+ _targetColsInodeType `setUnknown` _sourceInodeType+ _actualValue =+ Copy table_ _targetColsIactualValue _sourceIactualValue+ _lhsOactualValue =+ _actualValue+ _lhsObackType =+ _lhsIbackType+ _targetColsOinLoop =+ _lhsIinLoop+ _targetColsOscope =+ _lhsIscope+ _targetColsOsourcePos =+ _lhsIsourcePos+ _sourceOinLoop =+ _lhsIinLoop+ _sourceOscope =+ _lhsIscope+ _sourceOsourcePos =+ _lhsIsourcePos+ ( _targetColsIactualValue,_targetColsImessages,_targetColsInodeType,_targetColsIstrings) =+ (targetCols_ _targetColsOinLoop _targetColsOscope _targetColsOsourcePos )+ ( _sourceIactualValue,_sourceImessages,_sourceInodeType) =+ (source_ _sourceOinLoop _sourceOscope _sourceOsourcePos )+ in ( _lhsOactualValue,_lhsObackType,_lhsOmessages,_lhsOnodeType,_lhsOstatementInfo)))+sem_Statement_CopyData :: String ->+ T_Statement +sem_Statement_CopyData insData_ =+ (\ _lhsIbackType+ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOstatementInfo :: StatementInfo+ _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Statement+ _lhsObackType :: Type+ _lhsOstatementInfo =+ DefaultStatementInfo _lhsIbackType+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ CopyData insData_+ _lhsOactualValue =+ _actualValue+ _lhsObackType =+ _lhsIbackType+ in ( _lhsOactualValue,_lhsObackType,_lhsOmessages,_lhsOnodeType,_lhsOstatementInfo)))+sem_Statement_CreateDomain :: String ->+ T_TypeName ->+ (Maybe Expression) ->+ T_Statement +sem_Statement_CreateDomain name_ typ_ check_ =+ (\ _lhsIbackType+ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOstatementInfo :: StatementInfo+ _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Statement+ _lhsObackType :: Type+ _typOinLoop :: Bool+ _typOscope :: Scope+ _typOsourcePos :: MySourcePos+ _typIactualValue :: TypeName+ _typImessages :: ([Message])+ _typInodeType :: Type+ _lhsOstatementInfo =+ makeStatementInfo _lhsIbackType $ CreateDomainInfo name_ _typInodeType+ _lhsOmessages =+ _typImessages+ _lhsOnodeType =+ _typInodeType+ _actualValue =+ CreateDomain name_ _typIactualValue check_+ _lhsOactualValue =+ _actualValue+ _lhsObackType =+ _lhsIbackType+ _typOinLoop =+ _lhsIinLoop+ _typOscope =+ _lhsIscope+ _typOsourcePos =+ _lhsIsourcePos+ ( _typIactualValue,_typImessages,_typInodeType) =+ (typ_ _typOinLoop _typOscope _typOsourcePos )+ in ( _lhsOactualValue,_lhsObackType,_lhsOmessages,_lhsOnodeType,_lhsOstatementInfo)))+sem_Statement_CreateFunction :: T_Language ->+ String ->+ T_ParamDefList ->+ T_TypeName ->+ String ->+ T_FnBody ->+ T_Volatility ->+ T_Statement +sem_Statement_CreateFunction lang_ name_ params_ rettype_ bodyQuote_ body_ vol_ =+ (\ _lhsIbackType+ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOstatementInfo :: StatementInfo+ _bodyOinLoop :: Bool+ _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Statement+ _lhsObackType :: Type+ _langOinLoop :: Bool+ _langOscope :: Scope+ _langOsourcePos :: MySourcePos+ _paramsOinLoop :: Bool+ _paramsOscope :: Scope+ _paramsOsourcePos :: MySourcePos+ _rettypeOinLoop :: Bool+ _rettypeOscope :: Scope+ _rettypeOsourcePos :: MySourcePos+ _bodyOscope :: Scope+ _bodyOsourcePos :: MySourcePos+ _volOinLoop :: Bool+ _volOscope :: Scope+ _volOsourcePos :: MySourcePos+ _langIactualValue :: Language+ _langImessages :: ([Message])+ _langInodeType :: Type+ _paramsIactualValue :: ParamDefList+ _paramsImessages :: ([Message])+ _paramsInodeType :: Type+ _paramsIparams :: ([(String,Type)])+ _rettypeIactualValue :: TypeName+ _rettypeImessages :: ([Message])+ _rettypeInodeType :: Type+ _bodyIactualValue :: FnBody+ _bodyImessages :: ([Message])+ _bodyInodeType :: Type+ _volIactualValue :: Volatility+ _volImessages :: ([Message])+ _volInodeType :: Type+ _lhsOstatementInfo =+ makeStatementInfo _lhsIbackType $ CreateFunctionInfo (name_,map snd _paramsIparams,_rettypeInodeType)+ _bodyOinLoop =+ False+ _lhsOmessages =+ _langImessages ++ _paramsImessages ++ _rettypeImessages ++ _bodyImessages ++ _volImessages+ _lhsOnodeType =+ _langInodeType `setUnknown` _paramsInodeType `setUnknown` _rettypeInodeType `setUnknown` _bodyInodeType `setUnknown` _volInodeType+ _actualValue =+ CreateFunction _langIactualValue name_ _paramsIactualValue _rettypeIactualValue bodyQuote_ _bodyIactualValue _volIactualValue+ _lhsOactualValue =+ _actualValue+ _lhsObackType =+ _lhsIbackType+ _langOinLoop =+ _lhsIinLoop+ _langOscope =+ _lhsIscope+ _langOsourcePos =+ _lhsIsourcePos+ _paramsOinLoop =+ _lhsIinLoop+ _paramsOscope =+ _lhsIscope+ _paramsOsourcePos =+ _lhsIsourcePos+ _rettypeOinLoop =+ _lhsIinLoop+ _rettypeOscope =+ _lhsIscope+ _rettypeOsourcePos =+ _lhsIsourcePos+ _bodyOscope =+ _lhsIscope+ _bodyOsourcePos =+ _lhsIsourcePos+ _volOinLoop =+ _lhsIinLoop+ _volOscope =+ _lhsIscope+ _volOsourcePos =+ _lhsIsourcePos+ ( _langIactualValue,_langImessages,_langInodeType) =+ (lang_ _langOinLoop _langOscope _langOsourcePos )+ ( _paramsIactualValue,_paramsImessages,_paramsInodeType,_paramsIparams) =+ (params_ _paramsOinLoop _paramsOscope _paramsOsourcePos )+ ( _rettypeIactualValue,_rettypeImessages,_rettypeInodeType) =+ (rettype_ _rettypeOinLoop _rettypeOscope _rettypeOsourcePos )+ ( _bodyIactualValue,_bodyImessages,_bodyInodeType) =+ (body_ _bodyOinLoop _bodyOscope _bodyOsourcePos )+ ( _volIactualValue,_volImessages,_volInodeType) =+ (vol_ _volOinLoop _volOscope _volOsourcePos )+ in ( _lhsOactualValue,_lhsObackType,_lhsOmessages,_lhsOnodeType,_lhsOstatementInfo)))+sem_Statement_CreateTable :: String ->+ T_AttributeDefList ->+ T_ConstraintList ->+ T_Statement +sem_Statement_CreateTable name_ atts_ cons_ =+ (\ _lhsIbackType+ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOstatementInfo :: StatementInfo+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: Statement+ _lhsObackType :: Type+ _attsOinLoop :: Bool+ _attsOscope :: Scope+ _attsOsourcePos :: MySourcePos+ _consOinLoop :: Bool+ _consOscope :: Scope+ _consOsourcePos :: MySourcePos+ _attsIactualValue :: AttributeDefList+ _attsImessages :: ([Message])+ _attsInodeType :: Type+ _consIactualValue :: ConstraintList+ _consImessages :: ([Message])+ _consInodeType :: Type+ _lhsOnodeType =+ _attsInodeType+ _lhsOstatementInfo =+ makeStatementInfo _lhsIbackType $ RelvarInfo (name_, TableComposite, _attsInodeType)+ _lhsOmessages =+ _attsImessages ++ _consImessages+ _actualValue =+ CreateTable name_ _attsIactualValue _consIactualValue+ _lhsOactualValue =+ _actualValue+ _lhsObackType =+ _lhsIbackType+ _attsOinLoop =+ _lhsIinLoop+ _attsOscope =+ _lhsIscope+ _attsOsourcePos =+ _lhsIsourcePos+ _consOinLoop =+ _lhsIinLoop+ _consOscope =+ _lhsIscope+ _consOsourcePos =+ _lhsIsourcePos+ ( _attsIactualValue,_attsImessages,_attsInodeType) =+ (atts_ _attsOinLoop _attsOscope _attsOsourcePos )+ ( _consIactualValue,_consImessages,_consInodeType) =+ (cons_ _consOinLoop _consOscope _consOsourcePos )+ in ( _lhsOactualValue,_lhsObackType,_lhsOmessages,_lhsOnodeType,_lhsOstatementInfo)))+sem_Statement_CreateTableAs :: String ->+ T_SelectExpression ->+ T_Statement +sem_Statement_CreateTableAs name_ expr_ =+ (\ _lhsIbackType+ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOstatementInfo :: StatementInfo+ _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Statement+ _lhsObackType :: Type+ _exprOinLoop :: Bool+ _exprOscope :: Scope+ _exprOsourcePos :: MySourcePos+ _exprIactualValue :: SelectExpression+ _exprImessages :: ([Message])+ _exprInodeType :: Type+ _lhsOstatementInfo =+ makeStatementInfo _lhsIbackType $ RelvarInfo (name_, TableComposite, _exprInodeType)+ _lhsOmessages =+ _exprImessages+ _lhsOnodeType =+ _exprInodeType+ _actualValue =+ CreateTableAs name_ _exprIactualValue+ _lhsOactualValue =+ _actualValue+ _lhsObackType =+ _lhsIbackType+ _exprOinLoop =+ _lhsIinLoop+ _exprOscope =+ _lhsIscope+ _exprOsourcePos =+ _lhsIsourcePos+ ( _exprIactualValue,_exprImessages,_exprInodeType) =+ (expr_ _exprOinLoop _exprOscope _exprOsourcePos )+ in ( _lhsOactualValue,_lhsObackType,_lhsOmessages,_lhsOnodeType,_lhsOstatementInfo)))+sem_Statement_CreateType :: String ->+ T_TypeAttributeDefList ->+ T_Statement +sem_Statement_CreateType name_ atts_ =+ (\ _lhsIbackType+ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOstatementInfo :: StatementInfo+ _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Statement+ _lhsObackType :: Type+ _attsOinLoop :: Bool+ _attsOscope :: Scope+ _attsOsourcePos :: MySourcePos+ _attsIactualValue :: TypeAttributeDefList+ _attsImessages :: ([Message])+ _attsInodeType :: Type+ _lhsOstatementInfo =+ makeStatementInfo _lhsIbackType $ RelvarInfo (name_, Composite, _attsInodeType)+ _lhsOmessages =+ _attsImessages+ _lhsOnodeType =+ _attsInodeType+ _actualValue =+ CreateType name_ _attsIactualValue+ _lhsOactualValue =+ _actualValue+ _lhsObackType =+ _lhsIbackType+ _attsOinLoop =+ _lhsIinLoop+ _attsOscope =+ _lhsIscope+ _attsOsourcePos =+ _lhsIsourcePos+ ( _attsIactualValue,_attsImessages,_attsInodeType) =+ (atts_ _attsOinLoop _attsOscope _attsOsourcePos )+ in ( _lhsOactualValue,_lhsObackType,_lhsOmessages,_lhsOnodeType,_lhsOstatementInfo)))+sem_Statement_CreateView :: String ->+ T_SelectExpression ->+ T_Statement +sem_Statement_CreateView name_ expr_ =+ (\ _lhsIbackType+ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOstatementInfo :: StatementInfo+ _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Statement+ _lhsObackType :: Type+ _exprOinLoop :: Bool+ _exprOscope :: Scope+ _exprOsourcePos :: MySourcePos+ _exprIactualValue :: SelectExpression+ _exprImessages :: ([Message])+ _exprInodeType :: Type+ _lhsOstatementInfo =+ makeStatementInfo _lhsIbackType $ RelvarInfo (name_, ViewComposite, _exprInodeType)+ _lhsOmessages =+ _exprImessages+ _lhsOnodeType =+ _exprInodeType+ _actualValue =+ CreateView name_ _exprIactualValue+ _lhsOactualValue =+ _actualValue+ _lhsObackType =+ _lhsIbackType+ _exprOinLoop =+ _lhsIinLoop+ _exprOscope =+ _lhsIscope+ _exprOsourcePos =+ _lhsIsourcePos+ ( _exprIactualValue,_exprImessages,_exprInodeType) =+ (expr_ _exprOinLoop _exprOscope _exprOsourcePos )+ in ( _lhsOactualValue,_lhsObackType,_lhsOmessages,_lhsOnodeType,_lhsOstatementInfo)))+sem_Statement_Delete :: String ->+ T_Where ->+ (Maybe SelectList) ->+ T_Statement +sem_Statement_Delete table_ whr_ returning_ =+ (\ _lhsIbackType+ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOstatementInfo :: StatementInfo+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: Statement+ _lhsObackType :: Type+ _whrOinLoop :: Bool+ _whrOscope :: Scope+ _whrOsourcePos :: MySourcePos+ _whrIactualValue :: Where+ _whrImessages :: ([Message])+ _whrInodeType :: Type+ _lhsOnodeType =+ checkErrors [checkTableExists _lhsIscope _lhsIsourcePos table_+ ,_whrInodeType]+ $ TypeList []+ _lhsOstatementInfo =+ makeStatementInfo _lhsIbackType $ DeleteInfo table_+ _lhsOmessages =+ _whrImessages+ _actualValue =+ Delete table_ _whrIactualValue returning_+ _lhsOactualValue =+ _actualValue+ _lhsObackType =+ _lhsIbackType+ _whrOinLoop =+ _lhsIinLoop+ _whrOscope =+ _lhsIscope+ _whrOsourcePos =+ _lhsIsourcePos+ ( _whrIactualValue,_whrImessages,_whrInodeType) =+ (whr_ _whrOinLoop _whrOscope _whrOsourcePos )+ in ( _lhsOactualValue,_lhsObackType,_lhsOmessages,_lhsOnodeType,_lhsOstatementInfo)))+sem_Statement_DropFunction :: T_IfExists ->+ T_StringStringListPairList ->+ T_Cascade ->+ T_Statement +sem_Statement_DropFunction ifE_ sigs_ cascade_ =+ (\ _lhsIbackType+ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOstatementInfo :: StatementInfo+ _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Statement+ _lhsObackType :: Type+ _ifEOinLoop :: Bool+ _ifEOscope :: Scope+ _ifEOsourcePos :: MySourcePos+ _sigsOinLoop :: Bool+ _sigsOscope :: Scope+ _sigsOsourcePos :: MySourcePos+ _cascadeOinLoop :: Bool+ _cascadeOscope :: Scope+ _cascadeOsourcePos :: MySourcePos+ _ifEIactualValue :: IfExists+ _ifEImessages :: ([Message])+ _ifEInodeType :: Type+ _sigsIactualValue :: StringStringListPairList+ _sigsImessages :: ([Message])+ _sigsInodeType :: Type+ _cascadeIactualValue :: Cascade+ _cascadeImessages :: ([Message])+ _cascadeInodeType :: Type+ _lhsOstatementInfo =+ DefaultStatementInfo _lhsIbackType+ _lhsOmessages =+ _ifEImessages ++ _sigsImessages ++ _cascadeImessages+ _lhsOnodeType =+ _ifEInodeType `setUnknown` _sigsInodeType `setUnknown` _cascadeInodeType+ _actualValue =+ DropFunction _ifEIactualValue _sigsIactualValue _cascadeIactualValue+ _lhsOactualValue =+ _actualValue+ _lhsObackType =+ _lhsIbackType+ _ifEOinLoop =+ _lhsIinLoop+ _ifEOscope =+ _lhsIscope+ _ifEOsourcePos =+ _lhsIsourcePos+ _sigsOinLoop =+ _lhsIinLoop+ _sigsOscope =+ _lhsIscope+ _sigsOsourcePos =+ _lhsIsourcePos+ _cascadeOinLoop =+ _lhsIinLoop+ _cascadeOscope =+ _lhsIscope+ _cascadeOsourcePos =+ _lhsIsourcePos+ ( _ifEIactualValue,_ifEImessages,_ifEInodeType) =+ (ifE_ _ifEOinLoop _ifEOscope _ifEOsourcePos )+ ( _sigsIactualValue,_sigsImessages,_sigsInodeType) =+ (sigs_ _sigsOinLoop _sigsOscope _sigsOsourcePos )+ ( _cascadeIactualValue,_cascadeImessages,_cascadeInodeType) =+ (cascade_ _cascadeOinLoop _cascadeOscope _cascadeOsourcePos )+ in ( _lhsOactualValue,_lhsObackType,_lhsOmessages,_lhsOnodeType,_lhsOstatementInfo)))+sem_Statement_DropSomething :: T_DropType ->+ T_IfExists ->+ T_StringList ->+ T_Cascade ->+ T_Statement +sem_Statement_DropSomething dropType_ ifE_ names_ cascade_ =+ (\ _lhsIbackType+ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOstatementInfo :: StatementInfo+ _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Statement+ _lhsObackType :: Type+ _dropTypeOinLoop :: Bool+ _dropTypeOscope :: Scope+ _dropTypeOsourcePos :: MySourcePos+ _ifEOinLoop :: Bool+ _ifEOscope :: Scope+ _ifEOsourcePos :: MySourcePos+ _namesOinLoop :: Bool+ _namesOscope :: Scope+ _namesOsourcePos :: MySourcePos+ _cascadeOinLoop :: Bool+ _cascadeOscope :: Scope+ _cascadeOsourcePos :: MySourcePos+ _dropTypeIactualValue :: DropType+ _dropTypeImessages :: ([Message])+ _dropTypeInodeType :: Type+ _ifEIactualValue :: IfExists+ _ifEImessages :: ([Message])+ _ifEInodeType :: Type+ _namesIactualValue :: StringList+ _namesImessages :: ([Message])+ _namesInodeType :: Type+ _namesIstrings :: ([String])+ _cascadeIactualValue :: Cascade+ _cascadeImessages :: ([Message])+ _cascadeInodeType :: Type+ _lhsOstatementInfo =+ DefaultStatementInfo _lhsIbackType+ _lhsOmessages =+ _dropTypeImessages ++ _ifEImessages ++ _namesImessages ++ _cascadeImessages+ _lhsOnodeType =+ _dropTypeInodeType `setUnknown` _ifEInodeType `setUnknown` _namesInodeType `setUnknown` _cascadeInodeType+ _actualValue =+ DropSomething _dropTypeIactualValue _ifEIactualValue _namesIactualValue _cascadeIactualValue+ _lhsOactualValue =+ _actualValue+ _lhsObackType =+ _lhsIbackType+ _dropTypeOinLoop =+ _lhsIinLoop+ _dropTypeOscope =+ _lhsIscope+ _dropTypeOsourcePos =+ _lhsIsourcePos+ _ifEOinLoop =+ _lhsIinLoop+ _ifEOscope =+ _lhsIscope+ _ifEOsourcePos =+ _lhsIsourcePos+ _namesOinLoop =+ _lhsIinLoop+ _namesOscope =+ _lhsIscope+ _namesOsourcePos =+ _lhsIsourcePos+ _cascadeOinLoop =+ _lhsIinLoop+ _cascadeOscope =+ _lhsIscope+ _cascadeOsourcePos =+ _lhsIsourcePos+ ( _dropTypeIactualValue,_dropTypeImessages,_dropTypeInodeType) =+ (dropType_ _dropTypeOinLoop _dropTypeOscope _dropTypeOsourcePos )+ ( _ifEIactualValue,_ifEImessages,_ifEInodeType) =+ (ifE_ _ifEOinLoop _ifEOscope _ifEOsourcePos )+ ( _namesIactualValue,_namesImessages,_namesInodeType,_namesIstrings) =+ (names_ _namesOinLoop _namesOscope _namesOsourcePos )+ ( _cascadeIactualValue,_cascadeImessages,_cascadeInodeType) =+ (cascade_ _cascadeOinLoop _cascadeOscope _cascadeOsourcePos )+ in ( _lhsOactualValue,_lhsObackType,_lhsOmessages,_lhsOnodeType,_lhsOstatementInfo)))+sem_Statement_Execute :: T_Expression ->+ T_Statement +sem_Statement_Execute expr_ =+ (\ _lhsIbackType+ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOstatementInfo :: StatementInfo+ _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Statement+ _lhsObackType :: Type+ _exprOinLoop :: Bool+ _exprOscope :: Scope+ _exprOsourcePos :: MySourcePos+ _exprIactualValue :: Expression+ _exprIliftedColumnName :: String+ _exprImessages :: ([Message])+ _exprInodeType :: Type+ _lhsOstatementInfo =+ DefaultStatementInfo _lhsIbackType+ _lhsOmessages =+ _exprImessages+ _lhsOnodeType =+ _exprInodeType+ _actualValue =+ Execute _exprIactualValue+ _lhsOactualValue =+ _actualValue+ _lhsObackType =+ _lhsIbackType+ _exprOinLoop =+ _lhsIinLoop+ _exprOscope =+ _lhsIscope+ _exprOsourcePos =+ _lhsIsourcePos+ ( _exprIactualValue,_exprIliftedColumnName,_exprImessages,_exprInodeType) =+ (expr_ _exprOinLoop _exprOscope _exprOsourcePos )+ in ( _lhsOactualValue,_lhsObackType,_lhsOmessages,_lhsOnodeType,_lhsOstatementInfo)))+sem_Statement_ExecuteInto :: T_Expression ->+ T_StringList ->+ T_Statement +sem_Statement_ExecuteInto expr_ targets_ =+ (\ _lhsIbackType+ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOstatementInfo :: StatementInfo+ _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Statement+ _lhsObackType :: Type+ _exprOinLoop :: Bool+ _exprOscope :: Scope+ _exprOsourcePos :: MySourcePos+ _targetsOinLoop :: Bool+ _targetsOscope :: Scope+ _targetsOsourcePos :: MySourcePos+ _exprIactualValue :: Expression+ _exprIliftedColumnName :: String+ _exprImessages :: ([Message])+ _exprInodeType :: Type+ _targetsIactualValue :: StringList+ _targetsImessages :: ([Message])+ _targetsInodeType :: Type+ _targetsIstrings :: ([String])+ _lhsOstatementInfo =+ DefaultStatementInfo _lhsIbackType+ _lhsOmessages =+ _exprImessages ++ _targetsImessages+ _lhsOnodeType =+ _exprInodeType `setUnknown` _targetsInodeType+ _actualValue =+ ExecuteInto _exprIactualValue _targetsIactualValue+ _lhsOactualValue =+ _actualValue+ _lhsObackType =+ _lhsIbackType+ _exprOinLoop =+ _lhsIinLoop+ _exprOscope =+ _lhsIscope+ _exprOsourcePos =+ _lhsIsourcePos+ _targetsOinLoop =+ _lhsIinLoop+ _targetsOscope =+ _lhsIscope+ _targetsOsourcePos =+ _lhsIsourcePos+ ( _exprIactualValue,_exprIliftedColumnName,_exprImessages,_exprInodeType) =+ (expr_ _exprOinLoop _exprOscope _exprOsourcePos )+ ( _targetsIactualValue,_targetsImessages,_targetsInodeType,_targetsIstrings) =+ (targets_ _targetsOinLoop _targetsOscope _targetsOsourcePos )+ in ( _lhsOactualValue,_lhsObackType,_lhsOmessages,_lhsOnodeType,_lhsOstatementInfo)))+sem_Statement_ForIntegerStatement :: String ->+ T_Expression ->+ T_Expression ->+ T_StatementList ->+ T_Statement +sem_Statement_ForIntegerStatement var_ from_ to_ sts_ =+ (\ _lhsIbackType+ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOstatementInfo :: StatementInfo+ _stsOinLoop :: Bool+ _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Statement+ _lhsObackType :: Type+ _fromOinLoop :: Bool+ _fromOscope :: Scope+ _fromOsourcePos :: MySourcePos+ _toOinLoop :: Bool+ _toOscope :: Scope+ _toOsourcePos :: MySourcePos+ _stsOscope :: Scope+ _stsOsourcePos :: MySourcePos+ _fromIactualValue :: Expression+ _fromIliftedColumnName :: String+ _fromImessages :: ([Message])+ _fromInodeType :: Type+ _toIactualValue :: Expression+ _toIliftedColumnName :: String+ _toImessages :: ([Message])+ _toInodeType :: Type+ _stsIactualValue :: StatementList+ _stsImessages :: ([Message])+ _stsInodeType :: Type+ _stsIstatementInfo :: ([StatementInfo])+ _lhsOstatementInfo =+ DefaultStatementInfo _lhsIbackType+ _stsOinLoop =+ True+ _lhsOmessages =+ _fromImessages ++ _toImessages ++ _stsImessages+ _lhsOnodeType =+ _fromInodeType `setUnknown` _toInodeType `setUnknown` _stsInodeType+ _actualValue =+ ForIntegerStatement var_ _fromIactualValue _toIactualValue _stsIactualValue+ _lhsOactualValue =+ _actualValue+ _lhsObackType =+ _lhsIbackType+ _fromOinLoop =+ _lhsIinLoop+ _fromOscope =+ _lhsIscope+ _fromOsourcePos =+ _lhsIsourcePos+ _toOinLoop =+ _lhsIinLoop+ _toOscope =+ _lhsIscope+ _toOsourcePos =+ _lhsIsourcePos+ _stsOscope =+ _lhsIscope+ _stsOsourcePos =+ _lhsIsourcePos+ ( _fromIactualValue,_fromIliftedColumnName,_fromImessages,_fromInodeType) =+ (from_ _fromOinLoop _fromOscope _fromOsourcePos )+ ( _toIactualValue,_toIliftedColumnName,_toImessages,_toInodeType) =+ (to_ _toOinLoop _toOscope _toOsourcePos )+ ( _stsIactualValue,_stsImessages,_stsInodeType,_stsIstatementInfo) =+ (sts_ _stsOinLoop _stsOscope _stsOsourcePos )+ in ( _lhsOactualValue,_lhsObackType,_lhsOmessages,_lhsOnodeType,_lhsOstatementInfo)))+sem_Statement_ForSelectStatement :: String ->+ T_SelectExpression ->+ T_StatementList ->+ T_Statement +sem_Statement_ForSelectStatement var_ sel_ sts_ =+ (\ _lhsIbackType+ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOstatementInfo :: StatementInfo+ _stsOinLoop :: Bool+ _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Statement+ _lhsObackType :: Type+ _selOinLoop :: Bool+ _selOscope :: Scope+ _selOsourcePos :: MySourcePos+ _stsOscope :: Scope+ _stsOsourcePos :: MySourcePos+ _selIactualValue :: SelectExpression+ _selImessages :: ([Message])+ _selInodeType :: Type+ _stsIactualValue :: StatementList+ _stsImessages :: ([Message])+ _stsInodeType :: Type+ _stsIstatementInfo :: ([StatementInfo])+ _lhsOstatementInfo =+ DefaultStatementInfo _lhsIbackType+ _stsOinLoop =+ True+ _lhsOmessages =+ _selImessages ++ _stsImessages+ _lhsOnodeType =+ _selInodeType `setUnknown` _stsInodeType+ _actualValue =+ ForSelectStatement var_ _selIactualValue _stsIactualValue+ _lhsOactualValue =+ _actualValue+ _lhsObackType =+ _lhsIbackType+ _selOinLoop =+ _lhsIinLoop+ _selOscope =+ _lhsIscope+ _selOsourcePos =+ _lhsIsourcePos+ _stsOscope =+ _lhsIscope+ _stsOsourcePos =+ _lhsIsourcePos+ ( _selIactualValue,_selImessages,_selInodeType) =+ (sel_ _selOinLoop _selOscope _selOsourcePos )+ ( _stsIactualValue,_stsImessages,_stsInodeType,_stsIstatementInfo) =+ (sts_ _stsOinLoop _stsOscope _stsOsourcePos )+ in ( _lhsOactualValue,_lhsObackType,_lhsOmessages,_lhsOnodeType,_lhsOstatementInfo)))+sem_Statement_If :: T_ExpressionStatementListPairList ->+ T_StatementList ->+ T_Statement +sem_Statement_If cases_ els_ =+ (\ _lhsIbackType+ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOstatementInfo :: StatementInfo+ _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Statement+ _lhsObackType :: Type+ _casesOinLoop :: Bool+ _casesOscope :: Scope+ _casesOsourcePos :: MySourcePos+ _elsOinLoop :: Bool+ _elsOscope :: Scope+ _elsOsourcePos :: MySourcePos+ _casesIactualValue :: ExpressionStatementListPairList+ _casesImessages :: ([Message])+ _casesInodeType :: Type+ _elsIactualValue :: StatementList+ _elsImessages :: ([Message])+ _elsInodeType :: Type+ _elsIstatementInfo :: ([StatementInfo])+ _lhsOstatementInfo =+ DefaultStatementInfo _lhsIbackType+ _lhsOmessages =+ _casesImessages ++ _elsImessages+ _lhsOnodeType =+ _casesInodeType `setUnknown` _elsInodeType+ _actualValue =+ If _casesIactualValue _elsIactualValue+ _lhsOactualValue =+ _actualValue+ _lhsObackType =+ _lhsIbackType+ _casesOinLoop =+ _lhsIinLoop+ _casesOscope =+ _lhsIscope+ _casesOsourcePos =+ _lhsIsourcePos+ _elsOinLoop =+ _lhsIinLoop+ _elsOscope =+ _lhsIscope+ _elsOsourcePos =+ _lhsIsourcePos+ ( _casesIactualValue,_casesImessages,_casesInodeType) =+ (cases_ _casesOinLoop _casesOscope _casesOsourcePos )+ ( _elsIactualValue,_elsImessages,_elsInodeType,_elsIstatementInfo) =+ (els_ _elsOinLoop _elsOscope _elsOsourcePos )+ in ( _lhsOactualValue,_lhsObackType,_lhsOmessages,_lhsOnodeType,_lhsOstatementInfo)))+sem_Statement_Insert :: String ->+ T_StringList ->+ T_SelectExpression ->+ (Maybe SelectList) ->+ T_Statement +sem_Statement_Insert table_ targetCols_ insData_ returning_ =+ (\ _lhsIbackType+ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOstatementInfo :: StatementInfo+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: Statement+ _lhsObackType :: Type+ _targetColsOinLoop :: Bool+ _targetColsOscope :: Scope+ _targetColsOsourcePos :: MySourcePos+ _insDataOinLoop :: Bool+ _insDataOscope :: Scope+ _insDataOsourcePos :: MySourcePos+ _targetColsIactualValue :: StringList+ _targetColsImessages :: ([Message])+ _targetColsInodeType :: Type+ _targetColsIstrings :: ([String])+ _insDataIactualValue :: SelectExpression+ _insDataImessages :: ([Message])+ _insDataInodeType :: Type+ _lhsOnodeType =+ checkErrors [checkTableExists _lhsIscope _lhsIsourcePos table_+ ,_insDataInodeType+ ,checkColumnConsistency _lhsIscope _lhsIsourcePos table_ _targetColsIstrings (unwrapComposite $ unwrapSetOf _insDataInodeType)]+ _insDataInodeType+ _lhsOstatementInfo =+ makeStatementInfo _lhsIbackType $ InsertInfo table_ $ UnnamedCompositeType $ getColumnTypes _lhsIscope _lhsIsourcePos table_ _targetColsIstrings+ _lhsOmessages =+ _targetColsImessages ++ _insDataImessages+ _actualValue =+ Insert table_ _targetColsIactualValue _insDataIactualValue returning_+ _lhsOactualValue =+ _actualValue+ _lhsObackType =+ _lhsIbackType+ _targetColsOinLoop =+ _lhsIinLoop+ _targetColsOscope =+ _lhsIscope+ _targetColsOsourcePos =+ _lhsIsourcePos+ _insDataOinLoop =+ _lhsIinLoop+ _insDataOscope =+ _lhsIscope+ _insDataOsourcePos =+ _lhsIsourcePos+ ( _targetColsIactualValue,_targetColsImessages,_targetColsInodeType,_targetColsIstrings) =+ (targetCols_ _targetColsOinLoop _targetColsOscope _targetColsOsourcePos )+ ( _insDataIactualValue,_insDataImessages,_insDataInodeType) =+ (insData_ _insDataOinLoop _insDataOscope _insDataOsourcePos )+ in ( _lhsOactualValue,_lhsObackType,_lhsOmessages,_lhsOnodeType,_lhsOstatementInfo)))+sem_Statement_NullStatement :: T_Statement +sem_Statement_NullStatement =+ (\ _lhsIbackType+ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOstatementInfo :: StatementInfo+ _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Statement+ _lhsObackType :: Type+ _lhsOstatementInfo =+ DefaultStatementInfo _lhsIbackType+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ NullStatement+ _lhsOactualValue =+ _actualValue+ _lhsObackType =+ _lhsIbackType+ in ( _lhsOactualValue,_lhsObackType,_lhsOmessages,_lhsOnodeType,_lhsOstatementInfo)))+sem_Statement_Perform :: T_Expression ->+ T_Statement +sem_Statement_Perform expr_ =+ (\ _lhsIbackType+ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOstatementInfo :: StatementInfo+ _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Statement+ _lhsObackType :: Type+ _exprOinLoop :: Bool+ _exprOscope :: Scope+ _exprOsourcePos :: MySourcePos+ _exprIactualValue :: Expression+ _exprIliftedColumnName :: String+ _exprImessages :: ([Message])+ _exprInodeType :: Type+ _lhsOstatementInfo =+ DefaultStatementInfo _lhsIbackType+ _lhsOmessages =+ _exprImessages+ _lhsOnodeType =+ _exprInodeType+ _actualValue =+ Perform _exprIactualValue+ _lhsOactualValue =+ _actualValue+ _lhsObackType =+ _lhsIbackType+ _exprOinLoop =+ _lhsIinLoop+ _exprOscope =+ _lhsIscope+ _exprOsourcePos =+ _lhsIsourcePos+ ( _exprIactualValue,_exprIliftedColumnName,_exprImessages,_exprInodeType) =+ (expr_ _exprOinLoop _exprOscope _exprOsourcePos )+ in ( _lhsOactualValue,_lhsObackType,_lhsOmessages,_lhsOnodeType,_lhsOstatementInfo)))+sem_Statement_Raise :: T_RaiseType ->+ String ->+ T_ExpressionList ->+ T_Statement +sem_Statement_Raise level_ message_ args_ =+ (\ _lhsIbackType+ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOstatementInfo :: StatementInfo+ _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Statement+ _lhsObackType :: Type+ _levelOinLoop :: Bool+ _levelOscope :: Scope+ _levelOsourcePos :: MySourcePos+ _argsOinLoop :: Bool+ _argsOscope :: Scope+ _argsOsourcePos :: MySourcePos+ _levelIactualValue :: RaiseType+ _levelImessages :: ([Message])+ _levelInodeType :: Type+ _argsIactualValue :: ExpressionList+ _argsImessages :: ([Message])+ _argsInodeType :: Type+ _lhsOstatementInfo =+ DefaultStatementInfo _lhsIbackType+ _lhsOmessages =+ _levelImessages ++ _argsImessages+ _lhsOnodeType =+ _levelInodeType `setUnknown` _argsInodeType+ _actualValue =+ Raise _levelIactualValue message_ _argsIactualValue+ _lhsOactualValue =+ _actualValue+ _lhsObackType =+ _lhsIbackType+ _levelOinLoop =+ _lhsIinLoop+ _levelOscope =+ _lhsIscope+ _levelOsourcePos =+ _lhsIsourcePos+ _argsOinLoop =+ _lhsIinLoop+ _argsOscope =+ _lhsIscope+ _argsOsourcePos =+ _lhsIsourcePos+ ( _levelIactualValue,_levelImessages,_levelInodeType) =+ (level_ _levelOinLoop _levelOscope _levelOsourcePos )+ ( _argsIactualValue,_argsImessages,_argsInodeType) =+ (args_ _argsOinLoop _argsOscope _argsOsourcePos )+ in ( _lhsOactualValue,_lhsObackType,_lhsOmessages,_lhsOnodeType,_lhsOstatementInfo)))+sem_Statement_Return :: (Maybe Expression) ->+ T_Statement +sem_Statement_Return value_ =+ (\ _lhsIbackType+ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOstatementInfo :: StatementInfo+ _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Statement+ _lhsObackType :: Type+ _lhsOstatementInfo =+ DefaultStatementInfo _lhsIbackType+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ Return value_+ _lhsOactualValue =+ _actualValue+ _lhsObackType =+ _lhsIbackType+ in ( _lhsOactualValue,_lhsObackType,_lhsOmessages,_lhsOnodeType,_lhsOstatementInfo)))+sem_Statement_ReturnNext :: T_Expression ->+ T_Statement +sem_Statement_ReturnNext expr_ =+ (\ _lhsIbackType+ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOstatementInfo :: StatementInfo+ _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Statement+ _lhsObackType :: Type+ _exprOinLoop :: Bool+ _exprOscope :: Scope+ _exprOsourcePos :: MySourcePos+ _exprIactualValue :: Expression+ _exprIliftedColumnName :: String+ _exprImessages :: ([Message])+ _exprInodeType :: Type+ _lhsOstatementInfo =+ DefaultStatementInfo _lhsIbackType+ _lhsOmessages =+ _exprImessages+ _lhsOnodeType =+ _exprInodeType+ _actualValue =+ ReturnNext _exprIactualValue+ _lhsOactualValue =+ _actualValue+ _lhsObackType =+ _lhsIbackType+ _exprOinLoop =+ _lhsIinLoop+ _exprOscope =+ _lhsIscope+ _exprOsourcePos =+ _lhsIsourcePos+ ( _exprIactualValue,_exprIliftedColumnName,_exprImessages,_exprInodeType) =+ (expr_ _exprOinLoop _exprOscope _exprOsourcePos )+ in ( _lhsOactualValue,_lhsObackType,_lhsOmessages,_lhsOnodeType,_lhsOstatementInfo)))+sem_Statement_ReturnQuery :: T_SelectExpression ->+ T_Statement +sem_Statement_ReturnQuery sel_ =+ (\ _lhsIbackType+ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOstatementInfo :: StatementInfo+ _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Statement+ _lhsObackType :: Type+ _selOinLoop :: Bool+ _selOscope :: Scope+ _selOsourcePos :: MySourcePos+ _selIactualValue :: SelectExpression+ _selImessages :: ([Message])+ _selInodeType :: Type+ _lhsOstatementInfo =+ DefaultStatementInfo _lhsIbackType+ _lhsOmessages =+ _selImessages+ _lhsOnodeType =+ _selInodeType+ _actualValue =+ ReturnQuery _selIactualValue+ _lhsOactualValue =+ _actualValue+ _lhsObackType =+ _lhsIbackType+ _selOinLoop =+ _lhsIinLoop+ _selOscope =+ _lhsIscope+ _selOsourcePos =+ _lhsIsourcePos+ ( _selIactualValue,_selImessages,_selInodeType) =+ (sel_ _selOinLoop _selOscope _selOsourcePos )+ in ( _lhsOactualValue,_lhsObackType,_lhsOmessages,_lhsOnodeType,_lhsOstatementInfo)))+sem_Statement_SelectStatement :: T_SelectExpression ->+ T_Statement +sem_Statement_SelectStatement ex_ =+ (\ _lhsIbackType+ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOstatementInfo :: StatementInfo+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: Statement+ _lhsObackType :: Type+ _exOinLoop :: Bool+ _exOscope :: Scope+ _exOsourcePos :: MySourcePos+ _exIactualValue :: SelectExpression+ _exImessages :: ([Message])+ _exInodeType :: Type+ _lhsOnodeType =+ _exInodeType+ _lhsOstatementInfo =+ makeStatementInfo _lhsIbackType $ SelectInfo _exInodeType+ _lhsOmessages =+ _exImessages+ _actualValue =+ SelectStatement _exIactualValue+ _lhsOactualValue =+ _actualValue+ _lhsObackType =+ _lhsIbackType+ _exOinLoop =+ _lhsIinLoop+ _exOscope =+ _lhsIscope+ _exOsourcePos =+ _lhsIsourcePos+ ( _exIactualValue,_exImessages,_exInodeType) =+ (ex_ _exOinLoop _exOscope _exOsourcePos )+ in ( _lhsOactualValue,_lhsObackType,_lhsOmessages,_lhsOnodeType,_lhsOstatementInfo)))+sem_Statement_Truncate :: T_StringList ->+ T_RestartIdentity ->+ T_Cascade ->+ T_Statement +sem_Statement_Truncate tables_ restartIdentity_ cascade_ =+ (\ _lhsIbackType+ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOstatementInfo :: StatementInfo+ _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Statement+ _lhsObackType :: Type+ _tablesOinLoop :: Bool+ _tablesOscope :: Scope+ _tablesOsourcePos :: MySourcePos+ _restartIdentityOinLoop :: Bool+ _restartIdentityOscope :: Scope+ _restartIdentityOsourcePos :: MySourcePos+ _cascadeOinLoop :: Bool+ _cascadeOscope :: Scope+ _cascadeOsourcePos :: MySourcePos+ _tablesIactualValue :: StringList+ _tablesImessages :: ([Message])+ _tablesInodeType :: Type+ _tablesIstrings :: ([String])+ _restartIdentityIactualValue :: RestartIdentity+ _restartIdentityImessages :: ([Message])+ _restartIdentityInodeType :: Type+ _cascadeIactualValue :: Cascade+ _cascadeImessages :: ([Message])+ _cascadeInodeType :: Type+ _lhsOstatementInfo =+ DefaultStatementInfo _lhsIbackType+ _lhsOmessages =+ _tablesImessages ++ _restartIdentityImessages ++ _cascadeImessages+ _lhsOnodeType =+ _tablesInodeType `setUnknown` _restartIdentityInodeType `setUnknown` _cascadeInodeType+ _actualValue =+ Truncate _tablesIactualValue _restartIdentityIactualValue _cascadeIactualValue+ _lhsOactualValue =+ _actualValue+ _lhsObackType =+ _lhsIbackType+ _tablesOinLoop =+ _lhsIinLoop+ _tablesOscope =+ _lhsIscope+ _tablesOsourcePos =+ _lhsIsourcePos+ _restartIdentityOinLoop =+ _lhsIinLoop+ _restartIdentityOscope =+ _lhsIscope+ _restartIdentityOsourcePos =+ _lhsIsourcePos+ _cascadeOinLoop =+ _lhsIinLoop+ _cascadeOscope =+ _lhsIscope+ _cascadeOsourcePos =+ _lhsIsourcePos+ ( _tablesIactualValue,_tablesImessages,_tablesInodeType,_tablesIstrings) =+ (tables_ _tablesOinLoop _tablesOscope _tablesOsourcePos )+ ( _restartIdentityIactualValue,_restartIdentityImessages,_restartIdentityInodeType) =+ (restartIdentity_ _restartIdentityOinLoop _restartIdentityOscope _restartIdentityOsourcePos )+ ( _cascadeIactualValue,_cascadeImessages,_cascadeInodeType) =+ (cascade_ _cascadeOinLoop _cascadeOscope _cascadeOsourcePos )+ in ( _lhsOactualValue,_lhsObackType,_lhsOmessages,_lhsOnodeType,_lhsOstatementInfo)))+sem_Statement_Update :: String ->+ T_SetClauseList ->+ T_Where ->+ (Maybe SelectList) ->+ T_Statement +sem_Statement_Update table_ assigns_ whr_ returning_ =+ (\ _lhsIbackType+ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOstatementInfo :: StatementInfo+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: Statement+ _lhsObackType :: Type+ _assignsOinLoop :: Bool+ _assignsOscope :: Scope+ _assignsOsourcePos :: MySourcePos+ _whrOinLoop :: Bool+ _whrOscope :: Scope+ _whrOsourcePos :: MySourcePos+ _assignsIactualValue :: SetClauseList+ _assignsImessages :: ([Message])+ _assignsInodeType :: Type+ _assignsIpairs :: ([(String,Type)])+ _whrIactualValue :: Where+ _whrImessages :: ([Message])+ _whrInodeType :: Type+ _lhsOnodeType =+ checkErrors [checkTableExists _lhsIscope _lhsIsourcePos table_+ ,_whrInodeType+ ,_assignsInodeType+ ,checkColumnConsistency _lhsIscope _lhsIsourcePos+ table_ colNames colTypes]+ _assignsInodeType+ where+ colNames = map fst _assignsIpairs+ colTypes = _assignsIpairs+ _lhsOstatementInfo =+ makeStatementInfo _lhsIbackType $ UpdateInfo table_ $+ UnnamedCompositeType $ getColumnTypes _lhsIscope _lhsIsourcePos table_ $ map fst _assignsIpairs+ _lhsOmessages =+ _assignsImessages ++ _whrImessages+ _actualValue =+ Update table_ _assignsIactualValue _whrIactualValue returning_+ _lhsOactualValue =+ _actualValue+ _lhsObackType =+ _lhsIbackType+ _assignsOinLoop =+ _lhsIinLoop+ _assignsOscope =+ _lhsIscope+ _assignsOsourcePos =+ _lhsIsourcePos+ _whrOinLoop =+ _lhsIinLoop+ _whrOscope =+ _lhsIscope+ _whrOsourcePos =+ _lhsIsourcePos+ ( _assignsIactualValue,_assignsImessages,_assignsInodeType,_assignsIpairs) =+ (assigns_ _assignsOinLoop _assignsOscope _assignsOsourcePos )+ ( _whrIactualValue,_whrImessages,_whrInodeType) =+ (whr_ _whrOinLoop _whrOscope _whrOsourcePos )+ in ( _lhsOactualValue,_lhsObackType,_lhsOmessages,_lhsOnodeType,_lhsOstatementInfo)))+sem_Statement_WhileStatement :: T_Expression ->+ T_StatementList ->+ T_Statement +sem_Statement_WhileStatement expr_ sts_ =+ (\ _lhsIbackType+ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOstatementInfo :: StatementInfo+ _stsOinLoop :: Bool+ _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Statement+ _lhsObackType :: Type+ _exprOinLoop :: Bool+ _exprOscope :: Scope+ _exprOsourcePos :: MySourcePos+ _stsOscope :: Scope+ _stsOsourcePos :: MySourcePos+ _exprIactualValue :: Expression+ _exprIliftedColumnName :: String+ _exprImessages :: ([Message])+ _exprInodeType :: Type+ _stsIactualValue :: StatementList+ _stsImessages :: ([Message])+ _stsInodeType :: Type+ _stsIstatementInfo :: ([StatementInfo])+ _lhsOstatementInfo =+ DefaultStatementInfo _lhsIbackType+ _stsOinLoop =+ True+ _lhsOmessages =+ _exprImessages ++ _stsImessages+ _lhsOnodeType =+ _exprInodeType `setUnknown` _stsInodeType+ _actualValue =+ WhileStatement _exprIactualValue _stsIactualValue+ _lhsOactualValue =+ _actualValue+ _lhsObackType =+ _lhsIbackType+ _exprOinLoop =+ _lhsIinLoop+ _exprOscope =+ _lhsIscope+ _exprOsourcePos =+ _lhsIsourcePos+ _stsOscope =+ _lhsIscope+ _stsOsourcePos =+ _lhsIsourcePos+ ( _exprIactualValue,_exprIliftedColumnName,_exprImessages,_exprInodeType) =+ (expr_ _exprOinLoop _exprOscope _exprOsourcePos )+ ( _stsIactualValue,_stsImessages,_stsInodeType,_stsIstatementInfo) =+ (sts_ _stsOinLoop _stsOscope _stsOsourcePos )+ in ( _lhsOactualValue,_lhsObackType,_lhsOmessages,_lhsOnodeType,_lhsOstatementInfo)))+-- StatementList -----------------------------------------------+type StatementList = [(SourcePosStatement)]+-- cata+sem_StatementList :: StatementList ->+ T_StatementList +sem_StatementList list =+ (Prelude.foldr sem_StatementList_Cons sem_StatementList_Nil (Prelude.map sem_SourcePosStatement list) )+-- semantic domain+type T_StatementList = Bool ->+ Scope ->+ MySourcePos ->+ ( StatementList,([Message]),Type,([StatementInfo]))+data Inh_StatementList = Inh_StatementList {inLoop_Inh_StatementList :: Bool,scope_Inh_StatementList :: Scope,sourcePos_Inh_StatementList :: MySourcePos}+data Syn_StatementList = Syn_StatementList {actualValue_Syn_StatementList :: StatementList,messages_Syn_StatementList :: [Message],nodeType_Syn_StatementList :: Type,statementInfo_Syn_StatementList :: [StatementInfo]}+wrap_StatementList :: T_StatementList ->+ Inh_StatementList ->+ Syn_StatementList +wrap_StatementList sem (Inh_StatementList _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType,_lhsOstatementInfo) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_StatementList _lhsOactualValue _lhsOmessages _lhsOnodeType _lhsOstatementInfo ))+sem_StatementList_Cons :: T_SourcePosStatement ->+ T_StatementList ->+ T_StatementList +sem_StatementList_Cons hd_ tl_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOstatementInfo :: ([StatementInfo])+ _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: StatementList+ _hdOinLoop :: Bool+ _hdOscope :: Scope+ _hdOsourcePos :: MySourcePos+ _tlOinLoop :: Bool+ _tlOscope :: Scope+ _tlOsourcePos :: MySourcePos+ _hdIactualValue :: SourcePosStatement+ _hdImessages :: ([Message])+ _hdInodeType :: Type+ _hdIstatementInfo :: StatementInfo+ _tlIactualValue :: StatementList+ _tlImessages :: ([Message])+ _tlInodeType :: Type+ _tlIstatementInfo :: ([StatementInfo])+ _lhsOstatementInfo =+ _hdIstatementInfo : _tlIstatementInfo+ _lhsOmessages =+ _hdImessages ++ _tlImessages+ _lhsOnodeType =+ _hdInodeType `appendTypeList` _tlInodeType+ _actualValue =+ (:) _hdIactualValue _tlIactualValue+ _lhsOactualValue =+ _actualValue+ _hdOinLoop =+ _lhsIinLoop+ _hdOscope =+ _lhsIscope+ _hdOsourcePos =+ _lhsIsourcePos+ _tlOinLoop =+ _lhsIinLoop+ _tlOscope =+ _lhsIscope+ _tlOsourcePos =+ _lhsIsourcePos+ ( _hdIactualValue,_hdImessages,_hdInodeType,_hdIstatementInfo) =+ (hd_ _hdOinLoop _hdOscope _hdOsourcePos )+ ( _tlIactualValue,_tlImessages,_tlInodeType,_tlIstatementInfo) =+ (tl_ _tlOinLoop _tlOscope _tlOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType,_lhsOstatementInfo)))+sem_StatementList_Nil :: T_StatementList +sem_StatementList_Nil =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOstatementInfo :: ([StatementInfo])+ _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: StatementList+ _lhsOstatementInfo =+ []+ _lhsOmessages =+ []+ _lhsOnodeType =+ TypeList []+ _actualValue =+ []+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType,_lhsOstatementInfo)))+-- StringList --------------------------------------------------+type StringList = [(String)]+-- cata+sem_StringList :: StringList ->+ T_StringList +sem_StringList list =+ (Prelude.foldr sem_StringList_Cons sem_StringList_Nil list )+-- semantic domain+type T_StringList = Bool ->+ Scope ->+ MySourcePos ->+ ( StringList,([Message]),Type,([String]))+data Inh_StringList = Inh_StringList {inLoop_Inh_StringList :: Bool,scope_Inh_StringList :: Scope,sourcePos_Inh_StringList :: MySourcePos}+data Syn_StringList = Syn_StringList {actualValue_Syn_StringList :: StringList,messages_Syn_StringList :: [Message],nodeType_Syn_StringList :: Type,strings_Syn_StringList :: [String]}+wrap_StringList :: T_StringList ->+ Inh_StringList ->+ Syn_StringList +wrap_StringList sem (Inh_StringList _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType,_lhsOstrings) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_StringList _lhsOactualValue _lhsOmessages _lhsOnodeType _lhsOstrings ))+sem_StringList_Cons :: String ->+ T_StringList ->+ T_StringList +sem_StringList_Cons hd_ tl_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOstrings :: ([String])+ _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: StringList+ _tlOinLoop :: Bool+ _tlOscope :: Scope+ _tlOsourcePos :: MySourcePos+ _tlIactualValue :: StringList+ _tlImessages :: ([Message])+ _tlInodeType :: Type+ _tlIstrings :: ([String])+ _lhsOstrings =+ hd_ : _tlIstrings+ _lhsOmessages =+ _tlImessages+ _lhsOnodeType =+ _tlInodeType+ _actualValue =+ (:) hd_ _tlIactualValue+ _lhsOactualValue =+ _actualValue+ _tlOinLoop =+ _lhsIinLoop+ _tlOscope =+ _lhsIscope+ _tlOsourcePos =+ _lhsIsourcePos+ ( _tlIactualValue,_tlImessages,_tlInodeType,_tlIstrings) =+ (tl_ _tlOinLoop _tlOscope _tlOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType,_lhsOstrings)))+sem_StringList_Nil :: T_StringList +sem_StringList_Nil =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOstrings :: ([String])+ _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: StringList+ _lhsOstrings =+ []+ _lhsOmessages =+ []+ _lhsOnodeType =+ TypeList []+ _actualValue =+ []+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType,_lhsOstrings)))+-- StringStringListPair ----------------------------------------+type StringStringListPair = ( (String),(StringList))+-- cata+sem_StringStringListPair :: StringStringListPair ->+ T_StringStringListPair +sem_StringStringListPair ( x1,x2) =+ (sem_StringStringListPair_Tuple x1 (sem_StringList x2 ) )+-- semantic domain+type T_StringStringListPair = Bool ->+ Scope ->+ MySourcePos ->+ ( StringStringListPair,([Message]),Type)+data Inh_StringStringListPair = Inh_StringStringListPair {inLoop_Inh_StringStringListPair :: Bool,scope_Inh_StringStringListPair :: Scope,sourcePos_Inh_StringStringListPair :: MySourcePos}+data Syn_StringStringListPair = Syn_StringStringListPair {actualValue_Syn_StringStringListPair :: StringStringListPair,messages_Syn_StringStringListPair :: [Message],nodeType_Syn_StringStringListPair :: Type}+wrap_StringStringListPair :: T_StringStringListPair ->+ Inh_StringStringListPair ->+ Syn_StringStringListPair +wrap_StringStringListPair sem (Inh_StringStringListPair _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_StringStringListPair _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_StringStringListPair_Tuple :: String ->+ T_StringList ->+ T_StringStringListPair +sem_StringStringListPair_Tuple x1_ x2_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: StringStringListPair+ _x2OinLoop :: Bool+ _x2Oscope :: Scope+ _x2OsourcePos :: MySourcePos+ _x2IactualValue :: StringList+ _x2Imessages :: ([Message])+ _x2InodeType :: Type+ _x2Istrings :: ([String])+ _lhsOmessages =+ _x2Imessages+ _lhsOnodeType =+ _x2InodeType+ _actualValue =+ (x1_,_x2IactualValue)+ _lhsOactualValue =+ _actualValue+ _x2OinLoop =+ _lhsIinLoop+ _x2Oscope =+ _lhsIscope+ _x2OsourcePos =+ _lhsIsourcePos+ ( _x2IactualValue,_x2Imessages,_x2InodeType,_x2Istrings) =+ (x2_ _x2OinLoop _x2Oscope _x2OsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- StringStringListPairList ------------------------------------+type StringStringListPairList = [(StringStringListPair)]+-- cata+sem_StringStringListPairList :: StringStringListPairList ->+ T_StringStringListPairList +sem_StringStringListPairList list =+ (Prelude.foldr sem_StringStringListPairList_Cons sem_StringStringListPairList_Nil (Prelude.map sem_StringStringListPair list) )+-- semantic domain+type T_StringStringListPairList = Bool ->+ Scope ->+ MySourcePos ->+ ( StringStringListPairList,([Message]),Type)+data Inh_StringStringListPairList = Inh_StringStringListPairList {inLoop_Inh_StringStringListPairList :: Bool,scope_Inh_StringStringListPairList :: Scope,sourcePos_Inh_StringStringListPairList :: MySourcePos}+data Syn_StringStringListPairList = Syn_StringStringListPairList {actualValue_Syn_StringStringListPairList :: StringStringListPairList,messages_Syn_StringStringListPairList :: [Message],nodeType_Syn_StringStringListPairList :: Type}+wrap_StringStringListPairList :: T_StringStringListPairList ->+ Inh_StringStringListPairList ->+ Syn_StringStringListPairList +wrap_StringStringListPairList sem (Inh_StringStringListPairList _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_StringStringListPairList _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_StringStringListPairList_Cons :: T_StringStringListPair ->+ T_StringStringListPairList ->+ T_StringStringListPairList +sem_StringStringListPairList_Cons hd_ tl_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: StringStringListPairList+ _hdOinLoop :: Bool+ _hdOscope :: Scope+ _hdOsourcePos :: MySourcePos+ _tlOinLoop :: Bool+ _tlOscope :: Scope+ _tlOsourcePos :: MySourcePos+ _hdIactualValue :: StringStringListPair+ _hdImessages :: ([Message])+ _hdInodeType :: Type+ _tlIactualValue :: StringStringListPairList+ _tlImessages :: ([Message])+ _tlInodeType :: Type+ _lhsOmessages =+ _hdImessages ++ _tlImessages+ _lhsOnodeType =+ _hdInodeType `appendTypeList` _tlInodeType+ _actualValue =+ (:) _hdIactualValue _tlIactualValue+ _lhsOactualValue =+ _actualValue+ _hdOinLoop =+ _lhsIinLoop+ _hdOscope =+ _lhsIscope+ _hdOsourcePos =+ _lhsIsourcePos+ _tlOinLoop =+ _lhsIinLoop+ _tlOscope =+ _lhsIscope+ _tlOsourcePos =+ _lhsIsourcePos+ ( _hdIactualValue,_hdImessages,_hdInodeType) =+ (hd_ _hdOinLoop _hdOscope _hdOsourcePos )+ ( _tlIactualValue,_tlImessages,_tlInodeType) =+ (tl_ _tlOinLoop _tlOscope _tlOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_StringStringListPairList_Nil :: T_StringStringListPairList +sem_StringStringListPairList_Nil =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: StringStringListPairList+ _lhsOmessages =+ []+ _lhsOnodeType =+ TypeList []+ _actualValue =+ []+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- TableRef ----------------------------------------------------+data TableRef = JoinedTref (TableRef) (Natural) (JoinType) (TableRef) (OnExpr) + | SubTref (SelectExpression) (String) + | Tref (String) + | TrefAlias (String) (String) + | TrefFun (Expression) + | TrefFunAlias (Expression) (String) + deriving ( Eq,Show)+-- cata+sem_TableRef :: TableRef ->+ T_TableRef +sem_TableRef (JoinedTref _tbl _nat _joinType _tbl1 _onExpr ) =+ (sem_TableRef_JoinedTref (sem_TableRef _tbl ) (sem_Natural _nat ) (sem_JoinType _joinType ) (sem_TableRef _tbl1 ) (sem_OnExpr _onExpr ) )+sem_TableRef (SubTref _sel _alias ) =+ (sem_TableRef_SubTref (sem_SelectExpression _sel ) _alias )+sem_TableRef (Tref _tbl ) =+ (sem_TableRef_Tref _tbl )+sem_TableRef (TrefAlias _tbl _alias ) =+ (sem_TableRef_TrefAlias _tbl _alias )+sem_TableRef (TrefFun _fn ) =+ (sem_TableRef_TrefFun (sem_Expression _fn ) )+sem_TableRef (TrefFunAlias _fn _alias ) =+ (sem_TableRef_TrefFunAlias (sem_Expression _fn ) _alias )+-- semantic domain+type T_TableRef = Bool ->+ Scope ->+ MySourcePos ->+ ( TableRef,([QualifiedScope]),([String]),([Message]),Type)+data Inh_TableRef = Inh_TableRef {inLoop_Inh_TableRef :: Bool,scope_Inh_TableRef :: Scope,sourcePos_Inh_TableRef :: MySourcePos}+data Syn_TableRef = Syn_TableRef {actualValue_Syn_TableRef :: TableRef,idens_Syn_TableRef :: [QualifiedScope],joinIdens_Syn_TableRef :: [String],messages_Syn_TableRef :: [Message],nodeType_Syn_TableRef :: Type}+wrap_TableRef :: T_TableRef ->+ Inh_TableRef ->+ Syn_TableRef +wrap_TableRef sem (Inh_TableRef _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOidens,_lhsOjoinIdens,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_TableRef _lhsOactualValue _lhsOidens _lhsOjoinIdens _lhsOmessages _lhsOnodeType ))+sem_TableRef_JoinedTref :: T_TableRef ->+ T_Natural ->+ T_JoinType ->+ T_TableRef ->+ T_OnExpr ->+ T_TableRef +sem_TableRef_JoinedTref tbl_ nat_ joinType_ tbl1_ onExpr_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOidens :: ([QualifiedScope])+ _lhsOjoinIdens :: ([String])+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: TableRef+ _tblOinLoop :: Bool+ _tblOscope :: Scope+ _tblOsourcePos :: MySourcePos+ _natOinLoop :: Bool+ _natOscope :: Scope+ _natOsourcePos :: MySourcePos+ _joinTypeOinLoop :: Bool+ _joinTypeOscope :: Scope+ _joinTypeOsourcePos :: MySourcePos+ _tbl1OinLoop :: Bool+ _tbl1Oscope :: Scope+ _tbl1OsourcePos :: MySourcePos+ _onExprOinLoop :: Bool+ _onExprOscope :: Scope+ _onExprOsourcePos :: MySourcePos+ _tblIactualValue :: TableRef+ _tblIidens :: ([QualifiedScope])+ _tblIjoinIdens :: ([String])+ _tblImessages :: ([Message])+ _tblInodeType :: Type+ _natIactualValue :: Natural+ _natImessages :: ([Message])+ _natInodeType :: Type+ _joinTypeIactualValue :: JoinType+ _joinTypeImessages :: ([Message])+ _joinTypeInodeType :: Type+ _tbl1IactualValue :: TableRef+ _tbl1Iidens :: ([QualifiedScope])+ _tbl1IjoinIdens :: ([String])+ _tbl1Imessages :: ([Message])+ _tbl1InodeType :: Type+ _onExprIactualValue :: OnExpr+ _onExprImessages :: ([Message])+ _onExprInodeType :: Type+ _lhsOnodeType =+ checkErrors [_tblInodeType+ ,_tbl1InodeType]+ ret+ where+ ret = case (_natIactualValue, _onExprIactualValue) of+ (Natural, _) -> unionJoinList $ commonFieldNames+ _tblInodeType+ _tbl1InodeType+ (_,Just (JoinUsing s)) -> unionJoinList s+ _ -> unionJoinList []+ unionJoinList s = combineTableTypesWithUsingList+ _lhsIscope+ _lhsIsourcePos+ s+ _tblInodeType+ _tbl1InodeType+ _lhsOidens =+ _tblIidens ++ _tbl1Iidens+ _lhsOjoinIdens =+ commonFieldNames _tblInodeType _tbl1InodeType+ _lhsOmessages =+ _tblImessages ++ _natImessages ++ _joinTypeImessages ++ _tbl1Imessages ++ _onExprImessages+ _actualValue =+ JoinedTref _tblIactualValue _natIactualValue _joinTypeIactualValue _tbl1IactualValue _onExprIactualValue+ _lhsOactualValue =+ _actualValue+ _tblOinLoop =+ _lhsIinLoop+ _tblOscope =+ _lhsIscope+ _tblOsourcePos =+ _lhsIsourcePos+ _natOinLoop =+ _lhsIinLoop+ _natOscope =+ _lhsIscope+ _natOsourcePos =+ _lhsIsourcePos+ _joinTypeOinLoop =+ _lhsIinLoop+ _joinTypeOscope =+ _lhsIscope+ _joinTypeOsourcePos =+ _lhsIsourcePos+ _tbl1OinLoop =+ _lhsIinLoop+ _tbl1Oscope =+ _lhsIscope+ _tbl1OsourcePos =+ _lhsIsourcePos+ _onExprOinLoop =+ _lhsIinLoop+ _onExprOscope =+ _lhsIscope+ _onExprOsourcePos =+ _lhsIsourcePos+ ( _tblIactualValue,_tblIidens,_tblIjoinIdens,_tblImessages,_tblInodeType) =+ (tbl_ _tblOinLoop _tblOscope _tblOsourcePos )+ ( _natIactualValue,_natImessages,_natInodeType) =+ (nat_ _natOinLoop _natOscope _natOsourcePos )+ ( _joinTypeIactualValue,_joinTypeImessages,_joinTypeInodeType) =+ (joinType_ _joinTypeOinLoop _joinTypeOscope _joinTypeOsourcePos )+ ( _tbl1IactualValue,_tbl1Iidens,_tbl1IjoinIdens,_tbl1Imessages,_tbl1InodeType) =+ (tbl1_ _tbl1OinLoop _tbl1Oscope _tbl1OsourcePos )+ ( _onExprIactualValue,_onExprImessages,_onExprInodeType) =+ (onExpr_ _onExprOinLoop _onExprOscope _onExprOsourcePos )+ in ( _lhsOactualValue,_lhsOidens,_lhsOjoinIdens,_lhsOmessages,_lhsOnodeType)))+sem_TableRef_SubTref :: T_SelectExpression ->+ String ->+ T_TableRef +sem_TableRef_SubTref sel_ alias_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOidens :: ([QualifiedScope])+ _lhsOjoinIdens :: ([String])+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: TableRef+ _selOinLoop :: Bool+ _selOscope :: Scope+ _selOsourcePos :: MySourcePos+ _selIactualValue :: SelectExpression+ _selImessages :: ([Message])+ _selInodeType :: Type+ _lhsOnodeType =+ checkErrors [_selInodeType] $ unwrapSetOfComposite _selInodeType+ _lhsOidens =+ [(alias_, (unwrapComposite $ unwrapSetOf _selInodeType, []))]+ _lhsOjoinIdens =+ []+ _lhsOmessages =+ _selImessages+ _actualValue =+ SubTref _selIactualValue alias_+ _lhsOactualValue =+ _actualValue+ _selOinLoop =+ _lhsIinLoop+ _selOscope =+ _lhsIscope+ _selOsourcePos =+ _lhsIsourcePos+ ( _selIactualValue,_selImessages,_selInodeType) =+ (sel_ _selOinLoop _selOscope _selOsourcePos )+ in ( _lhsOactualValue,_lhsOidens,_lhsOjoinIdens,_lhsOmessages,_lhsOnodeType)))+sem_TableRef_Tref :: String ->+ T_TableRef +sem_TableRef_Tref tbl_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOjoinIdens :: ([String])+ _lhsOidens :: ([QualifiedScope])+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: TableRef+ _lhsOnodeType =+ fst $ getRelationType _lhsIscope _lhsIsourcePos tbl_+ _lhsOjoinIdens =+ []+ _lhsOidens =+ [(tbl_, both unwrapComposite $ getRelationType _lhsIscope _lhsIsourcePos tbl_)]+ _lhsOmessages =+ []+ _actualValue =+ Tref tbl_+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOidens,_lhsOjoinIdens,_lhsOmessages,_lhsOnodeType)))+sem_TableRef_TrefAlias :: String ->+ String ->+ T_TableRef +sem_TableRef_TrefAlias tbl_ alias_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOjoinIdens :: ([String])+ _lhsOidens :: ([QualifiedScope])+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: TableRef+ _lhsOnodeType =+ fst $ getRelationType _lhsIscope _lhsIsourcePos tbl_+ _lhsOjoinIdens =+ []+ _lhsOidens =+ [(alias_, both unwrapComposite $ getRelationType _lhsIscope _lhsIsourcePos tbl_)]+ _lhsOmessages =+ []+ _actualValue =+ TrefAlias tbl_ alias_+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOidens,_lhsOjoinIdens,_lhsOmessages,_lhsOnodeType)))+sem_TableRef_TrefFun :: T_Expression ->+ T_TableRef +sem_TableRef_TrefFun fn_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOjoinIdens :: ([String])+ _lhsOidens :: ([QualifiedScope])+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: TableRef+ _fnOinLoop :: Bool+ _fnOscope :: Scope+ _fnOsourcePos :: MySourcePos+ _fnIactualValue :: Expression+ _fnIliftedColumnName :: String+ _fnImessages :: ([Message])+ _fnInodeType :: Type+ _lhsOnodeType =+ getFnType _lhsIscope _lhsIsourcePos "" _fnIactualValue _fnInodeType+ _lhsOjoinIdens =+ []+ _lhsOidens =+ [second (\l -> (unwrapComposite l, [])) $ getFunIdens _lhsIscope _lhsIsourcePos "" _fnIactualValue _fnInodeType]+ _lhsOmessages =+ _fnImessages+ _actualValue =+ TrefFun _fnIactualValue+ _lhsOactualValue =+ _actualValue+ _fnOinLoop =+ _lhsIinLoop+ _fnOscope =+ _lhsIscope+ _fnOsourcePos =+ _lhsIsourcePos+ ( _fnIactualValue,_fnIliftedColumnName,_fnImessages,_fnInodeType) =+ (fn_ _fnOinLoop _fnOscope _fnOsourcePos )+ in ( _lhsOactualValue,_lhsOidens,_lhsOjoinIdens,_lhsOmessages,_lhsOnodeType)))+sem_TableRef_TrefFunAlias :: T_Expression ->+ String ->+ T_TableRef +sem_TableRef_TrefFunAlias fn_ alias_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOjoinIdens :: ([String])+ _lhsOidens :: ([QualifiedScope])+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: TableRef+ _fnOinLoop :: Bool+ _fnOscope :: Scope+ _fnOsourcePos :: MySourcePos+ _fnIactualValue :: Expression+ _fnIliftedColumnName :: String+ _fnImessages :: ([Message])+ _fnInodeType :: Type+ _lhsOnodeType =+ getFnType _lhsIscope _lhsIsourcePos alias_ _fnIactualValue _fnInodeType+ _lhsOjoinIdens =+ []+ _lhsOidens =+ [second (\l -> (unwrapComposite l, [])) $ getFunIdens _lhsIscope _lhsIsourcePos alias_ _fnIactualValue _fnInodeType]+ _lhsOmessages =+ _fnImessages+ _actualValue =+ TrefFunAlias _fnIactualValue alias_+ _lhsOactualValue =+ _actualValue+ _fnOinLoop =+ _lhsIinLoop+ _fnOscope =+ _lhsIscope+ _fnOsourcePos =+ _lhsIsourcePos+ ( _fnIactualValue,_fnIliftedColumnName,_fnImessages,_fnInodeType) =+ (fn_ _fnOinLoop _fnOscope _fnOsourcePos )+ in ( _lhsOactualValue,_lhsOidens,_lhsOjoinIdens,_lhsOmessages,_lhsOnodeType)))+-- TypeAttributeDef --------------------------------------------+data TypeAttributeDef = TypeAttDef (String) (TypeName) + deriving ( Eq,Show)+-- cata+sem_TypeAttributeDef :: TypeAttributeDef ->+ T_TypeAttributeDef +sem_TypeAttributeDef (TypeAttDef _name _typ ) =+ (sem_TypeAttributeDef_TypeAttDef _name (sem_TypeName _typ ) )+-- semantic domain+type T_TypeAttributeDef = Bool ->+ Scope ->+ MySourcePos ->+ ( TypeAttributeDef,String,([Message]),Type)+data Inh_TypeAttributeDef = Inh_TypeAttributeDef {inLoop_Inh_TypeAttributeDef :: Bool,scope_Inh_TypeAttributeDef :: Scope,sourcePos_Inh_TypeAttributeDef :: MySourcePos}+data Syn_TypeAttributeDef = Syn_TypeAttributeDef {actualValue_Syn_TypeAttributeDef :: TypeAttributeDef,attrName_Syn_TypeAttributeDef :: String,messages_Syn_TypeAttributeDef :: [Message],nodeType_Syn_TypeAttributeDef :: Type}+wrap_TypeAttributeDef :: T_TypeAttributeDef ->+ Inh_TypeAttributeDef ->+ Syn_TypeAttributeDef +wrap_TypeAttributeDef sem (Inh_TypeAttributeDef _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOattrName,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_TypeAttributeDef _lhsOactualValue _lhsOattrName _lhsOmessages _lhsOnodeType ))+sem_TypeAttributeDef_TypeAttDef :: String ->+ T_TypeName ->+ T_TypeAttributeDef +sem_TypeAttributeDef_TypeAttDef name_ typ_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOattrName :: String+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: TypeAttributeDef+ _typOinLoop :: Bool+ _typOscope :: Scope+ _typOsourcePos :: MySourcePos+ _typIactualValue :: TypeName+ _typImessages :: ([Message])+ _typInodeType :: Type+ _lhsOnodeType =+ _typInodeType+ _lhsOattrName =+ name_+ _lhsOmessages =+ _typImessages+ _actualValue =+ TypeAttDef name_ _typIactualValue+ _lhsOactualValue =+ _actualValue+ _typOinLoop =+ _lhsIinLoop+ _typOscope =+ _lhsIscope+ _typOsourcePos =+ _lhsIsourcePos+ ( _typIactualValue,_typImessages,_typInodeType) =+ (typ_ _typOinLoop _typOscope _typOsourcePos )+ in ( _lhsOactualValue,_lhsOattrName,_lhsOmessages,_lhsOnodeType)))+-- TypeAttributeDefList ----------------------------------------+type TypeAttributeDefList = [(TypeAttributeDef)]+-- cata+sem_TypeAttributeDefList :: TypeAttributeDefList ->+ T_TypeAttributeDefList +sem_TypeAttributeDefList list =+ (Prelude.foldr sem_TypeAttributeDefList_Cons sem_TypeAttributeDefList_Nil (Prelude.map sem_TypeAttributeDef list) )+-- semantic domain+type T_TypeAttributeDefList = Bool ->+ Scope ->+ MySourcePos ->+ ( TypeAttributeDefList,([Message]),Type)+data Inh_TypeAttributeDefList = Inh_TypeAttributeDefList {inLoop_Inh_TypeAttributeDefList :: Bool,scope_Inh_TypeAttributeDefList :: Scope,sourcePos_Inh_TypeAttributeDefList :: MySourcePos}+data Syn_TypeAttributeDefList = Syn_TypeAttributeDefList {actualValue_Syn_TypeAttributeDefList :: TypeAttributeDefList,messages_Syn_TypeAttributeDefList :: [Message],nodeType_Syn_TypeAttributeDefList :: Type}+wrap_TypeAttributeDefList :: T_TypeAttributeDefList ->+ Inh_TypeAttributeDefList ->+ Syn_TypeAttributeDefList +wrap_TypeAttributeDefList sem (Inh_TypeAttributeDefList _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_TypeAttributeDefList _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_TypeAttributeDefList_Cons :: T_TypeAttributeDef ->+ T_TypeAttributeDefList ->+ T_TypeAttributeDefList +sem_TypeAttributeDefList_Cons hd_ tl_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: TypeAttributeDefList+ _hdOinLoop :: Bool+ _hdOscope :: Scope+ _hdOsourcePos :: MySourcePos+ _tlOinLoop :: Bool+ _tlOscope :: Scope+ _tlOsourcePos :: MySourcePos+ _hdIactualValue :: TypeAttributeDef+ _hdIattrName :: String+ _hdImessages :: ([Message])+ _hdInodeType :: Type+ _tlIactualValue :: TypeAttributeDefList+ _tlImessages :: ([Message])+ _tlInodeType :: Type+ _lhsOnodeType =+ checkErrors [_tlInodeType, _hdInodeType] $+ consComposite (_hdIattrName, _hdInodeType) _tlInodeType+ _lhsOmessages =+ _hdImessages ++ _tlImessages+ _actualValue =+ (:) _hdIactualValue _tlIactualValue+ _lhsOactualValue =+ _actualValue+ _hdOinLoop =+ _lhsIinLoop+ _hdOscope =+ _lhsIscope+ _hdOsourcePos =+ _lhsIsourcePos+ _tlOinLoop =+ _lhsIinLoop+ _tlOscope =+ _lhsIscope+ _tlOsourcePos =+ _lhsIsourcePos+ ( _hdIactualValue,_hdIattrName,_hdImessages,_hdInodeType) =+ (hd_ _hdOinLoop _hdOscope _hdOsourcePos )+ ( _tlIactualValue,_tlImessages,_tlInodeType) =+ (tl_ _tlOinLoop _tlOscope _tlOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_TypeAttributeDefList_Nil :: T_TypeAttributeDefList +sem_TypeAttributeDefList_Nil =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: TypeAttributeDefList+ _lhsOnodeType =+ UnnamedCompositeType []+ _lhsOmessages =+ []+ _actualValue =+ []+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- TypeName ----------------------------------------------------+data TypeName = ArrayTypeName (TypeName) + | PrecTypeName (String) (Integer) + | SetOfTypeName (TypeName) + | SimpleTypeName (String) + deriving ( Eq,Show)+-- cata+sem_TypeName :: TypeName ->+ T_TypeName +sem_TypeName (ArrayTypeName _typ ) =+ (sem_TypeName_ArrayTypeName (sem_TypeName _typ ) )+sem_TypeName (PrecTypeName _tn _prec ) =+ (sem_TypeName_PrecTypeName _tn _prec )+sem_TypeName (SetOfTypeName _typ ) =+ (sem_TypeName_SetOfTypeName (sem_TypeName _typ ) )+sem_TypeName (SimpleTypeName _tn ) =+ (sem_TypeName_SimpleTypeName _tn )+-- semantic domain+type T_TypeName = Bool ->+ Scope ->+ MySourcePos ->+ ( TypeName,([Message]),Type)+data Inh_TypeName = Inh_TypeName {inLoop_Inh_TypeName :: Bool,scope_Inh_TypeName :: Scope,sourcePos_Inh_TypeName :: MySourcePos}+data Syn_TypeName = Syn_TypeName {actualValue_Syn_TypeName :: TypeName,messages_Syn_TypeName :: [Message],nodeType_Syn_TypeName :: Type}+wrap_TypeName :: T_TypeName ->+ Inh_TypeName ->+ Syn_TypeName +wrap_TypeName sem (Inh_TypeName _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_TypeName _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_TypeName_ArrayTypeName :: T_TypeName ->+ T_TypeName +sem_TypeName_ArrayTypeName typ_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: TypeName+ _typOinLoop :: Bool+ _typOscope :: Scope+ _typOsourcePos :: MySourcePos+ _typIactualValue :: TypeName+ _typImessages :: ([Message])+ _typInodeType :: Type+ _lhsOnodeType =+ let t = ArrayType _typInodeType+ in checkErrors+ [_typInodeType+ ,checkTypeExists _lhsIscope _lhsIsourcePos t]+ t+ _lhsOmessages =+ _typImessages+ _actualValue =+ ArrayTypeName _typIactualValue+ _lhsOactualValue =+ _actualValue+ _typOinLoop =+ _lhsIinLoop+ _typOscope =+ _lhsIscope+ _typOsourcePos =+ _lhsIsourcePos+ ( _typIactualValue,_typImessages,_typInodeType) =+ (typ_ _typOinLoop _typOscope _typOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_TypeName_PrecTypeName :: String ->+ Integer ->+ T_TypeName +sem_TypeName_PrecTypeName tn_ prec_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: TypeName+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ PrecTypeName tn_ prec_+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_TypeName_SetOfTypeName :: T_TypeName ->+ T_TypeName +sem_TypeName_SetOfTypeName typ_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: TypeName+ _typOinLoop :: Bool+ _typOscope :: Scope+ _typOsourcePos :: MySourcePos+ _typIactualValue :: TypeName+ _typImessages :: ([Message])+ _typInodeType :: Type+ _lhsOnodeType =+ checkErrors [_typInodeType]+ (SetOfType _typInodeType)+ _lhsOmessages =+ _typImessages+ _actualValue =+ SetOfTypeName _typIactualValue+ _lhsOactualValue =+ _actualValue+ _typOinLoop =+ _lhsIinLoop+ _typOscope =+ _lhsIscope+ _typOsourcePos =+ _lhsIsourcePos+ ( _typIactualValue,_typImessages,_typInodeType) =+ (typ_ _typOinLoop _typOscope _typOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_TypeName_SimpleTypeName :: String ->+ T_TypeName +sem_TypeName_SimpleTypeName tn_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: TypeName+ _lhsOnodeType =+ lookupTypeByName _lhsIscope _lhsIsourcePos $ canonicalizeTypeName tn_+ _lhsOmessages =+ []+ _actualValue =+ SimpleTypeName tn_+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- VarDef ------------------------------------------------------+data VarDef = VarDef (String) (TypeName) (Maybe Expression) + deriving ( Eq,Show)+-- cata+sem_VarDef :: VarDef ->+ T_VarDef +sem_VarDef (VarDef _name _typ _value ) =+ (sem_VarDef_VarDef _name (sem_TypeName _typ ) _value )+-- semantic domain+type T_VarDef = Bool ->+ Scope ->+ MySourcePos ->+ ( VarDef,([Message]),Type)+data Inh_VarDef = Inh_VarDef {inLoop_Inh_VarDef :: Bool,scope_Inh_VarDef :: Scope,sourcePos_Inh_VarDef :: MySourcePos}+data Syn_VarDef = Syn_VarDef {actualValue_Syn_VarDef :: VarDef,messages_Syn_VarDef :: [Message],nodeType_Syn_VarDef :: Type}+wrap_VarDef :: T_VarDef ->+ Inh_VarDef ->+ Syn_VarDef +wrap_VarDef sem (Inh_VarDef _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_VarDef _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_VarDef_VarDef :: String ->+ T_TypeName ->+ (Maybe Expression) ->+ T_VarDef +sem_VarDef_VarDef name_ typ_ value_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: VarDef+ _typOinLoop :: Bool+ _typOscope :: Scope+ _typOsourcePos :: MySourcePos+ _typIactualValue :: TypeName+ _typImessages :: ([Message])+ _typInodeType :: Type+ _lhsOmessages =+ _typImessages+ _lhsOnodeType =+ _typInodeType+ _actualValue =+ VarDef name_ _typIactualValue value_+ _lhsOactualValue =+ _actualValue+ _typOinLoop =+ _lhsIinLoop+ _typOscope =+ _lhsIscope+ _typOsourcePos =+ _lhsIsourcePos+ ( _typIactualValue,_typImessages,_typInodeType) =+ (typ_ _typOinLoop _typOscope _typOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- VarDefList --------------------------------------------------+type VarDefList = [(VarDef)]+-- cata+sem_VarDefList :: VarDefList ->+ T_VarDefList +sem_VarDefList list =+ (Prelude.foldr sem_VarDefList_Cons sem_VarDefList_Nil (Prelude.map sem_VarDef list) )+-- semantic domain+type T_VarDefList = Bool ->+ Scope ->+ MySourcePos ->+ ( VarDefList,([Message]),Type)+data Inh_VarDefList = Inh_VarDefList {inLoop_Inh_VarDefList :: Bool,scope_Inh_VarDefList :: Scope,sourcePos_Inh_VarDefList :: MySourcePos}+data Syn_VarDefList = Syn_VarDefList {actualValue_Syn_VarDefList :: VarDefList,messages_Syn_VarDefList :: [Message],nodeType_Syn_VarDefList :: Type}+wrap_VarDefList :: T_VarDefList ->+ Inh_VarDefList ->+ Syn_VarDefList +wrap_VarDefList sem (Inh_VarDefList _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_VarDefList _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_VarDefList_Cons :: T_VarDef ->+ T_VarDefList ->+ T_VarDefList +sem_VarDefList_Cons hd_ tl_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: VarDefList+ _hdOinLoop :: Bool+ _hdOscope :: Scope+ _hdOsourcePos :: MySourcePos+ _tlOinLoop :: Bool+ _tlOscope :: Scope+ _tlOsourcePos :: MySourcePos+ _hdIactualValue :: VarDef+ _hdImessages :: ([Message])+ _hdInodeType :: Type+ _tlIactualValue :: VarDefList+ _tlImessages :: ([Message])+ _tlInodeType :: Type+ _lhsOmessages =+ _hdImessages ++ _tlImessages+ _lhsOnodeType =+ _hdInodeType `appendTypeList` _tlInodeType+ _actualValue =+ (:) _hdIactualValue _tlIactualValue+ _lhsOactualValue =+ _actualValue+ _hdOinLoop =+ _lhsIinLoop+ _hdOscope =+ _lhsIscope+ _hdOsourcePos =+ _lhsIsourcePos+ _tlOinLoop =+ _lhsIinLoop+ _tlOscope =+ _lhsIscope+ _tlOsourcePos =+ _lhsIsourcePos+ ( _hdIactualValue,_hdImessages,_hdInodeType) =+ (hd_ _hdOinLoop _hdOscope _hdOsourcePos )+ ( _tlIactualValue,_tlImessages,_tlInodeType) =+ (tl_ _tlOinLoop _tlOscope _tlOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_VarDefList_Nil :: T_VarDefList +sem_VarDefList_Nil =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: VarDefList+ _lhsOmessages =+ []+ _lhsOnodeType =+ TypeList []+ _actualValue =+ []+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- Volatility --------------------------------------------------+data Volatility = Immutable + | Stable + | Volatile + deriving ( Eq,Show)+-- cata+sem_Volatility :: Volatility ->+ T_Volatility +sem_Volatility (Immutable ) =+ (sem_Volatility_Immutable )+sem_Volatility (Stable ) =+ (sem_Volatility_Stable )+sem_Volatility (Volatile ) =+ (sem_Volatility_Volatile )+-- semantic domain+type T_Volatility = Bool ->+ Scope ->+ MySourcePos ->+ ( Volatility,([Message]),Type)+data Inh_Volatility = Inh_Volatility {inLoop_Inh_Volatility :: Bool,scope_Inh_Volatility :: Scope,sourcePos_Inh_Volatility :: MySourcePos}+data Syn_Volatility = Syn_Volatility {actualValue_Syn_Volatility :: Volatility,messages_Syn_Volatility :: [Message],nodeType_Syn_Volatility :: Type}+wrap_Volatility :: T_Volatility ->+ Inh_Volatility ->+ Syn_Volatility +wrap_Volatility sem (Inh_Volatility _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_Volatility _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_Volatility_Immutable :: T_Volatility +sem_Volatility_Immutable =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Volatility+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ Immutable+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_Volatility_Stable :: T_Volatility +sem_Volatility_Stable =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Volatility+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ Stable+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_Volatility_Volatile :: T_Volatility +sem_Volatility_Volatile =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOmessages :: ([Message])+ _lhsOnodeType :: Type+ _lhsOactualValue :: Volatility+ _lhsOmessages =+ []+ _lhsOnodeType =+ UnknownType+ _actualValue =+ Volatile+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+-- Where -------------------------------------------------------+type Where = (Maybe (Expression))+-- cata+sem_Where :: Where ->+ T_Where +sem_Where (Prelude.Just x ) =+ (sem_Where_Just (sem_Expression x ) )+sem_Where Prelude.Nothing =+ sem_Where_Nothing+-- semantic domain+type T_Where = Bool ->+ Scope ->+ MySourcePos ->+ ( Where,([Message]),Type)+data Inh_Where = Inh_Where {inLoop_Inh_Where :: Bool,scope_Inh_Where :: Scope,sourcePos_Inh_Where :: MySourcePos}+data Syn_Where = Syn_Where {actualValue_Syn_Where :: Where,messages_Syn_Where :: [Message],nodeType_Syn_Where :: Type}+wrap_Where :: T_Where ->+ Inh_Where ->+ Syn_Where +wrap_Where sem (Inh_Where _lhsIinLoop _lhsIscope _lhsIsourcePos ) =+ (let ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType) =+ (sem _lhsIinLoop _lhsIscope _lhsIsourcePos )+ in (Syn_Where _lhsOactualValue _lhsOmessages _lhsOnodeType ))+sem_Where_Just :: T_Expression ->+ T_Where +sem_Where_Just just_ =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: Where+ _justOinLoop :: Bool+ _justOscope :: Scope+ _justOsourcePos :: MySourcePos+ _justIactualValue :: Expression+ _justIliftedColumnName :: String+ _justImessages :: ([Message])+ _justInodeType :: Type+ _lhsOnodeType =+ checkErrors+ [_justInodeType]+ (if _justInodeType /= typeBool+ then TypeError _lhsIsourcePos ExpressionMustBeBool+ else typeBool)+ _lhsOmessages =+ _justImessages+ _actualValue =+ Just _justIactualValue+ _lhsOactualValue =+ _actualValue+ _justOinLoop =+ _lhsIinLoop+ _justOscope =+ _lhsIscope+ _justOsourcePos =+ _lhsIsourcePos+ ( _justIactualValue,_justIliftedColumnName,_justImessages,_justInodeType) =+ (just_ _justOinLoop _justOscope _justOsourcePos )+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))+sem_Where_Nothing :: T_Where +sem_Where_Nothing =+ (\ _lhsIinLoop+ _lhsIscope+ _lhsIsourcePos ->+ (let _lhsOnodeType :: Type+ _lhsOmessages :: ([Message])+ _lhsOactualValue :: Where+ _lhsOnodeType =+ typeBool+ _lhsOmessages =+ []+ _actualValue =+ Nothing+ _lhsOactualValue =+ _actualValue+ in ( _lhsOactualValue,_lhsOmessages,_lhsOnodeType)))
+ Database/HsSqlPpp/Parser.lhs view
@@ -0,0 +1,1260 @@+Copyright 2009 Jake Wheat++The main file for parsing sql, uses parsec. Not sure if parsec is the+right choice, but it seems to do the job pretty well at the moment.++For syntax reference see+http://savage.net.au/SQL/sql-2003-2.bnf.html+and+http://savage.net.au/SQL/sql-92.bnf.html+for some online sql grammar guides+and+http://www.postgresql.org/docs/8.4/interactive/sql-syntax.html+for some notes on postgresql syntax (the rest of that manual is also helpful)++Some further reference/reading:++parsec tutorial:+http://legacy.cs.uu.nl/daan/download/parsec/parsec.html++parsec reference:+http://hackage.haskell.org/package/parsec-3.0.0++pdf about parsing, uses haskell and parser combinators for examples+and exercises:+http://www.cs.uu.nl/docs/vakken/gont/diktaat.pdf++The parsers are written top down as you go through the file, so the+top level sql text parsers appear first, then the statements, then the+fragments, then the utility parsers and other utilities at the bottom.++> module Database.HsSqlPpp.Parser (+> --parse fully formed sql statements from a string+> parseSql+> --parse a file containing sql statements only+> ,parseSqlFile+> --parse a file and return the parse tree and the+> --parser state also+> ,parseSqlFileWithState+> --parse an expression (one expression plus whitespace+> --only allowed+> ,parseExpression+> --parse fully formed plpgsql statements from a string+> ,parsePlpgsql+> )+> where++> import Text.Parsec hiding(many, optional, (<|>), string)+> import Text.Parsec.Expr+> import Text.Parsec.String++> import Control.Applicative+> import Control.Monad.Identity++> import Data.Maybe+> import Data.Char++> import Database.HsSqlPpp.Lexer+> import Database.HsSqlPpp.ParseErrors+> import Database.HsSqlPpp.Ast++> type ParseState = [MySourcePos]++> startState :: ParseState+> startState = []++> toMySp :: SourcePos -> MySourcePos+> toMySp sp = (sourceName sp, sourceLine sp, sourceColumn sp)++=====================================W==========================================++= Top level parsing functions++parse fully formed sql++> parseSql :: String -> Either ExtendedError StatementList+> parseSql s = statementsOnly $ parseIt (lexSqlText s) sqlStatements "" s startState++> parseSqlFile :: String -> IO (Either ExtendedError StatementList)+> parseSqlFile fn = do+> sc <- readFile fn+> x <- lexSqlFile fn+> return $ statementsOnly $ parseIt x sqlStatements fn sc startState++> parseSqlFileWithState :: String -> IO (Either ExtendedError StatementList)+> parseSqlFileWithState fn = do+> sc <- readFile fn+> x <- lexSqlFile fn+> return $ parseIt x sqlStatements fn sc startState++Parse expression fragment, used for testing purposes++> parseExpression :: String -> Either ExtendedError Expression+> parseExpression s = parseIt (lexSqlText s) (expr <* eof) "" s startState++parse plpgsql statements, used for testing purposes++> parsePlpgsql :: String -> Either ExtendedError StatementList+> parsePlpgsql s = parseIt (lexSqlText s) (many plPgsqlStatement <* eof) "" s startState++utility function to do error handling in one place++> parseIt lexed parser fn src ss =+> case lexed of+> Left er -> Left er+> Right toks -> convertToExtendedError+> (runParser parser ss fn toks) fn src++> statementsOnly :: Either ExtendedError StatementList+> -> Either ExtendedError StatementList+> statementsOnly s = case s of+> Left er -> Left er+> Right st -> Right st++================================================================================++= Parsing top level statements++> sqlStatements :: ParsecT [Token] ParseState Identity [(MySourcePos,Statement)]+> sqlStatements = many (sqlStatement True) <* eof++parse a statement++> sqlStatement :: Bool -> ParsecT [Token] ParseState Identity (MySourcePos,Statement)+> sqlStatement reqSemi = do+> p <- getAdjustedPosition+> st <- ((choice [+> selectStatement+> ,insert+> ,update+> ,delete+> ,truncateSt+> ,copy+> ,keyword "create" *>+> choice [+> createTable+> ,createType+> ,createFunction+> ,createView+> ,createDomain]+> ,keyword "drop" *>+> choice [+> dropSomething+> ,dropFunction]+> ]+> <* (if reqSemi+> then symbol ";" >> return ()+> else optional (symbol ";") >> return ()))+> <|> copyData)+> return (p, st)++> getAdjustedPosition :: ParsecT [Token] ParseState Identity MySourcePos+> getAdjustedPosition = do+> p <- toMySp <$> getPosition+> s <- getState+> case s of+> [] -> return p+> x:_ -> return $ adjustPosition x p++> adjustPosition :: MySourcePos -> MySourcePos -> MySourcePos+> adjustPosition (fn,pl,_) (_,l,c) = (fn,pl+l-1,c)++================================================================================++statement flavour parsers++top level/sql statements first++= select++select parser, parses things starting with the keyword 'select'++supports plpgsql 'select into' only for the variants which look like+'select into ([targets]) [columnNames] from ...+or+'select [columnNames] into ([targets]) from ...+This should be changed so it can only parse an into clause when+expecting a plpgsql statement.++recurses to support parsing excepts, unions, etc++> selectStatement :: ParsecT [Token] ParseState Identity Statement+> selectStatement = SelectStatement <$> selectExpression++> selectExpression :: ParsecT [Token] ParseState Identity SelectExpression+> selectExpression =+> choice [selectE, values]+> where+> selectE = do+> keyword "select"+> s1 <- selQuerySpec+> choice [+> --don't know if this does associativity in the correct order for+> --statements with multiple excepts/ intersects and no parens+> CombineSelect Except s1 <$> (keyword "except" *> selectExpression)+> ,CombineSelect Intersect s1 <$> (keyword "intersect" *> selectExpression)+> ,CombineSelect UnionAll s1 <$> (try (keyword "union"+> *> keyword "all") *> selectExpression)+> ,CombineSelect Union s1 <$> (keyword "union" *> selectExpression)+> ,return s1]+> where+> selQuerySpec = Select+> <$> option Dupes (Distinct <$ keyword "distinct")+> <*> selectList+> <*> tryOptionMaybe from+> <*> tryOptionMaybe whereClause+> <*> option [] groupBy+> <*> tryOptionMaybe having+> <*> option [] orderBy+> <*> option Asc (choice [+> Asc <$ keyword "asc"+> ,Desc <$ keyword "desc"])+> <*> tryOptionMaybe limit+> <*> tryOptionMaybe offset+> from = keyword "from" *> tref+> groupBy = keyword "group" *> keyword "by"+> *> commaSep1 expr+> having = keyword "having" *> expr+> orderBy = keyword "order" *> keyword "by"+> *> commaSep1 expr+> limit = keyword "limit" *> expr+> offset = keyword "offset" *> expr++> -- table refs+> -- have to cope with:+> -- a simple tableref i.e just a name+> -- an aliased table ref e.g. select a.b from tbl as a+> -- a sub select e.g. select a from (select b from c)+> -- - these are handled in tref+> -- then cope with joins recursively using joinpart below+> tref = threadOptionalSuffix getFirstTref joinPart+> getFirstTref = choice [+> SubTref+> <$> parens selectExpression+> <*> (optional (keyword "as") *> nkwid)+> ,optionalSuffix+> TrefFun (try $ identifier >>= functionCallSuffix)+> TrefFunAlias () (optional (keyword "as") *> nkwid)+> ,optionalSuffix+> Tref nkwid+> TrefAlias () (optional (keyword "as") *> nkwid)]+> --joinpart: parse a join after the first part of the tableref+> --(which is a table name, aliased table name or subselect) -+> --takes this tableref as an arg so it can recurse to multiple+> --joins+> joinPart tr1 = threadOptionalSuffix (readOneJoinPart tr1) joinPart+> readOneJoinPart tr1 = JoinedTref tr1+> --look for the join flavour first+> <$> option Unnatural (Natural <$ keyword "natural")+> <*> choice [+> Inner <$ keyword "inner"+> ,LeftOuter <$ try (keyword "left" *> keyword "outer")+> ,RightOuter <$ try (keyword "right" *> keyword "outer")+> ,FullOuter <$ try (keyword "full" >> keyword "outer")+> ,Cross <$ keyword "cross"]+> --recurse back to tref to read the table+> <*> (keyword "join" *> tref)+> --now try and read the join condition+> <*> choice [+> Just <$> (JoinOn <$> (keyword "on" *> expr))+> ,Just <$> (JoinUsing <$> (keyword "using" *> columnNameList))+> ,return Nothing]+> nkwid = try $ do+> x <- idString+> --avoid all these keywords as aliases since they can+> --appear immediately following a tableref as the next+> --part of the statement, if we don't do this then lots+> --of things don't parse. Seems a bit inelegant but+> --works for the tests and the test sql files don't know+> --if these should be allowed as aliases without "" or+> --[]+> if map toLower x `elem` ["as"+> ,"where"+> ,"except"+> ,"union"+> ,"intersect"+> ,"loop"+> ,"inner"+> ,"on"+> ,"left"+> ,"right"+> ,"full"+> ,"cross"+> ,"natural"+> ,"order"+> ,"group"+> ,"limit"+> ,"using"+> ,"from"]+> then fail "not keyword"+> else return x+> values = keyword "values" >>+> Values <$> commaSep1 (parens $ commaSep1 expr)+++= insert, update and delete++insert statement: supports option column name list,+multiple rows to insert and insert from select statements++> insert :: ParsecT [Token] ParseState Identity Statement+> insert = keyword "insert" >> keyword "into" >>+> Insert <$> idString+> <*> option [] (try columnNameList)+> <*> selectExpression+> <*> tryOptionMaybe returning++> update :: ParsecT [Token] ParseState Identity Statement+> update = keyword "update" >>+> Update+> <$> idString+> <*> (keyword "set" *> commaSep1 setClause)+> <*> tryOptionMaybe whereClause+> <*> tryOptionMaybe returning+> where+> setClause = choice+> [RowSetClause <$> parens (commaSep1 idString)+> <*> (symbol "=" *> parens (commaSep1 expr))+> ,SetClause <$> idString+> <*> (symbol "=" *> expr)]++> delete :: ParsecT [Token] ParseState Identity Statement+> delete = keyword "delete" >> keyword "from" >>+> Delete+> <$> idString+> <*> tryOptionMaybe whereClause+> <*> tryOptionMaybe returning++> truncateSt :: ParsecT [Token] ParseState Identity Statement+> truncateSt = keyword "truncate" >> optional (keyword "table") >>+> Truncate+> <$> commaSep1 idString+> <*> option ContinueIdentity (choice [+> ContinueIdentity <$ (keyword "continue"+> <* keyword "identity")+> ,RestartIdentity <$ (keyword "restart"+> <* keyword "identity")])+> <*> cascade++> copy :: ParsecT [Token] ParseState Identity Statement+> copy = do+> keyword "copy"+> tableName <- idString+> cols <- option [] (parens $ commaSep1 idString)+> keyword "from"+> src <- choice [+> CopyFilename <$> extrStr <$> stringLit+> ,Stdin <$ keyword "stdin"]+> return $ Copy tableName cols src++> copyData :: ParsecT [Token] ParseState Identity Statement+> copyData = CopyData <$> mytoken (\tok ->+> case tok of+> CopyPayloadTok n -> Just n+> _ -> Nothing)++= ddl++> createTable :: ParsecT [Token] ParseState Identity Statement+> createTable = do+> keyword "table"+> tname <- idString+> choice [+> CreateTableAs tname <$> (keyword "as" *> selectExpression)+> ,uncurry (CreateTable tname) <$> readAttsAndCons]+> where+> --parse our unordered list of attribute defs or constraints, for+> --each line want to try the constraint parser first, then the+> --attribute parser, so we need the swap to feed them in the+> --right order into createtable+> readAttsAndCons = parens (swap <$> multiPerm+> (try tableConstr)+> tableAtt+> (symbol ","))+> where swap (a,b) = (b,a)+> tableAtt = AttributeDef+> <$> idString+> <*> typeName+> <*> tryOptionMaybe (keyword "default" *> expr)+> <*> many rowConstraint+> tableConstr = choice [+> UniqueConstraint+> <$> try (keyword "unique" *> columnNameList)+> ,PrimaryKeyConstraint+> <$> try (keyword "primary" *> keyword "key"+> *> choice [+> (:[]) <$> idString+> ,parens (commaSep1 idString)])+> ,CheckConstraint+> <$> try (keyword "check" *> parens expr)+> ,ReferenceConstraint+> <$> try (keyword "foreign" *> keyword "key"+> *> parens (commaSep1 idString))+> <*> (keyword "references" *> idString)+> <*> option [] (parens $ commaSep1 idString)+> <*> onDelete+> <*> onUpdate]+> rowConstraint =+> choice [+> RowUniqueConstraint <$ keyword "unique"+> ,RowPrimaryKeyConstraint <$ keyword "primary" <* keyword "key"+> ,RowCheckConstraint <$> (keyword "check" *> parens expr)+> ,NullConstraint <$ keyword "null"+> ,NotNullConstraint <$ (keyword "not" *> keyword "null")+> ,RowReferenceConstraint+> <$> (keyword "references" *> idString)+> <*> option Nothing (try $ parens $ Just <$> idString)+> <*> onDelete+> <*> onUpdate+> ]+> onDelete = onSomething "delete"+> onUpdate = onSomething "update"+> onSomething k = option Restrict $ try $ keyword "on"+> *> keyword k *> cascade+++> createType :: ParsecT [Token] ParseState Identity Statement+> createType = keyword "type" >>+> CreateType+> <$> idString+> <*> (keyword "as" *> parens (commaSep1 typeAtt))+> where+> typeAtt = TypeAttDef <$> idString <*> typeName+++create function, support sql functions and plpgsql functions. Parses+the body in both cases and provides a statement list for the body+rather than just a string.++> createFunction :: ParsecT [Token] ParseState Identity Statement+> createFunction = do+> keyword "function"+> fnName <- idString+> params <- parens $ commaSep param+> retType <- keyword "returns" *> typeName+> keyword "as"+> bodypos <- getAdjustedPosition+> body <- stringLit+> lang <- readLang+> let (q, b) = parseBody lang body fnName bodypos+> CreateFunction lang fnName params retType q b <$> pVol+> where+> pVol = matchAKeyword [("volatile", Volatile)+> ,("stable", Stable)+> ,("immutable", Immutable)]+> readLang = keyword "language" *> matchAKeyword [("plpgsql", Plpgsql)+> ,("sql",Sql)]+> parseBody lang body fnName bodypos =+> case (parseIt+> (lexSqlText (extrStr body))+> (functionBody lang)+> ("function " ++ fnName)+> (extrStr body)+> [bodypos]) of+> Left er@(ExtendedError e _) ->+> -- don't know how to change the+> --position of the error we've been+> --given, so add some information to+> --show the position of the containing+> --function and the adjusted absolute+> --position of this error+> let ep = toMySp $ errorPos e+> (fn,fp,fc) = bodypos+> fnBit = "in function " ++ fnName ++ "\n"+> ++ fn ++ ":" ++ show fp ++ ":" ++ show fc ++ ":\n"+> (_,lp,lc) = adjustPosition bodypos ep+> lineBit = "on line\n"+> ++ fn ++ ":" ++ show lp ++ ":" ++ show lc ++ ":\n"+> in error $ show er ++ "\n" ++ fnBit ++ lineBit+> Right body' -> (quoteOfString body, body')++sql function is just a list of statements, the last one has the+trailing semicolon optional++> functionBody Sql = do+> a <- many (try $ sqlStatement True)+> -- this makes my head hurt, should probably write out+> -- more longhand+> SqlFnBody <$> option a ((\b -> (a++[b])) <$> sqlStatement False)++plpgsql function has an optional declare section, plus the statements+are enclosed in begin ... end; (semi colon after end is optional(++> functionBody Plpgsql =+> PlpgsqlFnBody+> <$> option [] declarePart+> <*> statementPart+> where+> statementPart = keyword "begin"+> *> many plPgsqlStatement+> <* keyword "end" <* optional (symbol ";") <* eof+> declarePart = keyword "declare"+> *> manyTill (try varDef) (lookAhead $ keyword "begin")++params to a function++> param :: ParsecT [Token] ParseState Identity ParamDef+> param = choice [+> try (ParamDef <$> idString <*> typeName)+> ,ParamDefTp <$> typeName]++variable declarations in a plpgsql function++> varDef :: ParsecT [Token] ParseState Identity VarDef+> varDef = VarDef+> <$> idString+> <*> typeName+> <*> tryOptionMaybe ((symbol ":=" <|> symbol "=")*> expr) <* symbol ";"+++> createView :: ParsecT [Token] ParseState Identity Statement+> createView = keyword "view" >>+> CreateView+> <$> idString+> <*> (keyword "as" *> selectExpression)++> createDomain :: ParsecT [Token] ParseState Identity Statement+> createDomain = keyword "domain" >>+> CreateDomain+> <$> idString+> <*> (tryOptionMaybe (keyword "as") *> typeName)+> <*> tryOptionMaybe (keyword "check" *> parens expr)++> dropSomething :: ParsecT [Token] ParseState Identity Statement+> dropSomething = do+> x <- try (choice [+> Domain <$ keyword "domain"+> ,Type <$ keyword "type"+> ,Table <$ keyword "table"+> ,View <$ keyword "view"+> ])+> (i,e,r) <- parseDrop idString+> return $ DropSomething x i e r++> dropFunction :: ParsecT [Token] ParseState Identity Statement+> dropFunction = do+> keyword "function"+> (i,e,r) <- parseDrop pFun+> return $ DropFunction i e r+> where+> pFun = (,) <$> idString+> <*> parens (many idString)++> parseDrop :: ParsecT [Token] ParseState Identity a+> -> ParsecT [Token] ParseState Identity (IfExists, [a], Cascade)+> parseDrop p = (,,)+> <$> ifExists+> <*> commaSep1 p+> <*> cascade+> where+> ifExists = option Require+> (try $ IfExists <$ (keyword "if"+> *> keyword "exists"))++================================================================================++= component parsers for sql statements++> whereClause :: ParsecT [Token] ParseState Identity Expression+> whereClause = keyword "where" *> expr++selectlist and selectitem: the bit between select and from+check for into either before the whole list of select columns+or after the whole list++> selectList :: ParsecT [Token] ParseState Identity SelectList+> selectList =+> choice [+> flip SelectList <$> readInto <*> itemList+> ,SelectList <$> itemList <*> option [] readInto]+> where+> readInto = keyword "into" *> commaSep1 idString+> itemList = commaSep1 selectItem+> selectItem = optionalSuffix+> SelExp expr+> SelectItem () (keyword "as" *> idString)++> returning :: ParsecT [Token] ParseState Identity SelectList+> returning = keyword "returning" *> selectList++> columnNameList :: ParsecT [Token] ParseState Identity [String]+> columnNameList = parens $ commaSep1 idString++> typeName :: ParsecT [Token] ParseState Identity TypeName+> typeName = choice [+> SetOfTypeName <$> (keyword "setof" *> typeName)+> ,do+> s <- map toLower <$> idString+> choice [+> PrecTypeName s <$> parens integer+> ,ArrayTypeName (SimpleTypeName s) <$ symbol "[" <* symbol "]"+> ,return $ SimpleTypeName s]]++> cascade :: ParsecT [Token] ParseState Identity Cascade+> cascade = option Restrict (choice [+> Restrict <$ keyword "restrict"+> ,Cascade <$ keyword "cascade"])++================================================================================++= plpgsql statements++> plPgsqlStatement :: ParsecT [Token] ParseState Identity (MySourcePos,Statement)+> plPgsqlStatement = do+> p <- getAdjustedPosition+> sqlStatement True+> <|> (,) p <$> (choice [+> continue+> ,execute+> ,caseStatement+> ,assignment+> ,ifStatement+> ,returnSt+> ,raise+> ,forStatement+> ,whileStatement+> ,perform+> ,nullStatement]+> <* symbol ";")++> nullStatement :: ParsecT [Token] ParseState Identity Statement+> nullStatement = NullStatement <$ keyword "null"++> continue :: ParsecT [Token] ParseState Identity Statement+> continue = ContinueStatement <$ keyword "continue"++> perform :: ParsecT [Token] ParseState Identity Statement+> perform = keyword "perform" >>+> Perform <$> expr++> execute :: ParsecT [Token] ParseState Identity Statement+> execute = keyword "execute" >>+> optionalSuffix+> Execute expr+> ExecuteInto () readInto+> where+> readInto = keyword "into" *> commaSep1 idString++> assignment :: ParsecT [Token] ParseState Identity Statement+> assignment = Assignment+> -- put the := in the first try to attempt to get a+> -- better error if the code looks like malformed+> -- assignment statement+> <$> try (idString <* (symbol ":=" <|> symbol "="))+> <*> expr++> returnSt :: ParsecT [Token] ParseState Identity Statement+> returnSt = keyword "return" >>+> choice [+> ReturnNext <$> (keyword "next" *> expr)+> ,ReturnQuery <$> (keyword "query" *> selectExpression)+> ,Return <$> tryOptionMaybe expr]++> raise :: ParsecT [Token] ParseState Identity Statement+> raise = keyword "raise" >>+> Raise+> <$> raiseType+> <*> (extrStr <$> stringLit)+> <*> option [] (symbol "," *> commaSep1 expr)+> where+> raiseType = matchAKeyword [("notice", RNotice)+> ,("exception", RException)+> ,("error", RError)]++> forStatement :: ParsecT [Token] ParseState Identity Statement+> forStatement = do+> keyword "for"+> start <- idString+> keyword "in"+> choice [(ForSelectStatement start <$> try selectExpression <*> theRest)+> ,(ForIntegerStatement start+> <$> expr+> <*> (symbol ".." *> expr)+> <*> theRest)]+> where+> theRest = keyword "loop" *> many plPgsqlStatement+> <* keyword "end" <* keyword "loop"++> whileStatement :: ParsecT [Token] ParseState Identity Statement+> whileStatement = keyword "while" >>+> WhileStatement+> <$> (expr <* keyword "loop")+> <*> many plPgsqlStatement <* keyword "end" <* keyword "loop"++> ifStatement :: ParsecT [Token] ParseState Identity Statement+> ifStatement = keyword "if" >>+> If+> <$> (ifPart <:> elseifParts)+> <*> (elsePart <* endIf)+> where+> ifPart = expr <.> (thn *> many plPgsqlStatement)+> elseifParts = many ((elseif *> expr) <.> (thn *> many plPgsqlStatement))+> elsePart = option [] (keyword "else" *> many plPgsqlStatement)+> endIf = keyword "end" <* keyword "if"+> thn = keyword "then"+> elseif = keyword "elseif"+> --might as well these in as well after all that+> -- can't do <,> unfortunately, so use <.> instead+> (<.>) a b = (,) <$> a <*> b++> caseStatement :: ParsecT [Token] ParseState Identity Statement+> caseStatement = keyword "case" >>+> CaseStatement <$> expr+> <*> many whenSt+> <*> option [] (keyword "else" *> many plPgsqlStatement)+> <* keyword "end" <* keyword "case"+> where+> whenSt = keyword "when" >>+> (,) <$> commaSep1 expr+> <*> (keyword "then" *> many plPgsqlStatement)++================================================================================++= expressions++This is the bit that makes it the most obvious that I don't really+know haskell, parsing theory or parsec ... robbed a parsing example+from haskell-cafe and mainly just kept changing it until it seemed to+work++> expr :: ParsecT [Token] ParseState Identity Expression+> expr = buildExpressionParser table factor+> <?> "expression"++> factor :: ParsecT [Token] ParseState Identity Expression+> factor =++First job is to take care of forms which start as a regular+expression, and then add a suffix on++> threadOptionalSuffixes fct [castSuffix+> ,betweenSuffix+> ,arraySubSuffix]+> where+> fct = choice [++order these so the ones which can be valid prefixes of others appear+further down the list, probably want to refactor this to use the+optionalsuffix parsers to improve speed.++One little speed optimisation, to help with pretty printed code which+can contain a lot of parens - check for nested ((+This little addition speeds up ./ParseFile.lhs sqltestfiles/system.sql+on my system from ~4 minutes to ~4 seconds (most of the 4s is probably+compilation overhead).++> try (lookAhead (symbol "(" >> symbol "(")) >> parens expr++start with the factors which start with parens - eliminate scalar+subqueries since they're easy to distinguish from the others then do in+predicate before row constructor, since an in predicate can start with+a row constructor, then finally vanilla parens++> ,scalarSubQuery+> ,try $ threadOptionalSuffix rowCtor inPredicateSuffix+> ,parens expr++we have two things which can start with a $,+do the position arg first, then we can unconditionally+try the dollar quoted string next++> ,positionalArg++string using quotes don't start like anything else and we've+already tried the other thing which starts with a $, so can+parse without a try++> ,stringLit++> ,floatLit+> ,integerLit++put the factors which start with keywords before the ones which start+with a function++> ,caseParse+> ,exists+> ,booleanLit+> ,nullLit+> ,arrayLit+> ,castKeyword+> ,substring++now do identifiers, functions, and window functions (each is a prefix+to the next one)++> ,threadOptionalSuffixes+> identifier+> [inPredicateSuffix+> ,\l -> threadOptionalSuffix (functionCallSuffix l) windowFnSuffix]]++== operator table++proper hacky, but sort of does the job+the 'missing' notes refer to pg operators which aren't yet supported+pg's operator table is on this page:+http://www.postgresql.org/docs/8.4/interactive/sql-syntax-lexical.html#SQL-SYNTAX-OPERATORS++will probably need something more custom to handle full range of sql+syntactical novelty, in particular the precedence rules mix these+operators up with irregular syntax operators, you can create new+operators during parsing, and some operators are prefix/postfix or+binary depending on the types of their operands (how do you parse+something like this?)/++The full list of operators from DefaultScope.hs should be used here.++> table :: [[Operator [Token] ParseState Identity Expression]]+> table = [--[binary "::" (BinOpCall Cast) AssocLeft]+> --missing [] for array element select+> [prefix "-" (FunCall "u-")]+> ,[binary "^" AssocLeft]+> ,[binary "*" AssocLeft+> ,idHackBinary "*" AssocLeft+> ,binary "/" AssocLeft+> ,binary "%" AssocLeft]+> ,[binary "+" AssocLeft+> ,binary "-" AssocLeft]+> --should be is isnull and notnull+> ,[postfixks ["is", "not", "null"] (FunCall "!isNotNull")+> ,postfixks ["is", "null"] (FunCall "!isNull")]+> --other operators all added in this list according to the pg docs:+> ,[binary "<->" AssocNone+> ,binary "<=" AssocRight+> ,binary ">=" AssocRight+> ,binary "||" AssocLeft+> ,prefix "@" (FunCall "@")+> ]+> --in should be here, but is treated as a factor instead+> --between+> --overlaps+> ,[binaryk "like" "!like" AssocNone+> ,binarycust "!=" "<>" AssocNone]+> --(also ilike similar)+> ,[lt "<" AssocNone+> ,binary ">" AssocNone]+> ,[binary "=" AssocRight+> ,binary "<>" AssocNone]+> ,[prefixk "not" (FunCall "!not")]+> ,[binaryk "and" "!and" AssocLeft+> ,binaryk "or" "!or" AssocLeft]]+> where+> --use different parsers for symbols and keywords to get the+> --right whitespace behaviour+> binary s+> = Infix (try (symbol s >> return (binaryF s)))+> binarycust s t+> = Infix (try (symbol s >> return (binaryF t)))+> -- * ends up being lexed as an id token rather than a symbol+> -- * token, so work around here+> idHackBinary s+> = Infix (try (keyword s >> return (binaryF s)))+> prefix s f+> = Prefix (try (symbol s >> return (unaryF f)))+> binaryk s o+> = Infix (try (keyword s >> return (binaryF o)))+> prefixk s f+> = Prefix (try (keyword s >> return (unaryF f)))+> --postfixk s f+> -- = Postfix (try (keyword s >> return f))+> postfixks ss f+> = Postfix (try (mapM_ keyword ss >> return (unaryF f)))+> unaryF f l = f [l]+> binaryF s l m = FunCall s [l,m]++some custom parsers++fix problem parsing <> - don't parse as "<" if it is immediately+followed by ">"++don't know if this is needed anymore.++> lt _ = Infix (dontFollowWith "<" ">" >>+> return (\l -> (\m -> FunCall "<" [l,m])))++> dontFollowWith c1 c2 =+> try $ symbol c1 *> ((do+> lookAhead $ symbol c2+> fail "dont follow")+> <|> return ())++== factor parsers++> scalarSubQuery :: ParsecT [Token] ParseState Identity Expression+> scalarSubQuery = try (symbol "(" *> lookAhead (keyword "select")) >>+> ScalarSubQuery+> <$> selectExpression <* symbol ")"++in predicate - an identifier or row constructor followed by 'in'+then a list of expressions or a subselect++> inPredicateSuffix :: Expression -> ParsecT [Token] ParseState Identity Expression+> inPredicateSuffix e =+> InPredicate e+> <$> option True (False <$ keyword "not")+> <*> (keyword "in" *> parens ((InSelect <$> selectExpression)+> <|>+> (InList <$> commaSep1 expr)))++row ctor: one of+row ()+row (expr)+row (expr, expr1, ...)+(expr, expr2,...) [implicit (no row keyword) version, at least two elements+ must be present]++(expr) parses to just expr rather than row(expr)+and () is a syntax error.++> rowCtor :: ParsecT [Token] ParseState Identity Expression+> rowCtor = FunCall "!rowCtor" <$> choice [+> keyword "row" *> parens (commaSep expr)+> ,parens $ commaSep2 expr]++> floatLit :: ParsecT [Token] ParseState Identity Expression+> floatLit = FloatLit <$> float++> integerLit :: ParsecT [Token] ParseState Identity Expression+> integerLit = IntegerLit <$> integer++case - only supports 'case when condition' flavour and not 'case+expression when value' currently++> caseParse :: ParsecT [Token] ParseState Identity Expression+> caseParse = keyword "case" >>+> choice [+> try $ CaseSimple <$> expr+> <*> many whenParse+> <*> tryOptionMaybe (keyword "else" *> expr)+> <* keyword "end"+> ,Case <$> many whenParse+> <*> tryOptionMaybe (keyword "else" *> expr)+> <* keyword "end"]+> where+> whenParse = (,) <$> (keyword "when" *> commaSep1 expr)+> <*> (keyword "then" *> expr)++> exists :: ParsecT [Token] ParseState Identity Expression+> exists = keyword "exists" >>+> Exists <$> parens selectExpression++> booleanLit :: ParsecT [Token] ParseState Identity Expression+> booleanLit = BooleanLit <$> (True <$ keyword "true"+> <|> False <$ keyword "false")++> nullLit :: ParsecT [Token] ParseState Identity Expression+> nullLit = NullLit <$ keyword "null"++> arrayLit :: ParsecT [Token] ParseState Identity Expression+> arrayLit = keyword "array" >>+> FunCall "!arrayCtor" <$> squares (commaSep expr)++> arraySubSuffix :: Expression -> ParsecT [Token] ParseState Identity Expression+> arraySubSuffix e = if e == Identifier "array"+> then fail "can't use array as identifier name"+> else FunCall "!arraySub" <$> ((e:) <$> squares (commaSep1 expr))++supports basic window functions of the form+fn() over ([partition bit]? [order bit]?)++frame clauses todo:+range unbounded preceding+range between unbounded preceding and current row+range between unbounded preceding and unbounded following+rows unbounded preceding+rows between unbounded preceding and current row+rows between unbounded preceding and unbounded following++> windowFnSuffix :: Expression -> ParsecT [Token] ParseState Identity Expression+> windowFnSuffix e = WindowFn e+> <$> (keyword "over" *> (symbol "(" *> option [] partitionBy))+> <*> option [] orderBy1+> <*> option Asc (try $ choice [+> Asc <$ keyword "asc"+> ,Desc <$ keyword "desc"])+> <* symbol ")"+> where+> orderBy1 = keyword "order" *> keyword "by" *> commaSep1 expr+> partitionBy = keyword "partition" *> keyword "by" *> commaSep1 expr++> betweenSuffix :: Expression -> ParsecT [Token] ParseState Identity Expression+> betweenSuffix a = do+> keyword "between"+> b <- dodgyParseElement+> keyword "and"+> c <- dodgyParseElement+> return $ FunCall "!between" [a,b,c]+> --can't use the full expression parser at this time+> --because of a conflict between the operator 'and' and+> --the 'and' part of a between++From postgresql src/backend/parser/gram.y++ * We have two expression types: a_expr is the unrestricted kind, and+ * b_expr is a subset that must be used in some places to avoid shift/reduce+ * conflicts. For example, we can't do BETWEEN as "BETWEEN a_expr AND a_expr"+ * because that use of AND conflicts with AND as a boolean operator. So,+ * b_expr is used in BETWEEN and we remove boolean keywords from b_expr.+ *+ * Note that '(' a_expr ')' is a b_expr, so an unrestricted expression can+ * always be used by surrounding it with parens.++Thanks to Sam Mason for the heads up on this.++TODO: copy this approach here.++> where+> dodgyParseElement = factor++> functionCallSuffix :: Expression -> ParsecT [Token] ParseState Identity Expression+> functionCallSuffix (Identifier fnName) = FunCall fnName <$> parens (commaSep expr)+> functionCallSuffix s = error $ "internal error: cannot make functioncall from " ++ show s++> castKeyword :: ParsecT [Token] ParseState Identity Expression+> castKeyword = keyword "cast" *> symbol "(" >>+> Cast <$> expr+> <*> (keyword "as" *> typeName <* symbol ")")++> castSuffix :: Expression -> ParsecT [Token] ParseState Identity Expression+> castSuffix ex = Cast ex <$> (symbol "::" *> typeName)++> substring :: ParsecT [Token] ParseState Identity Expression+> substring = do+> keyword "substring"+> symbol "("+> a <- expr+> keyword "from"+> b <- expr+> keyword "for"+> c <- expr+> symbol ")"+> return $ FunCall "!substring" [a,b,c]++> identifier :: ParsecT [Token] ParseState Identity Expression+> identifier = Identifier <$> idString++================================================================================++= Utility parsers++== tokeny things++keyword has to not be immediately followed by letters or numbers+(symbols and whitespace are ok) so we know that we aren't reading an+identifier which happens to start with a complete keyword++> keyword :: String -> ParsecT [Token] ParseState Identity String+> keyword k = mytoken (\tok ->+> case tok of+> IdStringTok i | lcase k == lcase i -> Just k+> _ -> Nothing)+> where+> lcase = map toLower++> idString :: MyParser String+> idString = mytoken (\tok -> case tok of+> IdStringTok i -> Just i+> _ -> Nothing)++> symbol :: String -> ParsecT [Token] ParseState Identity String+> symbol c = mytoken (\tok -> case tok of+> SymbolTok s | c==s -> Just c+> _ -> Nothing)++> integer :: MyParser Integer+> integer = mytoken (\tok -> case tok of+> IntegerTok n -> Just n+> _ -> Nothing)++> positionalArg :: ParsecT [Token] ParseState Identity Expression+> positionalArg = PositionalArg <$> mytoken (\tok -> case tok of+> PositionalArgTok n -> Just n+> _ -> Nothing)++> float :: MyParser Double+> float = mytoken (\tok -> case tok of+> FloatTok n -> Just n+> _ -> Nothing)++> stringLit :: MyParser Expression+> stringLit = mytoken (\tok ->+> case tok of+> StringTok d s -> Just $ StringLit d s+> _ -> Nothing)++couple of helper functions which extract the actual string+from a StringLD or StringL, and the delimiters which were used+(either ' or a dollar tag)++> extrStr :: Expression -> String+> extrStr (StringLit _ s) = s+> extrStr x = error $ "internal error: extrStr not supported for this type " ++ show x++> quoteOfString :: Expression -> String+> quoteOfString (StringLit tag _) = tag+> quoteOfString x = error $ "internal error: quoteType not supported for this type " ++ show x++== combinatory things++> parens :: ParsecT [Token] ParseState Identity a+> -> ParsecT [Token] ParseState Identity a+> parens = between (symbol "(") (symbol ")")++> squares :: ParsecT [Token] ParseState Identity a+> -> ParsecT [Token] ParseState Identity a+> squares = between (symbol "[") (symbol "]")++> tryOptionMaybe :: (Stream s m t) =>+> ParsecT s u m a -> ParsecT s u m (Maybe a)+> tryOptionMaybe p = try (optionMaybe p) <|> return Nothing++> commaSep2 :: ParsecT [Token] ParseState Identity a+> -> ParsecT [Token] ParseState Identity [a]+> commaSep2 p = sepBy2 p (symbol ",")++> sepBy2 :: (Stream s m t) =>+> ParsecT s u m a -> ParsecT s u m b -> ParsecT s u m [a]+> sepBy2 p sep = (p <* sep) <:> sepBy1 p sep++> commaSep :: ParsecT [Token] ParseState Identity a+> -> ParsecT [Token] ParseState Identity [a]+> commaSep p = sepBy p (symbol ",")++> commaSep1 :: ParsecT [Token] ParseState Identity a+> -> ParsecT [Token] ParseState Identity [a]+> commaSep1 p = sepBy1 p (symbol ",")++doesn't seem too gratuitous, comes up a few times++> (<:>) :: (Applicative f) =>+> f a -> f [a] -> f [a]+> (<:>) a b = (:) <$> a <*> b++pass a list of pairs of strings and values+try each pair k,v in turn,+if keyword k matches then return v+doesn't really add a lot of value++> matchAKeyword :: [(String, a)] -> ParsecT [Token] ParseState Identity a+> matchAKeyword [] = fail "no matches"+> matchAKeyword ((k,v):kvs) = v <$ keyword k <|> matchAKeyword kvs++parseOptionalSuffix++parse the start of something -> parseResultA,+then parse an optional suffix -> parseResultB+if this second parser succeeds, return fn2 parseResultA parseResultB+else return fn1 parseResultA++e.g.+parsing an identifier in a select list can be+fieldName+or+fieldName as alias+so we can pass+* IdentifierCtor+* identifier (returns aval)+* AliasedIdentifierCtor+* () - looks like a place holder, probably a crap idea+* parser for (as b) (returns bval)+as the args, which I like to ident like:+parseOptionalSuffix+ IdentifierCtor identifierParser+ AliasedIdentifierCtor () asAliasParser+and we get either+* IdentifierCtor identifierValue+or+* AliasedIdentifierCtor identifierValue aliasValue+as the result depending on whether the asAliasParser+succeeds or not.++probably this concept already exists under a better name in parsing+theory++> optionalSuffix :: (Stream s m t2) =>+> (t1 -> b)+> -> ParsecT s u m t1+> -> (t1 -> a -> b)+> -> ()+> -> ParsecT s u m a+> -> ParsecT s u m b+> optionalSuffix c1 p1 c2 _ p2 = do+> x <- p1+> option (c1 x) (c2 x <$> try p2)++threadOptionalSuffix++parse the start of something -> parseResultA,+then parse an optional suffix, passing parseResultA+ to this parser -> parseResultB+return parseResultB is it succeeds, else return parseResultA++sort of like a suffix operator parser where the suffixisable part+is parsed, then if the suffix is there it wraps the suffixisable+part in an enclosing tree node.++parser1 -> tree1+(parser2 tree1) -> maybe tree2+tree2 isnothing ? tree1 : tree2++> threadOptionalSuffix :: ParsecT [tok] st Identity a+> -> (a -> GenParser tok st a)+> -> ParsecT [tok] st Identity a+> threadOptionalSuffix p1 p2 = do+> x <- p1+> option x (try $ p2 x)++I'm pretty sure this is some standard monad operation but I don't know+what. It's a bit like the maybe monad but when you get nothing it+returns the previous result instead of nothing+- if you take the parsing specific stuff out you get:++p1 :: (Monad m) =>+ m b -> (b -> m (Maybe b)) -> m b+p1 = do+ x <- p1+ y <- p2 x+ case y of+ Nothing -> return x+ Just z -> return z+=====++like thread optional suffix, but we pass a list of suffixes in, not+much of a shorthand++> threadOptionalSuffixes :: ParsecT [tok] st Identity a+> -> [a -> GenParser tok st a]+> -> ParsecT [tok] st Identity a+> threadOptionalSuffixes p1 p2s = do+> x <- p1+> option x (try $ choice (map (\l -> l x) p2s))++couldn't work how to to perms so just did this hack instead+e.g.+a1,a2,b1,b2,a2,b3,b4 parses to ([a1,a2,a3],[b1,b2,b3,b4])++> multiPerm :: (Stream s m t) =>+> ParsecT s u m a1+> -> ParsecT s u m a+> -> ParsecT s u m sep+> -> ParsecT s u m ([a1], [a])++> multiPerm p1 p2 sep = do+> (r1, r2) <- unzip <$> sepBy1 parseAorB sep+> return (catMaybes r1, catMaybes r2)+> where+> parseAorB = choice [+> (\x -> (Just x,Nothing)) <$> p1+> ,(\y -> (Nothing, Just y)) <$> p2]++== lexer stuff++> type MyParser = GenParser Token ParseState++> mytoken :: (Tok -> Maybe a) -> MyParser a+> mytoken test+> = token showToken posToken testToken+> where+> showToken (_,tok) = show tok+> posToken (pos,_) = pos+> testToken (_,tok) = test tok
+ Database/HsSqlPpp/PrettyPrinter.lhs view
@@ -0,0 +1,538 @@+Copyright 2009 Jake Wheat++The pretty printer which prints ast nodes from Ast.hs+It uses the hughes pj pretty printer++Produces sort of readable code, but mainly just written to produce+reparsable text. Could do with some work to make the outputted text+layout better.++Not much other comments, since it all should be pretty self evident.++> module Database.HsSqlPpp.PrettyPrinter (+> --convert a sql ast to text+> printSql+> --convert a single expression parse node to text+> ,printExpression+> )+> where++> import Text.PrettyPrint+> import Data.List (stripPrefix)+> import Data.Maybe++> import Database.HsSqlPpp.Ast+> import Database.HsSqlPpp.TypeType++================================================================================++Public functions++> printSql :: StatementList -> String+> printSql ast = render $ vcat (map (convStatement . snd) ast) <> text "\n"++> printExpression :: Expression -> String+> printExpression = render . convExp++================================================================================++Conversion routines - convert Sql asts into Docs+= Statements++> convStatement :: Statement -> Doc++== selects++> convStatement (SelectStatement s) =+> convSelectExpression True s <> statementEnd++== dml++> convStatement (Insert tb atts idata rt) =+> text "insert into" <+> text tb+> <+> ifNotEmpty (parens . hcatCsvMap text) atts+> $+$ convSelectExpression True idata+> $+$ convReturning rt+> <> statementEnd++> convStatement (Update tb scs wh rt) =+> text "update" <+> text tb <+> text "set"+> <+> hcatCsvMap convSetClause scs+> <+> convWhere wh+> $+$ convReturning rt <> statementEnd+> where+> convSetClause (SetClause att ex) = text att <+> text "=" <+> convExp ex+> convSetClause (RowSetClause atts exs) =+> parens (hcatCsvMap text atts)+> <+> text "="+> <+> parens (hcatCsvMap convExp exs)++> convStatement (Delete tbl wh rt) = text "delete from" <+> text tbl+> <+> convWhere wh+> $+$ convReturning rt+> <> statementEnd++> convStatement (Truncate names ri casc) =+> text "truncate"+> <+> hcatCsvMap text names+> <+> text (case ri of+> RestartIdentity -> "restart identity"+> ContinueIdentity -> "continue identity")+> <+> convCasc casc+> <> statementEnd++== ddl++> convStatement (CreateTable tbl atts cns) =+> text "create table"+> <+> text tbl <+> lparen++> $+$ nest 2 (vcat (csv (map convAttDef atts ++ map convCon cns)))+> $+$ rparen <> statementEnd+> where+> convAttDef (AttributeDef n t def cons) =+> text n <+> convTypeName t+> <+> maybeConv (\e -> text "default" <+> convExp e) def+> <+> hsep (map (\e -> (case e of+> NullConstraint -> text "null"+> NotNullConstraint -> text "not null"+> RowCheckConstraint ew ->+> text "check" <+> parens (convExp ew)+> RowUniqueConstraint -> text "unique"+> RowPrimaryKeyConstraint -> text "primary key"+> RowReferenceConstraint tb att ondel onupd ->+> text "references" <+> text tb+> <+> maybeConv (parens . text) att+> <+> text "on delete" <+> convCasc ondel+> <+> text "on update" <+> convCasc onupd+> )) cons)+> convCon (UniqueConstraint c) = text "unique"+> <+> parens (hcatCsvMap text c)+> convCon (PrimaryKeyConstraint p) = text "primary key"+> <+> parens (hcatCsvMap text p)+> convCon (CheckConstraint c) = text "check" <+> parens (convExp c)+> convCon (ReferenceConstraint at tb rat ondel onupd) =+> text "foreign key" <+> parens (hcatCsvMap text at)+> <+> text "references" <+> text tb+> <+> ifNotEmpty (parens . hcatCsvMap text) rat+> <+> text "on delete" <+> convCasc ondel+> <+> text "on update" <+> convCasc onupd++++> convStatement (CreateTableAs t sel) =+> text "create table"+> <+> text t <+> text "as"+> $+$ convSelectExpression True sel+> <> statementEnd++> convStatement (CreateFunction lang name args retType qt body vol) =+> text "create function" <+> text name+> <+> parens (hcatCsvMap convParamDef args)+> <+> text "returns" <+> convTypeName retType <+> text "as" <+> text qt+> $+$ convFnBody body+> $+$ text qt <+> text "language"+> <+> text (case lang of+> Sql -> "sql"+> Plpgsql -> "plpgsql")+> <+> text (case vol of+> Volatile -> "volatile"+> Stable -> "stable"+> Immutable -> "immutable")+> <> statementEnd+> where+> convFnBody (SqlFnBody sts) = convNestedStatements sts+> convFnBody (PlpgsqlFnBody decls sts) =+> ifNotEmpty (\l -> text "declare"+> $+$ nest 2 (vcat $ map convVarDef l)) decls+> $+$ text "begin"+> $+$ convNestedStatements sts+> $+$ text "end;"+> convParamDef (ParamDef n t) = text n <+> convTypeName t+> convParamDef (ParamDefTp t) = convTypeName t+> convVarDef (VarDef n t v) =+> text n <+> convTypeName t+> <+> maybeConv (\x -> text ":=" <+> convExp x) v <> semi++++> convStatement (CreateView name sel) =+> text "create view" <+> text name <+> text "as"+> $+$ nest 2 (convSelectExpression True sel) <> statementEnd++> convStatement (CreateDomain name tp ex) =+> text "create domain" <+> text name <+> text "as"+> <+> convTypeName tp <+> checkExp ex <> statementEnd+> where+> checkExp = maybeConv (\e -> text "check" <+> parens (convExp e))++> convStatement (DropFunction ifExists fns casc) =+> text "drop function"+> <+> convIfExists ifExists+> <+> hcatCsvMap doFunction fns+> <+> convCasc casc+> <> statementEnd+> where+> doFunction (name,types) = text name <> parens (hcatCsvMap text types)++> convStatement (DropSomething dropType ifExists names casc) =+> text "drop"+> <+> text (case dropType of+> Table -> "table"+> View -> "view"+> Domain -> "domain"+> Type -> "type")+> <+> convIfExists ifExists+> <+> hcatCsvMap text names+> <+> convCasc casc+> <> statementEnd++> convStatement (CreateType name atts) =+> text "create type" <+> text name <+> text "as" <+> lparen+> $+$ nest 2 (vcat (csv+> (map (\(TypeAttDef n t) -> text n <+> convTypeName t) atts)))+> $+$ rparen <> statementEnd++== plpgsql++> convStatement NullStatement = text "null" <> statementEnd++> convStatement (Assignment name val) =+> text name <+> text ":=" <+> convExp val <> statementEnd++> convStatement (Return ex) =+> text "return" <+> maybeConv convExp ex <> statementEnd++> convStatement (ReturnNext ex) =+> text "return" <+> text "next" <+> convExp ex <> statementEnd++> convStatement (ReturnQuery sel) =+> text "return" <+> text "query"+> <+> convSelectExpression True sel <> statementEnd++> convStatement (Raise rt st exps) =+> text "raise"+> <+> case rt of+> RNotice -> text "notice"+> RException -> text "exception"+> RError -> text "error"+> <+> convExp (StringLit "'" st)+> <> ifNotEmpty (\e -> comma <+> csvExp e) exps+> <> statementEnd++> convStatement (ForSelectStatement i sel stmts) =+> text "for" <+> text i <+> text "in"+> <+> convSelectExpression True sel <+> text "loop"+> $+$ convNestedStatements stmts+> $+$ text "end loop" <> statementEnd++> convStatement (ForIntegerStatement var st en stmts) =+> text "for" <+> text var <+> text "in"+> <+> convExp st <+> text ".." <+> convExp en <+> text "loop"+> $+$ convNestedStatements stmts+> $+$ text "end loop" <> statementEnd++> convStatement (WhileStatement ex stmts) =+> text "while" <+> convExp ex <+> text "loop"+> $+$ convNestedStatements stmts+> $+$ text "end loop" <> statementEnd++> convStatement (ContinueStatement) = text "continue" <> statementEnd++> convStatement (Perform f@(FunCall _ _)) =+> text "perform" <+> convExp f <> statementEnd+> convStatement (Perform x) =+> error $ "internal error: convStatement not supported for " ++ show x++> convStatement (Copy tb cols src) =+> text "copy" <+> text tb+> <+> ifNotEmpty (parens . hcatCsvMap text) cols+> <+> text "from" <+> case src of+> CopyFilename s -> quotes $ text s+> Stdin -> text "stdin"+> <> statementEnd++> convStatement (CopyData s) = text s <> text "\\." <> newline++> convStatement (If conds els) =+> text "if" <+> convCond (head conds)+> $+$ vcat (map (\c -> text "elseif" <+> convCond c) $ tail conds)+> $+$ ifNotEmpty (\e -> text "else" $+$ convNestedStatements e) els+> $+$ text "end if" <> statementEnd+> where+> convCond (ex, sts) = convExp ex <+> text "then"+> $+$ convNestedStatements sts+> convStatement (Execute s) = text "execute" <+> convExp s <> statementEnd+> convStatement (ExecuteInto s is) = text "execute" <+> convExp s+> <+> text "into" <+> hcatCsvMap text is+> <> statementEnd++> convStatement (CaseStatement c conds els) =+> text "case" <+> convExp c+> $+$ nest 2 (+> vcat (map (uncurry convWhenSt) conds)+> $+$ convElseSt els+> ) $+$ text "end case" <> statementEnd+> where+> convWhenSt ex sts = text "when" <+> hcatCsvMap convExp ex+> <+> text "then" $+$ convNestedStatements sts+> convElseSt = ifNotEmpty (\s -> text "else" $+$ convNestedStatements s)+++> statementEnd :: Doc+> statementEnd = semi <> newline++================================================================================++= Statement components++== selects++> convSelectExpression :: Bool -> SelectExpression -> Doc+> convSelectExpression writeSelect (Select dis l tb wh grp hav+> ord orddir lim off) =+> text (if writeSelect then "select" else "")+> <+> (case dis of+> Dupes -> empty+> Distinct -> text "distinct")+> <+> convSelList l+> $+$ nest 2 (+> maybeConv (\tr -> text "from" <+> convTref tr) tb+> $+$ convWhere wh)+> <+> ifNotEmpty (\g -> text "group by" <+> hcatCsvMap convExp g) grp+> <+> maybeConv (\h -> text "having" <+> convExp h) hav+> <+> ifNotEmpty (\o -> text "order by" <+> hcatCsvMap convExp o+> <+> convDir orddir) ord+> <+> maybeConv (\lm -> text "limit" <+> convExp lm) lim+> <+> maybeConv (\offs -> text "offset" <+> convExp offs) off+> where+> convTref (Tref f) = text f+> convTref (TrefAlias f a) = text f <+> text a+> convTref (JoinedTref t1 nat jt t2 ex) =+> convTref t1+> $+$ (case nat of+> Natural -> text "natural"+> Unnatural -> empty)+> <+> text (case jt of+> Inner -> "inner"+> Cross -> "cross"+> LeftOuter -> "left outer"+> RightOuter -> "right outer"+> FullOuter -> "full outer")+> <+> text "join"+> <+> convTref t2+> <+> maybeConv (nest 2 . convJoinExpression) ex+> where+> convJoinExpression (JoinOn e) = text "on" <+> convExp e+> convJoinExpression (JoinUsing ids) =+> text "using" <+> parens (hcatCsvMap text ids)++> convTref (SubTref sub alias) =+> parens (convSelectExpression True sub)+> <+> text "as" <+> text alias+> convTref (TrefFun f@(FunCall _ _)) = convExp f+> convTref (TrefFun x) =+> error $ "internal error: node not supported in function tref: " ++ show x+> convTref (TrefFunAlias f@(FunCall _ _) a) =+> convExp f <+> text "as" <+> text a+> convTref (TrefFunAlias x _) =+> error $ "internal error: node not supported in function tref: " ++ show x++> convSelectExpression writeSelect (CombineSelect tp s1 s2) =+> convSelectExpression writeSelect s1+> $+$ (case tp of+> Except -> text "except"+> Union -> text "union"+> UnionAll -> text "union" <+> text "all"+> Intersect -> text "intersect")+> $+$ convSelectExpression True s2+> convSelectExpression _ (Values expss) =+> text "values" $$ nest 2 (vcat $ csv $ map (parens . csvExp) expss)++> convDir :: Direction -> Doc+> convDir d = text $ case d of+> Asc -> "asc"+> Desc -> "desc"+++> convWhere :: (Maybe Expression) -> Doc+> convWhere (Just ex) = text "where" <+> convExp ex+> convWhere Nothing = empty++> convSelList :: SelectList -> Doc+> convSelList (SelectList ex into) =+> hcatCsvMap convSelItem ex+> <+> ifNotEmpty (\i -> text "into" <+> hcatCsvMap text i) into+> where+> convSelItem (SelectItem ex1 nm) = convExp ex1 <+> text "as" <+> text nm+> convSelItem (SelExp e) = convExp e++> convCasc :: Cascade -> Doc+> convCasc casc = text $ case casc of+> Cascade -> "cascade"+> Restrict -> "restrict"++== ddl++> convReturning :: Maybe SelectList -> Doc+> convReturning l = case l of+> Nothing -> empty+> Just ls -> nest 2 (text "returning" <+> convSelList ls)++> convIfExists :: IfExists -> Doc+> convIfExists i = case i of+> Require -> empty+> IfExists -> text "if exists"++== plpgsql++> convNestedStatements :: StatementList -> Doc+> convNestedStatements = nest 2 . vcat . map (convStatement . snd)++> convTypeName :: TypeName -> Doc+> convTypeName (SimpleTypeName s) = text s+> convTypeName (PrecTypeName s i) = text s <> parens(integer i)+> convTypeName (ArrayTypeName t) = convTypeName t <> text "[]"+> convTypeName (SetOfTypeName t) = text "setof" <+> convTypeName t++= Expressions++> convExp :: Expression -> Doc+> convExp (Identifier i) = text i+> convExp (IntegerLit n) = integer n+> convExp (FloatLit n) = double n+> convExp (StringLit tag s) = text tag <> text replaceQuotes <> text tag+> where+> replaceQuotes = if tag == "'"+> then replace "'" "''" s+> else s++> convExp (FunCall n es) =+> --check for special operators+> case n of+> "!arrayCtor" -> text "array" <> brackets (csvExp es)+> "!between" -> convExp (head es) <+> text "between"+> <+> parens (convExp (es !! 1))+> <+> text "and"+> <+> parens (convExp (es !! 2))+> "!substring" -> text "substring"+> <> parens (convExp (head es)+> <+> text "from" <+> convExp (es !! 1)+> <+> text "for" <+> convExp (es !! 2))+> "!arraySub" -> case es of+> ((Identifier i):es1) -> text i <> brackets (csvExp es1)+> _ -> parens (convExp (head es)) <> brackets (csvExp (tail es))+> "!rowCtor" -> text "row" <> parens (hcatCsvMap convExp es)+> _ | isOperator n ->+> case getOperatorType n of+> BinaryOp ->+> parens (convExp (head es)+> <+> text (filterKeyword n)+> <+> convExp (es !! 1))+> PrefixOp -> parens (text (if n == "u-"+> then "-"+> else filterKeyword n)+> <+> convExp (head es))+> PostfixOp -> parens (convExp (head es) <+> text (filterKeyword n))+> | otherwise -> text n <> parens (csvExp es)+> where+> filterKeyword t = case t of+> "!and" -> "and"+> "!or" -> "or"+> "!not" -> "not"+> "!isNull" -> "is null"+> "!isNotNull" -> "is not null"+> "!like" -> "like"+> x -> x++> convExp (BooleanLit b) = bool b+> convExp (InPredicate att t lst) =+> convExp att <+> (if not t then text "not" else empty) <+> text "in"+> <+> parens (case lst of+> InList expr -> csvExp expr+> InSelect sel -> convSelectExpression True sel)+> convExp (ScalarSubQuery s) = parens (convSelectExpression True s)+> convExp NullLit = text "null"+> convExp (WindowFn fn partition order asc) =+> convExp fn <+> text "over"+> <+> (if hp || ho+> then+> parens ((if hp+> then text "partition by" <+> csvExp partition+> else empty)+> <+> (if ho+> then text "order by" <+> csvExp order+> <+> convDir asc+> else empty))+> else empty)+> where+> hp = not (null partition)+> ho = not (null order)+> convExp (Case whens els) =+> text "case"+> $+$ nest 2 (vcat (map convWhen whens)+> $+$ maybeConv (\e -> text "else" <+> convExp e) els)+> $+$ text "end"+> where+> convWhen (ex1, ex2) =+> text "when" <+> hcatCsvMap convExp ex1+> <+> text "then" <+> convExp ex2++> convExp (CaseSimple val whens els) =+> text "case" <+> convExp val+> $+$ nest 2 (vcat (map convWhen whens)+> $+$ maybeConv (\e -> text "else" <+> convExp e) els)+> $+$ text "end"+> where+> convWhen (ex1, ex2) =+> text "when" <+> hcatCsvMap convExp ex1+> <+> text "then" <+> convExp ex2++> convExp (PositionalArg a) = text "$" <> integer a+> convExp (Exists s) = text "exists" <+> parens (convSelectExpression True s)+> convExp (Cast ex t) = text "cast" <> parens (convExp ex+> <+> text "as"+> <+> convTypeName t)++= Utils++convert a list of expressions to horizontal csv++> csvExp :: [Expression] -> Doc+> csvExp = hcatCsvMap convExp++run conversion function if Just, return empty if nothing++> maybeConv :: (t -> Doc) -> Maybe t -> Doc+> maybeConv f c =+> case c of+> Nothing -> empty+> Just a -> f a++> csv :: [Doc] -> [Doc]+> csv = punctuate comma++> hcatCsv :: [Doc] -> Doc+> hcatCsv = hcat . csv++> ifNotEmpty :: ([a] -> Doc) -> [a] -> Doc+> ifNotEmpty c l = if null l then empty else c l++map the converter ex over a list+then hcatcsv the results++> hcatCsvMap :: (a -> Doc) -> [a] -> Doc+> hcatCsvMap ex = hcatCsv . map ex++> bool :: Bool -> Doc+> bool b = if b then text "true" else text "false"++> newline :: Doc+> newline = text "\n"++> replace :: (Eq a) => [a] -> [a] -> [a] -> [a]+> replace _ _ [] = []+> replace old new xs@(y:ys) =+> case stripPrefix old xs of+> Nothing -> y : replace old new ys+> Just ys' -> new ++ replace old new ys'
+ HsSqlSystem.lhs view
@@ -0,0 +1,374 @@+#! /usr/bin/env runhaskell++Copyright 2009 Jake Wheat++Command line access to a bunch of utility functions.++command line is+./HsSqlSystem.lhs [commandName] [commandArgs ...]++run+./HsSqlSystem.lhs help+to get a list of commands and purpose and usage info++TODO 1: add options to specify username and password (keep optional though)+TODO 2: think of a name for this command++> import System+> import System.IO+> import Control.Monad+> import System.Directory+> import Data.List++> import Database.HsSqlPpp.Parser+> import Database.HsSqlPpp.DatabaseLoader+> import Database.HsSqlPpp.Lexer+> import Database.HsSqlPpp.Ast+> import Database.HsSqlPpp.PrettyPrinter+> import Database.HsSqlPpp.DBAccess+> import Database.HsSqlPpp.ScopeReader++================================================================================++= main++> main :: IO ()+> main = do+> -- do this to avoid having to put flushes everywhere when we+> -- provide "..." progress thingys, etc.. should be fixed so only+> -- used in commands that need it+> hSetBuffering stdout NoBuffering+> args <- getArgs+> case () of+> _ | null args -> putStrLn "no command given" >> help False+> | args == ["help"] -> help False+> | args == ["help", "all"] -> help True+> | head args == "help" -> helpCommand (args !! 1)+> | otherwise -> case lookupCaller commands (head args) of+> Nothing -> putStrLn "unrecognised command" >> help False+> Just c -> call c $ tail args++> commands :: [CallEntry]+> commands = [clearDBCommand+> ,loadSqlCommand+> ,clearAndLoadSqlCommand+> ,lexFileCommand+> ,showFileAttsCommand+> ,parseFileCommand+> ,roundTripCommand+> ,getScopeCommand+> ,showTypesCommand+> ,showTypesDBCommand+> ,showInfoCommand+> ,showInfoDBCommand]++> lookupCaller :: [CallEntry] -> String -> Maybe CallEntry+> lookupCaller ce name = find (\(CallEntry nm _ _) -> name == nm) ce++> help :: Bool -> IO ()+> help full = do+> putStrLn "commands available"+> putStrLn "use 'help' to see a list of commands"+> putStrLn "use 'help all' to see a list of commands with descriptions"+> putStrLn "use 'help [command]' to see the description for that command\n"+> mapM_ putStrLn $ flip map commands (\(CallEntry nm desc _) ->+> if full+> then nm ++ "\n" ++ desc ++ "\n"+> else nm ++ "\n")++> helpCommand :: String -> IO ()+> helpCommand c =+> case lookupCaller commands c of+> Nothing -> putStrLn "unrecognised command" >> help False+> Just (CallEntry nm desc _) -> putStrLn $ nm ++ "\n" ++ desc++================================================================================++= load sql file++> loadSqlCommand :: CallEntry+> loadSqlCommand = CallEntry+> "loadsql"+> "This takes one or more files with sql source text, \+> \parses them then loads them into the database given."+> (Multiple loadSql)++> loadSql :: [String] -> IO ()+> loadSql args =+> let (db:fns) = args+> in forM_ fns $ \fn -> do+> res <- parseSqlFileWithState fn+> case res of+> Left er -> error $ show er+> Right ast -> putStrLn ("loading " ++ fn)+> >> loadIntoDatabase db fn ast++================================================================================++= small hack utility to help with testing++TODO: use the correct username in this command+TODO: do something more correct++> clearDBCommand :: CallEntry+> clearDBCommand = CallEntry+> "cleardb"+> "hacky util to clear a database"+> (Single cleardb)++> cleardb :: String -> IO ()+> cleardb db = do+> withConn ("dbname=" ++ db) $ \conn ->+> runSqlCommand conn "drop owned by jake cascade;"+> putStrLn $ "database " ++ db ++ " cleared."++================================================================================++> clearAndLoadSqlCommand :: CallEntry+> clearAndLoadSqlCommand = CallEntry+> "clearandloadsql"+> "cleardb then loadsql"+> (Multiple+> (\args -> do+> cleardb $ head args+> loadSql args))++================================================================================++> lexFileCommand :: CallEntry+> lexFileCommand = CallEntry+> "lexfile"+> "lex the file given and output the tokens on separate lines"+> (Single lexFile)+> lexFile :: FilePath -> IO ()+> lexFile f = do+> putStrLn $ "lexing " ++ show f+> x <- lexSqlFile f+> return ()+> case x of+> Left er -> print er+> Right l -> mapM_ print l++================================================================================++> showFileAttsCommand :: CallEntry+> showFileAttsCommand = CallEntry+> "showFileAtts"+> "run the ag over the given files and return all the attributes computed"+> (Multiple showfileatts)++> showfileatts :: [String] -> IO ()+> showfileatts = mapM_ pf+> where+> pf f = do+> putStrLn $ "parsing " ++ show f+> x <- parseSqlFileWithState f+> case x of+> Left er -> print er+> Right st -> do+> mapM_ print st+> putStrLn "\nchecking ast"+> let y = checkAst st+> print y+> return ()++================================================================================++> parseFileCommand :: CallEntry+> parseFileCommand = CallEntry+> "parsefile"+> "Routine to parse sql from a file, check that it appears to parse ok, \+> \that pretty printing it and parsing that text gives the same ast, \+> \and then displays the pretty printed version so you can see how well it's \+> \done"+> --(maybe it could interpolate each original statement with its+> --parsed, pretty printed version so you can more easily check how+> --authentic the sql is and how much has been silently dropped on the floor)+> (Multiple parseFile)++> parseFile :: [String] -> IO ()+> parseFile = mapM_ pf+> where+> pf f = do+> putStrLn $ "parsing " ++ show f+> x <- parseSqlFileWithState f+> case x of+> Left er -> print er+> Right st -> do+> --print l+> --putStrLn "END OF AST END OF AST END OF AST END OF AST END OF AST END OF AST"+> putStrLn "parse ok"+> print st+> let pp = printSql st+> --putStrLn pp+> --check roundtrip+> case parseSql pp of+> Left er -> error $ "roundtrip failed: " ++ show er+> Right st' -> if resetSps' st == resetSps' st'+> then putStrLn "roundtrip ok"+> else putStrLn "roundtrip failed: different ast"+> return ()++================================================================================++> showTypesCommand :: CallEntry+> showTypesCommand = CallEntry+> "showtypes"+> "reads each file, parses, type checks, then outputs the types \+> \interspersed with the pretty printed statements"+> -- todo: modify this so that is inserts the types as comments into the+> -- original source, get it to work correctly when run multiple times or+> -- the types have changed between runs (i.e. add or update the comments)+> (Multiple showTypes)++> showTypes :: [FilePath] -> IO ()+> showTypes = mapM_ pt+> where+> pt f = do+> x <- parseSqlFileWithState f+> case x of+> Left er -> print er+> Right sts -> do+> let types = zip (getStatementsType sts) sts+> mapM_ (\(t,st) -> putStrLn ("/*\n" ++ show t ++ "*/\n") >>+> putStrLn (printSql [st])) types++================================================================================++> showTypesDBCommand :: CallEntry+> showTypesDBCommand = CallEntry+> "showtypesdb"+> "pass the name of a database first, then \+> \filenames, reads each file, parses, type checks, \+> \then outputs the types interspersed with the \+> \pretty printed statements, will type check \+> \against the given database schema"+> (Multiple showTypesDB)+++> showTypesDB :: [FilePath] -> IO ()+> showTypesDB args = do+> let dbName = head args+> scope <- readScope dbName+> mapM_ (pt scope) $ tail args+> where+> pt scope f = do+> x <- parseSqlFileWithState f+> case x of+> Left er -> print er+> Right sts -> do+> let types = zip (getStatementsTypeScope scope sts) sts+> mapM_ (\(t,st) -> putStrLn ("/*\n" ++ show t ++ "*/\n") >>+> putStrLn (printSql [st])) types+++================================================================================++> showInfoCommand :: CallEntry+> showInfoCommand = CallEntry+> "showinfo"+> "reads each file, parses, type checks, then outputs info on each statement \+> \interspersed with the pretty printed statements"+> (Multiple showInfo)++> showInfo :: [FilePath] -> IO ()+> showInfo = mapM_ pt+> where+> pt f = do+> x <- parseSqlFileWithState f+> case x of+> Left er -> print er+> Right sts -> do+> let info = zip (getStatementsInfo sts) sts+> mapM_ (\(t,st) -> putStrLn ("/*\n" ++ show t ++ "*/\n") >>+> putStrLn (printSql [st])) info++================================================================================++> showInfoDBCommand :: CallEntry+> showInfoDBCommand = CallEntry+> "showinfodb"+> "pass the name of a database first, then \+> \filenames, reads each file, parses, type checks, \+> \then outputs info on each statement interspersed with the \+> \pretty printed statements, will type check \+> \against the given database schema"+> (Multiple showInfoDB)+++> showInfoDB :: [FilePath] -> IO ()+> showInfoDB args = do+> let dbName = head args+> scope <- readScope dbName+> mapM_ (pt scope) $ tail args+> where+> pt scope f = do+> x <- parseSqlFileWithState f+> case x of+> Left er -> print er+> Right sts -> do+> let info = zip (getStatementsInfoScope scope sts) sts+> mapM_ (\(t,st) -> putStrLn ("/*\n" ++ show t ++ "*/\n") >>+> putStrLn (printSql [st])) info+++================================================================================++> roundTripCommand :: CallEntry+> roundTripCommand = CallEntry+> "roundtripfile"+> "Used to test the parsing and pretty printing round trip. Takes two \+> \arguments, a source filename and a target filename. If the target file \+> \exists, it quits. Parses the source file then pretty prints it to the \+> \target filename."+> (Multiple roundTrip)++> roundTrip :: [FilePath] -> IO ()+> roundTrip args = do+> when (length args /= 2) $+> error "Please pass exactly two filenames, source and target."+> let (source:target:[]) = args+> targetExists <- doesFileExist target+> when targetExists $+> error "the target file name exists already, please delete it or choose a new filename"+> x <- parseSqlFile source+> case x of+> Left er -> print er+> Right l -> writeFile target $ printSql l++================================================================================++This writes out the default scope using show, which you can then+compile. The output is all on one big line (something like 400,000+characters!) and compiles very slowly for the catalog of a standard+template1 database...++> getScopeCommand :: CallEntry+> getScopeCommand = CallEntry+> "getscope"+> "read the catalogs for the given db and dump a scope variable source text to stdout"+> (Single getScope)+> getScope :: String -> IO ()+> getScope dbName = do+> s <- readScope dbName+> putStrLn "module Database.HsSqlPpp.DefaultScope where"+> putStrLn "import Database.HsSqlPpp.TypeType"+> putStrLn "import Database.HsSqlPpp.Scope"+> putStrLn "defaultScope :: Scope"+> putStr "defaultScope = "+> print s++================================================================================++> data CallEntry = CallEntry String String CallType+> -- name use++> data CallType = Single (String -> IO ())+> | Multiple ([String] -> IO ())++> call :: CallEntry -> [String] -> IO ()+> call (CallEntry _ _ ct) args =+> case ct of+> Single f | length args /= 1 -> error "please call this command with one argument"+> | otherwise -> f (head args)+> Multiple f -> f args
+ LICENSE view
@@ -0,0 +1,31 @@+Copyright Jake Wheat 2009++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of Jake Wheat nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.+
+ README view
@@ -0,0 +1,156 @@+Summary: A parser, pretty printer, and type checker for PostGreSQL SQL+and PL/pgSQL. BSD licensed.++The current aims of the project is to provide a parser and type+checker for a substantial portion of PostGreSQL SQL and PL/pgSQL.++Status: it successfully parses and accurately pretty prints the three+moderate sized SQL files from another project of mine, but there are+lots of missing bits. Coverage of SQL is reasonable, see below for+more details on what is supported and unsupported.++It also has the beginnings of a type checker, which currently can type+check a large subset of expressions and selects that the parser can+parse, but is in an early state. You can run the type checker on your+SQL, see the 'usage' file for details.++There is a command line wrapper, HsSqlSystem.lhs, which provides some+utility functions to access some of the library code.++It comes with a small test suite.++There is not much documentation at the moment. See the 'usage' file+where there are instructions on how to parse files, and type check+them to see how well the code supports your SQL source.++Most of the source files have plenty of comments, hopefully they can+provide some illumination.++It comes with a Cabal file, so you can compile it by unzipping and+using cabal configure && cabal build in the usual way. I think it+should work on all GHC 6.10.x and possibly also GHC 6.8.x.++See the file 'development' for some notes on how to work with the+source.++The main dependencies of this project are: Parsec 3, HUnit, HDBC and+UUAGC.++================================================================================++Homepage++The project is hosted on Launchpad+http://launchpad.net/hssqlppp/++You can get the latest code using Bazaar:+bzr branch lp:~jakewheat/hssqlppp/trunk++Contact++Let me know if you're using/ interesting in using the library, if you+have any problems or suggestions, etc.. All contributions, comments+and criticism welcome:++jakewheatmail@gmail.com++You can also report problems on the bug tracker on Launchpad. Let me+know if you have any problems trying out the stuff in the 'usage'+file, if you come across some SQL which doesn't parse or type check,+and I'm also interested in surveying what other dialects of SQL you+would be interested in using or contributing code for, and if you want+to fork the project (which is something I have nothing against).++================================================================================++= Syntax supported/ not supported:++== Parsing++Partially supports:+select statements (selectlists (*, qualified, aliased/correlation names, expressions)+ distinct, basic window functions,+ from (with explicit joins - natural, inner, cross, left, right,+ full outer, on and using), aliases, from functions+ where, group by, having, order by, limit, offset+ except, intersect, union++expressions: subselects, in, row ctors, strings + dollar strings,+ integers, case, exists, boolean literals, null, arrays+ and subscripting (slightly limited), function calls,+ identifiers, cast(x as y), between (quite limited),+ substring(x from a for b)++also partially supports:+insert (with multiple values and select support), update, delete (all+three with returning)+create and drop table, type, view, domain+create function for sql and plpgsql functions+all constraint types+sort of skips copy statements instead of erroring++plpgsql statements:+ select into+ null+ continue+ perform+ execute+ assignment+ if+ return, return next, return query+ raise+ for (select and integer variants)+ while+ case statement++Many things are missing at the moment, in particular+ selects: cte, implicit joins+ joins in updates (delete from, update using)+ alter statements+ create and drop apart from table, view, domain, type, function+ transaction commands+ triggers and trigger functions+ loop statement, labels+ error trapping+ cursors+This is a non-exhaustive list.++Expression support is patchy, should work pretty well for a lot of+simple stuff though. There is a strong possibility that for some+complex selects and expressions, the implicit precedence (that is,+bits without enclosing parenthesis) may parse in the wrong+direction. Please let me know if you encounter such an error.++== Type checking++Type checking supports a good subset of expressions and select+statements that the parser parses, and has basic support for insert,+update, delete and the various create statements that the parser+supports. Development work is currently focused in this area.++= Other current downsides:++The AST node types aren't well designed, in particular they contain+almost no location information, and no other annotations. This is due+to be fixed and is near the top of the TODO list.++Not much work has been done on correctly rejecting invalid SQL and not+much thought has been put into error messages and error reporting yet,+this is slowly improving, and at some point will become a major focus.++Supporting other SQL dialects: I think it might be realistic to+support portable select, insert, update and delete with ?+placeholders. I think cross platform DDL isn't ever going to be+sensible in non toy databases, and if you wanted to use this utility+e.g. support MySQL or MS SQL Server, start by forking the code.++Future plans:++* use this system to develop a Lint-type checker for PL/pgSQL;++* support type checking simple SQL statements that you'd embed in+ Haskell code, including with ? placeholders, to support generating+ type safe wrappers;++* possibly a lightweight code generation/ simple macro support to help+ with developing more robust PL/pgSQL code.
+ Setup.lhs view
@@ -0,0 +1,4 @@+#! /usr/bin/env runhaskell++> import Distribution.Simple+> main = defaultMain
+ TODO view
@@ -0,0 +1,281 @@+Annotation planning+add an annotation field to most nodes in the ast+something like+data Annotation = NonAnnotation+ | SourcePosAnnotation SourcePos+ | CheckedAnnotation SourcePos Type [Messages]++alter the parser to add sourcepositions to these nodes - assume that+ one source position per node will be enough for now (not+ necessarily a good assumption with weird sql syntax), and see if+ this gives us enough for good error messages, etc..++question:+if a node has no source position e.g. the all in select all or select+ distinct may correspond to a token or may be synthesized as the+ default if neither all or distinct is present. Should this have the+ source position of where the token would have appeared, should it+ inherit it from its parent, should there be a separate ctor to+ represent a fake node with no source position?++The way the type checking will then work is that instead of producing+ some attribute values it will produce a transformed ast tree with+ the type and message fields filled in. Then supply some utility+ functions to e.g. extract all the messages, extract all the type+ errors, extract the top level types, etc. Use some sort of tree+ walker to implement these utils++The way types and type errors will work is that instead of / in+ addition to the types being passed in attributes, they'll be saved+ in the transformed tree. Type errors won't percolate up to the top+ level, but sit with the node that is in error. Any parent nodes+ which need this type to calculate their own type, will use a+ separate error to say type unknown. If they can calculate their+ type without depending on a type erroring child node, then they do+ that, so e.g. typing a set of statements with create functions and+ views which use those functions: if the statements inside the+ functions have type errors, we can still find the types of the+ views, assuming that the function params and return type check+ properly, and are correct.++= Current TODO list++TODOs in rough order that they are intended to be done++stage 1: do some stuff patchily to try to get a bunch of common sql+ partially type-checking (focus is on getting the result types of+ most select statements)++todos for this stage:+integrate create types into scope, plus do drops with scope+chain scopes when showinfo-ing multiple files+Pretty printer for statementinfo++stage 2:+make this useful by working on the showinfodb function:+instead of interspersing the statementinfo with the pretty printed+ statements, insert or overwrite the statementinfo comments in the+ original source so we preserve formatting and other comments.+use the type pretty printer to make the statementinfo comments more readable+want to also output types of parts of statements, e.g. the select in a+ for statement or insert, etc.. Other things that could be useful+ include adding the resolved function prototype for each function+ used which has overloads so you can see which overload is being+ called, write out the canonicalized ast: so e.g. we have all the+ casts made explicit, etc.+With this in place, the code actually has some use for real code, in+ that we can use it to easily view the types of views, etc. inline+ in the real sql source code++stage 3:+review and choose from this list:+* do null inference+* some selective fixups here and there to the typing (e.g. type+ checking constraints in create tables)+* selectively add some missing syntax, to cover the most glaring hole+* schema qualification+* type check statements inside create function+* something else from the todo for milestone 0.1 below+* something else++================================================================================++rough milestones for release 0.1:+in addition to all the stage 3 items above,++add support for nearly all syntax for parsing and type checking,+ instead of doing piecemeal bits, so go through the pg manual part+ II, support almost everything, add comprehensive simple tests, go+ through the sql reference section also. This is the time to+ document more precisely what isn't supported so there is a clear+ reference for this+do ? placeholders, and do typesafe haskell wrapper generation using this+figure out what to do about tricky operator precedence parsing, etc.+ability to type check all of chaos sql+example for generating sql code from haskell using the ast+get database loader and typesafe access generators good enough to use+ in chaos+example usage of each of these+look at the error message formatting, particularly try to fix the+ parser errors so they make more sense+add annotation field to most ast nodes, store type and source+ positioning in this field, fix parser to add lots of accurate+ positioning information when parsing.+make sure the lint process works on text dumps of databases.+try checking the sample databases: http://pgfoundry.org/projects/dbsamples/+++================================================================================++some syntax todo, not organised:++------------+add support for following sql syntax (+ type checking)+alter table, common variations+create index+create rule+create trigger++ drops for all creates++ maybe alters?+ctes+loop, exit, labels+easy ones: transactions, savepoints, listen+prepare, execute + using+some more:+create or replace+alter table+transactions: begin, checkpoint, commit, end, rollback+cursors: declare, open, fetch, move, close, where current of+copy - parse properly+create database+create index+create rule+create trigger + plpgsql support+grant,revoke+listen, notify, unlisten+prepare, execute+savepoint, release savepoint, rollback to savepoint+set, reset+set constraints+set role+set transaction+correlated subquery attrs++plpgsql++blocks which aren't at the top level of a function+% types+strict on intos+not null for var defs+exception+execute using+get diagnostics+return query execute+raise missing bits+out params+elsif+loop+exit+labels+reverse, by in for+for in execute++expressions:+process string escapes, support dollar quoting and other quoting more+ robustly in the pretty printer+full user operator support (?)+fix expression parser properly to handle things like between - see+ grammar in pg source for info on how to do this+[:] array slices+aggregate: all and distinct+multi dimensional arrays: selectors and subscripting+missing keyword operators+datetime extract+time zone+subquery operators: any, some, all+in general, parsing operators is wrong, the lexer needs to be able to+ lex sequences of symbols into single/multiple operators correctly,+ what happens at the moment is a kludge, also, general operator+ parsing will change how operators are represented in the ast++================================================================================++some other random ideas:++null treatment+Basic motivation is to keep nulls carefully walled off, controlled,+ and be able to catch them when they sneak back into expressions,+ etc.. For each value, etc. we determine statically if it might be+ null. This can be done for return types of functions, fields in a+ select expression, etc.. (will do mappings e.g. if a functions+ inputs are all non null, then the output is non null, etc.). Once+ this is working ok, the second stage is to implement the anti null+ warnings/ errors.+Allow nulls in tables, outer joins, in coalesce, to be produced by+ selects (maybe add or remove from this allowed list, maybe make it+ configurable on a per project basis).+Never allow nulls to be an argument to a function call, (including+ ops, keyword ops, etc.). So every time you have a field being used+ in an expression and it cannot be statically verified to be non+ null, you have to insert a coalesce or fix it in some other way.+So nulls can still be used to represent optional values, n/a,+ etc.. and output to clients doing selects, but there is no need to+ grapple with:+* 3vl (or whatever it is that sql uses instead),+* what the result of a function call is if the some or all the+ arguments are null,+* what the result of a sum aggregate is if some of the values are null,+* etc.,+because none of these things are allowed.+++parser, converter and pretty printer for explain output, want to view+ how a query is executed in human readable pseudocode. Add lint type+ checks, etc. to this, which can suggest ways to rewrite the query+ to get better performance. Another idea is to make the dependencies+ on the values in the tables more explicit, so you can see how much+ the data can change before another plan is chosen, or you can see a+ bad assumption about the kind of data the query will be run on.++write a replacement psql shell, which can expose parse trees, type+ checks, lint checks, and doesn't use a one line at a time style+ interface (i.e. works more like writing and executing lisp in+ emacs, not like bash).++chain scope lookups instead of unioning them since unioning is too+ slow - or maybe use maps/sets, but need to quickly scan whole lists+ e.g. for function lookup, which can't really use any sort of key+ based lookup, where the key the function lookup uses is the same as the+ key the map/set uses.++incorporate pg regression test sql into parsing and type checking+ tests++write a show for parsec errors which formats the lex tokens and+ expected lists properly (was broken when moved to the separate+ lexer)++add haddock docs to public api++write some example programs with plenty of comments - will this mainly+ be used as a library or as a utility though?++redo cabal file to add compile time options: exes, pg support, tests+ or split into separate packages?++sort out modules/folder use++work on error reporting, add tests for malformed sql++add token location info to ast nodes, modify for type checking, etc+ support.++want to report multiple parse errors, perhaps can bodge this because+ of the property that ';' can only appear inside a string or+ comment, or otherwise at the end of a statement, so add some code+ to jump to the next end of statement looking ';' and continue to+ parse to end of file in an attempt to catch at least some further+ syntax errors++improve tests:+identify each bit of syntax and make sure there is a test for it+add some bigger tests: lots of sql statements, big functions+look for possible corner cases and add tests++get property checker working again - one problem is that the pretty+ printer will reject some asts (which the parser cannot+ produce), and the parser will probably reject some invalid sql that+ the pretty printer will happily produce from some asts.++ability to write new lint checks, and choose which lint checks to use+ on a per project basis.++plpgsql on 'roids:+write libraries in haskell, and then write syntax extensions for+ plpgsql using the extension mechanism to access these libs from+ extended plpgsql e.g. ui lib written in haskell, accessed by syntax+ extensions in plpgsql then can write the database and ui all in the+ same source code in the same language, with first class support for+ properly typed relation valued expressions, avoiding multiple+ languages and mapping/'impedance mismatch' between database types+ and types in the language you write the ui in.
+ Tests.lhs view
@@ -0,0 +1,20 @@+#!/usr/bin/env runghc++Copyright 2009 Jake Wheat++Runner for automated tests, just pulls in the tests defs from the+other files.+++> import Test.Framework+> import Database.HsSqlPpp.ParserTests+> import Database.HsSqlPpp.DatabaseLoaderTests+> import Database.HsSqlPpp.AstCheckTests++> main :: IO ()+> main =+> defaultMain [+> parserTests+> ,astCheckTests+> ,databaseLoaderTests+> ]
+ development view
@@ -0,0 +1,124 @@+Some brief notes on developing with this code.++The project comes with a working cabal file.++UUAGC is used in the type checking, there are some links at the top of+Ast.ag for more information.++Two of the files are generated:++DefaultScope.hs -> generated using ./HsSqlSystem.lhs getscope+ template1 (make a backup of this file if you want to regenerate it -+ you can get trapped without being able to run HsSqlSystem if the new+ file doesn't compile). You shouldn't need to regenerate this file+ unless you change the Scope data type, in which case you'll need to+ use the DefaultScopeEmpty.hs file to be able to generate a new+ scope. There is some info in the DefaultScopeEmpty.hs file along+ these lines.++Ast.hs -> this is generated from Ast.ag and Typechecking.ag using+ uuagc, see Ast.ag for instructions on how to do this.++If you are editing either of these files directly you're probably+doing something wrong.++See the file usage which gives some information on helper functions+you can try from ghci, and documents a bunch of utility functions you+can run from the command line.++There are rudimentary test for a lot of the functionality, see+ParserTests.lhs and AstCheckTests.lhs (for type checking). These+contain some small examples of how the code can be used. The+HsSqlSystem.lhs file contains a few more examples.++Source file overview:++(The type checking code is a bit spread out, ideally would want one+file for the ast, one file containing type checking code, and then+some clear additional little lib files, but the ast and type checking+are spread out in Ast.ag, AstUtils.lhs, TypeChecking.ag,+TypeCheckingH.lhs and TypeType.lhs. (The little libs also used in the+type checking are Scope.lhs, ScopeReader.lhs and TypeConversion.lhs.))++Ast.ag: uuagc source for the ast data types and the api functions for+ type checking asts.++AstCheckTests.lhs: hunit tests for type checking++AstUtils.lhs: some utilities used mainly in type checking++DatabaseLoader.lhs: beginnings of a program to load sql from source+ into postgresql, pretty rough and unfinished at+ the moment.++DatabaseLoaderTests.lhs: almost empty hunit tests, intended to be used+ mainly for testing error source positioning+ when using databaseloader.lhs++DBAccess.lhs: some simple wrappers around hdbc to run sql statements+ and do simple selects.++DefaultScopeEmpty.hs: an empty version of default scope, used to allow+ the default scope generation to run when you've+ hosed the DefaultScope.hs file.++DefaultScope.hs: generated file which contains the scope from a+ standard template1 database. The intended use is to+ support parsing and typechecking sql without having+ online access to postgresql. Not sure if this is+ useful. It's definitely quick enough to read this+ information from a database at type checking time.++HsSqlSystem.lhs: program to expose some functionality on the command+ line, mainly utilities to help with developing the+ source. Run './HsSqlSystem.lhs help' to list the+ commands.++Lexer.lhs: small file to lex sql source code.++ParseErrors.lhs: small utility to add a bit of extra value to parsec errors.++Parser.lhs: one of the main files - takes the output of the lexer and+ produces asts.++ParserTests.lhs: lots of hunit tests for the parser.++PrettyPrinter.lhs: code to produce reparsable source from an ast.++Scope.lhs: data type to store mainly information from the pg catalog,+ used during type checking, plus some utilities for this+ datatype.++ScopeReader.lhs: utility to read a scope data type from a+ database. Can access this function from+ HsSqlSystem.lhs.++Tests.lhs: small file to pull together the tests from other test+ suites, and make them into an executable.++TypeChecking.ag: the uuagc ATTR and SEM constructs used in type+ checking, plus the smaller bits of type checking code+ inline.++TypeCheckingH.lhs: larger bits of typechecking code and support types,+ functions, moved from TypeChecking.ag to mitigate+ some of the pain of developing using a+ preprocessor.++TypeConversion.lhs: code to support the type conversion algorithms+ used in postgresql, which are quite complicated.+ In particular, the code used to match an exact+ function given a name and a bunch of args.+++TypeType.lhs: Some types used by the type checker, should live with+ the ast nodes but are here to support splitting the code+ out of the ag files for the same reason that+ TypeCheckingH.lhs exists.++These files all have (hopefully) useful comments.++You'll find the jargon in this project easier to follow if you're+familiar with SQL and with the work of Date, Darwen, et al.. I plan to+add a glossary at some point, and to try to make the usage more+consistent.
+ hssqlppp.cabal view
@@ -0,0 +1,51 @@+Name: hssqlppp+Version: 0.0.4+Synopsis: Sql parser, pretty printer and type checker+Description: Sql parser, pretty printer and type checker, targets PostGreSQL SQL and PL/pgSQL, uses Parsec and UUAGC.+License: BSD3+License-file: LICENSE+Author: Jake Wheat+Maintainer: jakewheatmail@gmail.com+Build-Type: Simple+Cabal-Version: >=1.2+copyright: Copyright 2009 Jake Wheat+stability: pre-alpha+homepage: https://launchpad.net/hssqlppp+bug-reports: mailto:jakewheatmail@gmail.com+category: Database++extra-source-files: README,+ TODO,+ development,+ questions,+ usage,+ LICENSE+Library+ Build-Depends: base >= 3 && < 5,+ mtl,+ parsec >= 3,+ pretty,+ containers+ Exposed-modules: Database.HsSqlPpp.Parser,+ Database.HsSqlPpp.PrettyPrinter,+ Database.HsSqlPpp.Ast+++Executable HsSqlSystem+ Main-is: HsSqlSystem.lhs+ Build-Depends: base,+ haskell98,+ regex-posix,+ HDBC,+ HDBC-postgresql,+ directory+ Other-Modules: Database.HsSqlPpp.Parser, Database.HsSqlPpp.PrettyPrinter++Executable Tests+ Main-is: Tests.lhs+ Build-Depends: base,+ HUnit,+ test-framework,+ test-framework-hunit++ Other-Modules: Database.HsSqlPpp.Parser, Database.HsSqlPpp.PrettyPrinter
+ questions view
@@ -0,0 +1,88 @@+here are some queries that need investigating, and possibly posted to+the appropriate mailing list.++= haskell questions++generating the default scope, the layout is awful when saved to a+file. Is there an easy way to Show this value, with nice formatting?+Is there a better way to serialize this value rather than as a haskell+source file?++= ghc questions++getting+ghc: panic! (the 'impossible' happened)+ (GHC version 6.10.4 for i386-unknown-linux):+ linkBCO: >= 64k insns in BCO++Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug++when compiling defaultscope with -Wall, put together a bug report or+something.++-----+getting segmentation fault when trying to run code with profiling on+- ghc --make -prof -auto-all HsSqlSystem.lhs +RTS -K64M+then run ./HsSqlSystem++= cabal++when tried to install profiling, is there a short cut to reinstall all+the dependent libs with the profiling option on, had to do this one or+two libs at a time and it took ages.++after cabal stop complaining about libs without profiling on, tried to+build the code and got errors like HSHunit_p library not found, this+was fixed by re-cabal installing some libraries with profiling on that+cabal had missed - why did it pick up on some libs, and not others?++= uuagc++compare with aspectag - what are the upsides/downsides? Hypothetically+speaking, could ehc be changed to use aspectag, if not, what are the+limitations which would prevent this?++= postgresql questions++is a null literal treated as a unknown string for the purposes of+function resolution, resultset resolution, etc.?++how does the function resolution work for polymorphic functions++what situations can an empty array type check successfully, and when+is it rejected.++is it possible to create a full view of all the casts that are used in+implicit, etc., resolution, i.e. including the ones that aren't in pg_cast++is it correct to use the resolve result set type algo when determining+the type of common fields in a natural or using join?++looking at postgresql-doc-8.4/html/query-path.html, it is unclear+where type checking occurs - is it mainly in a separate stage, or+intermingled in with the other stages++is the way the keyword operators are typed correct (using the function+call match algo to sort the implicit casts)?++how does the parser handle parsing operators without knowing whether+they are prefix, postfix or binary until later++when is the b_expr parser used (should just need a grep over the+grammar file)++is the handling of between, coalesce, greatest, and least correct+(delegating the checks to <= operators or whatever, coalesce uses+resultsetresolution)++why doesn't this work:+select+ att.oid,+ cls.oid,+ cls.relkind,+ cls.relname,+ att.typname+ from pg_type att+ inner join pg_class cls using(oid);++-- column "oid" specified in USING clause does not exist in left table
+ usage view
@@ -0,0 +1,173 @@+Here are some notes on what you can currently do with the code:++= HsSqlSystem++Command line access to a number of functions is provided by+HsSqlSystem.lhs. You can list the commands using './HsSqlSystem.lhs+help', and you can get the descriptions of what these commands do+using './HsSqlSystem.lhs help all'.++The commands which access postgresql probably won't work right on your+system, they are in a very early alpha state.++The most interesting commands are:+* parsefile+* roundtripfile, loadsql+* showinfodb++== parsefile++Pass in one or more filenames for files containing sql source, and the+program will attempt to parse, then pretty print and reparse to see if+the two asts are the same. This can be used to check the program can+successfully parse your sql, and if pretty printing then parsing the+result mangles it - lack of such mangling might give you slightly more+confidence that it has parsed ok.++== roundtripfile, loadsql++Similar to parse file, pass in a source filename and a target+filename, and the code with parse then pretty print the text. You can+then load the pretty printed code into a database and run your test+suite to see if the code made it through the parsing and pretty+printing process ok, or you can just eyeball the resultant+sql.++The related command is loadsql, which will attempt to parse one or+more files then pretty print them line by line, loading each line+straight into a database to help with testing. This may be a bit more+fragile than using roundtripfile.++Loading the roundtripped sql into a database then running tests on it+will hopefully can give a bit more confidence that the sql has been+parsed accurately.++== showinfodb++This command will take a sql file, parse it, type check it and then+pretty print the lines interspersed with comments containing some+information for each command, either type errors, or some other+information tailored to the statement type (e.g. create function shows+function prototype, create view shows column names and types in view).++You pass a database in as the first arg, and it type checks against+the catalog of that database. It currently doesn't type check against+definitions given in the same file though, which is a bit of a+limitation, but you can load the sql files into pg first, then type+check and see types for some views, functions, etc..++some example output of showinfodb:++/*+RelvarInfo ("base_relvar_attributes",ViewComposite,SetOfType (UnnamedCompositeType [("attribute_name",ScalarType "name"),("type_name",ScalarType "name"),("relvar_name",ScalarType "name")]))*/++create view base_relvar_attributes as+ select attname as attribute_name,typname as type_name,relname as relvar_name+ from pg_attribute+ inner join pg_class on (attrelid = pg_class.oid)+ inner join pg_type on (atttypid = pg_type.oid)+ inner join base_relvars on (relname = base_relvars.relvar_name)+ where (attnum >= 1);++A pretty printer for the StatementInfo type is planned, to make this+comment more readable.+++== reasonably up to date output of './HsSqlSystem.lhs help all'++commands available+use 'help' to see a list of commands+use 'help all' to see a list of commands with descriptions+use 'help [command]' to see the description for that command++cleardb+hacky util to clear a database++loadsql+This takes one or more files with sql source text, parses them then+loads them into the database given.++clearandloadsql+cleardb then loadsql++lexfile+lex the file given and output the tokens on separate lines++showFileAtts+run the ag over the given files and return all the attributes computed++parsefile+Routine to parse sql from a file, check that it appears to parse ok,+that pretty printing it and parsing that text gives the same ast, and+then displays the pretty printed version so you can see how well it's+done++roundtripfile+Used to test the parsing and pretty printing round trip. Takes two+arguments, a source filename and a target filename. If the target file+exists, it quits. Parses the source file then pretty prints it to the+target filename.++getscope+read the catalogs for the given db and dump a scope variable source+text to stdout++showtypes+reads each file, parses, type checks, then outputs the types+interspersed with the pretty printed statements++showtypesdb+pass the name of a database first, then filenames, reads each file,+parses, type checks, then outputs the types interspersed with the+pretty printed statements, will type check against the given database+schema++showinfo+reads each file, parses, type checks, then outputs info on each+statement interspersed with the pretty printed statements++showinfodb+pass the name of a database first, then filenames, reads each file,+parses, type checks, then outputs info on each statement interspersed+with the pretty printed statements, will type check against the given+database schema+++================================================================================++= Using ghci++by loading different files into ghci, you can try commands out+interactively, here are some highlights:++load Parser.lhs, use parseSql:++Prelude Parser> parseSql "select a from b;"+Right [(("",1,1),SelectStatement (Select Dupes (SelectList [SelExp (Identifier "a")] []) (Just (Tref "b")) Nothing [] Nothing [] Asc Nothing Nothing))]+Prelude Parser> parseSql "select a b c from d;"+Left +---------------------+(line 1, column 10):+unexpected IdStringTok "b"+expecting operator+FILENAMESTUFF:+:1:10+------------+Check it out:+select a b c from d;+ ^+ERROR HERE++-----------------++load AstCheckTests.lhs, use parseAndGetType:++*AstCheckTests> parseAndGetType "select * from pg_attribute inner join pg_type on pg_attribute.atttypid = pg_type.oid;"+[SetOfType (UnnamedCompositeType [("attrelid",ScalarType "oid"),("attname",ScalarType "name"),("atttypid",ScalarType "oid"),("attstattarget",ScalarType "int4"),("attlen",ScalarType "int2"),("attnum",ScalarType "int2"),("attndims",ScalarType "int4"),("attcacheoff",ScalarType "int4"),("atttypmod",ScalarType "int4"),("attbyval",ScalarType "bool"),("attstorage",ScalarType "char"),("attalign",ScalarType "char"),("attnotnull",ScalarType "bool"),("atthasdef",ScalarType "bool"),("attisdropped",ScalarType "bool"),("attislocal",ScalarType "bool"),("attinhcount",ScalarType "int4"),("attacl",ArrayType (ScalarType "aclitem")),("typname",ScalarType "name"),("typnamespace",ScalarType "oid"),("typowner",ScalarType "oid"),("typlen",ScalarType "int2"),("typbyval",ScalarType "bool"),("typtype",ScalarType "char"),("typcategory",ScalarType "char"),("typispreferred",ScalarType "bool"),("typisdefined",ScalarType "bool"),("typdelim",ScalarType "char"),("typrelid",ScalarType "oid"),("typelem",ScalarType "oid"),("typarray",ScalarType "oid"),("typinput",ScalarType "regproc"),("typoutput",ScalarType "regproc"),("typreceive",ScalarType "regproc"),("typsend",ScalarType "regproc"),("typmodin",ScalarType "regproc"),("typmodout",ScalarType "regproc"),("typanalyze",ScalarType "regproc"),("typalign",ScalarType "char"),("typstorage",ScalarType "char"),("typnotnull",ScalarType "bool"),("typbasetype",ScalarType "oid"),("typtypmod",ScalarType "int4"),("typndims",ScalarType "int4"),("typdefaultbin",ScalarType "text"),("typdefault",ScalarType "text")])]++================================================================================++= run the automated tests++To run the test suite run ./Tests.lhs. This will run the tests for parsing+and pretty printing, and for type checking.