HXQ (empty) → 0.1
raw patch · 28 files changed
+7606/−0 lines, 28 filesdep +basedep +haskell98dep +template-haskellsetup-changed
Dependencies added: base, haskell98, template-haskell
Files
- HXQ.cabal +43/−0
- LICENSE +5/−0
- Main.hs +31/−0
- Makefile +19/−0
- Setup.lhs +5/−0
- XQuery.hs +437/−0
- XQueryParser.hs +3931/−0
- XQueryParser.y +383/−0
- data/cs.xml +618/−0
- hxml-0.2/00-LICENSE.txt +22/−0
- hxml-0.2/00-README.txt +57/−0
- hxml-0.2/Arrow.hs +194/−0
- hxml-0.2/AssocList.hs +56/−0
- hxml-0.2/DTD.hs +218/−0
- hxml-0.2/ETree.hs +44/−0
- hxml-0.2/Filter.hs +82/−0
- hxml-0.2/HXML.hs +38/−0
- hxml-0.2/LLParsing.hs +110/−0
- hxml-0.2/Misc.hs +60/−0
- hxml-0.2/NTree.hs +84/−0
- hxml-0.2/PrintXML.hs +91/−0
- hxml-0.2/Tree.hs +73/−0
- hxml-0.2/TreeBuild.hs +69/−0
- hxml-0.2/XML.hs +102/−0
- hxml-0.2/XMLCombinators.hs +182/−0
- hxml-0.2/XMLParse.hs +278/−0
- hxml-0.2/XMLScanner.hs +269/−0
- index.html +105/−0
+ HXQ.cabal view
@@ -0,0 +1,43 @@+Name: HXQ+Version: 0.1+Description: A Compiler from XQuery to Haskell+Synopsis: A Compiler from XQuery to Haskell+Category: XML+build-type: Simple+License-file: LICENSE+License: GPL+Author: Leonidas Fegaras+Maintainer: fegaras@cse.uta.edu+Homepage: http://lambda.uta.edu/HXQ/+extra-source-files:+ Makefile+ index.html+ data/cs.xml+ XQuery.hs+ XQueryParser.hs+ XQueryParser.y+ hxml-0.2/Arrow.hs+ hxml-0.2/LLParsing.hs+ hxml-0.2/XML.hs+ hxml-0.2/AssocList.hs+ hxml-0.2/Misc.hs+ hxml-0.2/XMLParse.hs+ hxml-0.2/DTD.hs+ hxml-0.2/NTree.hs+ hxml-0.2/XMLScanner.hs+ hxml-0.2/ETree.hs+ hxml-0.2/PrintXML.hs+ hxml-0.2/Filter.hs+ hxml-0.2/TreeBuild.hs+ hxml-0.2/Tree.hs+ hxml-0.2/HXML.hs+ hxml-0.2/XMLCombinators.hs+ hxml-0.2/00-LICENSE.txt+ hxml-0.2/00-README.txt++Build-Depends: base, haskell98, template-haskell++Executable: xquery+Main-is: Main.hs+ghc-options: -ihxml-0.2+
+ LICENSE view
@@ -0,0 +1,5 @@+Copyright (c) 2008 by Leonidas Fegaras, the University of Texas at Arlington. All rights reserved.+This material is provided as is, with absolutely no warranty expressed or implied.+Any use is at your own risk. Permission is hereby granted to use or copy this program+for any purpose, provided the above notices are retained on all copies.+
+ Main.hs view
@@ -0,0 +1,31 @@+{--------------------------------------------------------------+-+- The main program of the XQuery processor+- Programmer: Leonidas Fegaras (fegaras@cse.uta.edu)+- Date: 03/19/2008+-+---------------------------------------------------------------}++{-# OPTIONS_GHC -fth #-}+module Main where++import XQuery++f(d,s) = $(xe "<student dept='{$d/text()}'>{$s//firstname/text(),' ',$s//lastname/text()}</student>")++main = do a <- $(xq (" for $s in doc('data/cs.xml')//gradstudent "+ ++" orderby $s/gpa descending, $s//lastname "+ ++" return <student>{$s//firstname/text(),' ', "+ ++" $s//lastname/text(),' ', "+ ++" $s/gpa/text()}</student> "))+ putStrLn (show a)+ let query name = $(xq " doc('data/cs.xml')//gradstudent[.//lastname = $name]//firstname ")+ b <- query $(xe " 'Galanis' ") -- or use: query [XText "Galanis"]+ putStrLn (show b)+ c <- $(xq (" <good-students>{ "+ ++" let $d := doc('data/cs.xml') "+ ++" for $s in $d//gradstudent "+ ++" where $s/gpa = '4.0' "+ ++" return f($d//deptname,$s) "+ ++" }</good-students> "))+ putStrLn (show c)
+ Makefile view
@@ -0,0 +1,19 @@+hxml = hxml-0.2+options = -O+runopt = +RTS -S -RTS++xquery: XQueryParser.hs XQuery.hs Main.hs+ ghc $(options) -i${hxml} --make Main.hs -o xquery++XQueryParser.hs: XQueryParser.y+ happy -g -c XQueryParser.y++run: xquery+ ./xquery $(runopt)++test: XQueryParser.hs+ ghci -fth -i${hxml} XQuery.hs XQueryParser.hs++clean:+ /bin/rm -f *~ *.o *.hi XQueryParser.hs *.stat *.prof *.ps *.aux *.hp xquery+
+ Setup.lhs view
@@ -0,0 +1,5 @@+#! /usr/bin/env runhaskell+ +> import Distribution.Simple+> main = defaultMain+
+ XQuery.hs view
@@ -0,0 +1,437 @@+{-------------------------------------------------------------------------------------+-+- A Compiler from XQuery to Haskell+- Programmer: Leonidas Fegaras+- Email: fegaras@cse.uta.edu+- Web: http://lambda.uta.edu/+- Creation: 02/15/08, last update: 03/20/08+- +- Copyright (c) 2008 by Leonidas Fegaras, the University of Texas at Arlington. All rights reserved.+- This material is provided as is, with absolutely no warranty expressed or implied.+- Any use is at your own risk. Permission is hereby granted to use or copy this program+- for any purpose, provided the above notices are retained on all copies.+-+--------------------------------------------------------------------------------------}+++{-# OPTIONS_GHC -fth #-}++module XQuery (+ XTree(..), XSeq, xq, xe, cq+ ) where++import Char(isDigit)+import List(sortBy)+import XMLParse(XMLEvent(..),parseDocument)+import HXML(AttList)+import Language.Haskell.TH+import XQueryParser+++{--------------- XML Trees (rose trees) ----------------------------------------------}++type Stream = [XMLEvent]++type Tag = String++data XTree = XElem Tag AttList [XTree]+ | XText String+ | XInt Int+ | XFloat Float+ deriving Eq++type XSeq = [XTree]+++showAL :: AttList -> String+showAL = foldr(\(a,v) r -> " "++a++"=\'"++v++"\'"++r) []++showXT :: XTree -> String+showXT (XElem tag al xs) = "<"++tag++(showAL al)++">"++(showXS xs)++"</"++tag++">"+showXT (XText text) = text+showXT (XInt n) = " "++(show n)+showXT (XFloat n) = " "++(show n)++showXS :: XSeq -> String+showXS xs = concat (map showXT xs)++instance Show XTree where+ show t = showXT t+++-- lazily materialize the SAX stream into a DOM tree+materialize :: Stream -> XTree+materialize stream = XElem "root" [] [head (filter (\x -> case x of XElem _ _ _ -> True; _ -> False)+ (fst (ml stream)))]+ where m ((TextEvent t):xs) = (XText t,xs)+ m ((EmptyEvent n atts):xs) = (XElem n atts [],xs)+ m ((StartEvent n atts):xs) = let (el,xs') = ml xs+ in (XElem n atts el,xs')+ m (_:xs) = (XText "unrecognized",xs)+ m [] = (XText "unrecognized",[])+ ml ((EndEvent n):xs) = ([],xs)+ ml xs = let (e,xs') = m xs+ (el,xs'') = ml xs'+ in (e:el,xs'')+++{--------------- XPath Steps ---------------------------------------------------------}+++-- XPath step /tag or /*+child :: Tag -> XTree -> XSeq+child m x = case x of+ (XElem _ _ bs) -> foldr (\b s -> case b of+ (XElem k _ _) | (k==m || m=="*") -> b:s+ _ -> s) [] bs+ _ -> []+++-- XPath step //tag or //*+descendant :: Tag -> XTree -> XSeq+descendant m (x@(XElem t al cs)) | m==t || m=="*" = x:(concat (map (descendant m) cs))+descendant m (XElem t al cs) = concat (map (descendant m) cs)+descendant m _ = []+++-- XPath step /@attr or /@*+attribute :: Tag -> XTree -> XSeq+attribute m x = case x of+ (XElem _ al _) -> foldr (\(k,v) s -> if k==m || m=="*"+ then (XText v):s+ else s) [] al+ _ -> []+++-- XPath step //@attr or //@*+attributeDescendant :: Tag -> XTree -> XSeq+attributeDescendant m (x@(XElem _ al cs))+ = foldr (\(k,v) s -> if k==m || m=="*"+ then (XText v):s+ else s)+ (concat (map (attributeDescendant m) cs)) al+attributeDescendant m _ = []+++{------------ Functions --------------------------------------------------------------}+++-- like foldr but with an index+foldir :: (a -> Int -> b -> b) -> b -> [a] -> Int -> b+foldir c n [] i = n+foldir c n (x:xs) i = c x i (foldir c n xs (i+1))++trueXT = XText "true"++toString :: XSeq -> [String]+toString xs = foldr (\x r -> case x of+ XElem _ _ [XText t] -> t:r+ XText t -> t:r+ XInt n -> (show n):r+ XFloat n -> (show n):r+ _ -> r) [] xs++readNum :: String -> Maybe XTree+readNum cs = case span isDigit cs of+ (n,[]) -> Just (XInt (read n))+ (n,'.':rest) -> case span isDigit rest of+ (k,[]) -> Just (XFloat (read (n++('.':k))))+ _ -> Nothing+ _ -> Nothing++toNum :: XSeq -> XSeq+toNum xs = foldr (\x r -> case x of+ XElem _ _ [XText s]+ -> case readNum s of+ Just t -> t:r+ _ -> r+ XInt n -> x:r+ XFloat n -> x:r+ XText s -> case readNum s of+ Just t -> t:r+ _ -> r+ _ -> r) [] xs++text :: XSeq -> XSeq+text xs = foldr (\x r -> case x of+ XElem _ _ [z@(XText _)] -> z:r+ XElem _ _ [z@(XInt _)] -> z:r+ XElem _ _ [z@(XFloat _)] -> z:r+ XText _ -> x:r+ XInt _ -> x:r+ XFloat _ -> x:r+ _ -> r) [] xs++toFloat :: XTree -> Float+toFloat (XInt n) = fromIntegral n+toFloat (XFloat n) = n++contains :: String -> String -> Bool+contains xs ys | ((take (length ys) xs) == ys) = True+contains (_:xs) ys = contains xs ys+contains [] ys = False++distinct :: XSeq -> XSeq+distinct = foldl (\r a -> if elem a r then r else r++[a]) []++arithmetic :: (Float -> Float -> Float) -> XTree -> XTree -> XTree+arithmetic op (XInt n) (XInt m) = XInt (round (op (fromIntegral n) (fromIntegral m)))+arithmetic op (XFloat n) (XFloat m) = XFloat (op n m)+arithmetic op (XFloat n) (XInt m) = XFloat (op n (fromIntegral m))+arithmetic op (XInt n) (XFloat m) = XFloat (op (fromIntegral n) m)++compareXTrees :: XTree -> XTree -> Ordering+compareXTrees (XElem _ _ _) _ = EQ+compareXTrees _ (XElem _ _ _) = EQ+compareXTrees (XInt n) (XInt m) = compare n m+compareXTrees (XFloat n) (XInt m) = compare n (fromIntegral m)+compareXTrees (XInt n) (XFloat m) = compare (fromIntegral n) m+compareXTrees (XFloat n) (XFloat m) = compare n m+compareXTrees x y = let tx = case x of XText t -> t; XInt n -> show n; XFloat n -> show n+ ty = case y of XText t -> t; XInt n -> show n; XFloat n -> show n+ in compare tx ty++compareXSeqs :: Bool -> XSeq -> XSeq -> Ordering+compareXSeqs ord xs ys+ = let comps = [ compareXTrees x y | x <- xs, y <- ys ]+ in if ord+ then if all (\x -> x == LT) comps+ then LT+ else if all (\x -> x == GT) comps+ then GT+ else EQ+ else if all (\x -> x == LT) comps+ then GT+ else if all (\x -> x == GT) comps+ then LT+ else EQ+++type Function = [Q Exp] -> Q Exp++functions :: [(Tag,Int,Function)]+functions = [ ( "=", 2, \[xs,ys] -> [| [ trueXT | x <- text $xs, y <- text $ys, x == y ] |] ),+ ( "==", 2, \[xs,ys] -> [| [ trueXT | x <- $xs, y <- $ys, x == y ] |] ),+ ( "!=", 2, \[xs,ys] -> [| if null [ trueXT | x <- text $xs, y <- text $ys, x == y ] then [trueXT] else [] |] ),+ ( ">", 2, \[xs,ys] -> [| [ trueXT | x <- toNum $xs, y <- toNum $ys, compareXTrees x y == GT ] |] ),+ ( "<", 2, \[xs,ys] -> [| [ trueXT | x <- toNum $xs, y <- toNum $ys, compareXTrees x y == LT ] |] ),+ ( ">=", 2, \[xs,ys] -> [| [ trueXT | x <- toNum $xs, y <- toNum $ys, compareXTrees x y `elem` [GT,EQ] ] |] ),+ ( "<=", 2, \[xs,ys] -> [| [ trueXT | x <- toNum $xs, y <- toNum $ys, compareXTrees x y `elem` [LT,EQ] ] |] ),+ ( "+", 2, \[xs,ys] -> [| [ arithmetic (+) x y | x <- toNum $xs, y <- toNum $ys ] |] ),+ ( "-", 2, \[xs,ys] -> [| [ arithmetic (-) x y | x <- toNum $xs, y <- toNum $ys ] |] ),+ ( "*", 2, \[xs,ys] -> [| [ arithmetic (*) x y | x <- toNum $xs, y <- toNum $ys ] |] ),+ ( "div", 2, \[xs,ys] -> [| [ arithmetic (/) x y | x <- toNum $xs, y <- toNum $ys ] |] ),+ ( "idiv", 2, \[xs,ys] -> [| [ arithmetic div x y | x <- toNum $xs, y <- toNum $ys ] |] ),+ ( "uplus", 1, \[xs] -> [| [ x | x <- toNum $xs ] |] ),+ ( "uminus", 1, \[xs] -> [| [ case x of XInt n -> XInt (-n); XFloat n -> XFloat (-n) | x <- toNum $xs ] |] ),+ ( "and", 2, \[xs,ys] -> [| if (null $xs) || (null $ys) then [] else [trueXT] |] ),+ ( "or", 2, \[xs,ys] -> [| if (null $xs) && (null $ys) then [] else [trueXT] |] ),+ ( "not", 1, \[xs] -> [| if (null $xs) then [trueXT] else [] |] ),+ ( "some", 1, \[xs] -> [| if (null $xs) then [] else [trueXT] |] ),+ ( "count", 1, \[xs] -> [| [ XInt (length $xs) ] |] ),+ ( "sum", 1, \[xs] -> [| [ XFloat (sum [ toFloat x | x <- toNum $xs ]) ] |] ),+ ( "avg", 1, \[xs] -> [| let ys = $xs in [ XFloat ((sum [ toFloat x | x <- toNum ys ])+ / (fromIntegral (length ys))) ] |] ),+ ( "min", 1, \[xs] -> [| [ XFloat (minimum [ toFloat x | x <- toNum $xs ]) ] |] ),+ ( "max", 1, \[xs] -> [| [ XFloat (maximum [ toFloat x | x <- toNum $xs ]) ] |] ),+ ( "to", 2, \[xs,ys] -> [| [ XInt i | XInt n <- toNum $xs, XInt m <- toNum $ys, i <- [n..m] ] |] ),+ ( "text", 1, \[xs] -> [| text $xs |] ),+ ( "node", 1, \[xs] -> [| $xs |] ),+ ( "empty", 0, \[] -> [| [] |] ),+ ( "child", 2, \[tags,xs] -> [| [ z | (XText tag) <- $tags, x <- $xs, z <- child tag x ] |] ),+ ( "descendant", 2, \[tags,xs] -> [| [ z | (XText tag) <- $tags, x <- $xs, z <- descendant tag x ] |] ),+ ( "attribute", 2, \[tags,xs] -> [| [ z | (XText tag) <- $tags, x <- $xs, z <- attribute tag x ] |] ),+ ( "descendant_attribute", 2, \[tags,xs] -> [| [ z | (XText tag) <- $tags, x <- $xs,+ z <- attributeDescendant tag x ] |] ),+ ( "if", 3, \[cs,ts,es] -> [| if null $cs then $es else $ts |] ),+ ( "element", 2, \[tags,xs] -> [| [ x | tag <- toString $tags, x <- $xs,+ case x of XElem t _ _ -> t==tag || tag=="*"; _ -> False ] |] ),+ ( "attribute", 2, \[tags,xs] -> [| [ z | tag <- toString $tags, x <- $xs, z <- attribute tag x ] |] ),+ ( "contains", 2, \[xs,text] -> [| [ trueXT | x <- toString $xs, t <- toString $text, contains x t ] |] ),+ ( "concat", 2, \[xs,ys] -> [| $xs ++ $ys |] ),+ ( "distinct-nodes", 1, \[xs] -> [| distinct $xs |] ),+ ( "union", 2, \[xs,ys] -> [| distinct ($xs ++ $ys) |] ),+ ( "intersect", 2, \[xs,ys] -> [| filter (\x -> elem x $ys) $xs |] ),+ ( "except", 2, \[xs,ys] -> [| filter (\x -> not (elem x $ys)) $xs |] )+ ]+++-- make a function call+callF :: Tag -> Function+callF fname args = case filter (\(n,_,_) -> n==fname) functions of+ (_,len,f):_ -> if (length args) == len+ then f args+ else error ("wrong number of arguments in function call: " ++ fname)+ _ -> -- otherwise, it must be a Haskell function of type (XSeq,...,XSeq) -> XSeq+ let itp = foldr (\_ r -> appT r [t| XSeq |] ) (appT (tupleT (length args)) [t| XSeq |]) (tail args)+ fn = sigE (varE (mkName fname))+ (appT (appT arrowT itp) [t| XSeq |])+ in appE fn (tupE args)+++{------------ Optimizer --------------------------------------------------------------}+++-- get rid of backward steps+optimize :: Ast -> Ast+-- rule: x/tag/.. -> x[tag]+optimize (Ast "call" [Avar "parent",Ast "call" [Avar "child",tag,x]])+ = Ast "predicate" [Ast "call" [Avar "child",tag,Avar "."],optimize x]+-- rule: x//tag/.. -> x//*[tag]+optimize (Ast "call" [Avar "parent",Ast "call" [Avar "descendant",tag,x]])+ = Ast "predicate" [Ast "call" [Avar "child",tag,Avar "."],+ Ast "call" [Avar "descendant",Astring "*",optimize x]]+-- needs more rules+optimize (Ast n args) = Ast n (map optimize args)+optimize e = e+++{------------ Compiler ---------------------------------------------------------------}+++-- does the expression contain a last()?+containsLast :: Ast -> Bool+containsLast (Ast "call" [Avar "last"]) = True+containsLast (Ast f _) | elem f ["let","for","predicate"] = False+containsLast (Ast _ args) = or (map containsLast args)+containsLast _ = False+++-- Compile the AST e into Haskell code+-- context: context node+-- index: the element position in the parent sequence (=position())+-- seqSize: the seqSize of the parent sequence (=last())+compile :: Ast -> Q Exp -> Q Exp -> Q Exp -> Q Exp+compile e context index seqSize+ = case e of+ Avar "." -> context+ Avar v -> let x = varE (mkName v)+ in [| $x :: XSeq |]+ Aint n -> let x = litE (IntegerL (toInteger n))+ in [| [ XInt $x ] |]+ Afloat n -> let x = litE (RationalL (toRational n))+ in [| [ XFloat $x ] |]+ Astring s -> let x = litE (StringL s)+ in [| [ XText $x ] |]+ Ast "doc" [Aint n] -> let d = varE (mkName ("_doc"++(show n)))+ in [| [ $d ] |]+ Ast "call" [Avar "position"]+ -> index+ Ast "call" [Avar "last"]+ -> seqSize+ Ast "call" ((Avar f):args)+ -> callF f (map (\x -> compile x context index seqSize) args)+ Ast "construction" [Astring tag,Ast "attributes" al,body]+ -> let alc = foldr (\p r -> case p of+ Ast "pair" [Astring a,Astring v]+ -> let ac = litE (StringL a)+ vc = litE (StringL v)+ in [| ($ac,$vc) : $r |]+ Ast "pair" [Astring a,v]+ -> let ac = litE (StringL a)+ vc = compile v context index seqSize+ in [| ($ac,showXS $vc) : $r |])+ [| [] |] al+ ct = litE (StringL tag)+ bc = compile body context index seqSize+ in [| [ XElem $ct $alc $bc ] |]+ Ast "predicate" [condition,body]+ | containsLast condition+ -> let c = compile condition+ b = compile body context index seqSize+ in [| let bl = $b+ in foldir (\x i r -> case $(c [| [ x ] |] [| [ XInt i ] |] [| [ XInt (length bl) ] |]) of+ [] -> r+ [XInt n] -> if i==n then x:r else r -- indexing+ _ -> x:r) [] bl 1 |]+ Ast "predicate" [condition,body]+ -> let c = compile condition+ b = compile body context index seqSize+ in [| foldir (\x i r -> case $(c [| [ x ] |] [| [ XInt i ] |] seqSize) of+ [] -> r+ [XInt n] -> if i==n then x:r else r -- indexing+ _ -> x:r) [] $b 1 |]+ Ast "let" [Avar var,source,body]+ -> do s <- compile source context index seqSize+ b <- compile body context index seqSize+ return (AppE (LamE [VarP (mkName var)] b) s)+ Ast "for" [Avar var,Avar "$",source,body]+ -> let b = compile body [| $(varE (mkName var)) |] [| [] |] [| [ XInt 0 ] |]+ f = lamE [varP (mkName var)] [| \x -> $b ++ x |]+ s = compile source context index seqSize+ in [| foldr (\x -> $f [x]) [] $s |]+ Ast "for" [Avar var,Avar ivar,source,body]+ -> let b = compile body [| $(varE (mkName var)) |]+ [| $(varE (mkName ivar)) |] [| [ XInt 0 ] |]+ f = lamE [varP (mkName var)] (lamE [varP (mkName ivar)] [| \x -> $b ++ x |])+ s = compile source context index seqSize+ in [| foldir (\x i -> $f [x] [XInt i]) [] $s 1 |]+ Ast "sortTuple" (exp:orderBys) -- prepare each FLWOR tuple for sorting+ -> let res = foldl (\r a -> let ac = compile a context index seqSize+ in [| $r++[text $ac] |] )+ [| [ $(compile exp context index seqSize) ] |] orderBys+ in [| [ $res ] |]+ Ast "sort" (exp:ordList)+ -> let ce = compile exp context index seqSize+ ordering = foldl (\r (Avar ord)+ -> let asc = if ord == "ascending"+ then [| True |]+ else [| False |]+ in [| \(x:xs) (y:ys) -> case compareXSeqs $asc x y of+ EQ -> $r xs ys+ o -> o |])+ [| \xs ys -> EQ |] ordList+ in [| concatMap head (sortBy (\(_:xs) (_:ys) -> $ordering xs ys) ($ce::[[XSeq]])) |]+ _ -> error ("Illegal XQuery "++(show e))+++-- collect all input documents and assign them a unique number+getDocs :: Ast -> Int -> (Ast, Int, [(Int, String)])+getDocs query count =+ case query of+ Ast "call" [Avar "doc",Astring file]+ -> (Ast "doc" [Aint count], count+1, [(count,file)])+ Ast n args -> let (s,c,ns) = foldr (\a r c -> let (e,c1,n1) = getDocs a c+ (s,c2,n2) = r c1+ in (e:s,c2,n1++n2))+ (\c -> ([],c,[])) args count+ in (Ast n s,c,ns)+ _ -> (query,count,[])+++-- compile an XQuery AST that reads XML documents+compileQuery :: Ast -> Q Exp -> Q Exp+compileQuery query context+ = let (ast,_,ns) = getDocs query 0+ code = compile (optimize ast) context [| [] |] [| [ XInt 0 ] |]+ in foldr (\(n,file) r -> let d = lamE [varP (mkName ("_doc"++(show n)))] r+ in [| do doc <- readFile $(litE (StringL file))+ let x = materialize (parseDocument doc)+ $d x+ |])+ [| return $code |] ns+++-- Display the AST and the Haskell code of an input XQuery+cq :: String -> IO ()+cq query = do putStrLn "Abstract Syntax Tree:"+ let ast = parse (scan query)+ putStrLn (show ast)+ let opt = optimize ast+ putStrLn "Optimized AST:"+ putStrLn (show opt)+ putStrLn "Haskell Code:"+ let code = compileQuery opt [| [] |]+ runQ code >>= putStrLn.pprint+++-- Run an XQuery expression that does not read XML documents+-- When evaluated, it returns XSeq+xe :: String -> Q Exp+xe query = compile (optimize (parse (scan query))) [| [] |] [| [] |] [| [ XInt 0 ] |]+++-- Run an XQuery that reads XML documents+-- When evaluated, it returns IO XSeq+xq :: String -> Q Exp+xq query = compileQuery (parse (scan query)) [| [] |]
+ XQueryParser.hs view
@@ -0,0 +1,3931 @@+{-# OPTIONS -fglasgow-exts -cpp #-}+module XQueryParser where+import Char+#if __GLASGOW_HASKELL__ >= 503+import GHC.Exts+#else+import GlaExts+#endif++-- parser produced by Happy Version 1.17++newtype HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25 = HappyAbsSyn HappyAny+#if __GLASGOW_HASKELL__ >= 607+type HappyAny = GHC.Exts.Any+#else+type HappyAny = forall a . a+#endif+happyIn4 :: t4 -> (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25)+happyIn4 x = unsafeCoerce# x+{-# INLINE happyIn4 #-}+happyOut4 :: (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25) -> t4+happyOut4 x = unsafeCoerce# x+{-# INLINE happyOut4 #-}+happyIn5 :: t5 -> (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25)+happyIn5 x = unsafeCoerce# x+{-# INLINE happyIn5 #-}+happyOut5 :: (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25) -> t5+happyOut5 x = unsafeCoerce# x+{-# INLINE happyOut5 #-}+happyIn6 :: t6 -> (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25)+happyIn6 x = unsafeCoerce# x+{-# INLINE happyIn6 #-}+happyOut6 :: (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25) -> t6+happyOut6 x = unsafeCoerce# x+{-# INLINE happyOut6 #-}+happyIn7 :: t7 -> (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25)+happyIn7 x = unsafeCoerce# x+{-# INLINE happyIn7 #-}+happyOut7 :: (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25) -> t7+happyOut7 x = unsafeCoerce# x+{-# INLINE happyOut7 #-}+happyIn8 :: t8 -> (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25)+happyIn8 x = unsafeCoerce# x+{-# INLINE happyIn8 #-}+happyOut8 :: (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25) -> t8+happyOut8 x = unsafeCoerce# x+{-# INLINE happyOut8 #-}+happyIn9 :: t9 -> (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25)+happyIn9 x = unsafeCoerce# x+{-# INLINE happyIn9 #-}+happyOut9 :: (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25) -> t9+happyOut9 x = unsafeCoerce# x+{-# INLINE happyOut9 #-}+happyIn10 :: t10 -> (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25)+happyIn10 x = unsafeCoerce# x+{-# INLINE happyIn10 #-}+happyOut10 :: (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25) -> t10+happyOut10 x = unsafeCoerce# x+{-# INLINE happyOut10 #-}+happyIn11 :: t11 -> (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25)+happyIn11 x = unsafeCoerce# x+{-# INLINE happyIn11 #-}+happyOut11 :: (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25) -> t11+happyOut11 x = unsafeCoerce# x+{-# INLINE happyOut11 #-}+happyIn12 :: t12 -> (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25)+happyIn12 x = unsafeCoerce# x+{-# INLINE happyIn12 #-}+happyOut12 :: (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25) -> t12+happyOut12 x = unsafeCoerce# x+{-# INLINE happyOut12 #-}+happyIn13 :: t13 -> (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25)+happyIn13 x = unsafeCoerce# x+{-# INLINE happyIn13 #-}+happyOut13 :: (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25) -> t13+happyOut13 x = unsafeCoerce# x+{-# INLINE happyOut13 #-}+happyIn14 :: t14 -> (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25)+happyIn14 x = unsafeCoerce# x+{-# INLINE happyIn14 #-}+happyOut14 :: (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25) -> t14+happyOut14 x = unsafeCoerce# x+{-# INLINE happyOut14 #-}+happyIn15 :: t15 -> (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25)+happyIn15 x = unsafeCoerce# x+{-# INLINE happyIn15 #-}+happyOut15 :: (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25) -> t15+happyOut15 x = unsafeCoerce# x+{-# INLINE happyOut15 #-}+happyIn16 :: t16 -> (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25)+happyIn16 x = unsafeCoerce# x+{-# INLINE happyIn16 #-}+happyOut16 :: (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25) -> t16+happyOut16 x = unsafeCoerce# x+{-# INLINE happyOut16 #-}+happyIn17 :: t17 -> (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25)+happyIn17 x = unsafeCoerce# x+{-# INLINE happyIn17 #-}+happyOut17 :: (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25) -> t17+happyOut17 x = unsafeCoerce# x+{-# INLINE happyOut17 #-}+happyIn18 :: t18 -> (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25)+happyIn18 x = unsafeCoerce# x+{-# INLINE happyIn18 #-}+happyOut18 :: (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25) -> t18+happyOut18 x = unsafeCoerce# x+{-# INLINE happyOut18 #-}+happyIn19 :: t19 -> (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25)+happyIn19 x = unsafeCoerce# x+{-# INLINE happyIn19 #-}+happyOut19 :: (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25) -> t19+happyOut19 x = unsafeCoerce# x+{-# INLINE happyOut19 #-}+happyIn20 :: t20 -> (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25)+happyIn20 x = unsafeCoerce# x+{-# INLINE happyIn20 #-}+happyOut20 :: (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25) -> t20+happyOut20 x = unsafeCoerce# x+{-# INLINE happyOut20 #-}+happyIn21 :: t21 -> (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25)+happyIn21 x = unsafeCoerce# x+{-# INLINE happyIn21 #-}+happyOut21 :: (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25) -> t21+happyOut21 x = unsafeCoerce# x+{-# INLINE happyOut21 #-}+happyIn22 :: t22 -> (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25)+happyIn22 x = unsafeCoerce# x+{-# INLINE happyIn22 #-}+happyOut22 :: (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25) -> t22+happyOut22 x = unsafeCoerce# x+{-# INLINE happyOut22 #-}+happyIn23 :: t23 -> (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25)+happyIn23 x = unsafeCoerce# x+{-# INLINE happyIn23 #-}+happyOut23 :: (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25) -> t23+happyOut23 x = unsafeCoerce# x+{-# INLINE happyOut23 #-}+happyIn24 :: t24 -> (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25)+happyIn24 x = unsafeCoerce# x+{-# INLINE happyIn24 #-}+happyOut24 :: (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25) -> t24+happyOut24 x = unsafeCoerce# x+{-# INLINE happyOut24 #-}+happyIn25 :: t25 -> (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25)+happyIn25 x = unsafeCoerce# x+{-# INLINE happyIn25 #-}+happyOut25 :: (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25) -> t25+happyOut25 x = unsafeCoerce# x+{-# INLINE happyOut25 #-}+happyInTok :: Token -> (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25)+happyInTok x = unsafeCoerce# x+{-# INLINE happyInTok #-}+happyOutTok :: (HappyAbsSyn t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 t25) -> Token+happyOutTok x = unsafeCoerce# x+{-# INLINE happyOutTok #-}+++action_0 (27#) = happyShift action_12+action_0 (28#) = happyShift action_13+action_0 (29#) = happyShift action_14+action_0 (34#) = happyShift action_15+action_0 (41#) = happyShift action_16+action_0 (42#) = happyShift action_17+action_0 (43#) = happyShift action_18+action_0 (49#) = happyShift action_19+action_0 (55#) = happyShift action_20+action_0 (59#) = happyShift action_21+action_0 (60#) = happyShift action_22+action_0 (68#) = happyShift action_23+action_0 (69#) = happyShift action_24+action_0 (73#) = happyShift action_25+action_0 (75#) = happyShift action_26+action_0 (78#) = happyShift action_27+action_0 (79#) = happyShift action_28+action_0 (81#) = happyShift action_29+action_0 (82#) = happyShift action_30+action_0 (83#) = happyShift action_31+action_0 (4#) = happyGoto action_32+action_0 (5#) = happyGoto action_2+action_0 (6#) = happyGoto action_3+action_0 (8#) = happyGoto action_4+action_0 (15#) = happyGoto action_5+action_0 (16#) = happyGoto action_6+action_0 (17#) = happyGoto action_7+action_0 (20#) = happyGoto action_8+action_0 (23#) = happyGoto action_9+action_0 (24#) = happyGoto action_10+action_0 (25#) = happyGoto action_11+action_0 x = happyTcHack x happyFail++action_1 (27#) = happyShift action_12+action_1 (28#) = happyShift action_13+action_1 (29#) = happyShift action_14+action_1 (34#) = happyShift action_15+action_1 (41#) = happyShift action_16+action_1 (42#) = happyShift action_17+action_1 (43#) = happyShift action_18+action_1 (49#) = happyShift action_19+action_1 (55#) = happyShift action_20+action_1 (59#) = happyShift action_21+action_1 (60#) = happyShift action_22+action_1 (68#) = happyShift action_23+action_1 (69#) = happyShift action_24+action_1 (73#) = happyShift action_25+action_1 (75#) = happyShift action_26+action_1 (78#) = happyShift action_27+action_1 (79#) = happyShift action_28+action_1 (81#) = happyShift action_29+action_1 (82#) = happyShift action_30+action_1 (83#) = happyShift action_31+action_1 (5#) = happyGoto action_2+action_1 (6#) = happyGoto action_3+action_1 (8#) = happyGoto action_4+action_1 (15#) = happyGoto action_5+action_1 (16#) = happyGoto action_6+action_1 (17#) = happyGoto action_7+action_1 (20#) = happyGoto action_8+action_1 (23#) = happyGoto action_9+action_1 (24#) = happyGoto action_10+action_1 (25#) = happyGoto action_11+action_1 x = happyTcHack x happyFail++action_2 x = happyTcHack x happyReduce_91++action_3 (40#) = happyShift action_61+action_3 (41#) = happyShift action_62+action_3 (42#) = happyShift action_63+action_3 (43#) = happyShift action_64+action_3 (44#) = happyShift action_65+action_3 (45#) = happyShift action_66+action_3 (46#) = happyShift action_67+action_3 (47#) = happyShift action_68+action_3 (48#) = happyShift action_69+action_3 (49#) = happyShift action_70+action_3 (50#) = happyShift action_71+action_3 (51#) = happyShift action_72+action_3 (52#) = happyShift action_73+action_3 (53#) = happyShift action_74+action_3 (54#) = happyShift action_75+action_3 (55#) = happyShift action_76+action_3 (56#) = happyShift action_77+action_3 (57#) = happyShift action_78+action_3 (58#) = happyShift action_79+action_3 x = happyTcHack x happyReduce_1++action_4 (59#) = happyShift action_58+action_4 (60#) = happyShift action_59+action_4 (64#) = happyShift action_60+action_4 (11#) = happyGoto action_57+action_4 x = happyTcHack x happyReduce_48++action_5 x = happyTcHack x happyReduce_9++action_6 x = happyTcHack x happyReduce_8++action_7 (51#) = happyShift action_55+action_7 (71#) = happyShift action_56+action_7 x = happyTcHack x happyFail++action_8 x = happyTcHack x happyReduce_7++action_9 (32#) = happyShift action_53+action_9 (74#) = happyShift action_54+action_9 (21#) = happyGoto action_51+action_9 (22#) = happyGoto action_52+action_9 x = happyTcHack x happyReduce_75++action_10 x = happyTcHack x happyReduce_86++action_11 x = happyTcHack x happyReduce_88++action_12 (79#) = happyShift action_28+action_12 (5#) = happyGoto action_39+action_12 (9#) = happyGoto action_50+action_12 x = happyTcHack x happyFail++action_13 (79#) = happyShift action_28+action_13 (5#) = happyGoto action_39+action_13 (9#) = happyGoto action_49+action_13 x = happyTcHack x happyFail++action_14 (27#) = happyShift action_12+action_14 (28#) = happyShift action_13+action_14 (29#) = happyShift action_14+action_14 (34#) = happyShift action_15+action_14 (41#) = happyShift action_16+action_14 (42#) = happyShift action_17+action_14 (43#) = happyShift action_18+action_14 (49#) = happyShift action_19+action_14 (55#) = happyShift action_20+action_14 (59#) = happyShift action_21+action_14 (60#) = happyShift action_22+action_14 (68#) = happyShift action_23+action_14 (69#) = happyShift action_24+action_14 (73#) = happyShift action_25+action_14 (75#) = happyShift action_26+action_14 (78#) = happyShift action_27+action_14 (79#) = happyShift action_28+action_14 (81#) = happyShift action_29+action_14 (82#) = happyShift action_30+action_14 (83#) = happyShift action_31+action_14 (5#) = happyGoto action_2+action_14 (6#) = happyGoto action_48+action_14 (8#) = happyGoto action_4+action_14 (15#) = happyGoto action_5+action_14 (16#) = happyGoto action_6+action_14 (17#) = happyGoto action_7+action_14 (20#) = happyGoto action_8+action_14 (23#) = happyGoto action_9+action_14 (24#) = happyGoto action_10+action_14 (25#) = happyGoto action_11+action_14 x = happyTcHack x happyFail++action_15 (27#) = happyShift action_12+action_15 (28#) = happyShift action_13+action_15 (29#) = happyShift action_14+action_15 (34#) = happyShift action_15+action_15 (35#) = happyShift action_47+action_15 (41#) = happyShift action_16+action_15 (42#) = happyShift action_17+action_15 (43#) = happyShift action_18+action_15 (49#) = happyShift action_19+action_15 (55#) = happyShift action_20+action_15 (59#) = happyShift action_21+action_15 (60#) = happyShift action_22+action_15 (68#) = happyShift action_23+action_15 (69#) = happyShift action_24+action_15 (73#) = happyShift action_25+action_15 (75#) = happyShift action_26+action_15 (78#) = happyShift action_27+action_15 (79#) = happyShift action_28+action_15 (81#) = happyShift action_29+action_15 (82#) = happyShift action_30+action_15 (83#) = happyShift action_31+action_15 (5#) = happyGoto action_2+action_15 (6#) = happyGoto action_45+action_15 (7#) = happyGoto action_46+action_15 (8#) = happyGoto action_4+action_15 (15#) = happyGoto action_5+action_15 (16#) = happyGoto action_6+action_15 (17#) = happyGoto action_7+action_15 (20#) = happyGoto action_8+action_15 (23#) = happyGoto action_9+action_15 (24#) = happyGoto action_10+action_15 (25#) = happyGoto action_11+action_15 x = happyTcHack x happyFail++action_16 (27#) = happyShift action_12+action_16 (28#) = happyShift action_13+action_16 (29#) = happyShift action_14+action_16 (34#) = happyShift action_15+action_16 (41#) = happyShift action_16+action_16 (42#) = happyShift action_17+action_16 (43#) = happyShift action_18+action_16 (49#) = happyShift action_19+action_16 (55#) = happyShift action_20+action_16 (59#) = happyShift action_21+action_16 (60#) = happyShift action_22+action_16 (68#) = happyShift action_23+action_16 (69#) = happyShift action_24+action_16 (73#) = happyShift action_25+action_16 (75#) = happyShift action_26+action_16 (78#) = happyShift action_27+action_16 (79#) = happyShift action_28+action_16 (81#) = happyShift action_29+action_16 (82#) = happyShift action_30+action_16 (83#) = happyShift action_31+action_16 (5#) = happyGoto action_2+action_16 (6#) = happyGoto action_44+action_16 (8#) = happyGoto action_4+action_16 (15#) = happyGoto action_5+action_16 (16#) = happyGoto action_6+action_16 (17#) = happyGoto action_7+action_16 (20#) = happyGoto action_8+action_16 (23#) = happyGoto action_9+action_16 (24#) = happyGoto action_10+action_16 (25#) = happyGoto action_11+action_16 x = happyTcHack x happyFail++action_17 (27#) = happyShift action_12+action_17 (28#) = happyShift action_13+action_17 (29#) = happyShift action_14+action_17 (34#) = happyShift action_15+action_17 (41#) = happyShift action_16+action_17 (42#) = happyShift action_17+action_17 (43#) = happyShift action_18+action_17 (49#) = happyShift action_19+action_17 (55#) = happyShift action_20+action_17 (59#) = happyShift action_21+action_17 (60#) = happyShift action_22+action_17 (68#) = happyShift action_23+action_17 (69#) = happyShift action_24+action_17 (73#) = happyShift action_25+action_17 (75#) = happyShift action_26+action_17 (78#) = happyShift action_27+action_17 (79#) = happyShift action_28+action_17 (81#) = happyShift action_29+action_17 (82#) = happyShift action_30+action_17 (83#) = happyShift action_31+action_17 (5#) = happyGoto action_2+action_17 (6#) = happyGoto action_43+action_17 (8#) = happyGoto action_4+action_17 (15#) = happyGoto action_5+action_17 (16#) = happyGoto action_6+action_17 (17#) = happyGoto action_7+action_17 (20#) = happyGoto action_8+action_17 (23#) = happyGoto action_9+action_17 (24#) = happyGoto action_10+action_17 (25#) = happyGoto action_11+action_17 x = happyTcHack x happyFail++action_18 x = happyTcHack x happyReduce_89++action_19 (75#) = happyShift action_42+action_19 x = happyTcHack x happyFail++action_20 (27#) = happyShift action_12+action_20 (28#) = happyShift action_13+action_20 (29#) = happyShift action_14+action_20 (34#) = happyShift action_15+action_20 (41#) = happyShift action_16+action_20 (42#) = happyShift action_17+action_20 (43#) = happyShift action_18+action_20 (49#) = happyShift action_19+action_20 (55#) = happyShift action_20+action_20 (59#) = happyShift action_21+action_20 (60#) = happyShift action_22+action_20 (68#) = happyShift action_23+action_20 (69#) = happyShift action_24+action_20 (73#) = happyShift action_25+action_20 (75#) = happyShift action_26+action_20 (78#) = happyShift action_27+action_20 (79#) = happyShift action_28+action_20 (81#) = happyShift action_29+action_20 (82#) = happyShift action_30+action_20 (83#) = happyShift action_31+action_20 (5#) = happyGoto action_2+action_20 (6#) = happyGoto action_41+action_20 (8#) = happyGoto action_4+action_20 (15#) = happyGoto action_5+action_20 (16#) = happyGoto action_6+action_20 (17#) = happyGoto action_7+action_20 (20#) = happyGoto action_8+action_20 (23#) = happyGoto action_9+action_20 (24#) = happyGoto action_10+action_20 (25#) = happyGoto action_11+action_20 x = happyTcHack x happyFail++action_21 (79#) = happyShift action_28+action_21 (5#) = happyGoto action_39+action_21 (9#) = happyGoto action_40+action_21 x = happyTcHack x happyFail++action_22 (79#) = happyShift action_28+action_22 (5#) = happyGoto action_37+action_22 (10#) = happyGoto action_38+action_22 x = happyTcHack x happyFail++action_23 (34#) = happyShift action_36+action_23 x = happyTcHack x happyFail++action_24 (34#) = happyShift action_35+action_24 x = happyTcHack x happyFail++action_25 (34#) = happyShift action_15+action_25 (43#) = happyShift action_18+action_25 (75#) = happyShift action_26+action_25 (78#) = happyShift action_27+action_25 (79#) = happyShift action_28+action_25 (5#) = happyGoto action_2+action_25 (23#) = happyGoto action_34+action_25 (24#) = happyGoto action_10+action_25 (25#) = happyGoto action_11+action_25 x = happyTcHack x happyFail++action_26 (34#) = happyShift action_33+action_26 x = happyTcHack x happyReduce_90++action_27 x = happyTcHack x happyReduce_92++action_28 x = happyTcHack x happyReduce_2++action_29 x = happyTcHack x happyReduce_33++action_30 x = happyTcHack x happyReduce_34++action_31 x = happyTcHack x happyReduce_32++action_32 (84#) = happyAccept+action_32 x = happyTcHack x happyFail++action_33 (27#) = happyShift action_12+action_33 (28#) = happyShift action_13+action_33 (29#) = happyShift action_14+action_33 (34#) = happyShift action_15+action_33 (35#) = happyShift action_131+action_33 (41#) = happyShift action_16+action_33 (42#) = happyShift action_17+action_33 (43#) = happyShift action_18+action_33 (49#) = happyShift action_19+action_33 (55#) = happyShift action_20+action_33 (59#) = happyShift action_21+action_33 (60#) = happyShift action_22+action_33 (68#) = happyShift action_23+action_33 (69#) = happyShift action_24+action_33 (73#) = happyShift action_25+action_33 (75#) = happyShift action_26+action_33 (78#) = happyShift action_27+action_33 (79#) = happyShift action_28+action_33 (81#) = happyShift action_29+action_33 (82#) = happyShift action_30+action_33 (83#) = happyShift action_31+action_33 (5#) = happyGoto action_2+action_33 (6#) = happyGoto action_45+action_33 (7#) = happyGoto action_130+action_33 (8#) = happyGoto action_4+action_33 (15#) = happyGoto action_5+action_33 (16#) = happyGoto action_6+action_33 (17#) = happyGoto action_7+action_33 (20#) = happyGoto action_8+action_33 (23#) = happyGoto action_9+action_33 (24#) = happyGoto action_10+action_33 (25#) = happyGoto action_11+action_33 x = happyTcHack x happyFail++action_34 (32#) = happyShift action_53+action_34 (74#) = happyShift action_54+action_34 (21#) = happyGoto action_129+action_34 (22#) = happyGoto action_52+action_34 x = happyTcHack x happyReduce_76++action_35 (75#) = happyShift action_128+action_35 x = happyTcHack x happyFail++action_36 (75#) = happyShift action_127+action_36 x = happyTcHack x happyFail++action_37 (63#) = happyShift action_126+action_37 x = happyTcHack x happyFail++action_38 (62#) = happyShift action_125+action_38 x = happyTcHack x happyReduce_38++action_39 (61#) = happyShift action_124+action_39 x = happyTcHack x happyFail++action_40 (62#) = happyShift action_116+action_40 x = happyTcHack x happyReduce_37++action_41 x = happyTcHack x happyReduce_31++action_42 (75#) = happyShift action_123+action_42 (19#) = happyGoto action_122+action_42 x = happyTcHack x happyReduce_61++action_43 x = happyTcHack x happyReduce_30++action_44 x = happyTcHack x happyReduce_29++action_45 (40#) = happyShift action_61+action_45 (41#) = happyShift action_62+action_45 (42#) = happyShift action_63+action_45 (43#) = happyShift action_64+action_45 (44#) = happyShift action_65+action_45 (45#) = happyShift action_66+action_45 (46#) = happyShift action_67+action_45 (47#) = happyShift action_68+action_45 (48#) = happyShift action_69+action_45 (49#) = happyShift action_70+action_45 (50#) = happyShift action_71+action_45 (51#) = happyShift action_72+action_45 (52#) = happyShift action_73+action_45 (53#) = happyShift action_74+action_45 (54#) = happyShift action_75+action_45 (55#) = happyShift action_76+action_45 (56#) = happyShift action_77+action_45 (57#) = happyShift action_78+action_45 (58#) = happyShift action_79+action_45 x = happyTcHack x happyReduce_35++action_46 (35#) = happyShift action_120+action_46 (62#) = happyShift action_121+action_46 x = happyTcHack x happyFail++action_47 x = happyTcHack x happyReduce_94++action_48 (30#) = happyShift action_119+action_48 (40#) = happyShift action_61+action_48 (41#) = happyShift action_62+action_48 (42#) = happyShift action_63+action_48 (43#) = happyShift action_64+action_48 (44#) = happyShift action_65+action_48 (45#) = happyShift action_66+action_48 (46#) = happyShift action_67+action_48 (47#) = happyShift action_68+action_48 (48#) = happyShift action_69+action_48 (49#) = happyShift action_70+action_48 (50#) = happyShift action_71+action_48 (51#) = happyShift action_72+action_48 (52#) = happyShift action_73+action_48 (53#) = happyShift action_74+action_48 (54#) = happyShift action_75+action_48 (55#) = happyShift action_76+action_48 (56#) = happyShift action_77+action_48 (57#) = happyShift action_78+action_48 (58#) = happyShift action_79+action_48 x = happyTcHack x happyFail++action_49 (62#) = happyShift action_116+action_49 (72#) = happyShift action_118+action_49 x = happyTcHack x happyFail++action_50 (62#) = happyShift action_116+action_50 (72#) = happyShift action_117+action_50 x = happyTcHack x happyFail++action_51 (74#) = happyShift action_54+action_51 (22#) = happyGoto action_115+action_51 x = happyTcHack x happyReduce_77++action_52 x = happyTcHack x happyReduce_79++action_53 (27#) = happyShift action_12+action_53 (28#) = happyShift action_13+action_53 (29#) = happyShift action_14+action_53 (34#) = happyShift action_15+action_53 (41#) = happyShift action_16+action_53 (42#) = happyShift action_17+action_53 (43#) = happyShift action_18+action_53 (49#) = happyShift action_19+action_53 (55#) = happyShift action_20+action_53 (59#) = happyShift action_21+action_53 (60#) = happyShift action_22+action_53 (68#) = happyShift action_23+action_53 (69#) = happyShift action_24+action_53 (73#) = happyShift action_25+action_53 (75#) = happyShift action_26+action_53 (78#) = happyShift action_27+action_53 (79#) = happyShift action_28+action_53 (81#) = happyShift action_29+action_53 (82#) = happyShift action_30+action_53 (83#) = happyShift action_31+action_53 (5#) = happyGoto action_2+action_53 (6#) = happyGoto action_114+action_53 (8#) = happyGoto action_4+action_53 (15#) = happyGoto action_5+action_53 (16#) = happyGoto action_6+action_53 (17#) = happyGoto action_7+action_53 (20#) = happyGoto action_8+action_53 (23#) = happyGoto action_9+action_53 (24#) = happyGoto action_10+action_53 (25#) = happyGoto action_11+action_53 x = happyTcHack x happyFail++action_54 (34#) = happyShift action_15+action_54 (43#) = happyShift action_18+action_54 (73#) = happyShift action_111+action_54 (74#) = happyShift action_112+action_54 (75#) = happyShift action_26+action_54 (77#) = happyShift action_113+action_54 (78#) = happyShift action_27+action_54 (79#) = happyShift action_28+action_54 (5#) = happyGoto action_2+action_54 (23#) = happyGoto action_110+action_54 (24#) = happyGoto action_10+action_54 (25#) = happyGoto action_11+action_54 x = happyTcHack x happyFail++action_55 (36#) = happyShift action_106+action_55 (49#) = happyShift action_19+action_55 (70#) = happyShift action_107+action_55 (80#) = happyShift action_108+action_55 (83#) = happyShift action_109+action_55 (16#) = happyGoto action_104+action_55 (17#) = happyGoto action_7+action_55 (18#) = happyGoto action_105+action_55 x = happyTcHack x happyFail++action_56 x = happyTcHack x happyReduce_60++action_57 (65#) = happyShift action_103+action_57 (12#) = happyGoto action_102+action_57 x = happyTcHack x happyReduce_50++action_58 (79#) = happyShift action_28+action_58 (5#) = happyGoto action_39+action_58 (9#) = happyGoto action_101+action_58 x = happyTcHack x happyFail++action_59 (79#) = happyShift action_28+action_59 (5#) = happyGoto action_37+action_59 (10#) = happyGoto action_100+action_59 x = happyTcHack x happyFail++action_60 (27#) = happyShift action_12+action_60 (28#) = happyShift action_13+action_60 (29#) = happyShift action_14+action_60 (34#) = happyShift action_15+action_60 (41#) = happyShift action_16+action_60 (42#) = happyShift action_17+action_60 (43#) = happyShift action_18+action_60 (49#) = happyShift action_19+action_60 (55#) = happyShift action_20+action_60 (59#) = happyShift action_21+action_60 (60#) = happyShift action_22+action_60 (68#) = happyShift action_23+action_60 (69#) = happyShift action_24+action_60 (73#) = happyShift action_25+action_60 (75#) = happyShift action_26+action_60 (78#) = happyShift action_27+action_60 (79#) = happyShift action_28+action_60 (81#) = happyShift action_29+action_60 (82#) = happyShift action_30+action_60 (83#) = happyShift action_31+action_60 (5#) = happyGoto action_2+action_60 (6#) = happyGoto action_99+action_60 (8#) = happyGoto action_4+action_60 (15#) = happyGoto action_5+action_60 (16#) = happyGoto action_6+action_60 (17#) = happyGoto action_7+action_60 (20#) = happyGoto action_8+action_60 (23#) = happyGoto action_9+action_60 (24#) = happyGoto action_10+action_60 (25#) = happyGoto action_11+action_60 x = happyTcHack x happyFail++action_61 (27#) = happyShift action_12+action_61 (28#) = happyShift action_13+action_61 (29#) = happyShift action_14+action_61 (34#) = happyShift action_15+action_61 (41#) = happyShift action_16+action_61 (42#) = happyShift action_17+action_61 (43#) = happyShift action_18+action_61 (49#) = happyShift action_19+action_61 (55#) = happyShift action_20+action_61 (59#) = happyShift action_21+action_61 (60#) = happyShift action_22+action_61 (68#) = happyShift action_23+action_61 (69#) = happyShift action_24+action_61 (73#) = happyShift action_25+action_61 (75#) = happyShift action_26+action_61 (78#) = happyShift action_27+action_61 (79#) = happyShift action_28+action_61 (81#) = happyShift action_29+action_61 (82#) = happyShift action_30+action_61 (83#) = happyShift action_31+action_61 (5#) = happyGoto action_2+action_61 (6#) = happyGoto action_98+action_61 (8#) = happyGoto action_4+action_61 (15#) = happyGoto action_5+action_61 (16#) = happyGoto action_6+action_61 (17#) = happyGoto action_7+action_61 (20#) = happyGoto action_8+action_61 (23#) = happyGoto action_9+action_61 (24#) = happyGoto action_10+action_61 (25#) = happyGoto action_11+action_61 x = happyTcHack x happyFail++action_62 (27#) = happyShift action_12+action_62 (28#) = happyShift action_13+action_62 (29#) = happyShift action_14+action_62 (34#) = happyShift action_15+action_62 (41#) = happyShift action_16+action_62 (42#) = happyShift action_17+action_62 (43#) = happyShift action_18+action_62 (49#) = happyShift action_19+action_62 (55#) = happyShift action_20+action_62 (59#) = happyShift action_21+action_62 (60#) = happyShift action_22+action_62 (68#) = happyShift action_23+action_62 (69#) = happyShift action_24+action_62 (73#) = happyShift action_25+action_62 (75#) = happyShift action_26+action_62 (78#) = happyShift action_27+action_62 (79#) = happyShift action_28+action_62 (81#) = happyShift action_29+action_62 (82#) = happyShift action_30+action_62 (83#) = happyShift action_31+action_62 (5#) = happyGoto action_2+action_62 (6#) = happyGoto action_97+action_62 (8#) = happyGoto action_4+action_62 (15#) = happyGoto action_5+action_62 (16#) = happyGoto action_6+action_62 (17#) = happyGoto action_7+action_62 (20#) = happyGoto action_8+action_62 (23#) = happyGoto action_9+action_62 (24#) = happyGoto action_10+action_62 (25#) = happyGoto action_11+action_62 x = happyTcHack x happyFail++action_63 (27#) = happyShift action_12+action_63 (28#) = happyShift action_13+action_63 (29#) = happyShift action_14+action_63 (34#) = happyShift action_15+action_63 (41#) = happyShift action_16+action_63 (42#) = happyShift action_17+action_63 (43#) = happyShift action_18+action_63 (49#) = happyShift action_19+action_63 (55#) = happyShift action_20+action_63 (59#) = happyShift action_21+action_63 (60#) = happyShift action_22+action_63 (68#) = happyShift action_23+action_63 (69#) = happyShift action_24+action_63 (73#) = happyShift action_25+action_63 (75#) = happyShift action_26+action_63 (78#) = happyShift action_27+action_63 (79#) = happyShift action_28+action_63 (81#) = happyShift action_29+action_63 (82#) = happyShift action_30+action_63 (83#) = happyShift action_31+action_63 (5#) = happyGoto action_2+action_63 (6#) = happyGoto action_96+action_63 (8#) = happyGoto action_4+action_63 (15#) = happyGoto action_5+action_63 (16#) = happyGoto action_6+action_63 (17#) = happyGoto action_7+action_63 (20#) = happyGoto action_8+action_63 (23#) = happyGoto action_9+action_63 (24#) = happyGoto action_10+action_63 (25#) = happyGoto action_11+action_63 x = happyTcHack x happyFail++action_64 (27#) = happyShift action_12+action_64 (28#) = happyShift action_13+action_64 (29#) = happyShift action_14+action_64 (34#) = happyShift action_15+action_64 (41#) = happyShift action_16+action_64 (42#) = happyShift action_17+action_64 (43#) = happyShift action_18+action_64 (49#) = happyShift action_19+action_64 (55#) = happyShift action_20+action_64 (59#) = happyShift action_21+action_64 (60#) = happyShift action_22+action_64 (68#) = happyShift action_23+action_64 (69#) = happyShift action_24+action_64 (73#) = happyShift action_25+action_64 (75#) = happyShift action_26+action_64 (78#) = happyShift action_27+action_64 (79#) = happyShift action_28+action_64 (81#) = happyShift action_29+action_64 (82#) = happyShift action_30+action_64 (83#) = happyShift action_31+action_64 (5#) = happyGoto action_2+action_64 (6#) = happyGoto action_95+action_64 (8#) = happyGoto action_4+action_64 (15#) = happyGoto action_5+action_64 (16#) = happyGoto action_6+action_64 (17#) = happyGoto action_7+action_64 (20#) = happyGoto action_8+action_64 (23#) = happyGoto action_9+action_64 (24#) = happyGoto action_10+action_64 (25#) = happyGoto action_11+action_64 x = happyTcHack x happyFail++action_65 (27#) = happyShift action_12+action_65 (28#) = happyShift action_13+action_65 (29#) = happyShift action_14+action_65 (34#) = happyShift action_15+action_65 (41#) = happyShift action_16+action_65 (42#) = happyShift action_17+action_65 (43#) = happyShift action_18+action_65 (49#) = happyShift action_19+action_65 (55#) = happyShift action_20+action_65 (59#) = happyShift action_21+action_65 (60#) = happyShift action_22+action_65 (68#) = happyShift action_23+action_65 (69#) = happyShift action_24+action_65 (73#) = happyShift action_25+action_65 (75#) = happyShift action_26+action_65 (78#) = happyShift action_27+action_65 (79#) = happyShift action_28+action_65 (81#) = happyShift action_29+action_65 (82#) = happyShift action_30+action_65 (83#) = happyShift action_31+action_65 (5#) = happyGoto action_2+action_65 (6#) = happyGoto action_94+action_65 (8#) = happyGoto action_4+action_65 (15#) = happyGoto action_5+action_65 (16#) = happyGoto action_6+action_65 (17#) = happyGoto action_7+action_65 (20#) = happyGoto action_8+action_65 (23#) = happyGoto action_9+action_65 (24#) = happyGoto action_10+action_65 (25#) = happyGoto action_11+action_65 x = happyTcHack x happyFail++action_66 (27#) = happyShift action_12+action_66 (28#) = happyShift action_13+action_66 (29#) = happyShift action_14+action_66 (34#) = happyShift action_15+action_66 (41#) = happyShift action_16+action_66 (42#) = happyShift action_17+action_66 (43#) = happyShift action_18+action_66 (49#) = happyShift action_19+action_66 (55#) = happyShift action_20+action_66 (59#) = happyShift action_21+action_66 (60#) = happyShift action_22+action_66 (68#) = happyShift action_23+action_66 (69#) = happyShift action_24+action_66 (73#) = happyShift action_25+action_66 (75#) = happyShift action_26+action_66 (78#) = happyShift action_27+action_66 (79#) = happyShift action_28+action_66 (81#) = happyShift action_29+action_66 (82#) = happyShift action_30+action_66 (83#) = happyShift action_31+action_66 (5#) = happyGoto action_2+action_66 (6#) = happyGoto action_93+action_66 (8#) = happyGoto action_4+action_66 (15#) = happyGoto action_5+action_66 (16#) = happyGoto action_6+action_66 (17#) = happyGoto action_7+action_66 (20#) = happyGoto action_8+action_66 (23#) = happyGoto action_9+action_66 (24#) = happyGoto action_10+action_66 (25#) = happyGoto action_11+action_66 x = happyTcHack x happyFail++action_67 (27#) = happyShift action_12+action_67 (28#) = happyShift action_13+action_67 (29#) = happyShift action_14+action_67 (34#) = happyShift action_15+action_67 (41#) = happyShift action_16+action_67 (42#) = happyShift action_17+action_67 (43#) = happyShift action_18+action_67 (49#) = happyShift action_19+action_67 (55#) = happyShift action_20+action_67 (59#) = happyShift action_21+action_67 (60#) = happyShift action_22+action_67 (68#) = happyShift action_23+action_67 (69#) = happyShift action_24+action_67 (73#) = happyShift action_25+action_67 (75#) = happyShift action_26+action_67 (78#) = happyShift action_27+action_67 (79#) = happyShift action_28+action_67 (81#) = happyShift action_29+action_67 (82#) = happyShift action_30+action_67 (83#) = happyShift action_31+action_67 (5#) = happyGoto action_2+action_67 (6#) = happyGoto action_92+action_67 (8#) = happyGoto action_4+action_67 (15#) = happyGoto action_5+action_67 (16#) = happyGoto action_6+action_67 (17#) = happyGoto action_7+action_67 (20#) = happyGoto action_8+action_67 (23#) = happyGoto action_9+action_67 (24#) = happyGoto action_10+action_67 (25#) = happyGoto action_11+action_67 x = happyTcHack x happyFail++action_68 (27#) = happyShift action_12+action_68 (28#) = happyShift action_13+action_68 (29#) = happyShift action_14+action_68 (34#) = happyShift action_15+action_68 (41#) = happyShift action_16+action_68 (42#) = happyShift action_17+action_68 (43#) = happyShift action_18+action_68 (49#) = happyShift action_19+action_68 (55#) = happyShift action_20+action_68 (59#) = happyShift action_21+action_68 (60#) = happyShift action_22+action_68 (68#) = happyShift action_23+action_68 (69#) = happyShift action_24+action_68 (73#) = happyShift action_25+action_68 (75#) = happyShift action_26+action_68 (78#) = happyShift action_27+action_68 (79#) = happyShift action_28+action_68 (81#) = happyShift action_29+action_68 (82#) = happyShift action_30+action_68 (83#) = happyShift action_31+action_68 (5#) = happyGoto action_2+action_68 (6#) = happyGoto action_91+action_68 (8#) = happyGoto action_4+action_68 (15#) = happyGoto action_5+action_68 (16#) = happyGoto action_6+action_68 (17#) = happyGoto action_7+action_68 (20#) = happyGoto action_8+action_68 (23#) = happyGoto action_9+action_68 (24#) = happyGoto action_10+action_68 (25#) = happyGoto action_11+action_68 x = happyTcHack x happyFail++action_69 (27#) = happyShift action_12+action_69 (28#) = happyShift action_13+action_69 (29#) = happyShift action_14+action_69 (34#) = happyShift action_15+action_69 (41#) = happyShift action_16+action_69 (42#) = happyShift action_17+action_69 (43#) = happyShift action_18+action_69 (49#) = happyShift action_19+action_69 (55#) = happyShift action_20+action_69 (59#) = happyShift action_21+action_69 (60#) = happyShift action_22+action_69 (68#) = happyShift action_23+action_69 (69#) = happyShift action_24+action_69 (73#) = happyShift action_25+action_69 (75#) = happyShift action_26+action_69 (78#) = happyShift action_27+action_69 (79#) = happyShift action_28+action_69 (81#) = happyShift action_29+action_69 (82#) = happyShift action_30+action_69 (83#) = happyShift action_31+action_69 (5#) = happyGoto action_2+action_69 (6#) = happyGoto action_90+action_69 (8#) = happyGoto action_4+action_69 (15#) = happyGoto action_5+action_69 (16#) = happyGoto action_6+action_69 (17#) = happyGoto action_7+action_69 (20#) = happyGoto action_8+action_69 (23#) = happyGoto action_9+action_69 (24#) = happyGoto action_10+action_69 (25#) = happyGoto action_11+action_69 x = happyTcHack x happyFail++action_70 (27#) = happyShift action_12+action_70 (28#) = happyShift action_13+action_70 (29#) = happyShift action_14+action_70 (34#) = happyShift action_15+action_70 (41#) = happyShift action_16+action_70 (42#) = happyShift action_17+action_70 (43#) = happyShift action_18+action_70 (49#) = happyShift action_19+action_70 (55#) = happyShift action_20+action_70 (59#) = happyShift action_21+action_70 (60#) = happyShift action_22+action_70 (68#) = happyShift action_23+action_70 (69#) = happyShift action_24+action_70 (73#) = happyShift action_25+action_70 (75#) = happyShift action_26+action_70 (78#) = happyShift action_27+action_70 (79#) = happyShift action_28+action_70 (81#) = happyShift action_29+action_70 (82#) = happyShift action_30+action_70 (83#) = happyShift action_31+action_70 (5#) = happyGoto action_2+action_70 (6#) = happyGoto action_89+action_70 (8#) = happyGoto action_4+action_70 (15#) = happyGoto action_5+action_70 (16#) = happyGoto action_6+action_70 (17#) = happyGoto action_7+action_70 (20#) = happyGoto action_8+action_70 (23#) = happyGoto action_9+action_70 (24#) = happyGoto action_10+action_70 (25#) = happyGoto action_11+action_70 x = happyTcHack x happyFail++action_71 (27#) = happyShift action_12+action_71 (28#) = happyShift action_13+action_71 (29#) = happyShift action_14+action_71 (34#) = happyShift action_15+action_71 (41#) = happyShift action_16+action_71 (42#) = happyShift action_17+action_71 (43#) = happyShift action_18+action_71 (49#) = happyShift action_19+action_71 (55#) = happyShift action_20+action_71 (59#) = happyShift action_21+action_71 (60#) = happyShift action_22+action_71 (68#) = happyShift action_23+action_71 (69#) = happyShift action_24+action_71 (73#) = happyShift action_25+action_71 (75#) = happyShift action_26+action_71 (78#) = happyShift action_27+action_71 (79#) = happyShift action_28+action_71 (81#) = happyShift action_29+action_71 (82#) = happyShift action_30+action_71 (83#) = happyShift action_31+action_71 (5#) = happyGoto action_2+action_71 (6#) = happyGoto action_88+action_71 (8#) = happyGoto action_4+action_71 (15#) = happyGoto action_5+action_71 (16#) = happyGoto action_6+action_71 (17#) = happyGoto action_7+action_71 (20#) = happyGoto action_8+action_71 (23#) = happyGoto action_9+action_71 (24#) = happyGoto action_10+action_71 (25#) = happyGoto action_11+action_71 x = happyTcHack x happyFail++action_72 (27#) = happyShift action_12+action_72 (28#) = happyShift action_13+action_72 (29#) = happyShift action_14+action_72 (34#) = happyShift action_15+action_72 (41#) = happyShift action_16+action_72 (42#) = happyShift action_17+action_72 (43#) = happyShift action_18+action_72 (49#) = happyShift action_19+action_72 (55#) = happyShift action_20+action_72 (59#) = happyShift action_21+action_72 (60#) = happyShift action_22+action_72 (68#) = happyShift action_23+action_72 (69#) = happyShift action_24+action_72 (73#) = happyShift action_25+action_72 (75#) = happyShift action_26+action_72 (78#) = happyShift action_27+action_72 (79#) = happyShift action_28+action_72 (81#) = happyShift action_29+action_72 (82#) = happyShift action_30+action_72 (83#) = happyShift action_31+action_72 (5#) = happyGoto action_2+action_72 (6#) = happyGoto action_87+action_72 (8#) = happyGoto action_4+action_72 (15#) = happyGoto action_5+action_72 (16#) = happyGoto action_6+action_72 (17#) = happyGoto action_7+action_72 (20#) = happyGoto action_8+action_72 (23#) = happyGoto action_9+action_72 (24#) = happyGoto action_10+action_72 (25#) = happyGoto action_11+action_72 x = happyTcHack x happyFail++action_73 (27#) = happyShift action_12+action_73 (28#) = happyShift action_13+action_73 (29#) = happyShift action_14+action_73 (34#) = happyShift action_15+action_73 (41#) = happyShift action_16+action_73 (42#) = happyShift action_17+action_73 (43#) = happyShift action_18+action_73 (49#) = happyShift action_19+action_73 (55#) = happyShift action_20+action_73 (59#) = happyShift action_21+action_73 (60#) = happyShift action_22+action_73 (68#) = happyShift action_23+action_73 (69#) = happyShift action_24+action_73 (73#) = happyShift action_25+action_73 (75#) = happyShift action_26+action_73 (78#) = happyShift action_27+action_73 (79#) = happyShift action_28+action_73 (81#) = happyShift action_29+action_73 (82#) = happyShift action_30+action_73 (83#) = happyShift action_31+action_73 (5#) = happyGoto action_2+action_73 (6#) = happyGoto action_86+action_73 (8#) = happyGoto action_4+action_73 (15#) = happyGoto action_5+action_73 (16#) = happyGoto action_6+action_73 (17#) = happyGoto action_7+action_73 (20#) = happyGoto action_8+action_73 (23#) = happyGoto action_9+action_73 (24#) = happyGoto action_10+action_73 (25#) = happyGoto action_11+action_73 x = happyTcHack x happyFail++action_74 (27#) = happyShift action_12+action_74 (28#) = happyShift action_13+action_74 (29#) = happyShift action_14+action_74 (34#) = happyShift action_15+action_74 (41#) = happyShift action_16+action_74 (42#) = happyShift action_17+action_74 (43#) = happyShift action_18+action_74 (49#) = happyShift action_19+action_74 (55#) = happyShift action_20+action_74 (59#) = happyShift action_21+action_74 (60#) = happyShift action_22+action_74 (68#) = happyShift action_23+action_74 (69#) = happyShift action_24+action_74 (73#) = happyShift action_25+action_74 (75#) = happyShift action_26+action_74 (78#) = happyShift action_27+action_74 (79#) = happyShift action_28+action_74 (81#) = happyShift action_29+action_74 (82#) = happyShift action_30+action_74 (83#) = happyShift action_31+action_74 (5#) = happyGoto action_2+action_74 (6#) = happyGoto action_85+action_74 (8#) = happyGoto action_4+action_74 (15#) = happyGoto action_5+action_74 (16#) = happyGoto action_6+action_74 (17#) = happyGoto action_7+action_74 (20#) = happyGoto action_8+action_74 (23#) = happyGoto action_9+action_74 (24#) = happyGoto action_10+action_74 (25#) = happyGoto action_11+action_74 x = happyTcHack x happyFail++action_75 (27#) = happyShift action_12+action_75 (28#) = happyShift action_13+action_75 (29#) = happyShift action_14+action_75 (34#) = happyShift action_15+action_75 (41#) = happyShift action_16+action_75 (42#) = happyShift action_17+action_75 (43#) = happyShift action_18+action_75 (49#) = happyShift action_19+action_75 (55#) = happyShift action_20+action_75 (59#) = happyShift action_21+action_75 (60#) = happyShift action_22+action_75 (68#) = happyShift action_23+action_75 (69#) = happyShift action_24+action_75 (73#) = happyShift action_25+action_75 (75#) = happyShift action_26+action_75 (78#) = happyShift action_27+action_75 (79#) = happyShift action_28+action_75 (81#) = happyShift action_29+action_75 (82#) = happyShift action_30+action_75 (83#) = happyShift action_31+action_75 (5#) = happyGoto action_2+action_75 (6#) = happyGoto action_84+action_75 (8#) = happyGoto action_4+action_75 (15#) = happyGoto action_5+action_75 (16#) = happyGoto action_6+action_75 (17#) = happyGoto action_7+action_75 (20#) = happyGoto action_8+action_75 (23#) = happyGoto action_9+action_75 (24#) = happyGoto action_10+action_75 (25#) = happyGoto action_11+action_75 x = happyTcHack x happyFail++action_76 (27#) = happyShift action_12+action_76 (28#) = happyShift action_13+action_76 (29#) = happyShift action_14+action_76 (34#) = happyShift action_15+action_76 (41#) = happyShift action_16+action_76 (42#) = happyShift action_17+action_76 (43#) = happyShift action_18+action_76 (49#) = happyShift action_19+action_76 (55#) = happyShift action_20+action_76 (59#) = happyShift action_21+action_76 (60#) = happyShift action_22+action_76 (68#) = happyShift action_23+action_76 (69#) = happyShift action_24+action_76 (73#) = happyShift action_25+action_76 (75#) = happyShift action_26+action_76 (78#) = happyShift action_27+action_76 (79#) = happyShift action_28+action_76 (81#) = happyShift action_29+action_76 (82#) = happyShift action_30+action_76 (83#) = happyShift action_31+action_76 (5#) = happyGoto action_2+action_76 (6#) = happyGoto action_83+action_76 (8#) = happyGoto action_4+action_76 (15#) = happyGoto action_5+action_76 (16#) = happyGoto action_6+action_76 (17#) = happyGoto action_7+action_76 (20#) = happyGoto action_8+action_76 (23#) = happyGoto action_9+action_76 (24#) = happyGoto action_10+action_76 (25#) = happyGoto action_11+action_76 x = happyTcHack x happyFail++action_77 (27#) = happyShift action_12+action_77 (28#) = happyShift action_13+action_77 (29#) = happyShift action_14+action_77 (34#) = happyShift action_15+action_77 (41#) = happyShift action_16+action_77 (42#) = happyShift action_17+action_77 (43#) = happyShift action_18+action_77 (49#) = happyShift action_19+action_77 (55#) = happyShift action_20+action_77 (59#) = happyShift action_21+action_77 (60#) = happyShift action_22+action_77 (68#) = happyShift action_23+action_77 (69#) = happyShift action_24+action_77 (73#) = happyShift action_25+action_77 (75#) = happyShift action_26+action_77 (78#) = happyShift action_27+action_77 (79#) = happyShift action_28+action_77 (81#) = happyShift action_29+action_77 (82#) = happyShift action_30+action_77 (83#) = happyShift action_31+action_77 (5#) = happyGoto action_2+action_77 (6#) = happyGoto action_82+action_77 (8#) = happyGoto action_4+action_77 (15#) = happyGoto action_5+action_77 (16#) = happyGoto action_6+action_77 (17#) = happyGoto action_7+action_77 (20#) = happyGoto action_8+action_77 (23#) = happyGoto action_9+action_77 (24#) = happyGoto action_10+action_77 (25#) = happyGoto action_11+action_77 x = happyTcHack x happyFail++action_78 (27#) = happyShift action_12+action_78 (28#) = happyShift action_13+action_78 (29#) = happyShift action_14+action_78 (34#) = happyShift action_15+action_78 (41#) = happyShift action_16+action_78 (42#) = happyShift action_17+action_78 (43#) = happyShift action_18+action_78 (49#) = happyShift action_19+action_78 (55#) = happyShift action_20+action_78 (59#) = happyShift action_21+action_78 (60#) = happyShift action_22+action_78 (68#) = happyShift action_23+action_78 (69#) = happyShift action_24+action_78 (73#) = happyShift action_25+action_78 (75#) = happyShift action_26+action_78 (78#) = happyShift action_27+action_78 (79#) = happyShift action_28+action_78 (81#) = happyShift action_29+action_78 (82#) = happyShift action_30+action_78 (83#) = happyShift action_31+action_78 (5#) = happyGoto action_2+action_78 (6#) = happyGoto action_81+action_78 (8#) = happyGoto action_4+action_78 (15#) = happyGoto action_5+action_78 (16#) = happyGoto action_6+action_78 (17#) = happyGoto action_7+action_78 (20#) = happyGoto action_8+action_78 (23#) = happyGoto action_9+action_78 (24#) = happyGoto action_10+action_78 (25#) = happyGoto action_11+action_78 x = happyTcHack x happyFail++action_79 (27#) = happyShift action_12+action_79 (28#) = happyShift action_13+action_79 (29#) = happyShift action_14+action_79 (34#) = happyShift action_15+action_79 (41#) = happyShift action_16+action_79 (42#) = happyShift action_17+action_79 (43#) = happyShift action_18+action_79 (49#) = happyShift action_19+action_79 (55#) = happyShift action_20+action_79 (59#) = happyShift action_21+action_79 (60#) = happyShift action_22+action_79 (68#) = happyShift action_23+action_79 (69#) = happyShift action_24+action_79 (73#) = happyShift action_25+action_79 (75#) = happyShift action_26+action_79 (78#) = happyShift action_27+action_79 (79#) = happyShift action_28+action_79 (81#) = happyShift action_29+action_79 (82#) = happyShift action_30+action_79 (83#) = happyShift action_31+action_79 (5#) = happyGoto action_2+action_79 (6#) = happyGoto action_80+action_79 (8#) = happyGoto action_4+action_79 (15#) = happyGoto action_5+action_79 (16#) = happyGoto action_6+action_79 (17#) = happyGoto action_7+action_79 (20#) = happyGoto action_8+action_79 (23#) = happyGoto action_9+action_79 (24#) = happyGoto action_10+action_79 (25#) = happyGoto action_11+action_79 x = happyTcHack x happyFail++action_80 (40#) = happyShift action_61+action_80 (41#) = happyShift action_62+action_80 (42#) = happyShift action_63+action_80 (43#) = happyShift action_64+action_80 (44#) = happyShift action_65+action_80 (45#) = happyShift action_66+action_80 (46#) = happyShift action_67+action_80 (47#) = happyShift action_68+action_80 (48#) = happyShift action_69+action_80 (49#) = happyShift action_70+action_80 (50#) = happyShift action_71+action_80 (51#) = happyShift action_72+action_80 (52#) = happyShift action_73+action_80 (53#) = happyShift action_74+action_80 (54#) = happyShift action_75+action_80 (55#) = happyShift action_76+action_80 x = happyTcHack x happyReduce_28++action_81 (40#) = happyShift action_61+action_81 (41#) = happyShift action_62+action_81 (42#) = happyShift action_63+action_81 (43#) = happyShift action_64+action_81 (44#) = happyShift action_65+action_81 (45#) = happyShift action_66+action_81 (46#) = happyShift action_67+action_81 (47#) = happyShift action_68+action_81 (48#) = happyShift action_69+action_81 (49#) = happyShift action_70+action_81 (50#) = happyShift action_71+action_81 (51#) = happyShift action_72+action_81 (52#) = happyShift action_73+action_81 (53#) = happyShift action_74+action_81 (54#) = happyShift action_75+action_81 (55#) = happyShift action_76+action_81 x = happyTcHack x happyReduce_27++action_82 (40#) = happyShift action_61+action_82 (41#) = happyShift action_62+action_82 (42#) = happyShift action_63+action_82 (43#) = happyShift action_64+action_82 (44#) = happyShift action_65+action_82 (45#) = happyShift action_66+action_82 (46#) = happyShift action_67+action_82 (47#) = happyShift action_68+action_82 (48#) = happyShift action_69+action_82 (49#) = happyShift action_70+action_82 (50#) = happyShift action_71+action_82 (51#) = happyShift action_72+action_82 (52#) = happyShift action_73+action_82 (53#) = happyShift action_74+action_82 (54#) = happyShift action_75+action_82 (55#) = happyShift action_76+action_82 x = happyTcHack x happyReduce_26++action_83 (40#) = happyShift action_61+action_83 (41#) = happyShift action_62+action_83 (42#) = happyShift action_63+action_83 (43#) = happyShift action_64+action_83 (44#) = happyShift action_65+action_83 (45#) = happyShift action_66+action_83 (46#) = happyShift action_67+action_83 (47#) = happyShift action_68+action_83 (48#) = happyShift action_69+action_83 (49#) = happyShift action_70+action_83 (50#) = happyShift action_71+action_83 (51#) = happyShift action_72+action_83 (52#) = happyShift action_73+action_83 (55#) = happyFail+action_83 x = happyTcHack x happyReduce_25++action_84 (40#) = happyShift action_61+action_84 (41#) = happyShift action_62+action_84 (42#) = happyShift action_63+action_84 (43#) = happyShift action_64+action_84 (44#) = happyShift action_65+action_84 (45#) = happyShift action_66+action_84 (46#) = happyShift action_67+action_84 (47#) = happyShift action_68+action_84 (48#) = happyShift action_69+action_84 (49#) = happyShift action_70+action_84 (50#) = happyShift action_71+action_84 (51#) = happyShift action_72+action_84 (52#) = happyShift action_73+action_84 (53#) = happyShift action_74+action_84 (54#) = happyShift action_75+action_84 (55#) = happyShift action_76+action_84 x = happyTcHack x happyReduce_24++action_85 (40#) = happyShift action_61+action_85 (41#) = happyShift action_62+action_85 (42#) = happyShift action_63+action_85 (43#) = happyShift action_64+action_85 (44#) = happyShift action_65+action_85 (45#) = happyShift action_66+action_85 (46#) = happyShift action_67+action_85 (47#) = happyShift action_68+action_85 (48#) = happyShift action_69+action_85 (49#) = happyShift action_70+action_85 (50#) = happyShift action_71+action_85 (51#) = happyShift action_72+action_85 (52#) = happyShift action_73+action_85 (53#) = happyShift action_74+action_85 (55#) = happyShift action_76+action_85 x = happyTcHack x happyReduce_23++action_86 (40#) = happyShift action_61+action_86 (41#) = happyShift action_62+action_86 (42#) = happyShift action_63+action_86 (43#) = happyShift action_64+action_86 (44#) = happyShift action_65+action_86 (45#) = happyShift action_66+action_86 (46#) = happyShift action_67+action_86 x = happyTcHack x happyReduce_22++action_87 (40#) = happyShift action_61+action_87 (41#) = happyShift action_62+action_87 (42#) = happyShift action_63+action_87 (43#) = happyShift action_64+action_87 (44#) = happyShift action_65+action_87 (45#) = happyShift action_66+action_87 (46#) = happyShift action_67+action_87 x = happyTcHack x happyReduce_21++action_88 (40#) = happyShift action_61+action_88 (41#) = happyShift action_62+action_88 (42#) = happyShift action_63+action_88 (43#) = happyShift action_64+action_88 (44#) = happyShift action_65+action_88 (45#) = happyShift action_66+action_88 (46#) = happyShift action_67+action_88 x = happyTcHack x happyReduce_20++action_89 (40#) = happyShift action_61+action_89 (41#) = happyShift action_62+action_89 (42#) = happyShift action_63+action_89 (43#) = happyShift action_64+action_89 (44#) = happyShift action_65+action_89 (45#) = happyShift action_66+action_89 (46#) = happyShift action_67+action_89 x = happyTcHack x happyReduce_19++action_90 (40#) = happyShift action_61+action_90 (41#) = happyShift action_62+action_90 (42#) = happyShift action_63+action_90 (43#) = happyShift action_64+action_90 (44#) = happyShift action_65+action_90 (45#) = happyShift action_66+action_90 (46#) = happyShift action_67+action_90 x = happyTcHack x happyReduce_18++action_91 (40#) = happyShift action_61+action_91 (41#) = happyShift action_62+action_91 (42#) = happyShift action_63+action_91 (43#) = happyShift action_64+action_91 (44#) = happyShift action_65+action_91 (45#) = happyShift action_66+action_91 (46#) = happyShift action_67+action_91 x = happyTcHack x happyReduce_17++action_92 (40#) = happyShift action_61+action_92 x = happyTcHack x happyReduce_16++action_93 (40#) = happyShift action_61+action_93 x = happyTcHack x happyReduce_15++action_94 (40#) = happyShift action_61+action_94 x = happyTcHack x happyReduce_14++action_95 (40#) = happyShift action_61+action_95 x = happyTcHack x happyReduce_13++action_96 (40#) = happyShift action_61+action_96 (43#) = happyShift action_64+action_96 (44#) = happyShift action_65+action_96 (45#) = happyShift action_66+action_96 (46#) = happyShift action_67+action_96 x = happyTcHack x happyReduce_12++action_97 (40#) = happyShift action_61+action_97 (43#) = happyShift action_64+action_97 (44#) = happyShift action_65+action_97 (45#) = happyShift action_66+action_97 (46#) = happyShift action_67+action_97 x = happyTcHack x happyReduce_11++action_98 x = happyTcHack x happyReduce_10++action_99 (40#) = happyShift action_61+action_99 (41#) = happyShift action_62+action_99 (42#) = happyShift action_63+action_99 (43#) = happyShift action_64+action_99 (44#) = happyShift action_65+action_99 (45#) = happyShift action_66+action_99 (46#) = happyShift action_67+action_99 (47#) = happyShift action_68+action_99 (48#) = happyShift action_69+action_99 (49#) = happyShift action_70+action_99 (50#) = happyShift action_71+action_99 (51#) = happyShift action_72+action_99 (52#) = happyShift action_73+action_99 (53#) = happyShift action_74+action_99 (54#) = happyShift action_75+action_99 (55#) = happyShift action_76+action_99 (56#) = happyShift action_77+action_99 (57#) = happyShift action_78+action_99 (58#) = happyShift action_79+action_99 x = happyTcHack x happyReduce_47++action_100 (62#) = happyShift action_125+action_100 x = happyTcHack x happyReduce_40++action_101 (62#) = happyShift action_116+action_101 x = happyTcHack x happyReduce_39++action_102 (26#) = happyShift action_158+action_102 x = happyTcHack x happyFail++action_103 (27#) = happyShift action_12+action_103 (28#) = happyShift action_13+action_103 (29#) = happyShift action_14+action_103 (34#) = happyShift action_15+action_103 (41#) = happyShift action_16+action_103 (42#) = happyShift action_17+action_103 (43#) = happyShift action_18+action_103 (49#) = happyShift action_19+action_103 (55#) = happyShift action_20+action_103 (59#) = happyShift action_21+action_103 (60#) = happyShift action_22+action_103 (68#) = happyShift action_23+action_103 (69#) = happyShift action_24+action_103 (73#) = happyShift action_25+action_103 (75#) = happyShift action_26+action_103 (78#) = happyShift action_27+action_103 (79#) = happyShift action_28+action_103 (81#) = happyShift action_29+action_103 (82#) = happyShift action_30+action_103 (83#) = happyShift action_31+action_103 (5#) = happyGoto action_2+action_103 (6#) = happyGoto action_156+action_103 (8#) = happyGoto action_4+action_103 (13#) = happyGoto action_157+action_103 (15#) = happyGoto action_5+action_103 (16#) = happyGoto action_6+action_103 (17#) = happyGoto action_7+action_103 (20#) = happyGoto action_8+action_103 (23#) = happyGoto action_9+action_103 (24#) = happyGoto action_10+action_103 (25#) = happyGoto action_11+action_103 x = happyTcHack x happyFail++action_104 x = happyTcHack x happyReduce_66++action_105 (36#) = happyShift action_152+action_105 (49#) = happyShift action_19+action_105 (70#) = happyShift action_153+action_105 (80#) = happyShift action_154+action_105 (83#) = happyShift action_155+action_105 (16#) = happyGoto action_151+action_105 (17#) = happyGoto action_7+action_105 x = happyTcHack x happyFail++action_106 (27#) = happyShift action_12+action_106 (28#) = happyShift action_13+action_106 (29#) = happyShift action_14+action_106 (34#) = happyShift action_15+action_106 (41#) = happyShift action_16+action_106 (42#) = happyShift action_17+action_106 (43#) = happyShift action_18+action_106 (49#) = happyShift action_19+action_106 (55#) = happyShift action_20+action_106 (59#) = happyShift action_21+action_106 (60#) = happyShift action_22+action_106 (68#) = happyShift action_23+action_106 (69#) = happyShift action_24+action_106 (73#) = happyShift action_25+action_106 (75#) = happyShift action_26+action_106 (78#) = happyShift action_27+action_106 (79#) = happyShift action_28+action_106 (81#) = happyShift action_29+action_106 (82#) = happyShift action_30+action_106 (83#) = happyShift action_31+action_106 (5#) = happyGoto action_2+action_106 (6#) = happyGoto action_45+action_106 (7#) = happyGoto action_150+action_106 (8#) = happyGoto action_4+action_106 (15#) = happyGoto action_5+action_106 (16#) = happyGoto action_6+action_106 (17#) = happyGoto action_7+action_106 (20#) = happyGoto action_8+action_106 (23#) = happyGoto action_9+action_106 (24#) = happyGoto action_10+action_106 (25#) = happyGoto action_11+action_106 x = happyTcHack x happyFail++action_107 (75#) = happyShift action_149+action_107 x = happyTcHack x happyFail++action_108 x = happyTcHack x happyReduce_65++action_109 x = happyTcHack x happyReduce_64++action_110 (32#) = happyShift action_53+action_110 x = happyTcHack x happyReduce_81++action_111 (34#) = happyShift action_15+action_111 (43#) = happyShift action_18+action_111 (75#) = happyShift action_26+action_111 (78#) = happyShift action_27+action_111 (79#) = happyShift action_28+action_111 (5#) = happyGoto action_2+action_111 (23#) = happyGoto action_148+action_111 (24#) = happyGoto action_10+action_111 (25#) = happyGoto action_11+action_111 x = happyTcHack x happyFail++action_112 (34#) = happyShift action_15+action_112 (43#) = happyShift action_18+action_112 (73#) = happyShift action_147+action_112 (75#) = happyShift action_26+action_112 (78#) = happyShift action_27+action_112 (79#) = happyShift action_28+action_112 (5#) = happyGoto action_2+action_112 (23#) = happyGoto action_146+action_112 (24#) = happyGoto action_10+action_112 (25#) = happyGoto action_11+action_112 x = happyTcHack x happyFail++action_113 x = happyTcHack x happyReduce_85++action_114 (33#) = happyShift action_145+action_114 (40#) = happyShift action_61+action_114 (41#) = happyShift action_62+action_114 (42#) = happyShift action_63+action_114 (43#) = happyShift action_64+action_114 (44#) = happyShift action_65+action_114 (45#) = happyShift action_66+action_114 (46#) = happyShift action_67+action_114 (47#) = happyShift action_68+action_114 (48#) = happyShift action_69+action_114 (49#) = happyShift action_70+action_114 (50#) = happyShift action_71+action_114 (51#) = happyShift action_72+action_114 (52#) = happyShift action_73+action_114 (53#) = happyShift action_74+action_114 (54#) = happyShift action_75+action_114 (55#) = happyShift action_76+action_114 (56#) = happyShift action_77+action_114 (57#) = happyShift action_78+action_114 (58#) = happyShift action_79+action_114 x = happyTcHack x happyFail++action_115 x = happyTcHack x happyReduce_80++action_116 (79#) = happyShift action_28+action_116 (5#) = happyGoto action_144+action_116 x = happyTcHack x happyFail++action_117 (27#) = happyShift action_12+action_117 (28#) = happyShift action_13+action_117 (29#) = happyShift action_14+action_117 (34#) = happyShift action_15+action_117 (41#) = happyShift action_16+action_117 (42#) = happyShift action_17+action_117 (43#) = happyShift action_18+action_117 (49#) = happyShift action_19+action_117 (55#) = happyShift action_20+action_117 (59#) = happyShift action_21+action_117 (60#) = happyShift action_22+action_117 (68#) = happyShift action_23+action_117 (69#) = happyShift action_24+action_117 (73#) = happyShift action_25+action_117 (75#) = happyShift action_26+action_117 (78#) = happyShift action_27+action_117 (79#) = happyShift action_28+action_117 (81#) = happyShift action_29+action_117 (82#) = happyShift action_30+action_117 (83#) = happyShift action_31+action_117 (5#) = happyGoto action_2+action_117 (6#) = happyGoto action_143+action_117 (8#) = happyGoto action_4+action_117 (15#) = happyGoto action_5+action_117 (16#) = happyGoto action_6+action_117 (17#) = happyGoto action_7+action_117 (20#) = happyGoto action_8+action_117 (23#) = happyGoto action_9+action_117 (24#) = happyGoto action_10+action_117 (25#) = happyGoto action_11+action_117 x = happyTcHack x happyFail++action_118 (27#) = happyShift action_12+action_118 (28#) = happyShift action_13+action_118 (29#) = happyShift action_14+action_118 (34#) = happyShift action_15+action_118 (41#) = happyShift action_16+action_118 (42#) = happyShift action_17+action_118 (43#) = happyShift action_18+action_118 (49#) = happyShift action_19+action_118 (55#) = happyShift action_20+action_118 (59#) = happyShift action_21+action_118 (60#) = happyShift action_22+action_118 (68#) = happyShift action_23+action_118 (69#) = happyShift action_24+action_118 (73#) = happyShift action_25+action_118 (75#) = happyShift action_26+action_118 (78#) = happyShift action_27+action_118 (79#) = happyShift action_28+action_118 (81#) = happyShift action_29+action_118 (82#) = happyShift action_30+action_118 (83#) = happyShift action_31+action_118 (5#) = happyGoto action_2+action_118 (6#) = happyGoto action_142+action_118 (8#) = happyGoto action_4+action_118 (15#) = happyGoto action_5+action_118 (16#) = happyGoto action_6+action_118 (17#) = happyGoto action_7+action_118 (20#) = happyGoto action_8+action_118 (23#) = happyGoto action_9+action_118 (24#) = happyGoto action_10+action_118 (25#) = happyGoto action_11+action_118 x = happyTcHack x happyFail++action_119 (27#) = happyShift action_12+action_119 (28#) = happyShift action_13+action_119 (29#) = happyShift action_14+action_119 (34#) = happyShift action_15+action_119 (41#) = happyShift action_16+action_119 (42#) = happyShift action_17+action_119 (43#) = happyShift action_18+action_119 (49#) = happyShift action_19+action_119 (55#) = happyShift action_20+action_119 (59#) = happyShift action_21+action_119 (60#) = happyShift action_22+action_119 (68#) = happyShift action_23+action_119 (69#) = happyShift action_24+action_119 (73#) = happyShift action_25+action_119 (75#) = happyShift action_26+action_119 (78#) = happyShift action_27+action_119 (79#) = happyShift action_28+action_119 (81#) = happyShift action_29+action_119 (82#) = happyShift action_30+action_119 (83#) = happyShift action_31+action_119 (5#) = happyGoto action_2+action_119 (6#) = happyGoto action_141+action_119 (8#) = happyGoto action_4+action_119 (15#) = happyGoto action_5+action_119 (16#) = happyGoto action_6+action_119 (17#) = happyGoto action_7+action_119 (20#) = happyGoto action_8+action_119 (23#) = happyGoto action_9+action_119 (24#) = happyGoto action_10+action_119 (25#) = happyGoto action_11+action_119 x = happyTcHack x happyFail++action_120 x = happyTcHack x happyReduce_93++action_121 (27#) = happyShift action_12+action_121 (28#) = happyShift action_13+action_121 (29#) = happyShift action_14+action_121 (34#) = happyShift action_15+action_121 (41#) = happyShift action_16+action_121 (42#) = happyShift action_17+action_121 (43#) = happyShift action_18+action_121 (49#) = happyShift action_19+action_121 (55#) = happyShift action_20+action_121 (59#) = happyShift action_21+action_121 (60#) = happyShift action_22+action_121 (68#) = happyShift action_23+action_121 (69#) = happyShift action_24+action_121 (73#) = happyShift action_25+action_121 (75#) = happyShift action_26+action_121 (78#) = happyShift action_27+action_121 (79#) = happyShift action_28+action_121 (81#) = happyShift action_29+action_121 (82#) = happyShift action_30+action_121 (83#) = happyShift action_31+action_121 (5#) = happyGoto action_2+action_121 (6#) = happyGoto action_140+action_121 (8#) = happyGoto action_4+action_121 (15#) = happyGoto action_5+action_121 (16#) = happyGoto action_6+action_121 (17#) = happyGoto action_7+action_121 (20#) = happyGoto action_8+action_121 (23#) = happyGoto action_9+action_121 (24#) = happyGoto action_10+action_121 (25#) = happyGoto action_11+action_121 x = happyTcHack x happyFail++action_122 (75#) = happyShift action_139+action_122 x = happyTcHack x happyReduce_62++action_123 (47#) = happyShift action_138+action_123 x = happyTcHack x happyFail++action_124 (27#) = happyShift action_12+action_124 (28#) = happyShift action_13+action_124 (29#) = happyShift action_14+action_124 (34#) = happyShift action_15+action_124 (41#) = happyShift action_16+action_124 (42#) = happyShift action_17+action_124 (43#) = happyShift action_18+action_124 (49#) = happyShift action_19+action_124 (55#) = happyShift action_20+action_124 (59#) = happyShift action_21+action_124 (60#) = happyShift action_22+action_124 (68#) = happyShift action_23+action_124 (69#) = happyShift action_24+action_124 (73#) = happyShift action_25+action_124 (75#) = happyShift action_26+action_124 (78#) = happyShift action_27+action_124 (79#) = happyShift action_28+action_124 (81#) = happyShift action_29+action_124 (82#) = happyShift action_30+action_124 (83#) = happyShift action_31+action_124 (5#) = happyGoto action_2+action_124 (6#) = happyGoto action_137+action_124 (8#) = happyGoto action_4+action_124 (15#) = happyGoto action_5+action_124 (16#) = happyGoto action_6+action_124 (17#) = happyGoto action_7+action_124 (20#) = happyGoto action_8+action_124 (23#) = happyGoto action_9+action_124 (24#) = happyGoto action_10+action_124 (25#) = happyGoto action_11+action_124 x = happyTcHack x happyFail++action_125 (79#) = happyShift action_28+action_125 (5#) = happyGoto action_136+action_125 x = happyTcHack x happyFail++action_126 (27#) = happyShift action_12+action_126 (28#) = happyShift action_13+action_126 (29#) = happyShift action_14+action_126 (34#) = happyShift action_15+action_126 (41#) = happyShift action_16+action_126 (42#) = happyShift action_17+action_126 (43#) = happyShift action_18+action_126 (49#) = happyShift action_19+action_126 (55#) = happyShift action_20+action_126 (59#) = happyShift action_21+action_126 (60#) = happyShift action_22+action_126 (68#) = happyShift action_23+action_126 (69#) = happyShift action_24+action_126 (73#) = happyShift action_25+action_126 (75#) = happyShift action_26+action_126 (78#) = happyShift action_27+action_126 (79#) = happyShift action_28+action_126 (81#) = happyShift action_29+action_126 (82#) = happyShift action_30+action_126 (83#) = happyShift action_31+action_126 (5#) = happyGoto action_2+action_126 (6#) = happyGoto action_135+action_126 (8#) = happyGoto action_4+action_126 (15#) = happyGoto action_5+action_126 (16#) = happyGoto action_6+action_126 (17#) = happyGoto action_7+action_126 (20#) = happyGoto action_8+action_126 (23#) = happyGoto action_9+action_126 (24#) = happyGoto action_10+action_126 (25#) = happyGoto action_11+action_126 x = happyTcHack x happyFail++action_127 (35#) = happyShift action_134+action_127 x = happyTcHack x happyFail++action_128 (35#) = happyShift action_133+action_128 x = happyTcHack x happyFail++action_129 (74#) = happyShift action_54+action_129 (22#) = happyGoto action_115+action_129 x = happyTcHack x happyReduce_78++action_130 (35#) = happyShift action_132+action_130 (62#) = happyShift action_121+action_130 x = happyTcHack x happyFail++action_131 x = happyTcHack x happyReduce_96++action_132 x = happyTcHack x happyReduce_95++action_133 x = happyTcHack x happyReduce_57++action_134 x = happyTcHack x happyReduce_56++action_135 (40#) = happyShift action_61+action_135 (41#) = happyShift action_62+action_135 (42#) = happyShift action_63+action_135 (43#) = happyShift action_64+action_135 (44#) = happyShift action_65+action_135 (45#) = happyShift action_66+action_135 (46#) = happyShift action_67+action_135 (47#) = happyShift action_68+action_135 (48#) = happyShift action_69+action_135 (49#) = happyShift action_70+action_135 (50#) = happyShift action_71+action_135 (51#) = happyShift action_72+action_135 (52#) = happyShift action_73+action_135 (53#) = happyShift action_74+action_135 (54#) = happyShift action_75+action_135 (55#) = happyShift action_76+action_135 (56#) = happyShift action_77+action_135 (57#) = happyShift action_78+action_135 (58#) = happyShift action_79+action_135 x = happyTcHack x happyReduce_45++action_136 (63#) = happyShift action_175+action_136 x = happyTcHack x happyFail++action_137 (40#) = happyShift action_61+action_137 (41#) = happyShift action_62+action_137 (42#) = happyShift action_63+action_137 (43#) = happyShift action_64+action_137 (44#) = happyShift action_65+action_137 (45#) = happyShift action_66+action_137 (46#) = happyShift action_67+action_137 (47#) = happyShift action_68+action_137 (48#) = happyShift action_69+action_137 (49#) = happyShift action_70+action_137 (50#) = happyShift action_71+action_137 (51#) = happyShift action_72+action_137 (52#) = happyShift action_73+action_137 (53#) = happyShift action_74+action_137 (54#) = happyShift action_75+action_137 (55#) = happyShift action_76+action_137 (56#) = happyShift action_77+action_137 (57#) = happyShift action_78+action_137 (58#) = happyShift action_79+action_137 (76#) = happyShift action_174+action_137 x = happyTcHack x happyReduce_41++action_138 (38#) = happyShift action_172+action_138 (83#) = happyShift action_173+action_138 x = happyTcHack x happyFail++action_139 (47#) = happyShift action_171+action_139 x = happyTcHack x happyFail++action_140 (40#) = happyShift action_61+action_140 (41#) = happyShift action_62+action_140 (42#) = happyShift action_63+action_140 (43#) = happyShift action_64+action_140 (44#) = happyShift action_65+action_140 (45#) = happyShift action_66+action_140 (46#) = happyShift action_67+action_140 (47#) = happyShift action_68+action_140 (48#) = happyShift action_69+action_140 (49#) = happyShift action_70+action_140 (50#) = happyShift action_71+action_140 (51#) = happyShift action_72+action_140 (52#) = happyShift action_73+action_140 (53#) = happyShift action_74+action_140 (54#) = happyShift action_75+action_140 (55#) = happyShift action_76+action_140 (56#) = happyShift action_77+action_140 (57#) = happyShift action_78+action_140 (58#) = happyShift action_79+action_140 x = happyTcHack x happyReduce_36++action_141 (31#) = happyShift action_170+action_141 (40#) = happyShift action_61+action_141 (41#) = happyShift action_62+action_141 (42#) = happyShift action_63+action_141 (43#) = happyShift action_64+action_141 (44#) = happyShift action_65+action_141 (45#) = happyShift action_66+action_141 (46#) = happyShift action_67+action_141 (47#) = happyShift action_68+action_141 (48#) = happyShift action_69+action_141 (49#) = happyShift action_70+action_141 (50#) = happyShift action_71+action_141 (51#) = happyShift action_72+action_141 (52#) = happyShift action_73+action_141 (53#) = happyShift action_74+action_141 (54#) = happyShift action_75+action_141 (55#) = happyShift action_76+action_141 (56#) = happyShift action_77+action_141 (57#) = happyShift action_78+action_141 (58#) = happyShift action_79+action_141 x = happyTcHack x happyFail++action_142 (40#) = happyShift action_61+action_142 (41#) = happyShift action_62+action_142 (42#) = happyShift action_63+action_142 (43#) = happyShift action_64+action_142 (44#) = happyShift action_65+action_142 (45#) = happyShift action_66+action_142 (46#) = happyShift action_67+action_142 (47#) = happyShift action_68+action_142 (48#) = happyShift action_69+action_142 (49#) = happyShift action_70+action_142 (50#) = happyShift action_71+action_142 (51#) = happyShift action_72+action_142 (52#) = happyShift action_73+action_142 (53#) = happyShift action_74+action_142 (54#) = happyShift action_75+action_142 (55#) = happyShift action_76+action_142 (56#) = happyShift action_77+action_142 (57#) = happyShift action_78+action_142 (58#) = happyShift action_79+action_142 x = happyTcHack x happyReduce_5++action_143 (40#) = happyShift action_61+action_143 (41#) = happyShift action_62+action_143 (42#) = happyShift action_63+action_143 (43#) = happyShift action_64+action_143 (44#) = happyShift action_65+action_143 (45#) = happyShift action_66+action_143 (46#) = happyShift action_67+action_143 (47#) = happyShift action_68+action_143 (48#) = happyShift action_69+action_143 (49#) = happyShift action_70+action_143 (50#) = happyShift action_71+action_143 (51#) = happyShift action_72+action_143 (52#) = happyShift action_73+action_143 (53#) = happyShift action_74+action_143 (54#) = happyShift action_75+action_143 (55#) = happyShift action_76+action_143 (56#) = happyShift action_77+action_143 (57#) = happyShift action_78+action_143 (58#) = happyShift action_79+action_143 x = happyTcHack x happyReduce_4++action_144 (61#) = happyShift action_169+action_144 x = happyTcHack x happyFail++action_145 x = happyTcHack x happyReduce_87++action_146 (32#) = happyShift action_53+action_146 x = happyTcHack x happyReduce_83++action_147 (34#) = happyShift action_15+action_147 (43#) = happyShift action_18+action_147 (75#) = happyShift action_26+action_147 (78#) = happyShift action_27+action_147 (79#) = happyShift action_28+action_147 (5#) = happyGoto action_2+action_147 (23#) = happyGoto action_168+action_147 (24#) = happyGoto action_10+action_147 (25#) = happyGoto action_11+action_147 x = happyTcHack x happyFail++action_148 (32#) = happyShift action_53+action_148 x = happyTcHack x happyReduce_82++action_149 (51#) = happyShift action_167+action_149 x = happyTcHack x happyFail++action_150 (37#) = happyShift action_166+action_150 (62#) = happyShift action_121+action_150 x = happyTcHack x happyFail++action_151 x = happyTcHack x happyReduce_70++action_152 (27#) = happyShift action_12+action_152 (28#) = happyShift action_13+action_152 (29#) = happyShift action_14+action_152 (34#) = happyShift action_15+action_152 (41#) = happyShift action_16+action_152 (42#) = happyShift action_17+action_152 (43#) = happyShift action_18+action_152 (49#) = happyShift action_19+action_152 (55#) = happyShift action_20+action_152 (59#) = happyShift action_21+action_152 (60#) = happyShift action_22+action_152 (68#) = happyShift action_23+action_152 (69#) = happyShift action_24+action_152 (73#) = happyShift action_25+action_152 (75#) = happyShift action_26+action_152 (78#) = happyShift action_27+action_152 (79#) = happyShift action_28+action_152 (81#) = happyShift action_29+action_152 (82#) = happyShift action_30+action_152 (83#) = happyShift action_31+action_152 (5#) = happyGoto action_2+action_152 (6#) = happyGoto action_45+action_152 (7#) = happyGoto action_165+action_152 (8#) = happyGoto action_4+action_152 (15#) = happyGoto action_5+action_152 (16#) = happyGoto action_6+action_152 (17#) = happyGoto action_7+action_152 (20#) = happyGoto action_8+action_152 (23#) = happyGoto action_9+action_152 (24#) = happyGoto action_10+action_152 (25#) = happyGoto action_11+action_152 x = happyTcHack x happyFail++action_153 (75#) = happyShift action_164+action_153 x = happyTcHack x happyFail++action_154 x = happyTcHack x happyReduce_69++action_155 x = happyTcHack x happyReduce_68++action_156 (40#) = happyShift action_61+action_156 (41#) = happyShift action_62+action_156 (42#) = happyShift action_63+action_156 (43#) = happyShift action_64+action_156 (44#) = happyShift action_65+action_156 (45#) = happyShift action_66+action_156 (46#) = happyShift action_67+action_156 (47#) = happyShift action_68+action_156 (48#) = happyShift action_69+action_156 (49#) = happyShift action_70+action_156 (50#) = happyShift action_71+action_156 (51#) = happyShift action_72+action_156 (52#) = happyShift action_73+action_156 (53#) = happyShift action_74+action_156 (54#) = happyShift action_75+action_156 (55#) = happyShift action_76+action_156 (56#) = happyShift action_77+action_156 (57#) = happyShift action_78+action_156 (58#) = happyShift action_79+action_156 (66#) = happyShift action_162+action_156 (67#) = happyShift action_163+action_156 (14#) = happyGoto action_161+action_156 x = happyTcHack x happyReduce_55++action_157 (62#) = happyShift action_160+action_157 x = happyTcHack x happyReduce_49++action_158 (27#) = happyShift action_12+action_158 (28#) = happyShift action_13+action_158 (29#) = happyShift action_14+action_158 (34#) = happyShift action_15+action_158 (41#) = happyShift action_16+action_158 (42#) = happyShift action_17+action_158 (43#) = happyShift action_18+action_158 (49#) = happyShift action_19+action_158 (55#) = happyShift action_20+action_158 (59#) = happyShift action_21+action_158 (60#) = happyShift action_22+action_158 (68#) = happyShift action_23+action_158 (69#) = happyShift action_24+action_158 (73#) = happyShift action_25+action_158 (75#) = happyShift action_26+action_158 (78#) = happyShift action_27+action_158 (79#) = happyShift action_28+action_158 (81#) = happyShift action_29+action_158 (82#) = happyShift action_30+action_158 (83#) = happyShift action_31+action_158 (5#) = happyGoto action_2+action_158 (6#) = happyGoto action_159+action_158 (8#) = happyGoto action_4+action_158 (15#) = happyGoto action_5+action_158 (16#) = happyGoto action_6+action_158 (17#) = happyGoto action_7+action_158 (20#) = happyGoto action_8+action_158 (23#) = happyGoto action_9+action_158 (24#) = happyGoto action_10+action_158 (25#) = happyGoto action_11+action_158 x = happyTcHack x happyFail++action_159 (40#) = happyShift action_61+action_159 (41#) = happyShift action_62+action_159 (42#) = happyShift action_63+action_159 (43#) = happyShift action_64+action_159 (44#) = happyShift action_65+action_159 (45#) = happyShift action_66+action_159 (46#) = happyShift action_67+action_159 (47#) = happyShift action_68+action_159 (48#) = happyShift action_69+action_159 (49#) = happyShift action_70+action_159 (50#) = happyShift action_71+action_159 (51#) = happyShift action_72+action_159 (52#) = happyShift action_73+action_159 (53#) = happyShift action_74+action_159 (54#) = happyShift action_75+action_159 (55#) = happyShift action_76+action_159 (56#) = happyShift action_77+action_159 (57#) = happyShift action_78+action_159 (58#) = happyShift action_79+action_159 x = happyTcHack x happyReduce_3++action_160 (27#) = happyShift action_12+action_160 (28#) = happyShift action_13+action_160 (29#) = happyShift action_14+action_160 (34#) = happyShift action_15+action_160 (41#) = happyShift action_16+action_160 (42#) = happyShift action_17+action_160 (43#) = happyShift action_18+action_160 (49#) = happyShift action_19+action_160 (55#) = happyShift action_20+action_160 (59#) = happyShift action_21+action_160 (60#) = happyShift action_22+action_160 (68#) = happyShift action_23+action_160 (69#) = happyShift action_24+action_160 (73#) = happyShift action_25+action_160 (75#) = happyShift action_26+action_160 (78#) = happyShift action_27+action_160 (79#) = happyShift action_28+action_160 (81#) = happyShift action_29+action_160 (82#) = happyShift action_30+action_160 (83#) = happyShift action_31+action_160 (5#) = happyGoto action_2+action_160 (6#) = happyGoto action_185+action_160 (8#) = happyGoto action_4+action_160 (15#) = happyGoto action_5+action_160 (16#) = happyGoto action_6+action_160 (17#) = happyGoto action_7+action_160 (20#) = happyGoto action_8+action_160 (23#) = happyGoto action_9+action_160 (24#) = happyGoto action_10+action_160 (25#) = happyGoto action_11+action_160 x = happyTcHack x happyFail++action_161 x = happyTcHack x happyReduce_51++action_162 x = happyTcHack x happyReduce_53++action_163 x = happyTcHack x happyReduce_54++action_164 (51#) = happyShift action_184+action_164 x = happyTcHack x happyFail++action_165 (37#) = happyShift action_183+action_165 (62#) = happyShift action_121+action_165 x = happyTcHack x happyFail++action_166 x = happyTcHack x happyReduce_63++action_167 x = happyTcHack x happyReduce_59++action_168 (32#) = happyShift action_53+action_168 x = happyTcHack x happyReduce_84++action_169 (27#) = happyShift action_12+action_169 (28#) = happyShift action_13+action_169 (29#) = happyShift action_14+action_169 (34#) = happyShift action_15+action_169 (41#) = happyShift action_16+action_169 (42#) = happyShift action_17+action_169 (43#) = happyShift action_18+action_169 (49#) = happyShift action_19+action_169 (55#) = happyShift action_20+action_169 (59#) = happyShift action_21+action_169 (60#) = happyShift action_22+action_169 (68#) = happyShift action_23+action_169 (69#) = happyShift action_24+action_169 (73#) = happyShift action_25+action_169 (75#) = happyShift action_26+action_169 (78#) = happyShift action_27+action_169 (79#) = happyShift action_28+action_169 (81#) = happyShift action_29+action_169 (82#) = happyShift action_30+action_169 (83#) = happyShift action_31+action_169 (5#) = happyGoto action_2+action_169 (6#) = happyGoto action_182+action_169 (8#) = happyGoto action_4+action_169 (15#) = happyGoto action_5+action_169 (16#) = happyGoto action_6+action_169 (17#) = happyGoto action_7+action_169 (20#) = happyGoto action_8+action_169 (23#) = happyGoto action_9+action_169 (24#) = happyGoto action_10+action_169 (25#) = happyGoto action_11+action_169 x = happyTcHack x happyFail++action_170 (27#) = happyShift action_12+action_170 (28#) = happyShift action_13+action_170 (29#) = happyShift action_14+action_170 (34#) = happyShift action_15+action_170 (41#) = happyShift action_16+action_170 (42#) = happyShift action_17+action_170 (43#) = happyShift action_18+action_170 (49#) = happyShift action_19+action_170 (55#) = happyShift action_20+action_170 (59#) = happyShift action_21+action_170 (60#) = happyShift action_22+action_170 (68#) = happyShift action_23+action_170 (69#) = happyShift action_24+action_170 (73#) = happyShift action_25+action_170 (75#) = happyShift action_26+action_170 (78#) = happyShift action_27+action_170 (79#) = happyShift action_28+action_170 (81#) = happyShift action_29+action_170 (82#) = happyShift action_30+action_170 (83#) = happyShift action_31+action_170 (5#) = happyGoto action_2+action_170 (6#) = happyGoto action_181+action_170 (8#) = happyGoto action_4+action_170 (15#) = happyGoto action_5+action_170 (16#) = happyGoto action_6+action_170 (17#) = happyGoto action_7+action_170 (20#) = happyGoto action_8+action_170 (23#) = happyGoto action_9+action_170 (24#) = happyGoto action_10+action_170 (25#) = happyGoto action_11+action_170 x = happyTcHack x happyFail++action_171 (38#) = happyShift action_179+action_171 (83#) = happyShift action_180+action_171 x = happyTcHack x happyFail++action_172 (27#) = happyShift action_12+action_172 (28#) = happyShift action_13+action_172 (29#) = happyShift action_14+action_172 (34#) = happyShift action_15+action_172 (41#) = happyShift action_16+action_172 (42#) = happyShift action_17+action_172 (43#) = happyShift action_18+action_172 (49#) = happyShift action_19+action_172 (55#) = happyShift action_20+action_172 (59#) = happyShift action_21+action_172 (60#) = happyShift action_22+action_172 (68#) = happyShift action_23+action_172 (69#) = happyShift action_24+action_172 (73#) = happyShift action_25+action_172 (75#) = happyShift action_26+action_172 (78#) = happyShift action_27+action_172 (79#) = happyShift action_28+action_172 (81#) = happyShift action_29+action_172 (82#) = happyShift action_30+action_172 (83#) = happyShift action_31+action_172 (5#) = happyGoto action_2+action_172 (6#) = happyGoto action_178+action_172 (8#) = happyGoto action_4+action_172 (15#) = happyGoto action_5+action_172 (16#) = happyGoto action_6+action_172 (17#) = happyGoto action_7+action_172 (20#) = happyGoto action_8+action_172 (23#) = happyGoto action_9+action_172 (24#) = happyGoto action_10+action_172 (25#) = happyGoto action_11+action_172 x = happyTcHack x happyFail++action_173 x = happyTcHack x happyReduce_71++action_174 (79#) = happyShift action_28+action_174 (5#) = happyGoto action_177+action_174 x = happyTcHack x happyFail++action_175 (27#) = happyShift action_12+action_175 (28#) = happyShift action_13+action_175 (29#) = happyShift action_14+action_175 (34#) = happyShift action_15+action_175 (41#) = happyShift action_16+action_175 (42#) = happyShift action_17+action_175 (43#) = happyShift action_18+action_175 (49#) = happyShift action_19+action_175 (55#) = happyShift action_20+action_175 (59#) = happyShift action_21+action_175 (60#) = happyShift action_22+action_175 (68#) = happyShift action_23+action_175 (69#) = happyShift action_24+action_175 (73#) = happyShift action_25+action_175 (75#) = happyShift action_26+action_175 (78#) = happyShift action_27+action_175 (79#) = happyShift action_28+action_175 (81#) = happyShift action_29+action_175 (82#) = happyShift action_30+action_175 (83#) = happyShift action_31+action_175 (5#) = happyGoto action_2+action_175 (6#) = happyGoto action_176+action_175 (8#) = happyGoto action_4+action_175 (15#) = happyGoto action_5+action_175 (16#) = happyGoto action_6+action_175 (17#) = happyGoto action_7+action_175 (20#) = happyGoto action_8+action_175 (23#) = happyGoto action_9+action_175 (24#) = happyGoto action_10+action_175 (25#) = happyGoto action_11+action_175 x = happyTcHack x happyFail++action_176 (40#) = happyShift action_61+action_176 (41#) = happyShift action_62+action_176 (42#) = happyShift action_63+action_176 (43#) = happyShift action_64+action_176 (44#) = happyShift action_65+action_176 (45#) = happyShift action_66+action_176 (46#) = happyShift action_67+action_176 (47#) = happyShift action_68+action_176 (48#) = happyShift action_69+action_176 (49#) = happyShift action_70+action_176 (50#) = happyShift action_71+action_176 (51#) = happyShift action_72+action_176 (52#) = happyShift action_73+action_176 (53#) = happyShift action_74+action_176 (54#) = happyShift action_75+action_176 (55#) = happyShift action_76+action_176 (56#) = happyShift action_77+action_176 (57#) = happyShift action_78+action_176 (58#) = happyShift action_79+action_176 x = happyTcHack x happyReduce_46++action_177 x = happyTcHack x happyReduce_42++action_178 (39#) = happyShift action_189+action_178 (40#) = happyShift action_61+action_178 (41#) = happyShift action_62+action_178 (42#) = happyShift action_63+action_178 (43#) = happyShift action_64+action_178 (44#) = happyShift action_65+action_178 (45#) = happyShift action_66+action_178 (46#) = happyShift action_67+action_178 (47#) = happyShift action_68+action_178 (48#) = happyShift action_69+action_178 (49#) = happyShift action_70+action_178 (50#) = happyShift action_71+action_178 (51#) = happyShift action_72+action_178 (52#) = happyShift action_73+action_178 (53#) = happyShift action_74+action_178 (54#) = happyShift action_75+action_178 (55#) = happyShift action_76+action_178 (56#) = happyShift action_77+action_178 (57#) = happyShift action_78+action_178 (58#) = happyShift action_79+action_178 x = happyTcHack x happyFail++action_179 (27#) = happyShift action_12+action_179 (28#) = happyShift action_13+action_179 (29#) = happyShift action_14+action_179 (34#) = happyShift action_15+action_179 (41#) = happyShift action_16+action_179 (42#) = happyShift action_17+action_179 (43#) = happyShift action_18+action_179 (49#) = happyShift action_19+action_179 (55#) = happyShift action_20+action_179 (59#) = happyShift action_21+action_179 (60#) = happyShift action_22+action_179 (68#) = happyShift action_23+action_179 (69#) = happyShift action_24+action_179 (73#) = happyShift action_25+action_179 (75#) = happyShift action_26+action_179 (78#) = happyShift action_27+action_179 (79#) = happyShift action_28+action_179 (81#) = happyShift action_29+action_179 (82#) = happyShift action_30+action_179 (83#) = happyShift action_31+action_179 (5#) = happyGoto action_2+action_179 (6#) = happyGoto action_188+action_179 (8#) = happyGoto action_4+action_179 (15#) = happyGoto action_5+action_179 (16#) = happyGoto action_6+action_179 (17#) = happyGoto action_7+action_179 (20#) = happyGoto action_8+action_179 (23#) = happyGoto action_9+action_179 (24#) = happyGoto action_10+action_179 (25#) = happyGoto action_11+action_179 x = happyTcHack x happyFail++action_180 x = happyTcHack x happyReduce_73++action_181 (40#) = happyShift action_61+action_181 (41#) = happyShift action_62+action_181 (42#) = happyShift action_63+action_181 (43#) = happyShift action_64+action_181 (44#) = happyShift action_65+action_181 (45#) = happyShift action_66+action_181 (46#) = happyShift action_67+action_181 (47#) = happyShift action_68+action_181 (48#) = happyShift action_69+action_181 (49#) = happyShift action_70+action_181 (50#) = happyShift action_71+action_181 (51#) = happyShift action_72+action_181 (52#) = happyShift action_73+action_181 (53#) = happyShift action_74+action_181 (54#) = happyShift action_75+action_181 (55#) = happyShift action_76+action_181 (56#) = happyShift action_77+action_181 (57#) = happyShift action_78+action_181 (58#) = happyShift action_79+action_181 x = happyTcHack x happyReduce_6++action_182 (40#) = happyShift action_61+action_182 (41#) = happyShift action_62+action_182 (42#) = happyShift action_63+action_182 (43#) = happyShift action_64+action_182 (44#) = happyShift action_65+action_182 (45#) = happyShift action_66+action_182 (46#) = happyShift action_67+action_182 (47#) = happyShift action_68+action_182 (48#) = happyShift action_69+action_182 (49#) = happyShift action_70+action_182 (50#) = happyShift action_71+action_182 (51#) = happyShift action_72+action_182 (52#) = happyShift action_73+action_182 (53#) = happyShift action_74+action_182 (54#) = happyShift action_75+action_182 (55#) = happyShift action_76+action_182 (56#) = happyShift action_77+action_182 (57#) = happyShift action_78+action_182 (58#) = happyShift action_79+action_182 (76#) = happyShift action_187+action_182 x = happyTcHack x happyReduce_43++action_183 x = happyTcHack x happyReduce_67++action_184 x = happyTcHack x happyReduce_58++action_185 (40#) = happyShift action_61+action_185 (41#) = happyShift action_62+action_185 (42#) = happyShift action_63+action_185 (43#) = happyShift action_64+action_185 (44#) = happyShift action_65+action_185 (45#) = happyShift action_66+action_185 (46#) = happyShift action_67+action_185 (47#) = happyShift action_68+action_185 (48#) = happyShift action_69+action_185 (49#) = happyShift action_70+action_185 (50#) = happyShift action_71+action_185 (51#) = happyShift action_72+action_185 (52#) = happyShift action_73+action_185 (53#) = happyShift action_74+action_185 (54#) = happyShift action_75+action_185 (55#) = happyShift action_76+action_185 (56#) = happyShift action_77+action_185 (57#) = happyShift action_78+action_185 (58#) = happyShift action_79+action_185 (66#) = happyShift action_162+action_185 (67#) = happyShift action_163+action_185 (14#) = happyGoto action_186+action_185 x = happyTcHack x happyReduce_55++action_186 x = happyTcHack x happyReduce_52++action_187 (79#) = happyShift action_28+action_187 (5#) = happyGoto action_191+action_187 x = happyTcHack x happyFail++action_188 (39#) = happyShift action_190+action_188 (40#) = happyShift action_61+action_188 (41#) = happyShift action_62+action_188 (42#) = happyShift action_63+action_188 (43#) = happyShift action_64+action_188 (44#) = happyShift action_65+action_188 (45#) = happyShift action_66+action_188 (46#) = happyShift action_67+action_188 (47#) = happyShift action_68+action_188 (48#) = happyShift action_69+action_188 (49#) = happyShift action_70+action_188 (50#) = happyShift action_71+action_188 (51#) = happyShift action_72+action_188 (52#) = happyShift action_73+action_188 (53#) = happyShift action_74+action_188 (54#) = happyShift action_75+action_188 (55#) = happyShift action_76+action_188 (56#) = happyShift action_77+action_188 (57#) = happyShift action_78+action_188 (58#) = happyShift action_79+action_188 x = happyTcHack x happyFail++action_189 x = happyTcHack x happyReduce_72++action_190 x = happyTcHack x happyReduce_74++action_191 x = happyTcHack x happyReduce_44++happyReduce_1 = happySpecReduce_1 4# happyReduction_1+happyReduction_1 happy_x_1+ = case happyOut6 happy_x_1 of { happy_var_1 -> + happyIn4+ (happy_var_1+ )}++happyReduce_2 = happySpecReduce_1 5# happyReduction_2+happyReduction_2 happy_x_1+ = case happyOutTok happy_x_1 of { (Variable happy_var_1) -> + happyIn5+ (Avar happy_var_1+ )}++happyReduce_3 = happyReduce 5# 6# happyReduction_3+happyReduction_3 (happy_x_5 `HappyStk`+ happy_x_4 `HappyStk`+ happy_x_3 `HappyStk`+ happy_x_2 `HappyStk`+ happy_x_1 `HappyStk`+ happyRest)+ = case happyOut8 happy_x_1 of { happy_var_1 -> + case happyOut11 happy_x_2 of { happy_var_2 -> + case happyOut12 happy_x_3 of { happy_var_3 -> + case happyOut6 happy_x_5 of { happy_var_5 -> + happyIn6+ ((snd happy_var_3) (happy_var_1 (happy_var_2 ((fst happy_var_3) happy_var_5)))+ ) `HappyStk` happyRest}}}}++happyReduce_4 = happyReduce 4# 6# happyReduction_4+happyReduction_4 (happy_x_4 `HappyStk`+ happy_x_3 `HappyStk`+ happy_x_2 `HappyStk`+ happy_x_1 `HappyStk`+ happyRest)+ = case happyOut9 happy_x_2 of { happy_var_2 -> + case happyOut6 happy_x_4 of { happy_var_4 -> + happyIn6+ (call "some" [happy_var_2 happy_var_4]+ ) `HappyStk` happyRest}}++happyReduce_5 = happyReduce 4# 6# happyReduction_5+happyReduction_5 (happy_x_4 `HappyStk`+ happy_x_3 `HappyStk`+ happy_x_2 `HappyStk`+ happy_x_1 `HappyStk`+ happyRest)+ = case happyOut9 happy_x_2 of { happy_var_2 -> + case happyOut6 happy_x_4 of { happy_var_4 -> + happyIn6+ (call "not" [call "some" [happy_var_2 (call "not" [happy_var_4])]]+ ) `HappyStk` happyRest}}++happyReduce_6 = happyReduce 6# 6# happyReduction_6+happyReduction_6 (happy_x_6 `HappyStk`+ happy_x_5 `HappyStk`+ happy_x_4 `HappyStk`+ happy_x_3 `HappyStk`+ happy_x_2 `HappyStk`+ happy_x_1 `HappyStk`+ happyRest)+ = case happyOut6 happy_x_2 of { happy_var_2 -> + case happyOut6 happy_x_4 of { happy_var_4 -> + case happyOut6 happy_x_6 of { happy_var_6 -> + happyIn6+ (call "if" [happy_var_2,happy_var_4,happy_var_6]+ ) `HappyStk` happyRest}}}++happyReduce_7 = happySpecReduce_1 6# happyReduction_7+happyReduction_7 happy_x_1+ = case happyOut20 happy_x_1 of { happy_var_1 -> + happyIn6+ (happy_var_1+ )}++happyReduce_8 = happySpecReduce_1 6# happyReduction_8+happyReduction_8 happy_x_1+ = case happyOut16 happy_x_1 of { happy_var_1 -> + happyIn6+ (happy_var_1+ )}++happyReduce_9 = happySpecReduce_1 6# happyReduction_9+happyReduction_9 happy_x_1+ = case happyOut15 happy_x_1 of { happy_var_1 -> + happyIn6+ (happy_var_1+ )}++happyReduce_10 = happySpecReduce_3 6# happyReduction_10+happyReduction_10 happy_x_3+ happy_x_2+ happy_x_1+ = case happyOut6 happy_x_1 of { happy_var_1 -> + case happyOut6 happy_x_3 of { happy_var_3 -> + happyIn6+ (call "to" [happy_var_1,happy_var_3]+ )}}++happyReduce_11 = happySpecReduce_3 6# happyReduction_11+happyReduction_11 happy_x_3+ happy_x_2+ happy_x_1+ = case happyOut6 happy_x_1 of { happy_var_1 -> + case happyOut6 happy_x_3 of { happy_var_3 -> + happyIn6+ (call "+" [happy_var_1,happy_var_3]+ )}}++happyReduce_12 = happySpecReduce_3 6# happyReduction_12+happyReduction_12 happy_x_3+ happy_x_2+ happy_x_1+ = case happyOut6 happy_x_1 of { happy_var_1 -> + case happyOut6 happy_x_3 of { happy_var_3 -> + happyIn6+ (call "-" [happy_var_1,happy_var_3]+ )}}++happyReduce_13 = happySpecReduce_3 6# happyReduction_13+happyReduction_13 happy_x_3+ happy_x_2+ happy_x_1+ = case happyOut6 happy_x_1 of { happy_var_1 -> + case happyOut6 happy_x_3 of { happy_var_3 -> + happyIn6+ (call "*" [happy_var_1,happy_var_3]+ )}}++happyReduce_14 = happySpecReduce_3 6# happyReduction_14+happyReduction_14 happy_x_3+ happy_x_2+ happy_x_1+ = case happyOut6 happy_x_1 of { happy_var_1 -> + case happyOut6 happy_x_3 of { happy_var_3 -> + happyIn6+ (call "div" [happy_var_1,happy_var_3]+ )}}++happyReduce_15 = happySpecReduce_3 6# happyReduction_15+happyReduction_15 happy_x_3+ happy_x_2+ happy_x_1+ = case happyOut6 happy_x_1 of { happy_var_1 -> + case happyOut6 happy_x_3 of { happy_var_3 -> + happyIn6+ (call "idiv" [happy_var_1,happy_var_3]+ )}}++happyReduce_16 = happySpecReduce_3 6# happyReduction_16+happyReduction_16 happy_x_3+ happy_x_2+ happy_x_1+ = case happyOut6 happy_x_1 of { happy_var_1 -> + case happyOut6 happy_x_3 of { happy_var_3 -> + happyIn6+ (call "mod" [happy_var_1,happy_var_3]+ )}}++happyReduce_17 = happySpecReduce_3 6# happyReduction_17+happyReduction_17 happy_x_3+ happy_x_2+ happy_x_1+ = case happyOut6 happy_x_1 of { happy_var_1 -> + case happyOut6 happy_x_3 of { happy_var_3 -> + happyIn6+ (call "=" [happy_var_1,happy_var_3]+ )}}++happyReduce_18 = happySpecReduce_3 6# happyReduction_18+happyReduction_18 happy_x_3+ happy_x_2+ happy_x_1+ = case happyOut6 happy_x_1 of { happy_var_1 -> + case happyOut6 happy_x_3 of { happy_var_3 -> + happyIn6+ (call "!=" [happy_var_1,happy_var_3]+ )}}++happyReduce_19 = happySpecReduce_3 6# happyReduction_19+happyReduction_19 happy_x_3+ happy_x_2+ happy_x_1+ = case happyOut6 happy_x_1 of { happy_var_1 -> + case happyOut6 happy_x_3 of { happy_var_3 -> + happyIn6+ (call "<" [happy_var_1,happy_var_3]+ )}}++happyReduce_20 = happySpecReduce_3 6# happyReduction_20+happyReduction_20 happy_x_3+ happy_x_2+ happy_x_1+ = case happyOut6 happy_x_1 of { happy_var_1 -> + case happyOut6 happy_x_3 of { happy_var_3 -> + happyIn6+ (call "<=" [happy_var_1,happy_var_3]+ )}}++happyReduce_21 = happySpecReduce_3 6# happyReduction_21+happyReduction_21 happy_x_3+ happy_x_2+ happy_x_1+ = case happyOut6 happy_x_1 of { happy_var_1 -> + case happyOut6 happy_x_3 of { happy_var_3 -> + happyIn6+ (call ">" [happy_var_1,happy_var_3]+ )}}++happyReduce_22 = happySpecReduce_3 6# happyReduction_22+happyReduction_22 happy_x_3+ happy_x_2+ happy_x_1+ = case happyOut6 happy_x_1 of { happy_var_1 -> + case happyOut6 happy_x_3 of { happy_var_3 -> + happyIn6+ (call ">=" [happy_var_1,happy_var_3]+ )}}++happyReduce_23 = happySpecReduce_3 6# happyReduction_23+happyReduction_23 happy_x_3+ happy_x_2+ happy_x_1+ = case happyOut6 happy_x_1 of { happy_var_1 -> + case happyOut6 happy_x_3 of { happy_var_3 -> + happyIn6+ (call "and" [happy_var_1,happy_var_3]+ )}}++happyReduce_24 = happySpecReduce_3 6# happyReduction_24+happyReduction_24 happy_x_3+ happy_x_2+ happy_x_1+ = case happyOut6 happy_x_1 of { happy_var_1 -> + case happyOut6 happy_x_3 of { happy_var_3 -> + happyIn6+ (call "or" [happy_var_1,happy_var_3]+ )}}++happyReduce_25 = happySpecReduce_3 6# happyReduction_25+happyReduction_25 happy_x_3+ happy_x_2+ happy_x_1+ = case happyOut6 happy_x_1 of { happy_var_1 -> + case happyOut6 happy_x_3 of { happy_var_3 -> + happyIn6+ (call "not" [happy_var_1,happy_var_3]+ )}}++happyReduce_26 = happySpecReduce_3 6# happyReduction_26+happyReduction_26 happy_x_3+ happy_x_2+ happy_x_1+ = case happyOut6 happy_x_1 of { happy_var_1 -> + case happyOut6 happy_x_3 of { happy_var_3 -> + happyIn6+ (call "union" [happy_var_1,happy_var_3]+ )}}++happyReduce_27 = happySpecReduce_3 6# happyReduction_27+happyReduction_27 happy_x_3+ happy_x_2+ happy_x_1+ = case happyOut6 happy_x_1 of { happy_var_1 -> + case happyOut6 happy_x_3 of { happy_var_3 -> + happyIn6+ (call "itersect" [happy_var_1,happy_var_3]+ )}}++happyReduce_28 = happySpecReduce_3 6# happyReduction_28+happyReduction_28 happy_x_3+ happy_x_2+ happy_x_1+ = case happyOut6 happy_x_1 of { happy_var_1 -> + case happyOut6 happy_x_3 of { happy_var_3 -> + happyIn6+ (call "except" [happy_var_1,happy_var_3]+ )}}++happyReduce_29 = happySpecReduce_2 6# happyReduction_29+happyReduction_29 happy_x_2+ happy_x_1+ = case happyOut6 happy_x_2 of { happy_var_2 -> + happyIn6+ (call "uplus" [happy_var_2]+ )}++happyReduce_30 = happySpecReduce_2 6# happyReduction_30+happyReduction_30 happy_x_2+ happy_x_1+ = case happyOut6 happy_x_2 of { happy_var_2 -> + happyIn6+ (call "uminus" [happy_var_2]+ )}++happyReduce_31 = happySpecReduce_2 6# happyReduction_31+happyReduction_31 happy_x_2+ happy_x_1+ = case happyOut6 happy_x_2 of { happy_var_2 -> + happyIn6+ (call "not" [happy_var_2]+ )}++happyReduce_32 = happySpecReduce_1 6# happyReduction_32+happyReduction_32 happy_x_1+ = case happyOutTok happy_x_1 of { (TString happy_var_1) -> + happyIn6+ (Astring happy_var_1+ )}++happyReduce_33 = happySpecReduce_1 6# happyReduction_33+happyReduction_33 happy_x_1+ = case happyOutTok happy_x_1 of { (TInteger happy_var_1) -> + happyIn6+ (Aint happy_var_1+ )}++happyReduce_34 = happySpecReduce_1 6# happyReduction_34+happyReduction_34 happy_x_1+ = case happyOutTok happy_x_1 of { (TFloat happy_var_1) -> + happyIn6+ (Afloat happy_var_1+ )}++happyReduce_35 = happySpecReduce_1 7# happyReduction_35+happyReduction_35 happy_x_1+ = case happyOut6 happy_x_1 of { happy_var_1 -> + happyIn7+ ([happy_var_1]+ )}++happyReduce_36 = happySpecReduce_3 7# happyReduction_36+happyReduction_36 happy_x_3+ happy_x_2+ happy_x_1+ = case happyOut7 happy_x_1 of { happy_var_1 -> + case happyOut6 happy_x_3 of { happy_var_3 -> + happyIn7+ (happy_var_1++[happy_var_3]+ )}}++happyReduce_37 = happySpecReduce_2 8# happyReduction_37+happyReduction_37 happy_x_2+ happy_x_1+ = case happyOut9 happy_x_2 of { happy_var_2 -> + happyIn8+ (happy_var_2+ )}++happyReduce_38 = happySpecReduce_2 8# happyReduction_38+happyReduction_38 happy_x_2+ happy_x_1+ = case happyOut10 happy_x_2 of { happy_var_2 -> + happyIn8+ (happy_var_2+ )}++happyReduce_39 = happySpecReduce_3 8# happyReduction_39+happyReduction_39 happy_x_3+ happy_x_2+ happy_x_1+ = case happyOut8 happy_x_1 of { happy_var_1 -> + case happyOut9 happy_x_3 of { happy_var_3 -> + happyIn8+ (happy_var_1 . happy_var_3+ )}}++happyReduce_40 = happySpecReduce_3 8# happyReduction_40+happyReduction_40 happy_x_3+ happy_x_2+ happy_x_1+ = case happyOut8 happy_x_1 of { happy_var_1 -> + case happyOut10 happy_x_3 of { happy_var_3 -> + happyIn8+ (happy_var_1 . happy_var_3+ )}}++happyReduce_41 = happySpecReduce_3 9# happyReduction_41+happyReduction_41 happy_x_3+ happy_x_2+ happy_x_1+ = case happyOut5 happy_x_1 of { happy_var_1 -> + case happyOut6 happy_x_3 of { happy_var_3 -> + happyIn9+ (\x -> Ast "for" [happy_var_1,Avar "$",happy_var_3,x]+ )}}++happyReduce_42 = happyReduce 5# 9# happyReduction_42+happyReduction_42 (happy_x_5 `HappyStk`+ happy_x_4 `HappyStk`+ happy_x_3 `HappyStk`+ happy_x_2 `HappyStk`+ happy_x_1 `HappyStk`+ happyRest)+ = case happyOut5 happy_x_1 of { happy_var_1 -> + case happyOut6 happy_x_3 of { happy_var_3 -> + case happyOut5 happy_x_5 of { happy_var_5 -> + happyIn9+ (\x -> Ast "for" [happy_var_1,happy_var_5,happy_var_3,x]+ ) `HappyStk` happyRest}}}++happyReduce_43 = happyReduce 5# 9# happyReduction_43+happyReduction_43 (happy_x_5 `HappyStk`+ happy_x_4 `HappyStk`+ happy_x_3 `HappyStk`+ happy_x_2 `HappyStk`+ happy_x_1 `HappyStk`+ happyRest)+ = case happyOut9 happy_x_1 of { happy_var_1 -> + case happyOut5 happy_x_3 of { happy_var_3 -> + case happyOut6 happy_x_5 of { happy_var_5 -> + happyIn9+ (\x -> happy_var_1(Ast "for" [happy_var_3,Avar "$",happy_var_5,x])+ ) `HappyStk` happyRest}}}++happyReduce_44 = happyReduce 7# 9# happyReduction_44+happyReduction_44 (happy_x_7 `HappyStk`+ happy_x_6 `HappyStk`+ happy_x_5 `HappyStk`+ happy_x_4 `HappyStk`+ happy_x_3 `HappyStk`+ happy_x_2 `HappyStk`+ happy_x_1 `HappyStk`+ happyRest)+ = case happyOut9 happy_x_1 of { happy_var_1 -> + case happyOut5 happy_x_3 of { happy_var_3 -> + case happyOut6 happy_x_5 of { happy_var_5 -> + case happyOut5 happy_x_7 of { happy_var_7 -> + happyIn9+ (\x -> happy_var_1(Ast "for" [happy_var_3,happy_var_7,happy_var_5,x])+ ) `HappyStk` happyRest}}}}++happyReduce_45 = happySpecReduce_3 10# happyReduction_45+happyReduction_45 happy_x_3+ happy_x_2+ happy_x_1+ = case happyOut5 happy_x_1 of { happy_var_1 -> + case happyOut6 happy_x_3 of { happy_var_3 -> + happyIn10+ (\x -> Ast "let" [happy_var_1,happy_var_3,x]+ )}}++happyReduce_46 = happyReduce 5# 10# happyReduction_46+happyReduction_46 (happy_x_5 `HappyStk`+ happy_x_4 `HappyStk`+ happy_x_3 `HappyStk`+ happy_x_2 `HappyStk`+ happy_x_1 `HappyStk`+ happyRest)+ = case happyOut10 happy_x_1 of { happy_var_1 -> + case happyOut5 happy_x_3 of { happy_var_3 -> + case happyOut6 happy_x_5 of { happy_var_5 -> + happyIn10+ (\x -> happy_var_1(Ast "let" [happy_var_3,happy_var_5,x])+ ) `HappyStk` happyRest}}}++happyReduce_47 = happySpecReduce_2 11# happyReduction_47+happyReduction_47 happy_x_2+ happy_x_1+ = case happyOut6 happy_x_2 of { happy_var_2 -> + happyIn11+ (\x -> Ast "predicate" [happy_var_2,x]+ )}++happyReduce_48 = happySpecReduce_0 11# happyReduction_48+happyReduction_48 = happyIn11+ (id+ )++happyReduce_49 = happySpecReduce_2 12# happyReduction_49+happyReduction_49 happy_x_2+ happy_x_1+ = case happyOut13 happy_x_2 of { happy_var_2 -> + happyIn12+ ((\x -> Ast "sortTuple" (x:(fst happy_var_2)),+ \x -> Ast "sort" (x:(snd happy_var_2)))+ )}++happyReduce_50 = happySpecReduce_0 12# happyReduction_50+happyReduction_50 = happyIn12+ ((id,id)+ )++happyReduce_51 = happySpecReduce_2 13# happyReduction_51+happyReduction_51 happy_x_2+ happy_x_1+ = case happyOut6 happy_x_1 of { happy_var_1 -> + case happyOut14 happy_x_2 of { happy_var_2 -> + happyIn13+ (([happy_var_1],[happy_var_2])+ )}}++happyReduce_52 = happyReduce 4# 13# happyReduction_52+happyReduction_52 (happy_x_4 `HappyStk`+ happy_x_3 `HappyStk`+ happy_x_2 `HappyStk`+ happy_x_1 `HappyStk`+ happyRest)+ = case happyOut13 happy_x_1 of { happy_var_1 -> + case happyOut6 happy_x_3 of { happy_var_3 -> + case happyOut14 happy_x_4 of { happy_var_4 -> + happyIn13+ (((fst happy_var_1)++[happy_var_3],(snd happy_var_1)++[happy_var_4])+ ) `HappyStk` happyRest}}}++happyReduce_53 = happySpecReduce_1 14# happyReduction_53+happyReduction_53 happy_x_1+ = happyIn14+ (Avar "ascending"+ )++happyReduce_54 = happySpecReduce_1 14# happyReduction_54+happyReduction_54 happy_x_1+ = happyIn14+ (Avar "descending"+ )++happyReduce_55 = happySpecReduce_0 14# happyReduction_55+happyReduction_55 = happyIn14+ (Avar "ascending"+ )++happyReduce_56 = happyReduce 4# 15# happyReduction_56+happyReduction_56 (happy_x_4 `HappyStk`+ happy_x_3 `HappyStk`+ happy_x_2 `HappyStk`+ happy_x_1 `HappyStk`+ happyRest)+ = case happyOutTok happy_x_3 of { (QName happy_var_3) -> + happyIn15+ (call "element" [Avar happy_var_3]+ ) `HappyStk` happyRest}++happyReduce_57 = happyReduce 4# 15# happyReduction_57+happyReduction_57 (happy_x_4 `HappyStk`+ happy_x_3 `HappyStk`+ happy_x_2 `HappyStk`+ happy_x_1 `HappyStk`+ happyRest)+ = case happyOutTok happy_x_3 of { (QName happy_var_3) -> + happyIn15+ (call "attribute" [Avar happy_var_3]+ ) `HappyStk` happyRest}++happyReduce_58 = happyReduce 6# 16# happyReduction_58+happyReduction_58 (happy_x_6 `HappyStk`+ happy_x_5 `HappyStk`+ happy_x_4 `HappyStk`+ happy_x_3 `HappyStk`+ happy_x_2 `HappyStk`+ happy_x_1 `HappyStk`+ happyRest)+ = case happyOut17 happy_x_1 of { happy_var_1 -> + case happyOut18 happy_x_3 of { happy_var_3 -> + case happyOutTok happy_x_5 of { (QName happy_var_5) -> + happyIn16+ (if head happy_var_1 == Astring happy_var_5+ then Ast "construction" (happy_var_1++[concatAll happy_var_3])+ else error("Unmatched tags in element construction: "++happy_var_5)+ ) `HappyStk` happyRest}}}++happyReduce_59 = happyReduce 5# 16# happyReduction_59+happyReduction_59 (happy_x_5 `HappyStk`+ happy_x_4 `HappyStk`+ happy_x_3 `HappyStk`+ happy_x_2 `HappyStk`+ happy_x_1 `HappyStk`+ happyRest)+ = case happyOut17 happy_x_1 of { happy_var_1 -> + case happyOutTok happy_x_4 of { (QName happy_var_4) -> + happyIn16+ (if head happy_var_1 == Astring happy_var_4+ then Ast "construction" (happy_var_1++[call "empty" []])+ else error("Unmatched tags in element construction: "++happy_var_4)+ ) `HappyStk` happyRest}}++happyReduce_60 = happySpecReduce_2 16# happyReduction_60+happyReduction_60 happy_x_2+ happy_x_1+ = case happyOut17 happy_x_1 of { happy_var_1 -> + happyIn16+ (Ast "construction" (happy_var_1++[call "empty" []])+ )}++happyReduce_61 = happySpecReduce_2 17# happyReduction_61+happyReduction_61 happy_x_2+ happy_x_1+ = case happyOutTok happy_x_2 of { (QName happy_var_2) -> + happyIn17+ ([Astring happy_var_2,Ast "attributes" []]+ )}++happyReduce_62 = happySpecReduce_3 17# happyReduction_62+happyReduction_62 happy_x_3+ happy_x_2+ happy_x_1+ = case happyOutTok happy_x_2 of { (QName happy_var_2) -> + case happyOut19 happy_x_3 of { happy_var_3 -> + happyIn17+ ([Astring happy_var_2,Ast "attributes" happy_var_3]+ )}}++happyReduce_63 = happySpecReduce_3 18# happyReduction_63+happyReduction_63 happy_x_3+ happy_x_2+ happy_x_1+ = case happyOut7 happy_x_2 of { happy_var_2 -> + happyIn18+ (happy_var_2+ )}++happyReduce_64 = happySpecReduce_1 18# happyReduction_64+happyReduction_64 happy_x_1+ = case happyOutTok happy_x_1 of { (TString happy_var_1) -> + happyIn18+ ([Astring happy_var_1]+ )}++happyReduce_65 = happySpecReduce_1 18# happyReduction_65+happyReduction_65 happy_x_1+ = case happyOutTok happy_x_1 of { (XMLtext happy_var_1) -> + happyIn18+ ([Astring happy_var_1]+ )}++happyReduce_66 = happySpecReduce_1 18# happyReduction_66+happyReduction_66 happy_x_1+ = case happyOut16 happy_x_1 of { happy_var_1 -> + happyIn18+ ([happy_var_1]+ )}++happyReduce_67 = happyReduce 4# 18# happyReduction_67+happyReduction_67 (happy_x_4 `HappyStk`+ happy_x_3 `HappyStk`+ happy_x_2 `HappyStk`+ happy_x_1 `HappyStk`+ happyRest)+ = case happyOut18 happy_x_1 of { happy_var_1 -> + case happyOut7 happy_x_3 of { happy_var_3 -> + happyIn18+ (happy_var_1++happy_var_3+ ) `HappyStk` happyRest}}++happyReduce_68 = happySpecReduce_2 18# happyReduction_68+happyReduction_68 happy_x_2+ happy_x_1+ = case happyOut18 happy_x_1 of { happy_var_1 -> + case happyOutTok happy_x_2 of { (TString happy_var_2) -> + happyIn18+ (happy_var_1++[Astring happy_var_2]+ )}}++happyReduce_69 = happySpecReduce_2 18# happyReduction_69+happyReduction_69 happy_x_2+ happy_x_1+ = case happyOut18 happy_x_1 of { happy_var_1 -> + case happyOutTok happy_x_2 of { (XMLtext happy_var_2) -> + happyIn18+ (happy_var_1++[Astring happy_var_2]+ )}}++happyReduce_70 = happySpecReduce_2 18# happyReduction_70+happyReduction_70 happy_x_2+ happy_x_1+ = case happyOut18 happy_x_1 of { happy_var_1 -> + case happyOut16 happy_x_2 of { happy_var_2 -> + happyIn18+ (happy_var_1++[happy_var_2]+ )}}++happyReduce_71 = happySpecReduce_3 19# happyReduction_71+happyReduction_71 happy_x_3+ happy_x_2+ happy_x_1+ = case happyOutTok happy_x_1 of { (QName happy_var_1) -> + case happyOutTok happy_x_3 of { (TString happy_var_3) -> + happyIn19+ ([Ast "pair" [Astring happy_var_1,Astring happy_var_3]]+ )}}++happyReduce_72 = happyReduce 5# 19# happyReduction_72+happyReduction_72 (happy_x_5 `HappyStk`+ happy_x_4 `HappyStk`+ happy_x_3 `HappyStk`+ happy_x_2 `HappyStk`+ happy_x_1 `HappyStk`+ happyRest)+ = case happyOutTok happy_x_1 of { (QName happy_var_1) -> + case happyOut6 happy_x_4 of { happy_var_4 -> + happyIn19+ ([Ast "pair" [Astring happy_var_1,happy_var_4]]+ ) `HappyStk` happyRest}}++happyReduce_73 = happyReduce 4# 19# happyReduction_73+happyReduction_73 (happy_x_4 `HappyStk`+ happy_x_3 `HappyStk`+ happy_x_2 `HappyStk`+ happy_x_1 `HappyStk`+ happyRest)+ = case happyOut19 happy_x_1 of { happy_var_1 -> + case happyOutTok happy_x_2 of { (QName happy_var_2) -> + case happyOutTok happy_x_4 of { (TString happy_var_4) -> + happyIn19+ ((Ast "pair" [Astring happy_var_2,Astring happy_var_4]):happy_var_1+ ) `HappyStk` happyRest}}}++happyReduce_74 = happyReduce 6# 19# happyReduction_74+happyReduction_74 (happy_x_6 `HappyStk`+ happy_x_5 `HappyStk`+ happy_x_4 `HappyStk`+ happy_x_3 `HappyStk`+ happy_x_2 `HappyStk`+ happy_x_1 `HappyStk`+ happyRest)+ = case happyOut19 happy_x_1 of { happy_var_1 -> + case happyOutTok happy_x_2 of { (QName happy_var_2) -> + case happyOut6 happy_x_5 of { happy_var_5 -> + happyIn19+ ((Ast "pair" [Astring happy_var_2,happy_var_5]):happy_var_1+ ) `HappyStk` happyRest}}}++happyReduce_75 = happySpecReduce_1 20# happyReduction_75+happyReduction_75 happy_x_1+ = case happyOut23 happy_x_1 of { happy_var_1 -> + happyIn20+ (happy_var_1 "child" (Avar ".")+ )}++happyReduce_76 = happySpecReduce_2 20# happyReduction_76+happyReduction_76 happy_x_2+ happy_x_1+ = case happyOut23 happy_x_2 of { happy_var_2 -> + happyIn20+ (happy_var_2 "attribute" (Avar ".")+ )}++happyReduce_77 = happySpecReduce_2 20# happyReduction_77+happyReduction_77 happy_x_2+ happy_x_1+ = case happyOut23 happy_x_1 of { happy_var_1 -> + case happyOut21 happy_x_2 of { happy_var_2 -> + happyIn20+ (happy_var_2(happy_var_1 "child" (Avar "."))+ )}}++happyReduce_78 = happySpecReduce_3 20# happyReduction_78+happyReduction_78 happy_x_3+ happy_x_2+ happy_x_1+ = case happyOut23 happy_x_2 of { happy_var_2 -> + case happyOut21 happy_x_3 of { happy_var_3 -> + happyIn20+ (happy_var_3(happy_var_2 "attribute" (Avar "."))+ )}}++happyReduce_79 = happySpecReduce_1 21# happyReduction_79+happyReduction_79 happy_x_1+ = case happyOut22 happy_x_1 of { happy_var_1 -> + happyIn21+ (happy_var_1+ )}++happyReduce_80 = happySpecReduce_2 21# happyReduction_80+happyReduction_80 happy_x_2+ happy_x_1+ = case happyOut21 happy_x_1 of { happy_var_1 -> + case happyOut22 happy_x_2 of { happy_var_2 -> + happyIn21+ (happy_var_2 . happy_var_1+ )}}++happyReduce_81 = happySpecReduce_2 22# happyReduction_81+happyReduction_81 happy_x_2+ happy_x_1+ = case happyOut23 happy_x_2 of { happy_var_2 -> + happyIn22+ (\e -> happy_var_2 "child" e+ )}++happyReduce_82 = happySpecReduce_3 22# happyReduction_82+happyReduction_82 happy_x_3+ happy_x_2+ happy_x_1+ = case happyOut23 happy_x_3 of { happy_var_3 -> + happyIn22+ (\e -> happy_var_3 "attribute" e+ )}++happyReduce_83 = happySpecReduce_3 22# happyReduction_83+happyReduction_83 happy_x_3+ happy_x_2+ happy_x_1+ = case happyOut23 happy_x_3 of { happy_var_3 -> + happyIn22+ (\e -> happy_var_3 "descendant" e+ )}++happyReduce_84 = happyReduce 4# 22# happyReduction_84+happyReduction_84 (happy_x_4 `HappyStk`+ happy_x_3 `HappyStk`+ happy_x_2 `HappyStk`+ happy_x_1 `HappyStk`+ happyRest)+ = case happyOut23 happy_x_4 of { happy_var_4 -> + happyIn22+ (\e -> happy_var_4 "descendant_attribute" e+ ) `HappyStk` happyRest}++happyReduce_85 = happySpecReduce_2 22# happyReduction_85+happyReduction_85 happy_x_2+ happy_x_1+ = happyIn22+ (\e -> call "parent" [e]+ )++happyReduce_86 = happySpecReduce_1 23# happyReduction_86+happyReduction_86 happy_x_1+ = case happyOut24 happy_x_1 of { happy_var_1 -> + happyIn23+ (happy_var_1+ )}++happyReduce_87 = happyReduce 4# 23# happyReduction_87+happyReduction_87 (happy_x_4 `HappyStk`+ happy_x_3 `HappyStk`+ happy_x_2 `HappyStk`+ happy_x_1 `HappyStk`+ happyRest)+ = case happyOut23 happy_x_1 of { happy_var_1 -> + case happyOut6 happy_x_3 of { happy_var_3 -> + happyIn23+ (\t e -> Ast "predicate" [happy_var_3,happy_var_1 t e]+ ) `HappyStk` happyRest}}++happyReduce_88 = happySpecReduce_1 24# happyReduction_88+happyReduction_88 happy_x_1+ = case happyOut25 happy_x_1 of { happy_var_1 -> + happyIn24+ (\t e -> happy_var_1 t e+ )}++happyReduce_89 = happySpecReduce_1 24# happyReduction_89+happyReduction_89 happy_x_1+ = happyIn24+ (\t e -> call t [Astring "*",e]+ )++happyReduce_90 = happySpecReduce_1 24# happyReduction_90+happyReduction_90 happy_x_1+ = case happyOutTok happy_x_1 of { (QName happy_var_1) -> + happyIn24+ (\t e -> call t [Astring happy_var_1,e]+ )}++happyReduce_91 = happySpecReduce_1 25# happyReduction_91+happyReduction_91 happy_x_1+ = case happyOut5 happy_x_1 of { happy_var_1 -> + happyIn25+ (\_ _ -> happy_var_1+ )}++happyReduce_92 = happySpecReduce_1 25# happyReduction_92+happyReduction_92 happy_x_1+ = happyIn25+ (\_ e -> e+ )++happyReduce_93 = happySpecReduce_3 25# happyReduction_93+happyReduction_93 happy_x_3+ happy_x_2+ happy_x_1+ = case happyOut7 happy_x_2 of { happy_var_2 -> + happyIn25+ (\_ _ -> concatAll happy_var_2+ )}++happyReduce_94 = happySpecReduce_2 25# happyReduction_94+happyReduction_94 happy_x_2+ happy_x_1+ = happyIn25+ (\_ _ -> call "empty" []+ )++happyReduce_95 = happyReduce 4# 25# happyReduction_95+happyReduction_95 (happy_x_4 `HappyStk`+ happy_x_3 `HappyStk`+ happy_x_2 `HappyStk`+ happy_x_1 `HappyStk`+ happyRest)+ = case happyOutTok happy_x_1 of { (QName happy_var_1) -> + case happyOut7 happy_x_3 of { happy_var_3 -> + happyIn25+ (\_ _ -> call happy_var_1 happy_var_3+ ) `HappyStk` happyRest}}++happyReduce_96 = happySpecReduce_3 25# happyReduction_96+happyReduction_96 happy_x_3+ happy_x_2+ happy_x_1+ = case happyOutTok happy_x_1 of { (QName happy_var_1) -> + happyIn25+ (if elem happy_var_1 ["text"]+ then \_ e -> call happy_var_1 [e]+ else \_ _ -> call happy_var_1 []+ )}++happyNewToken action sts stk [] =+ action 84# 84# notHappyAtAll (HappyState action) sts stk []++happyNewToken action sts stk (tk:tks) =+ let cont i = action i i tk (HappyState action) sts stk tks in+ case tk of {+ RETURN -> cont 26#;+ SOME -> cont 27#;+ EVERY -> cont 28#;+ IF -> cont 29#;+ THEN -> cont 30#;+ ELSE -> cont 31#;+ LB -> cont 32#;+ RB -> cont 33#;+ LP -> cont 34#;+ RP -> cont 35#;+ LSB -> cont 36#;+ RSB -> cont 37#;+ LESCAPE -> cont 38#;+ RESCAPE -> cont 39#;+ TO -> cont 40#;+ PLUS -> cont 41#;+ MINUS -> cont 42#;+ TIMES -> cont 43#;+ DIV -> cont 44#;+ IDIV -> cont 45#;+ MOD -> cont 46#;+ TEQ -> cont 47#;+ TNEQ -> cont 48#;+ TLT -> cont 49#;+ LEQ -> cont 50#;+ TGT -> cont 51#;+ GEQ -> cont 52#;+ AND -> cont 53#;+ OR -> cont 54#;+ NOT -> cont 55#;+ UNION -> cont 56#;+ INTERSECT -> cont 57#;+ EXCEPT -> cont 58#;+ FOR -> cont 59#;+ LET -> cont 60#;+ IN -> cont 61#;+ COMMA -> cont 62#;+ ASSIGN -> cont 63#;+ WHERE -> cont 64#;+ ORDERBY -> cont 65#;+ ASCENDING -> cont 66#;+ DESCENDING -> cont 67#;+ ELEMENT -> cont 68#;+ ATTRIBUTE -> cont 69#;+ STAG -> cont 70#;+ ETAG -> cont 71#;+ SATISFIES -> cont 72#;+ ATSIGN -> cont 73#;+ SLASH -> cont 74#;+ QName happy_dollar_dollar -> cont 75#;+ AT -> cont 76#;+ DOTS -> cont 77#;+ DOT -> cont 78#;+ Variable happy_dollar_dollar -> cont 79#;+ XMLtext happy_dollar_dollar -> cont 80#;+ TInteger happy_dollar_dollar -> cont 81#;+ TFloat happy_dollar_dollar -> cont 82#;+ TString happy_dollar_dollar -> cont 83#;+ _ -> happyError' (tk:tks)+ }++happyError_ tk tks = happyError' (tk:tks)++newtype HappyIdentity a = HappyIdentity a+happyIdentity = HappyIdentity+happyRunIdentity (HappyIdentity a) = a++instance Monad HappyIdentity where+ return = HappyIdentity+ (HappyIdentity p) >>= q = q p++happyThen :: () => HappyIdentity a -> (a -> HappyIdentity b) -> HappyIdentity b+happyThen = (>>=)+happyReturn :: () => a -> HappyIdentity a+happyReturn = (return)+happyThen1 m k tks = (>>=) m (\a -> k a tks)+happyReturn1 :: () => a -> b -> HappyIdentity a+happyReturn1 = \a tks -> (return) a+happyError' :: () => [Token] -> HappyIdentity a+happyError' = HappyIdentity . parseError++parse tks = happyRunIdentity happySomeParser where+ happySomeParser = happyThen (happyParse action_0 tks) (\x -> happyReturn (happyOut4 x))++happySeq = happyDontSeq+++-- Abstract Syntax Tree for XQueries+data Ast = Ast String [Ast]+ | Avar String+ | Aint Int+ | Afloat Float+ | Astring String+ deriving Eq+++instance Show Ast+ where show (Ast s []) = s ++ "()"+ show (Ast s (x:xs)) = s ++ "(" ++ (show x)+ ++ (foldr (\a r -> ","++(show a)++r) "" xs)+ ++ ")"+ show (Avar s) = s+ show (Aint n) = show n+ show (Afloat n) = show n+ show (Astring s) = "\'" ++ s ++ "\'"+++call :: String -> [Ast] -> Ast+call name args = Ast "call" ((Avar name):args)+++concatAll :: [Ast] -> Ast+concatAll (x:xs) = foldl (\a r -> call "concat" [a,r]) x xs+concatAll _ = call "empty" []+++parseError tk = error ("Parse error: "++(show (take 10 tk)))+++data Token+ = RETURN | SOME | EVERY | IF | THEN | ELSE | LB | RB | LP | RP | LSB | RSB+ | LESCAPE | RESCAPE | TO | PLUS | MINUS | TIMES | DIV | IDIV | MOD+ | TEQ | TNEQ | TLT | LEQ | TGT | GEQ | AND | OR | NOT | UNION | INTERSECT+ | EXCEPT | FOR | LET | IN | COMMA | ASSIGN | WHERE | ORDERBY | ASCENDING+ | DESCENDING | ELEMENT | ATTRIBUTE | STAG | ETAG | SATISFIES | ATSIGN+ | SLASH | DEFINE | FUNCTION | AT | DOT | DOTS | TokenEOF+ | QName String | Variable String | XMLtext String | TInteger Int+ | TFloat Float | TString String+ deriving Show+++scan :: String -> [Token]+scan cs = lexer cs [0]+++xmlText "" = []+xmlText text = [XMLtext text]++-- scans XML PCDATA and returns an XMLtext token with the PCData text+xml :: String -> String -> [Int] -> [Token]+xml ('{':cs) text n = (xmlText text)++(LSB : lexer cs (0:n))+xml ('<':'/':cs) text n = (xmlText text)++(STAG : lexer cs n)+xml ('<':cs) text (k:n) = (xmlText text)++(TLT : lexer cs (k+2:n))+xml ('\'':'{':cs) text n = (xmlText text)++(LESCAPE : lexer cs n)+xml (c:cs) text n = xml cs (text++[c]) n+xml [] text _ = xmlText text+++isQN c = elem c "_:-" || isDigit c || isAlpha c++isVar c = elem c "_" || isDigit c || isAlpha c++-- the XQuery scanner+lexer :: String -> [Int] -> [Token]+lexer [] [0] = []+lexer [] _ = error("Unbalanced tags")+lexer (' ':'>':' ':cs) n = TGT : lexer cs n+lexer (c:cs) n+ | isSpace c = lexer cs n+ | isAlpha c = lexVar (c:cs) n+ | isDigit c = lexNum (c:cs) n+lexer ('$':cs) n = let (var,rest) = span isVar cs+ in (Variable var) : lexer rest n+lexer ('\'':'{':cs) n = LESCAPE : lexer cs n+lexer (':':'=':cs) n = ASSIGN : lexer cs n+lexer ('<':'/':cs) n = STAG : lexer cs n+lexer ('<':'=':cs) n = LEQ : lexer cs n+lexer ('>':'=':cs) n = GEQ : lexer cs n+lexer ('/':'>':cs) (k:n) = ETAG : lexer cs (k-2:n)+lexer ('.':'.':cs) n = DOTS : lexer cs n+lexer ('.':cs) n = DOT : lexer cs n+lexer ('}':'\'':cs) n = RESCAPE : lexer cs n+lexer ('!':'=':cs) n = TNEQ : lexer cs n+lexer ('\'':cs) n = lexString cs n+lexer ('[':cs) n = LB : lexer cs n+lexer (']':cs) n = RB : lexer cs n+lexer ('(':cs) n = LP : lexer cs n+lexer (')':cs) n = RP : lexer cs n+lexer ('}':cs) (_:n) = RSB : xml cs "" n+lexer ('+':cs) n = PLUS : lexer cs n+lexer ('-':cs) n = MINUS : lexer cs n+lexer ('*':cs) n = TIMES : lexer cs n+lexer ('=':cs) n = TEQ : lexer cs n+lexer ('<':c:cs) n | not(isAlpha c) = TLT : lexer (c:cs) n+lexer ('<':cs) (k:n) = TLT : lexer cs (k+2:n)+lexer ('>':cs) (k:n) = TGT : (if k==1 then lexer cs (k-1:n) else xml cs "" (k-1:n))+lexer (',':cs) n = COMMA : lexer cs n+lexer ('@':cs) n = ATSIGN : lexer cs n+lexer ('/':cs) n = SLASH : lexer cs n+lexer ('{':cs) n = LSB : lexer cs n+lexer (c:cs) n = error ("illegal character "++[c])++lexNum cs n = if null rest || head rest /= '.'+ then TInteger (read k) : lexer rest n+ else let (m,rest2) = span isDigit (tail rest)+ in TFloat (read (k++('.':m))) : lexer rest2 n+ where (k,rest) = span isDigit cs++lexString cs n = TString s : lexer (tail rest) n+ where (s,rest) = span inString cs+ inString c = c /= '\''++lexVar cs n =+ case span isQN cs of+ ("return",rest) -> RETURN : lexer rest n+ ("some",rest) -> SOME : lexer rest n+ ("every",rest) -> EVERY : lexer rest n+ ("if",rest) -> IF : lexer rest n+ ("then",rest) -> THEN : lexer rest n+ ("else",rest) -> ELSE : lexer rest n+ ("to",rest) -> TO : lexer rest n+ ("div",rest) -> DIV : lexer rest n+ ("idiv",rest) -> IDIV : lexer rest n+ ("mod",rest) -> MOD : lexer rest n+ ("and",rest) -> AND : lexer rest n+ ("or",rest) -> OR : lexer rest n+ ("not",rest) -> NOT : lexer rest n+ ("union",rest) -> UNION : lexer rest n+ ("intersect",rest) -> INTERSECT : lexer rest n+ ("except",rest) -> EXCEPT : lexer rest n+ ("for",rest) -> FOR : lexer rest n+ ("let",rest) -> LET : lexer rest n+ ("in",rest) -> IN : lexer rest n+ ("where",rest) -> WHERE : lexer rest n+ ("orderby",rest) -> ORDERBY : lexer rest n+ ("ascending",rest) -> ASCENDING : lexer rest n+ ("descending",rest) -> DESCENDING : lexer rest n+ ("element",rest) -> ELEMENT : lexer rest n+ ("attribute",rest) -> ATTRIBUTE : lexer rest n+ ("satisfies",rest) -> SATISFIES : lexer rest n+ ("define",rest) -> DEFINE : lexer rest n+ ("function",rest) -> FUNCTION : lexer rest n+ ("at",rest) -> AT : lexer rest n+ (var,rest) -> QName var : lexer rest n+{-# LINE 1 "templates/GenericTemplate.hs" #-}+{-# LINE 1 "templates/GenericTemplate.hs" #-}+{-# LINE 1 "<built-in>" #-}+{-# LINE 1 "<command line>" #-}+{-# LINE 1 "templates/GenericTemplate.hs" #-}+-- Id: GenericTemplate.hs,v 1.26 2005/01/14 14:47:22 simonmar Exp ++{-# LINE 28 "templates/GenericTemplate.hs" #-}+++++++++{-# LINE 49 "templates/GenericTemplate.hs" #-}++{-# LINE 59 "templates/GenericTemplate.hs" #-}++{-# LINE 68 "templates/GenericTemplate.hs" #-}++infixr 9 `HappyStk`+data HappyStk a = HappyStk a (HappyStk a)++-----------------------------------------------------------------------------+-- starting the parse++happyParse start_state = happyNewToken start_state notHappyAtAll notHappyAtAll++-----------------------------------------------------------------------------+-- Accepting the parse++-- If the current token is 1#, it means we've just accepted a partial+-- parse (a %partial parser). We must ignore the saved token on the top of+-- the stack in this case.+happyAccept 1# tk st sts (_ `HappyStk` ans `HappyStk` _) =+ happyReturn1 ans+happyAccept j tk st sts (HappyStk ans _) = + (happyTcHack j ) (happyReturn1 ans)++-----------------------------------------------------------------------------+-- Arrays only: do the next action++{-# LINE 155 "templates/GenericTemplate.hs" #-}++-----------------------------------------------------------------------------+-- HappyState data type (not arrays)++++newtype HappyState b c = HappyState+ (Int# -> -- token number+ Int# -> -- token number (yes, again)+ b -> -- token semantic value+ HappyState b c -> -- current state+ [HappyState b c] -> -- state stack+ c)++++-----------------------------------------------------------------------------+-- Shifting a token++happyShift new_state 1# tk st sts stk@(x `HappyStk` _) =+ let i = (case unsafeCoerce# x of { (I# (i)) -> i }) in+-- trace "shifting the error token" $+ new_state i i tk (HappyState (new_state)) ((st):(sts)) (stk)++happyShift new_state i tk st sts stk =+ happyNewToken new_state ((st):(sts)) ((happyInTok (tk))`HappyStk`stk)++-- happyReduce is specialised for the common cases.++happySpecReduce_0 i fn 1# tk st sts stk+ = happyFail 1# tk st sts stk+happySpecReduce_0 nt fn j tk st@((HappyState (action))) sts stk+ = action nt j tk st ((st):(sts)) (fn `HappyStk` stk)++happySpecReduce_1 i fn 1# tk st sts stk+ = happyFail 1# tk st sts stk+happySpecReduce_1 nt fn j tk _ sts@(((st@(HappyState (action))):(_))) (v1`HappyStk`stk')+ = let r = fn v1 in+ happySeq r (action nt j tk st sts (r `HappyStk` stk'))++happySpecReduce_2 i fn 1# tk st sts stk+ = happyFail 1# tk st sts stk+happySpecReduce_2 nt fn j tk _ ((_):(sts@(((st@(HappyState (action))):(_))))) (v1`HappyStk`v2`HappyStk`stk')+ = let r = fn v1 v2 in+ happySeq r (action nt j tk st sts (r `HappyStk` stk'))++happySpecReduce_3 i fn 1# tk st sts stk+ = happyFail 1# tk st sts stk+happySpecReduce_3 nt fn j tk _ ((_):(((_):(sts@(((st@(HappyState (action))):(_))))))) (v1`HappyStk`v2`HappyStk`v3`HappyStk`stk')+ = let r = fn v1 v2 v3 in+ happySeq r (action nt j tk st sts (r `HappyStk` stk'))++happyReduce k i fn 1# tk st sts stk+ = happyFail 1# tk st sts stk+happyReduce k nt fn j tk st sts stk+ = case happyDrop (k -# (1# :: Int#)) sts of+ sts1@(((st1@(HappyState (action))):(_))) ->+ let r = fn stk in -- it doesn't hurt to always seq here...+ happyDoSeq r (action nt j tk st1 sts1 r)++happyMonadReduce k nt fn 1# tk st sts stk+ = happyFail 1# tk st sts stk+happyMonadReduce k nt fn j tk st sts stk =+ happyThen1 (fn stk tk) (\r -> action nt j tk st1 sts1 (r `HappyStk` drop_stk))+ where sts1@(((st1@(HappyState (action))):(_))) = happyDrop k ((st):(sts))+ drop_stk = happyDropStk k stk++happyMonad2Reduce k nt fn 1# tk st sts stk+ = happyFail 1# tk st sts stk+happyMonad2Reduce k nt fn j tk st sts stk =+ happyThen1 (fn stk tk) (\r -> happyNewToken new_state sts1 (r `HappyStk` drop_stk))+ where sts1@(((st1@(HappyState (action))):(_))) = happyDrop k ((st):(sts))+ drop_stk = happyDropStk k stk++++++ new_state = action+++happyDrop 0# l = l+happyDrop n ((_):(t)) = happyDrop (n -# (1# :: Int#)) t++happyDropStk 0# l = l+happyDropStk n (x `HappyStk` xs) = happyDropStk (n -# (1#::Int#)) xs++-----------------------------------------------------------------------------+-- Moving to a new state after a reduction++{-# LINE 253 "templates/GenericTemplate.hs" #-}+happyGoto action j tk st = action j j tk (HappyState action)+++-----------------------------------------------------------------------------+-- Error recovery (1# is the error token)++-- parse error if we are in recovery and we fail again+happyFail 1# tk old_st _ stk =+-- trace "failing" $ + happyError_ tk++{- We don't need state discarding for our restricted implementation of+ "error". In fact, it can cause some bogus parses, so I've disabled it+ for now --SDM++-- discard a state+happyFail 1# tk old_st (((HappyState (action))):(sts)) + (saved_tok `HappyStk` _ `HappyStk` stk) =+-- trace ("discarding state, depth " ++ show (length stk)) $+ action 1# 1# tk (HappyState (action)) sts ((saved_tok`HappyStk`stk))+-}++-- Enter error recovery: generate an error token,+-- save the old token and carry on.+happyFail i tk (HappyState (action)) sts stk =+-- trace "entering error recovery" $+ action 1# 1# tk (HappyState (action)) sts ( (unsafeCoerce# (I# (i))) `HappyStk` stk)++-- Internal happy errors:++notHappyAtAll = error "Internal Happy error\n"++-----------------------------------------------------------------------------+-- Hack to get the typechecker to accept our action functions+++happyTcHack :: Int# -> a -> a+happyTcHack x y = y+{-# INLINE happyTcHack #-}+++-----------------------------------------------------------------------------+-- Seq-ing. If the --strict flag is given, then Happy emits +-- happySeq = happyDoSeq+-- otherwise it emits+-- happySeq = happyDontSeq++happyDoSeq, happyDontSeq :: a -> b -> b+happyDoSeq a b = a `seq` b+happyDontSeq a b = b++-----------------------------------------------------------------------------+-- Don't inline any functions from the template. GHC has a nasty habit+-- of deciding to inline happyGoto everywhere, which increases the size of+-- the generated parser quite a bit.++{-# LINE 317 "templates/GenericTemplate.hs" #-}+{-# NOINLINE happyShift #-}+{-# NOINLINE happySpecReduce_0 #-}+{-# NOINLINE happySpecReduce_1 #-}+{-# NOINLINE happySpecReduce_2 #-}+{-# NOINLINE happySpecReduce_3 #-}+{-# NOINLINE happyReduce #-}+{-# NOINLINE happyMonadReduce #-}+{-# NOINLINE happyGoto #-}+{-# NOINLINE happyFail #-}++-- end of Happy Template.
+ XQueryParser.y view
@@ -0,0 +1,383 @@+{-------------------------------------------------------------------------------------+-+- An XQuery parser+- Programmer: Leonidas Fegaras+- Email: fegaras@cse.uta.edu+- Web: http://lambda.uta.edu/+- Creation: 02/15/08, last update: 03/18/08+- +- Copyright (c) 2008 by Leonidas Fegaras, the University of Texas at Arlington. All rights reserved.+- This material is provided as is, with absolutely no warranty expressed or implied.+- Any use is at your own risk. Permission is hereby granted to use or copy this program+- for any purpose, provided the above notices are retained on all copies.+-+--------------------------------------------------------------------------------------}++{+module XQueryParser where+import Char+}++%name parse+%tokentype { Token }+%error { parseError }++%token+ 'return' { RETURN }+ 'some' { SOME }+ 'every' { EVERY }+ 'if' { IF }+ 'then' { THEN }+ 'else' { ELSE }+ '[' { LB }+ ']' { RB }+ '(' { LP }+ ')' { RP }+ '{' { LSB }+ '}' { RSB }+ '\'{' { LESCAPE }+ '}\'' { RESCAPE }+ 'to' { TO }+ '+' { PLUS }+ '-' { MINUS }+ '*' { TIMES }+ 'div' { DIV }+ 'idiv' { IDIV }+ 'mod' { MOD }+ '=' { TEQ }+ '!=' { TNEQ }+ '<' { TLT }+ '<=' { LEQ }+ '>' { TGT }+ '>=' { GEQ }+ 'and' { AND }+ 'or' { OR }+ 'not' { NOT }+ 'union' { UNION }+ 'intersect' { INTERSECT }+ 'except' { EXCEPT }+ 'for' { FOR }+ 'let' { LET }+ 'in' { IN }+ ',' { COMMA }+ ':=' { ASSIGN }+ 'where' { WHERE }+ 'orderby' { ORDERBY }+ 'ascending' { ASCENDING }+ 'descending' { DESCENDING }+ 'element' { ELEMENT }+ 'attribute' { ATTRIBUTE }+ '</' { STAG }+ '/>' { ETAG }+ 'satisfies' { SATISFIES }+ '@' { ATSIGN }+ '/' { SLASH }+ 'QName' { QName $$ }+ 'at' { AT }+ '..' { DOTS }+ '.' { DOT }+ 'Variable' { Variable $$ }+ 'XMLtext' { XMLtext $$ }+ 'Integer' { TInteger $$ }+ 'Double' { TFloat $$ }+ 'String' { TString $$ }+++%nonassoc 'for' 'let' 'satisfies' 'return'+%nonassoc 'else'+%left 'intersect' 'union' 'except'+%right 'or'+%right 'and'+%nonassoc 'not'+%left '=' '<' '>' '<=' '>=' '!='+%left '+' '-'+%left '*' 'div' 'idiv' 'mod'+%left 'to'+%nonassoc UMINUS+++%%++prog : expr { $1 }++var : 'Variable' { Avar $1 }++expr : clauses opt_where opt_order+ 'return' expr { (snd $3) ($1 ($2 ((fst $3) $5))) }+ | 'some' for_bindings+ 'satisfies' expr { call "some" [$2 $4] }+ | 'every' for_bindings + 'satisfies' expr { call "not" [call "some" [$2 (call "not" [$4])]] }+ | 'if' expr 'then' expr 'else' expr { call "if" [$2,$4,$6] }+ | full_path { $1 }+ | element { $1 }+ | computed { $1 }+ | expr 'to' expr { call "to" [$1,$3] }+ | expr '+' expr { call "+" [$1,$3] }+ | expr '-' expr { call "-" [$1,$3] }+ | expr '*' expr { call "*" [$1,$3] }+ | expr 'div' expr { call "div" [$1,$3] }+ | expr 'idiv' expr { call "idiv" [$1,$3] }+ | expr 'mod' expr { call "mod" [$1,$3] }+ | expr '=' expr { call "=" [$1,$3] }+ | expr '!=' expr { call "!=" [$1,$3] }+ | expr '<' expr { call "<" [$1,$3] }+ | expr '<=' expr { call "<=" [$1,$3] }+ | expr '>' expr { call ">" [$1,$3] }+ | expr '>=' expr { call ">=" [$1,$3] }+ | expr 'and' expr { call "and" [$1,$3] }+ | expr 'or' expr { call "or" [$1,$3] }+ | expr 'not' expr { call "not" [$1,$3] }+ | expr 'union' expr { call "union" [$1,$3] }+ | expr 'intersect' expr { call "itersect" [$1,$3] }+ | expr 'except' expr { call "except" [$1,$3] }+ | '+' expr %prec UMINUS { call "uplus" [$2] }+ | '-' expr %prec UMINUS { call "uminus" [$2] }+ | 'not' expr %prec UMINUS { call "not" [$2] }+ | 'String' { Astring $1 }+ | 'Integer' { Aint $1 }+ | 'Double' { Afloat $1 }++expl : expr { [$1] }+ | expl ',' expr { $1++[$3] }++clauses : 'for' for_bindings { $2 }+ | 'let' let_bindings { $2 }+ | clauses 'for' for_bindings { $1 . $3 }+ | clauses 'let' let_bindings { $1 . $3 }++for_bindings : var 'in' expr { \x -> Ast "for" [$1,Avar "$",$3,x] }+ | var 'in' expr 'at' var { \x -> Ast "for" [$1,$5,$3,x] }+ | for_bindings ',' var 'in' expr { \x -> $1(Ast "for" [$3,Avar "$",$5,x]) }+ | for_bindings ',' var 'in' expr+ 'at' var { \x -> $1(Ast "for" [$3,$7,$5,x]) }++let_bindings : var ':=' expr { \x -> Ast "let" [$1,$3,x] }+ | let_bindings ','+ var ':=' expr { \x -> $1(Ast "let" [$3,$5,x]) }++opt_where : 'where' expr { \x -> Ast "predicate" [$2,x] }+ | {- empty -} { id }++opt_order : 'orderby' order_list { (\x -> Ast "sortTuple" (x:(fst $2)),+ \x -> Ast "sort" (x:(snd $2))) }+ | {- empty -} { (id,id) }++order_list : expr mode { ([$1],[$2]) }+ | order_list ',' expr mode { ((fst $1)++[$3],(snd $1)++[$4]) }++mode : 'ascending' { Avar "ascending" }+ | 'descending' { Avar "descending" }+ | {- empty -} { Avar "ascending" }++computed : 'element' '(' 'QName' ')' { call "element" [Avar $3] }+ | 'attribute' '(' 'QName' ')' { call "attribute" [Avar $3] }++element : stag '>' content '</' 'QName' '>' { if head $1 == Astring $5+ then Ast "construction" ($1++[concatAll $3])+ else error("Unmatched tags in element construction: "++$5) }+ | stag '>' '</' 'QName' '>' { if head $1 == Astring $4+ then Ast "construction" ($1++[call "empty" []])+ else error("Unmatched tags in element construction: "++$4) }+ | stag '/>' { Ast "construction" ($1++[call "empty" []]) }++stag : '<' 'QName' { [Astring $2,Ast "attributes" []] }+ | '<' 'QName' attributes { [Astring $2,Ast "attributes" $3] }++content : '{' expl '}' { $2 }+ | 'String' { [Astring $1] }+ | 'XMLtext' { [Astring $1] }+ | element { [$1] }+ | content '{' expl '}' { $1++$3 }+ | content 'String' { $1++[Astring $2] }+ | content 'XMLtext' { $1++[Astring $2] }+ | content element { $1++[$2] }++attributes : 'QName' '=' 'String' { [Ast "pair" [Astring $1,Astring $3]] }+ | 'QName' '=' '\'{' expr '}\'' { [Ast "pair" [Astring $1,$4]] }+ | attributes 'QName' '=' 'String' { (Ast "pair" [Astring $2,Astring $4]):$1 }+ | attributes 'QName' '='+ '\'{' expr '}\'' { (Ast "pair" [Astring $2,$5]):$1 }++full_path : predicate_step { $1 "child" (Avar ".") }+ | '@' predicate_step { $2 "attribute" (Avar ".") }+ | predicate_step path { $2($1 "child" (Avar ".")) }+ | '@' predicate_step path { $3($2 "attribute" (Avar ".")) }++path : step { $1 }+ | path step { $2 . $1 }++step : '/' predicate_step { \e -> $2 "child" e }+ | '/' '@' predicate_step { \e -> $3 "attribute" e }+ | '/' '/' predicate_step { \e -> $3 "descendant" e }+ | '/' '/' '@' predicate_step { \e -> $4 "descendant_attribute" e }+ | '/' '..' { \e -> call "parent" [e] }++predicate_step : simple_step { $1 }+ | predicate_step '[' expr ']' { \t e -> Ast "predicate" [$3,$1 t e] }++simple_step : primary_expr { \t e -> $1 t e }+ | '*' { \t e -> call t [Astring "*",e] }+ | 'QName' { \t e -> call t [Astring $1,e] }++primary_expr : var { \_ _ -> $1 }+ | '.' { \_ e -> e }+ | '(' expl ')' { \_ _ -> concatAll $2 }+ | '(' ')' { \_ _ -> call "empty" [] }+ | 'QName' '(' expl ')' { \_ _ -> call $1 $3 }+ | 'QName' '(' ')' { if elem $1 ["text"]+ then \_ e -> call $1 [e]+ else \_ _ -> call $1 [] }+++{+++-- Abstract Syntax Tree for XQueries+data Ast = Ast String [Ast]+ | Avar String+ | Aint Int+ | Afloat Float+ | Astring String+ deriving Eq+++instance Show Ast+ where show (Ast s []) = s ++ "()"+ show (Ast s (x:xs)) = s ++ "(" ++ (show x)+ ++ (foldr (\a r -> ","++(show a)++r) "" xs)+ ++ ")"+ show (Avar s) = s+ show (Aint n) = show n+ show (Afloat n) = show n+ show (Astring s) = "\'" ++ s ++ "\'"+++call :: String -> [Ast] -> Ast+call name args = Ast "call" ((Avar name):args)+++concatAll :: [Ast] -> Ast+concatAll (x:xs) = foldl (\a r -> call "concat" [a,r]) x xs+concatAll _ = call "empty" []+++parseError tk = error ("Parse error: "++(show (take 10 tk)))+++data Token+ = RETURN | SOME | EVERY | IF | THEN | ELSE | LB | RB | LP | RP | LSB | RSB+ | LESCAPE | RESCAPE | TO | PLUS | MINUS | TIMES | DIV | IDIV | MOD+ | TEQ | TNEQ | TLT | LEQ | TGT | GEQ | AND | OR | NOT | UNION | INTERSECT+ | EXCEPT | FOR | LET | IN | COMMA | ASSIGN | WHERE | ORDERBY | ASCENDING+ | DESCENDING | ELEMENT | ATTRIBUTE | STAG | ETAG | SATISFIES | ATSIGN+ | SLASH | DEFINE | FUNCTION | AT | DOT | DOTS | TokenEOF+ | QName String | Variable String | XMLtext String | TInteger Int+ | TFloat Float | TString String+ deriving Show+++scan :: String -> [Token]+scan cs = lexer cs [0]+++xmlText "" = []+xmlText text = [XMLtext text]++-- scans XML PCDATA and returns an XMLtext token with the PCData text+xml :: String -> String -> [Int] -> [Token]+xml ('{':cs) text n = (xmlText text)++(LSB : lexer cs (0:n))+xml ('<':'/':cs) text n = (xmlText text)++(STAG : lexer cs n)+xml ('<':cs) text (k:n) = (xmlText text)++(TLT : lexer cs (k+2:n))+xml ('\'':'{':cs) text n = (xmlText text)++(LESCAPE : lexer cs n)+xml (c:cs) text n = xml cs (text++[c]) n+xml [] text _ = xmlText text+++isQN c = elem c "_:-" || isDigit c || isAlpha c++isVar c = elem c "_" || isDigit c || isAlpha c++-- the XQuery scanner+lexer :: String -> [Int] -> [Token]+lexer [] [0] = []+lexer [] _ = error("Unbalanced tags")+lexer (' ':'>':' ':cs) n = TGT : lexer cs n+lexer (c:cs) n+ | isSpace c = lexer cs n+ | isAlpha c = lexVar (c:cs) n+ | isDigit c = lexNum (c:cs) n+lexer ('$':cs) n = let (var,rest) = span isVar cs+ in (Variable var) : lexer rest n+lexer ('\'':'{':cs) n = LESCAPE : lexer cs n+lexer (':':'=':cs) n = ASSIGN : lexer cs n+lexer ('<':'/':cs) n = STAG : lexer cs n+lexer ('<':'=':cs) n = LEQ : lexer cs n+lexer ('>':'=':cs) n = GEQ : lexer cs n+lexer ('/':'>':cs) (k:n) = ETAG : lexer cs (k-2:n)+lexer ('.':'.':cs) n = DOTS : lexer cs n+lexer ('.':cs) n = DOT : lexer cs n+lexer ('}':'\'':cs) n = RESCAPE : lexer cs n+lexer ('!':'=':cs) n = TNEQ : lexer cs n+lexer ('\'':cs) n = lexString cs n+lexer ('[':cs) n = LB : lexer cs n+lexer (']':cs) n = RB : lexer cs n+lexer ('(':cs) n = LP : lexer cs n+lexer (')':cs) n = RP : lexer cs n+lexer ('}':cs) (_:n) = RSB : xml cs "" n+lexer ('+':cs) n = PLUS : lexer cs n+lexer ('-':cs) n = MINUS : lexer cs n+lexer ('*':cs) n = TIMES : lexer cs n+lexer ('=':cs) n = TEQ : lexer cs n+lexer ('<':c:cs) n | not(isAlpha c) = TLT : lexer (c:cs) n+lexer ('<':cs) (k:n) = TLT : lexer cs (k+2:n)+lexer ('>':cs) (k:n) = TGT : (if k==1 then lexer cs (k-1:n) else xml cs "" (k-1:n))+lexer (',':cs) n = COMMA : lexer cs n+lexer ('@':cs) n = ATSIGN : lexer cs n+lexer ('/':cs) n = SLASH : lexer cs n+lexer ('{':cs) n = LSB : lexer cs n+lexer (c:cs) n = error ("illegal character "++[c])++lexNum cs n = if null rest || head rest /= '.'+ then TInteger (read k) : lexer rest n+ else let (m,rest2) = span isDigit (tail rest)+ in TFloat (read (k++('.':m))) : lexer rest2 n+ where (k,rest) = span isDigit cs++lexString cs n = TString s : lexer (tail rest) n+ where (s,rest) = span inString cs+ inString c = c /= '\''++lexVar cs n =+ case span isQN cs of+ ("return",rest) -> RETURN : lexer rest n+ ("some",rest) -> SOME : lexer rest n+ ("every",rest) -> EVERY : lexer rest n+ ("if",rest) -> IF : lexer rest n+ ("then",rest) -> THEN : lexer rest n+ ("else",rest) -> ELSE : lexer rest n+ ("to",rest) -> TO : lexer rest n+ ("div",rest) -> DIV : lexer rest n+ ("idiv",rest) -> IDIV : lexer rest n+ ("mod",rest) -> MOD : lexer rest n+ ("and",rest) -> AND : lexer rest n+ ("or",rest) -> OR : lexer rest n+ ("not",rest) -> NOT : lexer rest n+ ("union",rest) -> UNION : lexer rest n+ ("intersect",rest) -> INTERSECT : lexer rest n+ ("except",rest) -> EXCEPT : lexer rest n+ ("for",rest) -> FOR : lexer rest n+ ("let",rest) -> LET : lexer rest n+ ("in",rest) -> IN : lexer rest n+ ("where",rest) -> WHERE : lexer rest n+ ("orderby",rest) -> ORDERBY : lexer rest n+ ("ascending",rest) -> ASCENDING : lexer rest n+ ("descending",rest) -> DESCENDING : lexer rest n+ ("element",rest) -> ELEMENT : lexer rest n+ ("attribute",rest) -> ATTRIBUTE : lexer rest n+ ("satisfies",rest) -> SATISFIES : lexer rest n+ ("define",rest) -> DEFINE : lexer rest n+ ("function",rest) -> FUNCTION : lexer rest n+ ("at",rest) -> AT : lexer rest n+ (var,rest) -> QName var : lexer rest n+}
+ data/cs.xml view
@@ -0,0 +1,618 @@+<?xml version="1.0"?>+<!-- Revision: test xml data file -->++<department>+ <deptname>Computer Sciences</deptname>++ <gradstudent>+ <name>+ <lastname>Aboulnaga</lastname>+ <firstname>Ashraf</firstname>+ </name>+ <phone>2626623</phone>+ <email>ashraf@cs.wisc.edu</email>+ <address>+ <city>Madison</city>+ <state>WI</state>+ <zip>53705</zip> + </address>+ <office>7360</office>+ <url>www.cs.wisc.edu/~ashraf</url>+ <gpa>4.0</gpa>+ </gradstudent>++ <gradstudent>+ <name>+ <lastname>Ailamaki</lastname>+ <firstname>Anastasia</firstname>+ </name>+ <phone>2652311</phone>+ <email>natassa@cs.wisc.edu</email>+ <address>+ <city>Madison</city>+ <state>WI</state>+ <zip>53706</zip> + </address>+ <office>7351</office>+ <url>www.cs.wisc.edu/~natassa</url>+ <gpa>4.0</gpa>+ </gradstudent>++ <gradstudent>+ <name>+ <lastname>Almeida</lastname>+ <firstname>Jussara</firstname>+ </name>+ <phone>2622542</phone>+ <email>jussara@cs.wisc.edu</email>+ <address>+ <city>Madison</city>+ <state>WI</state>+ <zip>53706</zip> + </address>+ <office>7358</office>+ <gpa>3.5</gpa>+ </gradstudent>++ <gradstudent>+ <name>+ <lastname>Basney</lastname>+ <firstname>Jim</firstname>+ </name>+ <phone>2625368</phone>+ <email>jbasney@cs.wisc.edu</email>+ <address>+ <city>Madison</city>+ <state>WI</state>+ <zip>53706</zip> + </address>+ <office>3395</office>+ <url>www.cs.wisc.edu/~jbasney</url>+ <gpa>4.0</gpa>+ </gradstudent>+ + <gradstudent>+ <name>+ <lastname>Polyzotis</lastname>+ <firstname>Neoklis</firstname>+ </name>+ <phone>2652311</phone>+ <email>alkis@cs.wisc.edu</email>+ <address>+ <city>Madison</city>+ <state>WI</state>+ <zip>53705</zip> + </address>+ <office>7351</office>+ <url>www.cs.wisc.edu/~alkis</url>+ <gpa>4.0</gpa>+ </gradstudent>++ <gradstudent>+ <name>+ <lastname>Galanis</lastname>+ <firstname>Leonidas</firstname>+ </name>+ <phone>2625596</phone>+ <email>lgalanis@cs.wisc.edu</email>+ <address>+ <city>Madison</city>+ <state>WI</state>+ <zip>53705</zip> + </address>+ <office>1343</office>+ <url>www.cs.wisc.edu/~lgalanis</url>+ <gpa>3.5</gpa>+ </gradstudent>+ + <gradstudent>+ <name>+ <lastname>Reddy</lastname>+ <firstname>Sridhar</firstname>+ </name>+ <phone>2625596</phone>+ <email>sridhar@cs.wisc.edu</email>+ <address>+ <city>Madison</city>+ <state>WI</state>+ <zip>53705</zip> + </address>+ <office>7360</office>+ <url>www.cs.wisc.edu/~sridhar</url>+ <gpa>4.0</gpa>+ </gradstudent>++ <gradstudent>+ <name>+ <lastname>Beyer</lastname>+ <firstname>Kevin</firstname>+ </name>+ <phone>2626629</phone>+ <email>beyer@cs.wisc.edu</email>+ <address>+ <city>Madison</city>+ <state>WI</state>+ <zip>53705</zip> + </address>+ <office>7390</office>+ <url>www.cs.wisc.edu/~beyer</url>+ <gpa>4.0</gpa>+ </gradstudent>++ <gradstudent>+ <name>+ <lastname>Butts</lastname>+ <firstname>Adam</firstname>+ </name>+ <phone>2626618</phone>+ <email>butts@cs.wisc.edu</email>+ <address>+ <city>Madison</city>+ <state>WI</state>+ <zip>53705</zip> + </address>+ <office>6382</office>+ <url>www.cs.wisc.edu/~butts</url>+ <gpa>4.0</gpa>+ </gradstudent>++ <gradstudent>+ <name>+ <lastname>Bezenek</lastname>+ <firstname>Todd</firstname>+ </name>+ <phone>2656605</phone>+ <email>bezenek@cs.wisc.edu</email>+ <address>+ <city>Madison</city>+ <state>WI</state>+ <zip>53706</zip> + </address>+ <office>1331</office>+ <url>www.cs.wisc.edu/~bezenek</url>+ <gpa>4.0</gpa>+ </gradstudent>+ <gradstudent>++ <name>+ <lastname>Chan</lastname>+ <firstname>Chee-Yong</firstname>+ </name>+ <phone>2626629</phone>+ <email>cychan@cs.wisc.edu</email>+ <address>+ <city>Madison</city>+ <state>WI</state>+ <zip>53706</zip> + </address>+ <office>7394</office>+ <gpa>3.5</gpa>+ </gradstudent>++ <gradstudent>+ <name>+ <lastname>Chang</lastname>+ <firstname>Richard</firstname>+ </name>+ <phone>2626612</phone>+ <email>pdc@cs.wisc.edu</email>+ <address>+ <city>Madison</city>+ <state>WI</state>+ <zip>53706</zip> + </address>+ <office>5384</office>+ <url>www.cs.wisc.edu/~pdc</url>+ <gpa>3.5</gpa>+ </gradstudent>+ + <gradstudent>+ <name>+ <lastname>Deych</lastname>+ <firstname>Gregory</firstname>+ </name>+ <phone>2652455</phone>+ <email>gdeych@cs.wisc.edu</email>+ <address>+ <city>Madison</city>+ <state>WI</state>+ <zip>53705</zip> + </address>+ <office>7351</office>+ <url>www.cs.wisc.edu/~gdeych</url>+ <gpa>4.0</gpa>+ </gradstudent>++ <gradstudent>+ <name>+ <lastname>Dreyfuss</lastname>+ <firstname>Mark</firstname>+ </name>+ <phone>2625596</phone>+ <email>md@cs.wisc.edu</email>+ <address>+ <city>Madison</city>+ <state>WI</state>+ <zip>53705</zip> + </address>+ <office>1343</office>+ <url>www.cs.wisc.edu/~md</url>+ <gpa>3.5</gpa>+ </gradstudent>+ + <gradstudent>+ <name>+ <lastname>Yang</lastname>+ <firstname>Fan</firstname>+ </name>+ <phone>2625596</phone>+ <email>fyang@cs.wisc.edu</email>+ <address>+ <city>Madison</city>+ <state>WI</state>+ <zip>53705</zip> + </address>+ <office>1343</office>+ <url>www.cs.wisc.edu/~fyang</url>+ <gpa>4.0</gpa>+ </gradstudent>++ <gradstudent>+ <name>+ <lastname>Donjerkovic</lastname>+ <firstname>Donko</firstname>+ </name>+ <phone>26245542</phone>+ <email>donko@cs.wisc.edu</email>+ <address>+ <city>Madison</city>+ <state>WI</state>+ <zip>53705</zip> + </address>+ <office>7366</office>+ <url>www.cs.wisc.edu/~donko</url>+ <gpa>4.0</gpa>+ </gradstudent>++ <gradstudent>+ <name>+ <lastname>Finley</lastname>+ <firstname>Paul</firstname>+ </name>+ <phone>2622455</phone>+ <email>finley@cs.wisc.edu</email>+ <address>+ <city>Madison</city>+ <state>WI</state>+ <zip>53706</zip> + </address>+ <office>1309</office>+ <gpa>3.5</gpa>+ </gradstudent>++ <gradstudent>+ <gpa>3.5</gpa>+ <name>+ <lastname>Finton</lastname>+ <firstname>David</firstname>+ </name>+ <phone>2626612</phone>+ <email>finton@cs.wisc.edu</email>+ <address>+ <city>Madison</city>+ <state>WI</state>+ <zip>53706</zip> + </address>+ <office>5384</office>+ <url>www.cs.wisc.edu/~finton</url>+ </gradstudent>+ + <gradstudent>+ <name>+ <lastname>Fung</lastname>+ <firstname>Glenn</firstname>+ </name>+ <phone>2652455</phone>+ <email>gfung@cs.wisc.edu</email>+ <address>+ <city>Madison</city>+ <state>WI</state>+ <zip>53705</zip> + </address>+ <office>7351</office>+ <url>www.cs.wisc.edu/~gfung</url>+ <gpa>4.0</gpa>+ </gradstudent>++ <gradstudent>+ <name>+ <lastname>Gast</lastname>+ <firstname>James</firstname>+ </name>+ <phone>2625596</phone>+ <email>jgast@cs.wisc.edu</email>+ <address>+ <city>Madison</city>+ <state>WI</state>+ <zip>53705</zip> + </address>+ <office>1552</office>+ <url>www.cs.wisc.edu/~jgast</url>+ <gpa>3.5</gpa>+ </gradstudent>+ + <gradstudent>+ <name>+ <lastname>Glew</lastname>+ <firstname>Andrew</firstname>+ </name>+ <phone>2625596</phone>+ <email>glew@cs.wisc.edu</email>+ <address>+ <city>Madison</city>+ <state>WI</state>+ <zip>53705</zip> + </address>+ <office>1343</office>+ <url>www.cs.wisc.edu/~glew</url>+ <gpa>4.0</gpa>+ </gradstudent>++ <gradstudent>+ <name>+ <lastname>Gupta</lastname>+ <firstname>Anurag</firstname>+ </name>+ <phone>2621243</phone>+ <email>anurag@cs.wisc.edu</email>+ <address>+ <city>Madison</city>+ <state>WI</state>+ <zip>53705</zip> + </address>+ <office>1346</office>+ <url>www.cs.wisc.edu/~anurag</url>+ <gpa>4.0</gpa>+ </gradstudent>++ <staff>+ <name>+ <lastname>Weber</lastname>+ <firstname>Lorene</firstname>+ </name>+ <phone>2627967</phone>+ <email>lorene@cs.wisc.edu</email>+ <office>5373</office>+ </staff>+ + <staff>+ <name>+ <lastname>Cuccia</lastname>+ <firstname>Laura</firstname>+ </name>+ <phone>2622454</phone>+ <email>laura@cs.wisc.edu</email>+ <office>5333</office>+ </staff>++ <staff>+ <name>+ <lastname>Diewald</lastname>+ <firstname>Debra</firstname>+ </name>+ <phone>2622454</phone>+ <email>debra@cs.wisc.edu</email>+ <office>5333</office>+ </staff>++ <staff>+ <name>+ <lastname>Johnson</lastname>+ <firstname>Marie</firstname>+ </name>+ <phone>2627433</phone>+ <email>marie@cs.wisc.edu</email>+ <office>5356</office>+ </staff>+ + <staff>+ <name>+ <lastname>Nelson</lastname>+ <firstname>Anne</firstname>+ </name>+ <phone>2622324</phone>+ <email>nelsona@cs.wisc.edu</email>+ <office>7366</office>+ </staff>++ <staff>+ <name>+ <lastname>Werner</lastname>+ <firstname>Virginia</firstname>+ </name>+ <phone>2622454</phone>+ <email>laura@cs.wisc.edu</email>+ <office>5333</office>+ </staff>+++ <faculty>+ <name>+ <lastname>Bach</lastname>+ <firstname>Eric</firstname>+ </name>+ <phone>2627997</phone>+ <email>bach@cs.wisc.edu</email>+ <office>7385</office>+ </faculty>++ <faculty>+ <name>+ <lastname>Reps</lastname>+ <firstname>Thomas</firstname>+ </name>+ <phone>2627497</phone>+ <email>reps@cs.wisc.edu</email>+ <office>5389</office>+ </faculty>++ <faculty>+ <name>+ <lastname>Naugthon</lastname>+ <firstname>Jeff</firstname>+ </name>+ <phone>2627997</phone>+ <email>naughton@cs.wisc.edu</email>+ <office>7371</office>+ </faculty>++ <faculty>+ <name>+ <lastname>Dewitt</lastname>+ <firstname>David</firstname>+ </name>+ <phone>2635489</phone>+ <email>dewitt@cs.wisc.edu</email>+ <office>7363</office>+ </faculty>+ + <faculty>+ <name>+ <lastname>Dyer</lastname>+ <firstname>Charles</firstname>+ </name>+ <phone>2627997</phone>+ <email>dyer@cs.wisc.edu</email>+ <office>7377</office>+ </faculty>++ <faculty>+ <name>+ <lastname>Ioannidis</lastname>+ <firstname>Yannis</firstname>+ </name>+ <phone>2627497</phone>+ <email>yannis@cs.wisc.edu</email>+ <office>7373</office>+ </faculty> ++ <faculty>+ <name>+ <lastname>Ramakrishnan</lastname>+ <firstname>Raghu</firstname>+ </name>+ <phone>2627397</phone>+ <email>raghu@cs.wisc.edu</email>+ <office>7355</office>+ </faculty>++ <faculty>+ <name>+ <lastname>Solomon</lastname>+ <firstname>Marvin</firstname>+ </name>+ <phone>2627497</phone>+ <email>solomon@cs.wisc.edu</email>+ <office>7379</office>+ </faculty> ++ + <faculty>+ <name>+ <lastname>Hill</lastname>+ <firstname>Mark</firstname>+ </name>+ <phone>2627397</phone>+ <email>hill@cs.wisc.edu</email>+ <office>7355</office>+ </faculty>++ <faculty>+ <name>+ <lastname>Wood</lastname>+ <firstname>David</firstname>+ </name>+ <phone>2627497</phone>+ <email>wood@cs.wisc.edu</email>+ <office>7379</office>+ </faculty> +++ <undergradstudent>+ <name>+ <lastname>King</lastname>+ <firstname>James</firstname>+ </name>+ <phone>2626623</phone>+ <email>jking@cs.wisc.edu</email>+ <address>+ <city>Madison</city>+ <state>WI</state>+ <zip>53705</zip> + </address>+ <gpa>3.0</gpa>+ </undergradstudent>++ <undergradstudent>+ <name>+ <lastname>Wagner</lastname>+ <firstname>James</firstname>+ </name>+ <phone>2626634</phone>+ <email>wagner@cs.wisc.edu</email>+ <address>+ <city>Madison</city>+ <state>WI</state>+ <zip>53705</zip> + </address>+ <gpa>3.5</gpa>+ </undergradstudent>+ + <undergradstudent>+ <name>+ <lastname>Bloy</lastname>+ <firstname>Michael</firstname>+ </name>+ <phone>2626433</phone>+ <email>bloy@cs.wisc.edu</email>+ <address>+ <city>Madison</city>+ <state>WI</state>+ <zip>53705</zip> + </address>+ <gpa>3.6</gpa>+ </undergradstudent>++ <undergradstudent>+ <name>+ <lastname>Cahil</lastname>+ <firstname>Michael</firstname>+ </name>+ <phone>2623323</phone>+ <email>cahil@cs.wisc.edu</email>+ <address>+ <city>Madison</city>+ <state>WI</state>+ <zip>53705</zip> + </address>+ <gpa>4.0</gpa>+ </undergradstudent>++ <undergradstudent>+ <name>+ <lastname>Galanis</lastname>+ <firstname>Mitsos</firstname>+ </name>+ <phone>2626623</phone>+ <email>mitsos@cs.wisc.edu</email>+ <address>+ <city>Madison</city>+ <state>WI</state>+ <zip>53705</zip> + </address>+ <gpa>4.0</gpa>+ </undergradstudent>++++</department>
+ hxml-0.2/00-LICENSE.txt view
@@ -0,0 +1,22 @@+LICENSE ("MIT-style")++Copyright (C) 2000, 2001, Joe English++Permission is hereby granted to use, copy, modify, distribute,+and license this software and its documentation for any purpose, provided+that existing copyright notices are retained in all copies and that this+notice is included in any distributions. No written agreement,+license, or royalty fee is required for any of the authorized uses.+Modifications to this software may be copyrighted by their authors+and need not follow the licensing terms described here, provided that+the new terms are clearly indicated on the first page of each file where+they apply.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT+SHALL THE AUTHORS OF THIS SOFTWARE BE LIABLE TO ANY PARTY FOR+DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES+ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION.++
+ hxml-0.2/00-README.txt view
@@ -0,0 +1,57 @@++$Id: 00-README.txt,v 1.3 2003/08/01 19:59:00 joe Exp $++5 Mar 2002++Announcing HXML version 0.2, a non-validating XML parser written in Haskell.++HXML is available at:++ <URL: http://www.flightlab.com/~joe/hxml >++The current version is 0.2, and is pre-beta quality.++HXML has been tested with GHC 6.0, GHC 5.02, NHC 1.10, and +various versions of Hugs 98.++Please contact Joe English <jenglish@flightlab.com> with+any questions, comments, or bug reports.++* * * KNOWN BUGS++ + The XML declaration is ignored.+ + Unicode support is only as good as that provided+ by the Haskell system (i.e., typically not very).+ + Does not do any well-formedness or validity checks.+ + Under Hugs 98 only, suffers a serious space fault.+ + Does not support XML Namespaces.++* * * USAGE++Documentation in XML format is available in the 'doc' subdirectory,+along with a Haskell program which converts it into HTML.+Run 'make html' in that directory to build the HTML docs+with Hugs. doc/mkSite.hs also serves as an example of how+to use the library.++* * * INSTALLATION++Installation instructions depend on the Haskell system.+For Hugs, put the sources somewhere in the Hugs search path.+For NHC, just use 'hmake'.++For GHC, copy Makefile.dist to Makefile, edit as desired, and run+ make library+ make profiled-library ;# optional+Next, edit the file "hxml.conf.in" and replace @INSTDIR@+with the installation directory (i.e., wherever you extracted+the distribution). Finally, run+ ghc-pkg --add hxml.conf.in+If all goes well, you may then use 'ghc -package hxml' to access+the library.++At some point, I'll add proper 'configure ; make ; make install' support.+Recommended procedures for doing this are still (Aug 2003) being hashed out+on various mailing lists.++* * * END.
+ hxml-0.2/Arrow.hs view
@@ -0,0 +1,194 @@+----------------------------------------------------------------------------+--+-- Module : HXML.Arrow+-- Copyright : (C) 2000-2002 Joe English. Freely redistributable.+-- License : "MIT-style"+--+-- Author : Joe English <jenglish@flightlab.com>+-- Stability : experimental+-- Portability : portable+--+-- CVS : $Id: Arrow.hs,v 1.8 2002/10/12 01:58:56 joe Exp $+--+----------------------------------------------------------------------------+--+-- [30 Jan 1999]+-- Arrow combinator library; inspired by John Hughes'+-- "Generalizing Monads to Arrows"++module Arrow where++import Monad++infixr 5 ++++infixr 3 >&<, &&&+infixr 2 >|<, |||, ?>, >?>, :>+infixl 1 >>>++class Arrow a where+ arr :: (b -> c) -> a b c+ (>>>) :: a b c -> a c d -> a b d+ apfst :: a b c -> a (b,x) (c,x)+ apsnd :: a b c -> a (x,b) (x,c)+ (>&<) :: a b c -> a d e -> a (b,d) (c,e)+ (&&&) :: a b c -> a b d -> a b (c,d)+ liftA2 :: (b -> c -> d) -> a e b -> a e c -> a e d+ aConst :: c -> a b c+ idArrow :: a b b+ -- Minimal implementation: arr, >>>, apfst or >&<++ apsnd f = arr swap >>> apfst f >>> arr swap+ where swap (x,y) = (y,x)+ f >&< g = apfst f >>> apsnd g+ -- OR: (arr fst >>> f) &&& (arr snd >>> g)+ f &&& g = arr twin >>> (f >&< g)+ where twin a = (a,a)+ apfst f = f >&< arr id+ liftA2 op f g = (f &&& g) >>> arr (uncurry op)+ aConst c = arr (const c)+ idArrow = arr id+ -- swap :: (a,b) -> (b,a)+ -- twin :: a -> (a,a)+ -- uncurry :: (a -> b -> c) -> (a,b) -> c++data Choice a = a :> a+class (Arrow a) => ArrowChoice a where+ apl :: a b c -> a (Either b d) (Either c d)+ apr :: a b c -> a (Either d b) (Either d c)+ (>|<) :: a b c -> a d e -> a (Either b d) (Either c e)+ (|||) :: a b c -> a d c -> a (Either b d) c+ ( ?>) :: (b -> Bool) -> Choice (a b c) -> a b c+ (>?>) :: a b Bool -> Choice (a b c) -> a b c++ -- Minimal implementation: >|< or apl++ apl f = f >|< idArrow+ apr f = arr mirror >>> apl f >>> arr mirror+ where mirror = either Right Left+ f >|< g = apl f >>> apr g+ f ||| g = (f >|< g) >>> arr (either id id)++ p >?> (f :> g) = liftA2 lrtag p idArrow >>> (f ||| g)+ where lrtag c = if c then Left else Right+ p ?> choice = arr p >?> choice+ -- mirror :: Either a b -> Either b a+ -- lrtag :: Bool -> b -> Either b b+++class (Arrow a) => ArrowApply a where+ app :: a (a b c,b) c++class (Arrow a) => ArrowZero a where+ aZero :: a b c+ aMaybe :: a (Maybe c) c+ aGuard :: (b -> Bool) -> a b b++ aGuard p = arr (\x -> if p x then Just x else Nothing) >>> aMaybe++{- Alternate interfaces:+ aMaybe :: (b -> Maybe c) -> a b c+ aMaybe :: a b (Maybe c) -> a b c+ aGuard :: a b Bool -> a b b+-}++class (Arrow a) => ArrowPlus a where+ (+++) :: a b c -> a b c -> a b c++{- ************************************************************ -}++{- NOTE: comment this out if NHC98 1.10 gives you problems -}++instance Arrow (->) where+ arr = id+ f >>> g = \x -> g (f x) -- (>>>) = flip (.)+ apfst f (x,y) = (f x, y)+ apsnd g (x,y) = (x, g y)+ f >&< g = \(x,y) -> (f x, g y)+ f &&& g = \x -> (f x, g x)+ liftA2 op f g x = op (f x) (g x)+ aConst = const++instance ArrowChoice (->) where+ f ||| g = either f g+ f >|< g = either (Left . f) (Right . g)+ apl f = either (Left . f) Right+ apr f = either Left (Right . f)+ p ?> (f :> g) = \x -> if p x then f x else g x++instance ArrowApply (->) where+ app (f,x) = f x++{- END -}++{- ************************************************************ -}++-- Reader arrow++newtype R a b c = R (a -> b -> c)+instance Arrow (R a) where+ arr = R . const -- arr f = R (\a b -> f b)+ R f >>> R g = R (\a -> g a . f a) -- R (\a b -> g a (f a b))+ apfst (R f) = R (\a (x,y) -> (f a x,y))+ apsnd (R f) = R (\a (x,y) -> (x,f a y))+ R f >&< R g = R (\a (x,y) -> (f a x,g a y))+ R f &&& R g = R (\a x -> (f a x,g a x))+ liftA2 o (R f) (R g)= R (\a x -> o (f a x) (g a x))+ aConst c = R (\_a _b -> c)++instance ArrowChoice (R a) where+ R f >|< R g = R (\a -> either (Left . f a) (Right . g a))+ R f ||| R g = R (\a -> either (f a) (g a))++readR :: (a -> c) -> R a b c+readR f = R (\a _b -> f a)++runR :: R a b c -> a -> b ->c+runR (R f) = f++{- ************************************************************ -}++-- Monadic arrows (called "Kleisli" arrows in Hughes)++newtype MA m a b = MA (a -> m b)++runMA :: (Monad m) => (MA m a b) -> a -> m b+runMA (MA f) = f++reflectMA :: (Monad m) => (a -> m b) -> MA m a b+reflectMA = MA++aJoin :: (Monad m) => MA m (m a) a+aJoin = reflectMA id++instance (Monad m, Functor m) => Arrow (MA m) where+ arr f = MA (return . f)+ MA f >>> MA g = MA (\b -> f b >>= g)+ MA f >&< MA g = MA (\(b,d) -> f b >>= \c-> g d >>= \e-> return (c,e))+ MA f &&& MA g = MA (\b -> f b >>= \c-> g b >>= \e-> return (c,e))+ apfst (MA f) = MA (\(b,d) -> f b >>= \c-> return (c,d))+ apsnd (MA g) = MA (\(b,d) -> g d >>= \e-> return (b,e))+ aConst c = MA (\_b -> return c)+ idArrow = MA return+ liftA2 op (MA f) (MA g)+ = MA (\x -> f x >>= \l -> fmap (\r -> op l r) (g x))++instance (Monad m, Functor m) => ArrowChoice (MA m) where+ MA f ||| MA g = MA (either f g)+ MA f >|< MA g = MA (either (fmap Left . f) (fmap Right . g))+ p ?> (MA f :> MA g) = MA (\x -> if p x then f x else g x)+ apl (MA f) = MA (either (fmap Left . f) (return . Right))+ apr (MA g) = MA (either (return . Left) (fmap Right . g))++instance (Monad m, Functor m) => ArrowApply (MA m) where+ app = MA (\(MA f,x) -> f x)++instance (MonadPlus m, Functor m) => ArrowZero (MA m) where+ aZero = MA (const mzero)+ aMaybe = MA (maybe mzero return)+ aGuard p = MA (\x -> if p x then return x else mzero)++instance (MonadPlus m, Functor m) => ArrowPlus (MA m) where+ MA f +++ MA g = MA (\x -> mplus (f x) (g x))++{- ************************************************************ -}+
+ hxml-0.2/AssocList.hs view
@@ -0,0 +1,56 @@+----------------------------------------------------------------------------+--+-- Module : AssocList.hs+-- Copyright : (C) 2000-2002 Joe English. Freely redistributable.+-- License : "MIT-style"+--+-- Author : Joe English <jenglish@flightlab.com>+-- Stability : provisional+-- Portability : portable+--+-- CVS : $Id: AssocList.hs,v 1.5 2002/10/12 01:58:56 joe Exp $+--+----------------------------------------------------------------------------+--+-- Quick hack; need a stub FiniteMap implementation+--++module AssocList + ( FM, unsafeLookup, lookupM, lookupWithDefault, empty+ , insert , insertWith+ ) where++import Prelude -- hiding (null,map,foldr,foldl,foldr1,foldl1,filter)++type FM k a = [(k,a)]++lookupM :: (Eq k) => FM k a -> k -> Maybe a+lookupM = flip Prelude.lookup++lookupWithDefault :: (Eq key) => FM key elt -> elt -> key -> elt+lookupWithDefault m d = maybe d id . lookupM m++unsafeLookup :: (Eq a) => FM a b -> a -> b+unsafeLookup m = maybe (error "Error: Not found") id . lookupM m++insertWith :: (Eq k) => (a -> a -> a) -> k -> a -> FM k a -> FM k a+insertWith _ key elt [] = [(key,elt)]+insertWith c key elt ((k,e):l)+ | k == key = (k,c e elt):l+ | otherwise = (k,e):insertWith c key elt l++insert :: (Eq k) => k -> a -> FM k a -> FM k a+insert = insertWith (\_old new -> new)++{-+-- GHC 'data' library convention:+addToFM_C :: (elt -> elt -> elt) -> FM key elt -> key -> elt -> FM key elt+addToFM :: FM key elt -> key -> elt -> FM key elt+lookupFM :: FM key elt -> key -> Maybe elt+lookupWithDefaultFM :: FM key elt -> elt -> key -> elt+-}++empty :: FM a b+empty = []++-- EOF --
+ hxml-0.2/DTD.hs view
@@ -0,0 +1,218 @@+----------------------------------------------------------------------------+--+-- Module : HXML.DTD+-- Copyright : (C) 2000-2002 Joe English. Freely redistributable.+-- License : "MIT-style"+--+-- Author : Joe English <jenglish@flightlab.com>+-- Stability : provisional+-- Portability : portable+--+-- CVS : $Id: DTD.hs,v 1.6 2002/10/12 01:58:57 joe Exp $+--+----------------------------------------------------------------------------+--+-- | Data types for SGML and XML document type definitions.+-- This is based on the SGML property set found in the DSSSL spec,+-- section 9.6.+--+-- History:+-- [23 Jan 2000], taken from earlier work, [4 Jan 1997]+--++module DTD where++import XML+import qualified AssocList as FM++type GI = Name -- generic identifier (element type name)+type DCN = Name -- data content notation name ++-- | Content expression, parameterized over type of primitive tokens+data CE a =+ Prim a -- ^ Primitive content token+ | Rep (CE a) -- ^ Zero or more, '*' occurrence indicator+ | Opt (CE a) -- ^ Optional, '?' occurrence indicator+ | Plus (CE a) -- ^ One or more, '+' occurrence indicator+ | Seq [(CE a)] -- ^ Sequence, ',' connector+ | Or [(CE a)] -- ^ Alternation, '|' connector+ | And [(CE a)] -- ^ Permutation, '&' connector+ deriving Eq++data PrimitiveToken =+ PCDATA -- ^ Parsed character data+ | ELEMENT GI -- ^ Element+ deriving Eq++type ModelGroup = CE PrimitiveToken+data CONTYPE = -- (element) content type+ DC_EMPTY -- ^ declared content (also: CDATA, RCDATA in SGML)+ | DC_ANY -- ^ "ANY"+ | DC_MODELGRP ModelGroup+ deriving Show++data ELEMTYPE = ELEMTYPE { -- element type definition+ gi :: GI, -- ^ generic identifier+ contype :: CONTYPE, -- ^ content type+ omissibility:: (Bool,Bool), -- ^ omitstrt+omitend+ inclusions :: [GI],+ exclusions :: [GI] } deriving Show++-- Missing: attdefs, srmap(nm); all from DTGABS++data ATT_TYPE = -- (dcltype/decl value type)+ ATcdata+ | ATentity+ | ATentities+ | ATid+ | ATidref+ | ATidrefs+ | ATnmtoken -- %%% or name/number/nutoken+ | ATnmtokens -- %%% or names/numbers/nutokens+ | ATnotation [DCN] -- List of notation names+ | ATenumerated [Name] -- nmtkgrp / name token group+ deriving Show++data ATT_DV = -- attribute default value (dflttype/default value type)+ ADVfixed String -- "#FIXED ..."+ | ADVrequired -- "#REQUIRED"+ | ADVimplied -- "#IMPLIED"+ | ADVdefault String -- "..."+ -- SGML only:+ | ADVcurrent -- "#CURRENT"+ | ADVconref -- "#CONREF"+ deriving Show++data ATTDEF = ATTDEF { -- attribute definition+ att_name :: Name,+ att_type :: ATT_TYPE,+ att_dv :: ATT_DV } deriving Show++type ATTSPEC = (Name,String) -- (attasgn/attribute assignment)+++-- +-- Entities:+--++type ExternalID = (Maybe PUBID, Maybe SYSID)+type PUBID = String+type SYSID = String++data ENTTYPE = -- entity type+ ETtext -- SGML text entity+ | ETcdata+ | ETsdata+ | ETndata+ | ETsubdoc+ | ETpi -- processing instruction entity++data EntityText =+ EN_INTERNAL String -- entity.text/replacement text + | EN_EXTERNAL ExternalID -- entity.extid/external identifier+ deriving Show++data Entity = Entity {+ ename :: Name, -- name+ etype :: ENTTYPE, -- enttype/entity type+ etext :: EntityText, -- see above+ edcn :: Maybe DCN, -- notname/notation name+ eatts :: [ATTSPEC] -- atts/attributes+}++type EntityMap = FM.FM Name EntityText+predefinedEntities :: EntityMap+predefinedEntities = foldr (uncurry FM.insert) FM.empty predefinedGEs+ where+ (==>) = \a b -> (a,EN_INTERNAL b)+ predefinedGEs = [+ "lt" ==> "<",+ "amp" ==> "&",+ "gt" ==> ">",+ "apos" ==> "'",+ "quot" ==> "\"" ]+-- +-- Utility routine, used by scanner:+--++expandInternalEntity :: EntityMap -> Name -> Maybe String+expandInternalEntity entities name = + case FM.lookupM entities name of+ Just (EN_INTERNAL text) -> Just text+ _ -> Nothing++--+-- DTDS:+--+data DTD = DTD {+ elements :: FM.FM Name ELEMTYPE, -- elemtps / element types+ attlists :: FM.FM Name [ATTDEF], -- elemtype.attdefs+ genents :: FM.FM Name EntityText, -- general entities+ parments :: FM.FM Name EntityText, -- parameter entities+ notations:: [DCN], -- nots/notations+ dtdname :: Name -- name (document type name)+} deriving Show++emptyDTD :: DTD+emptyDTD = DTD {+ elements = FM.empty,+ attlists = FM.empty,+ genents = predefinedEntities,+ parments = FM.empty,+ dtdname = "",+ notations= []+} ++declareParameterEntity,declareGeneralEntity :: Name -> EntityText -> DTD -> DTD+declareParameterEntity name entityText dtd =+ dtd { parments = FM.insertWith keepOld name entityText (parments dtd) }+ where keepOld old _new = old+declareGeneralEntity name entityText dtd =+ dtd { genents = FM.insertWith keepOld name entityText (genents dtd) }+ where keepOld old _new = old++-- %%% DEAL WITH DUPLICATE DEFINITIONS HERE:+declareElements :: [GI] -> (Bool,Bool) -> CONTYPE -> ([GI],[GI]) -> DTD -> DTD+declareElements elementNames omissibility contentDefinition (incl,excl) dtd =+ dtd { elements = foldl mkElement (elements dtd) elementNames }+ where mkElement fm gi = FM.insert gi el fm where + el = ELEMTYPE {+ gi = gi,+ contype = contentDefinition,+ omissibility = omissibility,+ inclusions = incl,+ exclusions = excl+ }++-- %%% DEAL WITH DUPLICATES:+declareAttlist :: [GI] -> [ATTDEF] -> DTD -> DTD+declareAttlist elementNames attdefs dtd =+ dtd { attlists = foldl addAttdefs (attlists dtd) elementNames }+ where addAttdefs fm gi = FM.insert gi attdefs fm++declareNotation :: DCN -> ExternalID -> DTD -> DTD+declareNotation dcn _unused dtd =+ dtd { notations = dcn : notations dtd }++-- Need srmaps::Dict[SRASSOC]+usemaps::Dict{-GI-}srmap(nm)|elemtype.srmap(nm)+-- notation: name, extid, attdefs++instance Show PrimitiveToken where+ showsPrec _ PCDATA = showString "#PCDATA"+ showsPrec _ (ELEMENT gi) = showString gi++instance (Show prim) => Show (CE prim) where+ showsPrec _ mg = pp mg where+ pp (Prim p) = shows p+ pp (Rep x) = shows x . showString "*"+ pp (Opt x) = shows x . showString "?"+ pp (Plus x) = shows x . showString "+"+ pp (Seq x) = showgroup ", " x+ pp (Or x) = showgroup " | " x+ pp (And x) = showgroup " & " x+ showgroup delim l = showString "(" . showl l . showString ")" where+ showl [x] = shows x+ showl (x:xs) = shows x . showString delim . showl xs+ showl [] = showString "-- ERROR: empty model group! --"++-- EOF --
+ hxml-0.2/ETree.hs view
@@ -0,0 +1,44 @@+----------------------------------------------------------------------------+--+-- Module : HXML.ETree+-- Copyright : (C) 2000-2002 Joe English. Freely redistributable.+-- License : "MIT-style"+--+-- Author : Joe English <jenglish@flightlab.com>+-- Stability : experimental+-- Portability : portable+--+-- CVS : $Id: ETree.hs,v 1.3 2002/10/12 01:58:57 joe Exp $+--+----------------------------------------------------------------------------+--+-- 11 Mar 2002+--+-- Simplified XML representation with only the essential Infoset properties.+--++module ETree(ETree, xmlToETree, etreeToXML) where++import XML+import Tree++data ETree+ = Element Name AttList [ETree]+ | Text String+ deriving Show++xmlToETree :: XML -> ETree+xmlToETree = maybe fallback id . foldTree etree mcons [] where+ etree (TXNode txt) _ = Just $ Text txt+ etree (ELNode gi atts) c = Just $ Element gi atts c+ etree RTNode (c:_) = Just c+ etree _ _ = Nothing+ mcons = maybe id (:)+ fallback = Text "Error: ill-formed XML input"++etreeToXML :: ETree -> XML+etreeToXML = anaTree psi where+ psi (Text txt) = (TXNode txt,[])+ psi (Element gi atts content) = (ELNode gi atts,content)++-- EOF --
+ hxml-0.2/Filter.hs view
@@ -0,0 +1,82 @@+----------------------------------------------------------------------------+--+-- Module : HXML.Filter+-- Copyright : (C) 2002 Joe English. Freely redistributable.+-- License : "MIT-style"+--+-- Author : Joe English <jenglish@flightlab.com>+-- Stability : experimental+-- Portability : portable+--+-- CVS : $Id: Filter.hs,v 1.3 2002/10/12 01:58:57 joe Exp $+--+----------------------------------------------------------------------------+--+-- | Filter arrows: @(a -> [b])@+--+-- @Filter a b@ is essentially the same as the Monadic arrow @MA [] a b@,+-- but it uses a different version of the bind operation at certain+-- points to reduce heap drag.+--++module Filter(Filter, runFilter, makeFilter, apFilter, aEach) where++import Arrow++newtype Filter a b = F (a -> [b])++runFilter :: Filter a b -> a -> [b]+runFilter (F f) = f++makeFilter :: (a -> [b]) -> Filter a b+makeFilter = F++apFilter :: ([a] -> [b]) -> Filter c a -> Filter c b+apFilter func filt = makeFilter (func . runFilter filt)++aEach :: Filter [a] a+aEach = makeFilter id++(!>>=) :: [a] -> (a -> [b]) -> [b]+[] !>>= _ = []+[x] !>>= f = f x+(x:xs) !>>= f = f x ++ (xs !>>= f)++wrap :: a -> [a]+wrap x = [x]++instance Arrow Filter where+ arr f = F $ wrap . f+ F f >>> F g = F $ concatMap g . f+ F f >&< F g = F $ \(b,d) -> f b !>>= \c-> g d !>>= \e-> [(c,e)]+ F f &&& F g = F $ \b -> f b !>>= \c-> g b !>>= \e-> [(c,e)]+ apfst (F f) = F $ \(b,d) -> f b !>>= \c-> [(c,d)]+ apsnd (F g) = F $ \(b,d) -> g d !>>= \e-> [(b,e)]+ aConst c = F $ const [c]+ idArrow = F wrap+ liftA2 h (F f) (F g)= F $ \x -> f x !>>= \l -> map (h l) (g x)++instance ArrowChoice Filter where+ F f ||| F g = F $ either f g+ F f >|< F g = F $ either (map Left . f) (map Right . g)+ apl (F f) = F $ either (map Left . f) (wrap . Right)+ apr (F g) = F $ either (wrap . Left) (map Right . g)+ p ?> (F f :> F g)= F $ \x -> if p x then f x else g x+ F p >?> (F f :> F g)= F $ \x -> p x !>>= \c -> if c then f x else g x++instance ArrowZero Filter where+ aZero = F (const [])+ aMaybe = F (maybe [] wrap)+ aGuard p = F (\x -> if p x then [x] else [])++instance ArrowPlus Filter where+ F f +++ F g = F (\x -> f x ++ g x)++{- Alternate implementation:+ type Filter a b = MA [] a b+ runFilter = runMA+ makeFilter = reflectMA+ aEach = aJoin+-}++-- EOF --
+ hxml-0.2/HXML.hs view
@@ -0,0 +1,38 @@+----------------------------------------------------------------------------+--+-- Module : HXML+-- Copyright : (C) 2001-2002 Joe English. Freely redistributable.+-- License : "MIT-style"+--+-- Author : Joe English <jenglish@flightlab.com>+-- Stability : experimental+-- Portability : portable+--+-- Created : 1 Nov 2001+-- CVS : $Id: HXML.hs,v 1.5 2002/10/12 01:58:57 joe Exp $+--+----------------------------------------------------------------------------+--+-- | Package module for HXML -- just reexports all the public modules.+--++module HXML + ( module XML+ , module Tree+ , module PrintXML+ , module ETree++ , parseXML+ ) where++import XML+import XMLParse+import Tree+import TreeBuild+import PrintXML+import ETree++parseXML :: String -> Tree XMLNode+parseXML = buildTree . parseDocument++-- EOF --
+ hxml-0.2/LLParsing.hs view
@@ -0,0 +1,110 @@+{-# OPTIONS -fno-warn-missing-signatures #-}+{-# OPTIONS -fglasgow-exts #-}+----------------------------------------------------------------------------+--+-- Module : HXML.LLParsing+-- Copyright : (C) 2000-2002 Joe English. Freely redistributable.+-- License : "MIT-style"+--+-- Author : Joe English <jenglish@flightlab.com>+-- Stability : experimental+-- Portability : portable (wants rank-2 polymorphism but can live without it)+--+-- CVS : $Id: LLParsing.hs,v 1.6 2002/10/12 01:58:57 joe Exp $+--+----------------------------------------------------------------------------+--+-- 20 Jan 2000+-- Simple, non-backtracking, no-lookahead parser combinators.+-- Use with caution!+--++module LLParsing+ ( pTest , pCheck , pSym , pSucceed+ ,(<|>),(<*>),(<$>),(<^>),(<$),(<*),(*>),(<?>),(<**>)+ , pMaybe , pFoldr , pList , pSome , pChainr , pChainl, pTry+ , pRun+ ) where++infixl 3 <|>+infixl 4 <*>, <$>, <^>, <?>, <$, <*, *>, <**>++{- <H98> -}+-- Use this for Haskell 98:+newtype P p = P p+{- </H98> -}++{- <H98EXT> -}+{-+-- Use this if the system supports rank-2 polymorphism:+newtype Parser sym res = P (forall a .+ (res -> [sym] -> a) -- ok continuation+ -> ([sym] -> a) -- failure continuation+ -> ([sym] -> a) -- error continuation+ -> [sym] -- input+ -> a) -- result++pTest :: (a -> Bool) -> Parser a a+pCheck :: (a -> Maybe b) -> Parser a b+pSym :: (Eq a) => a -> Parser a a+pSucceed:: b -> Parser a b+(<|>) :: Parser a b -> Parser a b -> Parser a b -- union+(<*>) :: Parser a (b->c) -> Parser a b -> Parser a c -- sequence+(<$>) :: (b->c) -> Parser a b -> Parser a c -- application+(<$ ) :: c -> Parser a b -> Parser a c -- application, dropr+(<^>) :: Parser a b -> Parser a c -> Parser a (b,c) -- sequence+(<* ) :: Parser a b -> Parser a c -> Parser a b -- sequence, dropr+( *>) :: Parser a b -> Parser a c -> Parser a c -- sequence, dropl+(<?>) :: Parser a b -> b -> Parser a b -- optional+(<**>) :: Parser s b -> Parser s (b->a) -> Parser s a -- postfix application+pMaybe :: Parser s a -> Parser s (Maybe a)+pFoldr :: (a->b->b) -> b -> Parser s a -> Parser s b+pList :: Parser a b -> Parser a [b]+pSome :: Parser a b -> Parser a [b]+pChainr :: Parser a (b -> b -> b) -> Parser a b -> Parser a b+pChainl :: Parser a (b -> b -> b) -> Parser a b -> Parser a b+pRun :: Parser a b -> [a] -> Maybe (b,[a])+-}+{- </H98EXT> -}++pTest pred = P (ptest pred)+ where+ ptest _p _o f _e [] = f []+ ptest p ok f _e l@(c:cs)+ | p c = ok c cs+ | otherwise = f l++pSym a = pTest (a==)+pCheck cmf = P (pcheck cmf) where+ pcheck _mf _ok f _e [] = f []+ pcheck mf ok f _e cs@(c:s) = case (mf c) of+ Just x -> ok x s+ Nothing -> f cs++pTry (P pa) = P (\ok f _e i -> pa ok f (\ _i' -> f i) i)++pSucceed a = P (\ok _f _e -> ok a)+(P pa) <|> (P pb) = P (\ok f e -> pa ok (pb ok f e) e)+(P pa) <*> (P pb) = P (\ok f e -> pa (\a -> pb (ok . a) e e) f e)+(P pa) <?> a = P (\ok _f -> pa ok (ok a))+(P pa) <^> (P pb) = P (\ok f e -> pa (\a->pb(\b->ok (a,b)) e e) f e)+f <$> (P pb) = P (\ok -> pb (ok . f))+f <$ (P pb) = P (\ok -> pb (ok . const f))+pa <* pb = curry fst <$> pa <*> pb+pa *> pb = curry snd <$> pa <*> pb+pa <**> pb = (\x f -> f x) <$> pa <*> pb++pMaybe p = Just <$> p <|> pSucceed Nothing+pFoldr op e p = loop where loop = (op <$> p <*> loop) <?> e+pList = pFoldr (:) []+pSome p = (:) <$> p <*> pList p+pChainr op p = loop+ where loop = p <**> ((flip <$> op <*> loop) <?> id)+pChainl op p = foldl ap <$> p <*> pList (flip <$> op <*> p)+ where ap x f = f x++pRun (P p) = p just2 fail fail where+ just2 x y = Just (x,y)+ fail = const Nothing++-- EOF --
+ hxml-0.2/Misc.hs view
@@ -0,0 +1,60 @@+----------------------------------------------------------------------------+--+-- Module : HXML.Misc+-- Copyright : (C) 2000-2002 Joe English. Freely redistributable.+-- License : "MIT-style"+--+-- Author : Joe English <jenglish@flightlab.com>+-- Stability : experimental+-- Portability : portable+--+-- CVS : $Id: Misc.hs,v 1.8 2002/10/12 01:58:58 joe Exp $+--+----------------------------------------------------------------------------+--+-- 21 Jan 2000+-- Miscellaneous combinators that I find useful+--+ +module Misc where++errNYI :: String -> a+errNYI msg = error ("Not Yet Implemented: " ++ msg)++-- Kleisli composition:+o :: (Monad m) => (b -> m c) -> (a -> m b) -> (a -> m c)+f `o` g = \x -> g x >>= f++-- Some useful anamorphisms:+maybeStar, maybePlus :: (a -> Maybe a) -> a -> [a]+maybeStar f a = a : maybe [] (maybeStar f) (f a)+maybePlus f a = maybe [] (maybeStar f) (f a)++-- Used to be in Haskell Prelude:+done :: Monad m => m ()+done = return ()++-- H98: found in module Monad:+liftM2 :: (Monad m) => (b->c->d) -> m b -> m c -> m d+liftM2 op x y = x >>= \a -> y >>= \b -> return (op a b)++-- H98: found in module Maybe:+maybeToList :: Maybe a -> [a]+maybeToList Nothing = []+maybeToList (Just a) = [a]++-- ... other stuff+instance Monad ((->) s) where -- Reader Monad+ return = const+ f >>= g = \x -> g (f x) x++lift :: (b->c->d) -> (a->b) -> (a->c) -> (a->d)+lift f g h x = f (g x) (h x)++pair :: a -> b -> (a,b)+pair x y = (x,y)++wrap :: a -> [a]+wrap x = [x]++-- EOF --
+ hxml-0.2/NTree.hs view
@@ -0,0 +1,84 @@+----------------------------------------------------------------------------+--+-- Module : HXML.NTree+-- Copyright : (C) 2000-2002 Joe English. Freely redistributable.+-- License : "MIT-style"+--+-- Author : Joe English <jenglish@flightlab.com>+-- Stability : experimental+-- Portability : portable+--+-- CVS : $Id: NTree.hs,v 1.3 2002/10/12 01:58:58 joe Exp $+--+----------------------------------------------------------------------------+--+-- Description: "Navigable trees": allow a program to traverse +-- up the tree as well as down.+--++module NTree where++import Tree+import Misc (maybeStar, maybePlus, maybeToList, o)++data NTree a = NT+ (Tree a) -- self+ [NTree a] -- ancestors+ [Tree a] -- previous siblings (in reverse order)+ [Tree a] -- following siblings++ntree :: Tree a -> NTree a+ntree nd = NT nd [] [] []++subtreeNT :: NTree a -> Tree a+subtreeNT (NT nd _ _ _) = nd++dataNT :: NTree a -> a+dataNT (NT (Tree a _) _ _ _) = a++upNT, downNT, leftNT, rightNT :: NTree a -> Maybe (NTree a)++upNT (NT _ (p:_) _ _) = Just p+upNT (NT _ [] _ _) = Nothing+downNT t@(NT (Tree _ (c:cs)) u _ _) = Just (NT c (t:u) [] cs)+downNT (NT (Tree _ [] ) _ _ _) = Nothing+leftNT (NT s u (l:ls) r) = Just (NT l u ls (s:r))+leftNT (NT _ _ [] _) = Nothing+rightNT (NT s u l (r:rs)) = Just (NT r u (s:l) rs)+rightNT (NT _ _ _ [] ) = Nothing++-- preorderNT t = t : concatMap preorderNT (children t)+-- where children = maybe [] (maybeStar rightNT) . downNT+preorderNT :: NTree a -> [NTree a]+preorderNT = visit [] where+ visit k t = t : maybe k (visit' k) (downNT t)+ visit' k t = visit (maybe k (visit' k) (rightNT t)) t++revPreorderNT :: NTree a -> [NTree a]+revPreorderNT t = t : concatMap revPreorderNT (reverse (children t))+ where children = maybe [] (maybeStar rightNT) . downNT++-- XPath axes:++ancestorAxis, ancestorOrSelfAxis, childAxis,+ descendantAxis, descendantOrSelfAxis,+ followingAxis, followingSiblingAxis, parentAxis,+ precedingAxis, precedingSiblingAxis, selfAxis + :: NTree a -> [NTree a]++-- attributeAxis, namespaceAxis : not supported++parentAxis = maybeToList . upNT+ancestorAxis = \(NT _ u _ _) -> u -- or: maybePlus upNT+ancestorOrSelfAxis = \t@(NT _ u _ _) -> t:u -- or: maybeStar upNT+childAxis = maybe [] (maybeStar rightNT) . downNT+descendantAxis = tail . preorderNT -- concatMap preorderNT . childAxis+descendantOrSelfAxis = preorderNT+followingSiblingAxis = maybePlus rightNT+precedingSiblingAxis = maybePlus leftNT+selfAxis = wrap where wrap x = [x]++followingAxis = preorderNT `o` followingSiblingAxis `o` ancestorOrSelfAxis +precedingAxis = revPreorderNT `o` precedingSiblingAxis `o` ancestorOrSelfAxis++-- EOF --
+ hxml-0.2/PrintXML.hs view
@@ -0,0 +1,91 @@+----------------------------------------------------------------------------+--+-- Module : HXML.PrintXML+-- Copyright : (C) 2000-2002 Joe English. Freely redistributable.+-- License : "MIT-style"+--+-- Author : Joe English <jenglish@flightlab.com>+-- Stability : experimental+-- Portability : portable+--+-- CVS : $Id: PrintXML.hs,v 1.5 2002/10/12 01:58:58 joe Exp $+--+----------------------------------------------------------------------------++module PrintXML + ( printXML, showXML+ , printEvent, showEvent, showEvents, printEvents+ ) where++import XML+import Tree+import TreeBuild+import XMLParse (XMLEvent(..))++printXML :: XML -> IO ()+printXML = printEvents . serializeTree++showXML :: XML -> String+showXML t = pp t [] where+ pp (Tree nd children) k = case nd of+ RTNode -> ppl children k+ TXNode txt -> textEscape txt k+ PINode tgt [] -> "<?" ++ tgt ++ "?>" ++ k+ PINode tgt val -> "<?" ++ tgt ++ " " ++ val ++ "?>" ++ k+ CXNode txt -> "<!--" ++ txt ++ "-->" ++ k+ ENNode ename -> "&" ++ ename ++ ";" ++ k+ ELNode gi attlist ->+ let atts = showAttlist attlist+ in case children of+ [] -> "<" ++ gi ++ atts ++ "/>" ++ k+ _ -> "<" ++ gi ++ atts ++ ">"+ ++ ppl children ("</" ++ gi ++ "\n>" ++ k)+ ppl [] k = k+ ppl (x:xs) k = pp x (ppl xs k)++showEvent :: XMLEvent -> String+printEvent :: XMLEvent -> IO ()+showEvents :: [XMLEvent] -> String+printEvents :: [XMLEvent] -> IO ()++showEvents = concatMap showEvent+printEvent = putStr . showEvent+printEvents = mapM_ printEvent++showEvent (StartEvent gi atts) = "<" ++ gi ++ showAttlist atts ++ ">"+showEvent (EmptyEvent gi atts) = "<" ++ gi ++ showAttlist atts ++ "/>"+showEvent (EndEvent gi) = "</" ++ gi ++ "\n>"+showEvent (TextEvent txt) = textEscape txt []+showEvent (PIEvent tgt []) = "<?" ++ tgt ++ "?>"+showEvent (PIEvent tgt val) = "<?" ++ tgt ++ " " ++ val ++ "?>"+showEvent (GERefEvent name) = "&" ++ name ++ ";"+showEvent (CommentEvent txt) = "<--" ++ txt ++ "-->"+showEvent (ErrorEvent txt) = error txt++showAttlist :: [(Name,String)] -> String+showAttlist attlist = concat [' ':patt nm val | (nm,val) <- attlist]+ where+ vi = "="+ patt nm val = nm ++ vi ++ "\"" ++ attvalEscape val "\""++textEscape, attvalEscape :: String -> ShowS++textEscape [] k = k+textEscape (c:cs) k =+ case c of+ '<' -> "<" ++ textEscape cs k+ '>' -> ">" ++ textEscape cs k+ '&' -> "&" ++ textEscape cs k+ _ -> c : textEscape cs k++attvalEscape [] k = k+attvalEscape (c:cs) k =+ case c of+ '<' -> "<" ++ attvalEscape cs k+ '>' -> ">" ++ attvalEscape cs k+ '&' -> "&" ++ attvalEscape cs k+ '\'' -> "'" ++ attvalEscape cs k+ '\"' -> """ ++ attvalEscape cs k+ _ -> c : attvalEscape cs k++-- EOF --
+ hxml-0.2/Tree.hs view
@@ -0,0 +1,73 @@+----------------------------------------------------------------------------+--+-- Module : HXML.Tree+-- Copyright : (C) 2000-2002 Joe English. Freely redistributable.+-- License : "MIT-style"+--+-- Author : Joe English <jenglish@flightlab.com>+-- Stability : experimental+-- Portability : portable+--+-- CVS : $Id: Tree.hs,v 1.9 2002/10/12 01:58:58 joe Exp $+--+----------------------------------------------------------------------------+--+-- 7 Jan 2000+--++module Tree where++data Tree a = Tree a [Tree a]+ deriving Show++--+-- Projections:+--+treeRoot :: Tree a -> a+treeChildren :: Tree a -> [Tree a]+treeRoot (Tree a _) = a+treeChildren (Tree _ c) = c++leafNode :: a -> Tree a+leafNode x = Tree x []++-- preorderTree (Tree a c) = a : concatMap preorderTree c+-- preorderTree = cataTree(\(x,bs) -> x : concat bs)+preorderTree :: Tree a -> [a]+preorderTree t = traverse t [] where+ traverse (Tree a c) k = a : travlist c k+ travlist (c:cs) k = traverse c (travlist cs k)+ travlist [] k = k++-- The usual polytypic routines:++mapTree :: (a -> b) -> Tree a -> Tree b+mapTree f (Tree a c) = Tree (f a) (map (mapTree f) c)++instance Functor Tree where fmap = mapTree++-- type TreeF a b = (a, [b])+cataTree :: ((a, [b]) -> b) -> Tree a -> b -- (TreeF a b -> b) -> Tree a -> b+anaTree :: (b -> (a, [b])) -> b -> Tree a -- (b -> TreeF a b) -> b -> Tree a+cataTree f (Tree a c) = f (a,map (cataTree f) c)+anaTree g b = let (a,bs) = g b in Tree a (map (anaTree g) bs)++-- A friendlier variant of cataTree:+--+foldTree :: (a -> b -> c) -> (c -> b -> b) -> b -> Tree a -> c+foldTree tree cons nil (Tree a c)+ = tree a (foldr cons nil (map (foldTree tree cons nil) c))++-- Downwards accumulation:+--+scanTree :: (a -> b -> a) -> a -> Tree b -> Tree a+scanTree op a (Tree b children)+ = let a' = a `op` b in Tree a' (map (scanTree op a') children)++-- A variant:+--+accumTree :: (a -> b -> (c, a)) -> a -> Tree b -> Tree c+accumTree op a (Tree b children)+ = let (c,a') = a `op` b in Tree c (map (accumTree op a') children)++-- EOF --
+ hxml-0.2/TreeBuild.hs view
@@ -0,0 +1,69 @@+----------------------------------------------------------------------------+--+-- Module : HXML.TreeBuild+-- Copyright : (C) 2000-2002 Joe English. Freely redistributable.+-- License : "MIT-style"+--+-- Author : Joe English <jenglish@flightlab.com>+-- Stability : experimental+-- Portability : portable+--+-- CVS : $Id: TreeBuild.hs,v 1.7 2002/10/12 01:58:58 joe Exp $+--+----------------------------------------------------------------------------+--+-- 30 Jan 2000+--++module TreeBuild (buildTree, constructTree, serializeTree) where++import XMLParse+import XML+import Tree++--+-- TODO: add basic error-checks: matching end-tags, ensure input exhausted+--+-- %%% There is apparently a space leak here, but I can't find it.+-- %%% Update 28 Feb 2000: There is a leak, but it's fixed+-- %%% by a well-known GC implementation technique. Hugs 98 happens+-- %%% not to implement this technique, but STG Hugs (and most other+-- %%% Haskell systems) do implement it.+-- %%% Thanks to Simon Peyton-Jones, Malcolm Wallace, Colin Runcinman+-- %%% Mark Jones, and others for investigating this.++buildTree :: [XMLEvent] -> Tree XMLNode+buildTree = constructTree Tree (:) []++constructTree :: (XMLNode -> f -> t) -> (t -> f -> f) -> f -> [XMLEvent] -> t+constructTree tree cons nil events = let+ pair x y = (x,y)+ addNode nd children es = addTree (tree nd children) es+ addLeaf nd es = addTree (tree nd nil) es+ addTree t es = let (s,es') = build es in pair (cons t s) es'+ build [] = pair nil []+ build (e:es) = case e of+ StartEvent gi atts -> let (c,es') = build es + in addNode (ELNode gi atts) c es'+ EndEvent _ -> pair nil es+ EmptyEvent gi atts -> addLeaf (ELNode gi atts) es+ TextEvent s -> addLeaf (TXNode s) es+ PIEvent tgt val -> addLeaf (PINode tgt val) es+ CommentEvent txt -> addLeaf (CXNode txt) es+ GERefEvent name -> addLeaf (ENNode name) es+ ErrorEvent s -> error s -- %%% deal with this+ in tree RTNode (fst (build events))++serializeTree :: Tree XMLNode -> [XMLEvent]+serializeTree tree = sn tree [] where+ sn (Tree node content) k = case node of+ RTNode -> sl content k+ ELNode gi atts -> StartEvent gi atts : sl content (EndEvent gi : k)+ TXNode txt -> TextEvent txt : k+ PINode tgt val -> PIEvent tgt val : k+ CXNode txt -> CommentEvent txt : k+ ENNode name -> GERefEvent name : k+ sl [] k = k+ sl (x:xs) k = sn x (sl xs k)++-- EOF --
+ hxml-0.2/XML.hs view
@@ -0,0 +1,102 @@+----------------------------------------------------------------------------+--+-- Module : HXML.XML+-- Copyright : (C) 2000-2002 Joe English. Freely redistributable.+-- License : "MIT-style"+--+-- Author : Joe English <jenglish@flightlab.com>+-- Stability : experimental+-- Portability : portable+--+-- CVS : $Id: XML.hs,v 1.9 2002/10/12 01:58:59 joe Exp $+--+----------------------------------------------------------------------------+--+-- 16 Jan 2000+-- Basic XML data types+--++module XML+ ( XMLNode(..)+ , Name, XML, AttList+ , stringValue, nodeName+ , xAttlist, xAttval+ , attributes, attval+ , xELNode, xTXNode, xPINode+ ) where++import Tree++type Name = String -- %%% XMLNS makes this more complex+type GI = Name -- generic identifier, element type name+type AttList = [(Name,String)] -- attribute list+type XML = Tree XMLNode++data XMLNode =+ RTNode -- root node+ | ELNode GI AttList -- element node: GI, attributes+ | TXNode String -- text node+ | PINode Name String -- processing instruction (target,value)+ | CXNode String -- comment node+ | ENNode Name -- general entity reference++ -- XPath also defines:+ -- ATNodeP Name String -- attribute node+ -- NSNodeP Name {- prefix-} String {-URI-} -- namespace node+ deriving Show++stringValue :: XML -> String -- [XPATH, 5]+stringValue nd@(Tree d _) = case d of+ RTNode -> concat [sv | TXNode sv <- preorderTree nd] -- [XPATH 5.1]+ ELNode _ _ -> concat [sv | TXNode sv <- preorderTree nd] -- [XPATH 5.2]+ TXNode s -> s -- [XPATH 5.7]+ PINode _ v -> v -- [XPATH 5.5]+ CXNode s -> s -- [XPATH 5.6]+ ENNode _ -> "" -- [not defined in XPATH]+ -- ATNodeP _ v -> v -- [XPATH 5.3]+ -- NSNodeP _ uri -> uri -- [XPATH 5.4]++-- %%% need to fix this to account for [XMLNS]+nodeName :: XMLNode -> Maybe Name -- [XPATH, 5; "expanded-name"]+nodeName nd = case nd of+ ELNode gi _ -> Just gi -- %%% Check [XMLNS]+ PINode tgt _-> Just tgt -- [XPATH 5.5], pi target, null URI+ ENNode name -> Just name -- [not defined in XPATH]+ --ATNodeP n _-> Just n -- %%% Check [XMLNS]+ --NSNodeP p _-> Just p -- [XPATH 5.4], ns prefix, null URI+ RTNode -> Nothing -- [XPATH 5.1]+ TXNode _ -> Nothing -- [XPATH 5.7]+ CXNode _ -> Nothing -- [XPATH 5.6]++--+-- Accessors:+--+xAttlist :: XMLNode -> AttList+xAttlist (ELNode _ attlist) = attlist+xAttlist _ = []++xAttval :: Name -> XMLNode -> Maybe String+xAttval name = lookup name . xAttlist++xELNode :: (Name -> AttList -> a) -> XMLNode -> Maybe a+xTXNode :: (String -> a) -> XMLNode -> Maybe a+xPINode :: (String -> String -> a) -> XMLNode -> Maybe a++xELNode f (ELNode gi atts) = Just (f gi atts)+xELNode _ _ = Nothing+xTXNode f (TXNode txt) = Just (f txt)+xTXNode _ _ = Nothing+xPINode f (PINode tgt val) = Just (f tgt val)+xPINode _ _ = Nothing++--+-- Tree +--++attributes :: XML -> AttList+attributes = xAttlist . treeRoot++attval :: Name -> XML -> Maybe String+attval name = xAttval name . treeRoot++-- EOF --
+ hxml-0.2/XMLCombinators.hs view
@@ -0,0 +1,182 @@+----------------------------------------------------------------------------+--+-- Module : XMLCombinators+-- Copyright : (C) 2001,2002 Joe English. Freely redistributable.+-- License : "MIT-style"+--+-- Author : Joe English <jenglish@flightlab.com>+-- Stability : experimental+-- Portability : portable+--+-- CVS : $Id: XMLCombinators.hs,v 1.6 2003/06/18 18:47:03 joe Exp $+--+----------------------------------------------------------------------------+--+-- 2 Nov 2001; revised 5 Nov 2001 to use Arrows.+--++module XMLCombinators+ ( module Arrow, module Filter, module HXML+ , xmlFilterMain, testFilter+ , qSelf, qChildren, qDescendants, qSubtree+ , qElem, qElems, qText, qEntity+ , qAttval, qAttlist, qNodeName+ , mkElem, mkElement+ , mkText, mkLiteral+ , mkAtt+ , apChildren, keepText+ , qInner, qOuter, qFirst+ , qMatch, qTest+ , aFoldTree, aScanTree+ , (.//), (./), (|>|), (|?>), qChildElem+ )+ where++import Monad+import Arrow+import Filter+import HXML++infixr 2 |?> -- same as ?>, :>+infixl 1 ./, .// -- same as >>>++--+-- Predicate adapters:+--++qMatch :: Filter a b -> Filter a a+qMatch f = aGuard (not . null . runFilter f)++qTest :: Filter a b -> Filter a Bool+qTest f = makeFilter (return . not . null . runFilter f)++(|?>) :: Filter a x -> Choice (Filter a b) -> Filter a b+f |?> choice = (not . null . runFilter f) ?> choice++--+-- Constructors:+--++mkNode :: a -> Filter s (Tree a) -> Filter s (Tree a)+mkNode nd body = makeFilter (\x -> [Tree nd (runFilter body x)])++mkLiteral :: String -> Filter a XML+mkLiteral = aConst . leafNode . TXNode++mkElem :: Name -> Filter a XML -> Filter a XML+mkElem name = mkNode (ELNode name [])++mkElement :: Name -> Filter a (Name,String) -> Filter a XML -> Filter a XML+mkElement name atts body = arr $ \x ->+ Tree (ELNode name (runFilter atts x)) (runFilter body x)++mkAtt :: Name -> Filter a String -> Filter a (Name,String)+mkAtt name val = aConst name &&& val++mkText :: Filter String XML+mkText = arr (leafNode . TXNode)++--+-- Navigation:+--++qChildren, qDescendants, qSubtree :: Filter (Tree a) (Tree a)+qChildren = makeFilter treeChildren+qSubtree = qSelf +++ (qChildren >>> qSubtree)+qDescendants = qChildren >>> qSubtree++qInner, qOuter :: Filter (Tree a) b -> Filter (Tree a) b+qOuter p = p |>| (qChildren >>> qOuter p)+qInner p = (qChildren >>> qInner p) |>| p+++(|>|) :: Filter a b -> Filter a b -> Filter a b+f |>| g = makeFilter choose where+ choose x = let fx = runFilter f x in if null fx then runFilter g x else fx++qFirst :: Filter a b -> Filter a b+qFirst = apFilter take1 where+ take1 [] = []+ take1 (x:_) = [x]++--+-- Editing:+--++apChildren :: Filter (Tree a) (Tree a) -> Filter (Tree a) (Tree a)+apChildren f = arr (\(Tree x ts) -> Tree x (ts >>= runFilter f))++aFoldTree, aScanTree :: Filter (Tree a) (Tree a) -> Filter (Tree a) (Tree a)++aFoldTree f = apChildren (aFoldTree f) >>> f+aScanTree f = f >>> apChildren (aScanTree f)++--+-- Predicates:+--++qElem :: Name -> Filter XML XML+qElem name = aGuard (q . treeRoot) where+ q (ELNode gi _) = gi == name+ q _ = False++qElems :: [Name] -> Filter XML XML -- = foldr1 (|>|) . map qElem+qElems gis = aGuard (test . treeRoot) where+ test (ELNode gi _) = elem gi gis+ test _ = False++qText :: Filter XML XML+qText = aGuard (isTXNode . treeRoot) where+ isTXNode (TXNode _) = True+ isTXNode _ = False++qEntity :: Filter XML XML+qEntity = aGuard (isENNode . treeRoot) where+ isENNode (ENNode _) = True+ isENNode _ = False++qSelf :: Filter x x+qSelf = arr id++--+-- Extractions:+--++keepText :: Filter XML XML+keepText = qSubtree >>> (qText |>| qEntity)+-- ALT: arr stringValue >>> mkText++qAttval :: Name -> Filter XML String+qAttval name = arr (attval name) >>> aMaybe++qAttlist :: Filter XML (Name,String)+qAttlist = makeFilter attributes++qNodeName :: Filter XML Name+qNodeName = arr (nodeName . treeRoot) >>> aMaybe++--+-- Shorthand:+--++(./), (.//) :: Filter a XML -> String -> Filter a XML+f ./ gi = f >>> qChildren >>> qElem gi+f .// gi = f >>> qOuter (qElem gi)++qChildElem :: String -> Filter XML XML+qChildElem gi = qFirst (qChildren >>> qElem gi)++--+-- Utilities:+--++xmlFilterMain :: Filter XML XML -> IO ()+xmlFilterMain f =+ getContents >>= mapM_ printXML . runFilter f . parseXML+ >> putChar '\n'++testFilter :: FilePath -> Filter XML XML -> IO ()+testFilter filename f =+ readFile filename >>= mapM_ printXML . runFilter f . parseXML++-- EOF --
+ hxml-0.2/XMLParse.hs view
@@ -0,0 +1,278 @@+{-# OPTIONS -fno-warn-missing-signatures #-}+----------------------------------------------------------------------------+--+-- Module : XMLParse+-- Copyright : (C) 2000-2002 Joe English. Freely redistributable.+-- License : "MIT-style"+--+-- Author : Joe English <jenglish@flightlab.com>+-- Stability : experimental+-- Portability : portable+--+-- CVS : $Id: XMLParse.hs,v 1.9 2002/10/12 01:58:59 joe Exp $+--+----------------------------------------------------------------------------+--+-- started 23 Jan 2000+--+-- TODO: expand parameter entity references in DTD and parameter literals+-- TODO: implement marked sections in DTD+--++module XMLParse+ ( XMLEvent(..)+ , parseInstance, parseDTD, parseDocument+ ) where++import XMLScanner+import LLParsing+import XML+import DTD+import Misc+import List(unfoldr)++parseInstance :: String -> [XMLEvent]++newtype UNPARSED = UNPARSED String -- Unparsed literal+ deriving Show++replaceGERefs (UNPARSED s) = expandReferences DTD.predefinedEntities s+replacePERefs (UNPARSED s) = s -- %%% FIX+attributeValueLiteral = replaceGERefs <$> pLiteral+parameterLiteral = replacePERefs <$> pLiteral+systemLiteral = unparsed <$> pLiteral+ where unparsed (UNPARSED s) = s++-- External interface:++data XMLEvent =+ StartEvent Name [(Name,String)] -- start-tag (gi, attspecs)+ | EmptyEvent Name [(Name,String)] -- empty element tag (gi,attspecs)+ | EndEvent Name -- end-tag (gi)+ | TextEvent String -- character data (text)+ | PIEvent Name String -- processing instruction (tgt value)+ | GERefEvent Name -- general entity reference (ename)+ | CommentEvent String -- comment+ | ErrorEvent String -- error report+ deriving (Read,Show)++-- Too strict: parseInstance = fmap fst . pRun (pList instanceItem) . pcdataMode+parseInstance = unfoldr (pRun instanceItem) . pcdataMode+parseDTD = foldl (\a b->b a) emptyDTD . unfoldr (pRun dtdItem) . markupMode++parseDocument text = + case pRun prolog (pcdataMode text) of+ Just (_, rest) -> unfoldr (pRun instanceItem) rest+ Nothing -> [ErrorEvent "Error parsing prolog"] -- can't happen.++-- Interface to scanner:++pDelim d = pTest (==d)+pKeyword kw = pTest (\d->case d of NAME n -> n == kw; _ -> False)+rniName kw = pTest (\d->case d of RNINAME n -> n == kw; _ -> False)+pName = pCheck (\d->case d of NAME n -> Just n ; _ -> Nothing)+pGEREF = pCheck (\d->case d of GEREF n -> Just n ; _ -> Nothing)+pPEREF = pCheck (\d->case d of PEREF n -> Just n ; _ -> Nothing)+pLiteral = pCheck literal where+ literal (LITERAL s) = Just (UNPARSED s)+ literal _ = Nothing+pCDATA = pCheck cdata where+ cdata (CDATA txt) = Just txt+ cdata (WS ws) = Just ws+ cdata _ = Nothing++-- Main grammar:++-- dtdItem :: Parser Delimiter (DTD -> DTD)+dtdItem =+ dtdDeclaration+ <|> const id <$> processingInstruction -- %%% REPORT THESE+ <|> const id <$> sgmlCommentDeclaration+ <|> const id <$> pPEREF -- %%% FIX++dtdDeclaration =+ pDelim MDO *> (+ pKeyword "ELEMENT" *> elementDeclaration+ <|> pKeyword "ATTLIST" *> attlistDeclaration+ <|> pKeyword "ENTITY" *> entityDeclaration+ <|> pKeyword "NOTATION" *> notationDeclaration+ ) <* pDelim MDC++prolog =+ pair <$> (ws *> pMaybe xmlDeclaration) <*> (ws *> pMaybe doctypeDeclaration)++ws = () <$ pList (pTest (\d -> case d of WS _ -> True ; _ -> False))++xmlDeclaration = processingInstruction++doctypeDeclaration = + pDelim MDO *> pKeyword "DOCTYPE" *> doctype <* pDelim MDC+doctype =+ () <$ pName <* externalIdentifier {-pMaybe internalSubset-}++--+-- Common constructs:+--++elementNames =+ wrap <$> pName <|> nameGroup+nameGroup =+ (:) <$ pDelim GRPO <*> pName <*>+ ( (:) <$ pDelim SEQ <*> pName <*> pList (pDelim SEQ *> pName)+ <|> (:) <$ pDelim OR <*> pName <*> pList (pDelim OR *> pName)+ <|> (:) <$ pDelim AND <*> pName <*> pList (pDelim AND *> pName)+ <|> pSucceed []+ ) <* pDelim GRPC++externalIdentifier =+ pair Nothing+ <$ pKeyword "SYSTEM" <*> pMaybe systemLiteral+ <|> pair <$ pKeyword "PUBLIC"+ <*> (Just <$> systemLiteral) <*> pMaybe systemLiteral+ <|> pSucceed (Nothing,Nothing) -- implicit identifier++-- This works for XML:+xmlCommentDeclaration =+ pDelim MDOCOM *> pcdata <* pDelim COM <* pDelim MDC+ where pcdata = pFoldr (++) [] pCDATA++-- This works for SGML:+sgmlCommentDeclaration =+ (++) <$ pDelim MDOCOM <*> (pcdata <* pDelim COM) <*> comments <* pDelim MDC+ where pcdata = pFoldr (++) [] pCDATA+ comments = pFoldr (++) [] (pDelim COM *> pcdata <* pDelim COM)++processingInstruction =+ makePI . concat <$ pDelim PIO <*> pList pCDATA <* pDelim PIC where + makePI string =+ let (pitgt, rest) = span isNMCHAR string+ pival = dropWhile isSEPCHAR rest+ in (pitgt,pival)++--+-- Instance items:+--++instanceItem =+ pTag+ <|> TextEvent <$> pCDATA -- also: WSEvent+ <|> GERefEvent <$> pGEREF+ <|> uncurry PIEvent <$> processingInstruction+ <|> CommentEvent <$> xmlCommentDeclaration++pTag =+ startEvent <$ pDelim STAGO <*> pName <*> attributes <*> tagc+ <|> EndEvent <$ pDelim ETAGO <*> pName <* pDelim TAGC+ where+ attributes = pList (pName <* pDelim VI <^> attributeValue)+ tagc = StartEvent <$ pDelim TAGC + <|> EmptyEvent <$ pDelim EETAGC+ startEvent name atts closing = closing name atts++attributeValue = -- XML: attributeValueLiteral only+ attributeValueLiteral <|> pName++--+-- <!ELEMENT ...> declarations+--+elementDeclaration =+ declareElements+ <$> elementNames <*> omissibility <*> contentDefinition <*> exceptions+ where+ omissibility =+ (pair <$> dashoro <*> dashoro) <?> (False,False)+ dashoro =+ (True <$ pKeyword "O" <|> False <$ pDelim MINUS)+ exceptions = -- NOTE ambiguity+ pair <$> (pDelim MINUS *> nameGroup <?> [])+ <*> (pDelim PLUS *> nameGroup <?> [])++contentDefinition = -- in SGML: "declared content-or-content-model-w/oexc"+ DC_EMPTY <$ pKeyword "EMPTY"+ <|> DC_ANY <$ pKeyword "ANY"+ <|> DC_MODELGRP <$> contentModel++contentModel =+ ( Prim . ELEMENT <$> pName+ <|> Prim PCDATA <$ rniName "#PCDATA"+ <|> pDelim GRPO *> contentModel <**>+ ( mk Seq <$> pSome (pDelim SEQ *> contentModel)+ <|> mk And <$> pSome (pDelim AND *> contentModel)+ <|> mk Or <$> pSome (pDelim OR *> contentModel)+ <|> pSucceed id ) <* pDelim GRPC+ ) <**> occurrenceIndicator+ where mk f l a = f (a:l)++occurrenceIndicator =+ Plus <$ pDelim PLUS+ <|> Rep <$ pDelim REP+ <|> Opt <$ pDelim OPT+ <|> pSucceed id++--+-- <!ATTLIST ...> declarations:+--+-- Also need: <!ATTLIST #NOTATION ... > , <!ATTLIST #ANY ...>+--+attlistDeclaration =+ declareAttlist <$> elementNames <*> pList attributeDefinition++attributeDefinition =+ ATTDEF <$> pName <*> declaredValue <*> defaultValue+declaredValue =+ ATcdata <$ pKeyword "CDATA"+ <|> ATid <$ pKeyword "ID"+ <|> ATidref <$ pKeyword "IDREF"+ <|> ATidrefs <$ pKeyword "IDREFS"+ <|> ATentity <$ pKeyword "ENTITY"+ <|> ATentities <$ pKeyword "ENTITIES"+ <|> ATnmtoken <$ pKeyword "NMTOKEN"+ <|> ATnmtokens <$ pKeyword "NMTOKENS"+ <|> ATnotation <$ pKeyword "NOTATION" <*> nameGroup+ <|> ATenumerated <$> nameGroup+ -- SGML only: (NB: currently ignore distinction between these)+ <|> ATnmtoken <$ pKeyword "NAME"+ <|> ATnmtoken <$ pKeyword "NUMBER"+ <|> ATnmtoken <$ pKeyword "NUTOKEN"+ <|> ATnmtokens <$ pKeyword "NAMES"+ <|> ATnmtokens <$ pKeyword "NUMBERS"+ <|> ATnmtokens <$ pKeyword "NUTOKENS"+defaultValue = -- SGML: also #CURRENT, #CONREF+ ADVimplied <$ rniName "#IMPLIED"+ <|> ADVrequired <$ rniName "#REQUIRED"+ <|> ADVfixed <$ rniName "#FIXED" <*> attributeValue+ <|> ADVdefault <$> attributeValue+ -- SGML only:+ <|> ADVcurrent <$ rniName "#CURRENT"+ <|> ADVconref <$ rniName "#CONREF"++-- Entity declarations:+-- %%% In SGML grammar there are a few more restrictions++entityDeclaration =+ declareParameterEntity <$ pDelim PERO <*> pName <*> entityText+ <|> declareGeneralEntity <$> pName <*> entityText++-- @@@ Discards entity type, DCN, and data attributes+entityText =+ EN_INTERNAL <$> parameterLiteral+ <|> EN_EXTERNAL <$> externalIdentifier <* entityType where+ entityType =+ ETsubdoc <$ pKeyword "SUBDOC"+ <|> csndata <* pName <* dataAttributes+ dataAttributes =+ pDelim DSO+ *> pList (pair <$> pName <* pDelim VI <*> attributeValue)+ <* pDelim DSC+ csndata = + ETcdata <$ pKeyword "CDATA" + <|> ETsdata <$ pKeyword "SDATA"+ <|> ETndata <$ pKeyword "NDATA"++notationDeclaration =+ declareNotation <$> pName <*> externalIdentifier++-- SGML: also need SHORTREF, USEMAP(1) in DTDs;+-- LINKTYPE in prolog; USEMAP(2), USELINK in instance.++-- EOF --
+ hxml-0.2/XMLScanner.hs view
@@ -0,0 +1,269 @@+----------------------------------------------------------------------------+--+-- Module : XMLScanner+-- Copyright : (C) 2000-2002 Joe English. Freely redistributable.+-- License : "MIT-style"+--+-- Author : Joe English <jenglish@flightlab.com>+-- Stability : experimental+-- Portability : portable+--+-- CVS : $Id: XMLScanner.hs,v 1.9 2002/10/12 01:58:59 joe Exp $+--+----------------------------------------------------------------------------+--+-- 9 Jan 2000+--++-- doesn't check as many errors as it ought to...++module XMLScanner+ ( Delimiter(..)+ , pcdataMode, markupMode+ , isNMCHAR, isSEPCHAR+ , expandReferences+ ) where++import XML -- for "Name"+import Char++import qualified DTD++isSEPCHAR, isNMCHAR, isNMSTART :: Char -> Bool++isSEPCHAR = isSpace+isNMCHAR c = isAlphaNum c || c `elem` ".-_:" -- 2.3 prodn 4+--isNMSTART c = isAlpha c || c `elem` "_:" -- 2.3 prodn 5+isNMSTART c = isAlphaNum c || c `elem` "_:" -- for NUTOKEN, NMTOKEN attvals++-- Utility:+--+-- doSpan pred k f g s = k (f x) (g y) where (x,y) = span pred s+--+doSpan :: (a -> Bool) -> (b -> c -> d) -> ([a] -> b) -> ([a] -> c) -> [a] -> d+doSpan pred k f g = sp f where+ sp f' [] = k (f' []) (g [])+ sp f' s@(c:cs)+ | pred c = sp (f' . (c:)) cs+ | otherwise = k (f' []) (g s)++drop1 :: [a] -> [a] -- drop1 == drop 1; safe version of tail+drop1 [] = []+drop1 (_:xs) = xs++data Delimiter =+ -- character data mode:+ WS String -- whitespace+ | CDATA String -- character data+ | GEREF Name -- general entity reference+ | STAGO -- start tag open, "<"+ | ETAGO -- end tag open, "</"++ -- Markup mode and character data mode:+ | MDO -- markup declaration open, "<!"+ | MDOCOM -- MDO + COM delimiter-in-context, "<!--"+ | MDODSO -- MDO + DSO delimiter-in-context, "<!["+ | PIO -- processing instruction open, "<?"+ | PIC -- processing instruction close, "?>" (">" in SGML)++ -- Errors:+ | LEXERR String -- lexical error+ | REST String -- rest of input++ -- Markup mode:+ | NAME Name -- name+ | RNINAME Name -- name prefixed with RNI (#)+ | PEREF Name -- parameter entity reference+ | LITERAL String -- attribute value literal or parameter literal++ | TAGC -- tag close, ">"+ | VI -- value indicator, "="+ | EETAGC -- empty element tag close (XML), "/>"++ | MDC -- markup declaration close, ">"+ | DSO -- declaration subset open, "["+ | DSC -- declaration subset close, "]"+ | MSC -- DSC+MDC, delimiter-in-context, "]]>"+ | COM -- comment, "--"+ | GRPO -- group open, "("+ | GRPC -- group close, ")"+ | AND -- and connector, "&"+ | OR -- or connector, "|"+ | SEQ -- seq connector, ","+ | OPT -- opt occurrence indicator, "?"+ | REP -- rep occurrence indicator, "*"+ | PLUS -- plus occurrence indicator, inclusion, "+"+ | MINUS -- exclusion, omission flag, "-"+ | PERO -- parameter entity reference open, "%"+ -- ALSO:+ -- Shortref -- short reference string (SGML only)+ -- NET -- null end-tag (SGML only)+ -- RNI -- reserved name indicator, "#"+ -- LIT -- literal, """+ -- LITA -- alternative literal, "'"+ -- CRO -- character reference open, "&#"+ -- HCRO -- hex character reference open, "&#X" (new in XML)+ -- ERO -- entity reference open, "&"+ -- REFC -- reference close, ";"+ deriving (Eq, Show)++pcdataMode, tagMode, markupMode :: String -> [Delimiter]++-- [STAGO, ETAGO, NET, CRO, ERO, MDO, MDOCOM, MDODSO, PIO, MSC]+pcdataMode [] = []+pcdataMode ('<':s) = case s of+ '!':'-':'-':r -> MDOCOM : comMode pcdataMode r+ '!':'[':r -> {- MDODSO : -} msMode r+ '!':r -> MDO : markupMode r+ '/':r -> ETAGO : tagMode r+ '?':r -> PIO : piMode pcdataMode r+ ']':']':'>':r -> MSC : pcdataMode r+ r -> STAGO : tagMode r+pcdataMode ('&':'#':s) = doSpan (';'/=) (:) mkCREF (pcdataMode . drop1) s+ where mkCREF = CDATA . return . chr . stringToInt 10+pcdataMode ('&':s) =+ case span isNMCHAR s of+ (ename,';':r) -> GEREF ename : pcdataMode r+ (junk,r) -> LEXERR ("Bad entity reference " ++ junk)+ : pcdataMode r+pcdataMode ('>':r) = LEXERR "Warning: %%% SKIPPING UNESCAPED '>'":pcdataMode r+pcdataMode (c:s)+ | isSEPCHAR c = doSpan isSEPCHAR (:) (WS . (c:)) pcdataMode s+ | otherwise = doSpan isDATACHAR (:) (CDATA . (c:)) pcdataMode s+ where isDATACHAR ch =+ case ch of '<' -> False; '&' ->False; _ -> True++tagMode [] = []+tagMode ('/':'>':r) = EETAGC : pcdataMode r+tagMode ('>':r) = TAGC : pcdataMode r+tagMode ('=':r) = VI : tagMode r+tagMode ('"':r) = doSpan ('"'/=) (:) LITERAL (tagMode . drop1) r+tagMode ('\'':r) = doSpan ('\''/=) (:) LITERAL (tagMode . drop1) r+tagMode ('<':'/':r) = ETAGO : tagMode r -- not allowed in XML+tagMode ('<':r) = STAGO : tagMode r -- not allowed in XML+tagMode cs@(c:s)+ | isSEPCHAR c = tagMode (dropWhile isSEPCHAR s)+ | isNMSTART c = doSpan isNMCHAR (:) NAME tagMode cs+ | otherwise = LEXERR [c] : tagMode s+++-- [ERO, CRO, HCRO]+expandReferences :: DTD.EntityMap -> String -> String+expandReferences entities = expand where+ expand s = case s of+ [] -> []+ '&':'#':'X':r -> doCharRef 16 expand r+ '&':'#':r -> doCharRef 10 expand r+ '&':r -> doEntityRef entities expand r+ x:r -> x : expand r++doCharRef :: Int -> (String -> String) -> [Char] -> [Char]+doCharRef base k = doSpan (';'/=) (:) (chr . stringToInt base) (k . drop1)+stringToInt :: Int -> String -> Int+stringToInt base = foldl digit 0 . map digitToInt+ where digit num next = base*num + next++-- @@@ This is not quite right: should rescan the replacement text.+doEntityRef :: DTD.EntityMap -> (String -> String) -> String -> String+doEntityRef entities k r = doSpan (';'/=) (++) replacement (k . drop1) r where+ replacement ename = case DTD.expandInternalEntity entities ename of+ Just s -> s+ _ -> error ("entity " ++ ename ++ " not defined")++-- [...]+markupMode [] = []+markupMode ('%':s) = case span isNMCHAR s of+ ([], ' ':r) -> PERO : markupMode r -- %%% Not Quite Right+ (ename,';':r) -> PEREF ename : markupMode r+ (ename,r) -> LEXERR ("Bad parameter entity reference %" ++ ename)+ : markupMode r+markupMode ('-':'-':r) = eatComment r+markupMode ('>':r) = MDC : markupMode r -- %%% or pcdataMode?+markupMode ('"':r) = doSpan ('"'/=) (:) LITERAL (markupMode . drop1) r+markupMode ('\'':r) = doSpan ('\''/=) (:) LITERAL (markupMode . drop1) r+markupMode ('#':r) = doSpan isNMCHAR (:) (RNINAME . ('#':)) markupMode r+markupMode ('<':'!':'-':'-':r)+ = MDOCOM : comMode markupMode r+markupMode ('<':'!':r) = MDO : markupMode r+markupMode ('<':'?':r) = PIO : piMode markupMode r+markupMode s@('<':_) = pcdataMode s -- %%% Not strictly correct, but+ -- %%% needed to parse the prolog.+markupMode cs@(c:s)+ | isSEPCHAR c = markupMode (dropWhile isSEPCHAR s)+ | isNMSTART c = doSpan isNMCHAR (:) NAME markupMode cs+ | otherwise = (case c of+ '&' -> AND+ '|' -> OR+ ',' -> SEQ+ '?' -> OPT+ '*' -> REP+ '+' -> PLUS+ '-' -> MINUS+ '[' -> DSO+ ']' -> DSC+ '(' -> GRPO+ ')' -> GRPC+ _ -> LEXERR [c]) : markupMode s++--+-- Internal recognition modes:+--++msMode, cdataMode, eatComment :: String -> [Delimiter]++piMode, comMode, cdMode :: (String -> [Delimiter]) -> String -> [Delimiter]++--+-- msMode: marked section in instance. +-- @@@ Only supports XML instance syntax (<![CDATA[ ... ]]>);+-- In SGML (and XML DTDs), parameter entity references and whitespace+-- are also allowed, in addition to INCLUDE and IGNORE keywords.+-- 'cdataMode' checks for nested occurrences of <![. this is not+-- an error according to the XML or SGML specs, but it ought to be.+-- ++msMode ('C':'D':'A':'T':'A':'[':rest) = cdataMode rest+msMode s = + let (ms, rest) = span ('['/=) s+ in LEXERR ("Illegal marked section ["++ms) : pcdataMode (drop1 rest)++cdataMode (']':']':'>':rest) = pcdataMode rest+cdataMode ('<':'!':'[':rest) = error "Nested <![ in marked section"+cdataMode [] = []+cdataMode (c:cs) = doSpan spn (:) (CDATA . (c:)) cdataMode cs where+ spn '\n' = False+ spn ']' = False+ spn '<' = False+ spn _ = True++--+-- comMode (inside comments): [COM]+--+comMode prevMode cs = case cs of+ [] -> []+ '-':'-':r -> COM : cdMode prevMode r+ (c:s) -> doSpan brk (:) (CDATA . (c:)) (comMode prevMode) s where+ brk '-' = False+ brk '\n' = False -- split long comments at line breaks+ brk _ = True++-- cdMode (inside comment declarations): [COM,MDC, ignore whitespace]+cdMode prevMode cs = case cs of+ [] -> []+ '>':r -> MDC : prevMode r+ '-':'-':r -> COM : comMode prevMode r+ c:s -> if isSEPCHAR c+ then cdMode prevMode (dropWhile isSEPCHAR s)+ else LEXERR [c] : cdMode prevMode s++eatComment cs = case cs of+ [] -> []+ '-':'-':r -> markupMode r+ (_:r) -> eatComment r++piMode prevMode cs = case cs of+ [] -> []+ '?':'>':r -> PIC : prevMode r+ (c:s) -> doSpan ('?'/=) (:) (CDATA . (c:)) (piMode prevMode) s++-- EOF --
+ index.html view
@@ -0,0 +1,105 @@+<html>+<head><title>HXQ: A Compiler from XQuery to Haskell</title></head>+<body>+<center>+<h1>HXQ: A Compiler from XQuery to Haskell</h1>+</center>+<p>+<h2>Description</h2>+<p>+HXQ is a fast and space-efficient translator from XQuery to+embedded Haskell code (the translation is based on GHC templates).+It takes full advantage+of Haskell's lazy evaluation to keep in memory only those parts of XML data+needed at each point of evaluation, thus performing stream-based evaluation.+This results to an implementation that is as fast and space-efficient as+any stream-based+implementation based on SAX filters or finite state machines. Furthermore,+the coding is far simpler and extensible since its based on XML trees, rather+than SAX events (both the code generator and the the XQuery parser are about 400 lines each).+For example, the XQuery below against the <a href="http://dblp.uni-trier.de/xml/">DBLP XML database</a>+(420MB) runs in 1.5 minutes on my laptop.+My high-performance Java implementation of XQuery, called <a href="/XQPull/">XQPull</a>,+which is stream-based (based on a StAX events), took about the same time.+<p>+<h2>Installation Instructions</h2>+<p>+If you haven't done so, install the Glasgow Haskell Compiler,+<a href="http://www.haskell.org/ghc/">ghc</a>,+and the parser generator for Haskell,+<a href="http://www.haskell.org/happy/">happy</a>.+For example, in Fedora Linux, you install both using:+<pre>+yum install ghc happy+</pre>+Then download <a href="/HXQ-0.1.tar.gz">HXQ</a> and untar it.+You can either use cabal or make to build it. Then run xquery to test drive it.+<p>+<h2>Current Status</h2>+<p>+HXQ supports most essential XQuery features, although some system functions are missing (but are easy to add).+It does not have static typechecking; it leaves all checking to Haskell. This means that it distinguishes regular predicates+from indexing at run time: if an XPath predicate returns an integer at run time, it is indexing and this index is+checked against the current node position. The most important omission is backward step axes, such as /.. (parent).+Some, but not all, parent axis steps are removed using optimization rules, all others cause a compilation error.+<p>+<h2>Use</h2>+<p>+HXQ represents XML data as rose trees:+<pre>+type Tag = String++type AttList = [(String,String)]++data XTree = XElem Tag AttList [XTree]+ | XText String+ | XInt Int+ | XFloat Float++type XSeq = [XTree]+</pre>+which basically means that one cannot implement backward navigation steps directly.+The main functions for embedding XQueries in Haskell are:+<ul>+<li> <tt>$(xe query)</tt>+<li> <tt>$(xq query)</tt>+</ul>+where <tt>query</tt> is a string value (a Haskell expression that evaluates+to a string <b>at compile-time</b>), They both translate the query into Haskell+code, which is compiled and optimized into machine code directly. The code that xe generates has type <tt>XSeq</tt> (a sequence of XML trees)+while the code that xq generates has type <tt>(IO XSeq)</tt>. If the query reads+at least one document (using doc(...)), then you should use xq since it requires+IO. To define constant XML data or a function body, it is better to use xe.+You can use the value of a Haskell variable <tt>v</tt> inside a query using+<tt>$v</tt> as long as <tt>v</tt> has type <tt>XSeq</tt>.+To use a function in a query, it should be defined in Haskell+with type <tt>(XSeq,...,XSeq) -> XSeq</tt>.+<p>+Here is an example of a main program:+<pre>+f(x,y) = $(xe "<article><first>{$x}</first><second>{$y}</second></article>")++main = do a <- $(xq ("<result>{ "+ ++" for $x in doc('data/dblp.xml')//inproceedings at $i "+ ++" where $x/author = 'Leonidas Fegaras' "+ ++" orderby $x/year descending "+ ++" return <paper>{ $i, ') ', $x/booktitle/text(), "+ ++" ': ', $x/title/text() "+ ++" }</paper> "+ ++" }</result> "))+ putStrLn (show a)+ b <- $(xq " f( $a/paper[10], $a/paper[8] ) ")+ putStrLn (show b)+</pre>+Another example, can be found in <a href="Main.hs">Main.hs</a>.+<p>+If you want to extend HXQ, you need to read about <a href="http://www.haskell.org/bz/thdoc.htm">Template Haskell</a>.+Use <tt>make test</tt> to do various translation tests in ghci. You can look at the+Abstract Syntax Trees and the generated code from a query by evaluating+<tt>cq query</tt>. Basically, the way you generate Haskell code is+similar to operational semantics (where [| ... |] are syntactic brackets).+</body>+<p>+<hr>+<p>+<address>Last modified: 03/18/08 by <a href="http://lambda.uta.edu/">Leonidas Fegaras</a></address>