Index: 0.1/Lexer.lhs --- 0.1/Lexer.lhs Tue, 17 Feb 1998 21:04:10 +0100 thorn (hsparser/16_Lexer.lhs 1.1 644) +++ 0.1(w)/Lexer.lhs Fri, 30 Jun 2000 14:32:39 +0200 thorn (hsparser/16_Lexer.lhs 1.1 644) @@ -129,10 +134,10 @@ > ] > isIdent c = isAlpha c || isDigit c || c == '\'' || c == '_' -> isSymbol c = elem c ":!#$%&*+./<=>?@\\^|-" +> isSymbol c = elem c ":!#$%&*+./<=>?@\\^|-~" > isWhite c = elem c " \n\r\t\v\f" -> tAB_LENGTH = 8 +> tAB_LENGTH = 8 :: Int The source location, (y,x), is the coordinates of the previous token. col is the current column in the source file. If col is 0, we are Index: 0.1/PrettyM.hs --- 0.1/PrettyM.hs Tue, 17 Feb 1998 21:04:10 +0100 thorn (hsparser/0_PrettyM.hs 1.1 644) +++ 0.1(w)/PrettyM.hs Tue, 02 May 2000 18:59:03 +0200 thorn (hsparser/0_PrettyM.hs 1.1 644) @@ -4,7 +4,7 @@ all appears the same. May be useful to rewrite this as a state transformer, rather than a - state reader monad. Could then set different diplay conditions for + state reader monad. Could then set different display conditions for subsections of the Parser. See Pretty.hs for description of the combinators @@ -51,7 +51,7 @@ newtype DocM s a = DocM (s -> a) instance Functor (DocM s) where - map f xs = [f x | x <- xs] + fmap f (DocM g) = DocM (f . g) instance Monad (DocM s) where (>>=) = thenDocM @@ -145,13 +145,13 @@ aM $+$ bM = do{a<-aM;b<-bM;return (a P.$+$ b)} hcat,hsep,vcat,sep,cat,fsep,fcat :: [Doc] -> Doc -hcat dl = accumulate dl >>= return . P.hcat -hsep dl = accumulate dl >>= return . P.hsep -vcat dl = accumulate dl >>= return . P.vcat -sep dl = accumulate dl >>= return . P.sep -cat dl = accumulate dl >>= return . P.cat -fsep dl = accumulate dl >>= return . P.fsep -fcat dl = accumulate dl >>= return . P.fcat +hcat dl = sequence dl >>= return . P.hcat +hsep dl = sequence dl >>= return . P.hsep +vcat dl = sequence dl >>= return . P.vcat +sep dl = sequence dl >>= return . P.sep +cat dl = sequence dl >>= return . P.cat +fsep dl = sequence dl >>= return . P.fsep +fcat dl = sequence dl >>= return . P.fcat -- Some More Index: 0.1/Main.lhs --- 0.1/Main.lhs Tue, 17 Feb 1998 21:04:10 +0100 thorn (hsparser/15_Main.lhs 1.1 644) +++ 0.1(w)/Main.lhs Tue, 02 May 2000 18:59:03 +0200 thorn (hsparser/15_Main.lhs 1.1 644) @@ -66,7 +66,7 @@ > handleFlag LexOnly = show . testLexer > handleFlag ParseLength = show . length . (\(_,_,d) -> d) . testParser > handleFlag ParseInternal = show . testParser -> handleFlag (ParsePretty layout) = renderWithMode defaultMode{layout} +> handleFlag (ParsePretty layout) = renderWithMode defaultMode{layout=layout} > . ppHsModule . testParser > numToks :: ParseResult [Token] -> Int Index: 0.1/HsSyn.lhs --- 0.1/HsSyn.lhs Tue, 17 Feb 1998 21:04:10 +0100 thorn (hsparser/17_HsSyn.lhs 1.1 644) +++ 0.1(w)/HsSyn.lhs Tue, 27 Jun 2000 16:05:10 +0200 thorn (hsparser/17_HsSyn.lhs 1.1 644) @@ -155,6 +173,7 @@ > hiding_name = UnQual "hiding" > minus_name = UnQual "-" > pling_name = UnQual "!" +> negate_name = Qual prelude_mod "negate" > unit_tycon_name = unit_con_name > fun_tycon_name = Qual prelude_mod "->" Index: 0.1/HsParser.ly --- 0.1/HsParser.ly Tue, 17 Feb 1998 21:04:10 +0100 thorn (hsparser/18_HsParser.l 1.1 644) +++ 0.1(w)/HsParser.ly Tue, 20 Jun 2000 14:39:37 +0200 thorn (hsparser/18_HsParser.l 1.1 644) @@ -370,8 +363,8 @@ > | 'let' declslist 'in' exp { HsLet (reverse $2) $4 } > | 'if' exp 'then' exp 'else' exp { HsIf $2 $4 $6 } > | 'case' exp 'of' altslist { HsCase $2 (reverse $4) } -> | '-' appexp { HsApp (HsVar minus_name) $2 } -> | 'do' stmtlist { HsDo $2 } +> | '-' appexp { HsApp (HsVar negate_name) $2 } +> | 'do' stmtlist { HsDo (reverse $2) } > | appexp { $1 } > appexp :: { HsExp } Index: 0.1/HsPretty.hs --- 0.1/HsPretty.hs Tue, 17 Feb 1998 21:04:10 +0100 thorn (hsparser/19_HsPretty.h 1.1 644) +++ 0.1(w)/HsPretty.hs Tue, 02 May 2000 18:59:03 +0200 thorn (hsparser/19_HsPretty.h 1.1 644) @@ -236,7 +236,7 @@ brackets . myFsep $ [ppHsExp exp, char '|'] ++ (punctuate comma . map ppHsStmt $ stmtList) ppHsExp (HsExpTypeSig pos exp ty) = - myFsep[ppHsExp exp, text "::", ppHsType ty] + myFsep[ppHsExp exp, text "::", ppHsQualType ty] ------------------------- Case bodies ------------------------- @@ -301,7 +301,7 @@ then space $$ dl else dl} topLevel :: Doc -> [Doc] -> Doc topLevel header dl = do - e <- map layout getPPEnv + e <- fmap layout getPPEnv case e of PPOffsideRule -> header $$ vcat dl PPSemiColon -> header $$ (braces . vcat . punctuate semi) dl @@ -310,14 +310,14 @@ body :: (PPHsMode -> Int) -> [Doc] -> Doc body f dl = do - e <- map layout getPPEnv + e <- fmap layout getPPEnv case e of PPOffsideRule -> indent PPSemiColon -> indentExplicit _ -> inline where inline = braces . hsep . punctuate semi $ dl - indent = do{i <-map f getPPEnv;nest i . vcat $ dl} - indentExplicit = do {i <- map f getPPEnv; + indent = do{i <- fmap f getPPEnv;nest i . vcat $ dl} + indentExplicit = do {i <- fmap f getPPEnv; nest i . braces . vcat . punctuate semi $ dl} ($$$) :: Doc -> Doc -> Doc