>>>>> "Sigbjorn" == Sigbjorn Finne <[EMAIL PROTECTED]> writes:
Sigbjorn> Hi,
Sigbjorn> you don't say what version you're using, but I'm guessing
Sigbjorn> it's 3.01. There'a a couple of patches that should fix
Sigbjorn> the problem of cross-module scc inlinings for 3.01 -
Sigbjorn> appended at the end.
Sigbjorn> Pls let us know if this doesn't fix things.
Sigbjorn> --Sigbjorn
Thanks your patch worked great. Now, I've got lots of numbers to look
at which should keep me quiet for a bit, except for the following
ObBugs (all from ghc-3.01 on solaris):
ObBug1
------
gmake install can't remove the existing ghc symbolic link before
re-creating.
ObBug2
------
I want to run gmake install (necessary with the library
re-organisations!). I get the following error:
[keving@holly] kgbuild [52] make uninstall
/bin/sh: syntax error at line 1: `;' unexpected
make: *** [uninstall] Error 2
[keving@holly] kgbuild [53]
If I run gmake -d uninstall I am little wiser:
[keving@holly] kgbuild [55] gmake -d uninstall
GNU Make version 3.72.1, by Richard Stallman and Roland McGrath.
Copyright (C) 1988, 89, 90, 91, 92, 93, 94 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Reading makefiles...
Reading makefile `Makefile'...
Reading makefile `mk/boilerplate.mk' (search path) (no ~ expansion)...
Reading makefile `mk/config.mk' (search path) (no ~ expansion)...
Reading makefile `mk/paths.mk' (search path) (no ~ expansion)...
Reading makefile `mk/opts.mk' (search path) (no ~ expansion)...
Reading makefile `mk/suffix.mk' (search path) (no ~ expansion)...
Reading makefile `mk/build.mk' (search path) (don't care) (no ~ expansion)...
Reading makefile `.depend' (search path) (don't care) (no ~ expansion)...
Reading makefile `mk/target.mk' (search path) (no ~ expansion)...
Child access: user 1011 (real 1011), group 22 (real 22)
Got a SIGCHLD; 1 unreaped children.
Child access: user 1011 (real 1011), group 22 (real 22)
Child access: user 1011 (real 1011), group 22 (real 22)
Updating makefiles....
Considering target file `mk/target.mk'.
Looking for an implicit rule for `mk/target.mk'.
No implicit rule found for `mk/target.mk'.
Finished dependencies of target file `mk/target.mk'.
No need to remake target `mk/target.mk'.
Considering target file `.depend'.
Looking for an implicit rule for `.depend'.
No implicit rule found for `.depend'.
Finished dependencies of target file `.depend'.
No need to remake target `.depend'.
Considering target file `mk/build.mk'.
Looking for an implicit rule for `mk/build.mk'.
No implicit rule found for `mk/build.mk'.
Finished dependencies of target file `mk/build.mk'.
No need to remake target `mk/build.mk'.
Considering target file `mk/suffix.mk'.
Looking for an implicit rule for `mk/suffix.mk'.
No implicit rule found for `mk/suffix.mk'.
Finished dependencies of target file `mk/suffix.mk'.
No need to remake target `mk/suffix.mk'.
Considering target file `mk/opts.mk'.
Looking for an implicit rule for `mk/opts.mk'.
No implicit rule found for `mk/opts.mk'.
Finished dependencies of target file `mk/opts.mk'.
No need to remake target `mk/opts.mk'.
Considering target file `mk/paths.mk'.
Looking for an implicit rule for `mk/paths.mk'.
No implicit rule found for `mk/paths.mk'.
Finished dependencies of target file `mk/paths.mk'.
No need to remake target `mk/paths.mk'.
Considering target file `mk/config.mk'.
Looking for an implicit rule for `mk/config.mk'.
No implicit rule found for `mk/config.mk'.
Finished dependencies of target file `mk/config.mk'.
No need to remake target `mk/config.mk'.
Considering target file `mk/boilerplate.mk'.
Looking for an implicit rule for `mk/boilerplate.mk'.
No implicit rule found for `mk/boilerplate.mk'.
Finished dependencies of target file `mk/boilerplate.mk'.
No need to remake target `mk/boilerplate.mk'.
Considering target file `Makefile'.
Looking for an implicit rule for `Makefile'.
No implicit rule found for `Makefile'.
Finished dependencies of target file `Makefile'.
No need to remake target `Makefile'.
Updating goal targets....
Considering target file `uninstall'.
File `uninstall' does not exist.
Finished dependencies of target file `uninstall'.
Target `uninstall' is double-colon and has no dependencies.
Must remake target `uninstall'.
Child access: user 1011 (real 1011), group 22 (real 22)
/bin/sh: syntax error at line 1: `;' unexpected
Putting child 0x00068730 PID 12129 on the chain.
Live child 0x00068730 PID 12129
Reaping losing child 0x00068730 PID 12129
gmake: *** [uninstall] Error 2
Removing child 0x00068730 PID 12129 from chain.
[keving@holly] kgbuild [56]
ObBug3
------
hstags is missing a semi-colon from the end of line 70.
ObBug4
------
I realise that some time ago one of the ghc lists said that 'anyone who
compiles a happy output file with optimisation flags set has cold
semolina for brains' (or words to that effect). However, if I compile
the hs file produced from the following happy file with a -O flag ghc
will bust whatever heap size I give it, works OK without the
optimisation flag. I don't need an optimised parser, but my cold
semolina can't be bothered working out how to write a Makefile that
passes different options to one file than all the others ....
As you can see I stole the parser from an example. It parses boolean
expressions.
booleqns.ly
-- Taken from AndysExample in the happy distribution which parses
-- numeric expressions. This parses a list of boolean eqns
-- (e.g. fun x y = x ^ y)
-- Kevin Glynn ([EMAIL PROTECTED])
-- History:
-- 18 Feb 1998 keving Created from ParseBExpr.ly
-- 2 Mar 1998 keving Mod lexer to ignore comments (# to eol)
> {
> module ParseBEqns (parseBEqns, beLexer) where
> import Char
> import BoolExpr
> import BoolEqns
> }
> %name parseBEqns
> %tokentype { Token }
The parser will be of type [Token] -> ?, where ? is determined by the
production rules. Now we declare all the possible tokens:
%monad { P } { thenP } { returnP }
> %token
> var { TokenVar $$ }
> '^' { TokenAnd }
> 'v' { TokenOr }
> '~' { TokenNot }
> '->' { TokenImpl }
> '<-' { TokenRImpl }
> '<->' { TokenIff }
> true { TokenTrue }
> false { TokenFalse }
> '(' { TokenOB }
> ')' { TokenCB }
> '=' { TokenEquals }
> ';' { TokenSep }
> ',' { TokenComma }
The left hand side are the names of the terminals or tokens,
and the right hand side is how to pattern match them.
Like yacc, we include %% here, for no real reason.
> %%
Now we have the production rules. I'm trying to capture the priority
of operations. May need to experiment with that.
> FuncDefs :: { [FuncDef] }
> FuncDefs : { [] }
> | FuncDefs Func { $2 : $1 }
> Func :: { FuncDef }
> Func : var Args '=' BoolExpr ';' { ($1, (reverse $2, $4)) }
> Args :: { [String] }
> Args : { [] }
> | Args var { $2 : $1 }
> BoolExpr :: { BoolExpr }
> BoolExpr : BoolExpr '->' IffExp { BImpl $1 $3 }
> | BoolExpr '<-' IffExp { BImpl $3 $1 }
> | IffExp { $1 }
> IffExp :: { BoolExpr }
> IffExp : IffExp '<->' OrExp { BIff $1 $3 }
> | OrExp { $1 }
> OrExp :: { BoolExpr }
> OrExp : OrExp 'v' AndExp { BOr $1 $3 }
> | AndExp { $1 }
> AndExp :: { BoolExpr }
> AndExp : AndExp '^' BasExp { BAnd $1 $3 }
> | BasExp { $1 }
> BasExp :: { BoolExpr }
> BasExp : '~' BasExp { BNot $2 }
> | var { BVar $1 }
> | true { BTrue }
> | false { BFalse }
> | '(' BoolExpr ')' { $2 }
> | var Lexp_plus { BFun $1 (reverse $2) }
> Lexp_plus :: { [BoolExpr] }
> Lexp_plus : BoolExpr { [$1] }
> | Lexp_plus ',' BoolExpr { $3 : $1 }
We are simply returning the parsed data structure !
Now we need some extra code, to support this parser,
and make in complete:
> {
All parsers must declair this function,
which is called when an error is detected.
Note that currently we do no error recovery.
> happyError :: [Token] -> a
> happyError _ = error ("Parse error\n")
Now we declare the datastructure that we are parsing.
(Imported from BoolExpr.hs)
The datastructure for the tokens...
> data Token
> = TokenVar String
> | TokenNot
> | TokenAnd
> | TokenOr
> | TokenIff
> | TokenImpl
> | TokenRImpl
> | TokenFalse
> | TokenTrue
> | TokenOB
> | TokenCB
> | TokenEquals
> | TokenSep
> | TokenComma
.. and a simple lexer that returns this datastructure.
> beLexer :: String -> [Token]
> beLexer [] = []
> beLexer ('#':cs) = beLexer (dropWhile (\c -> not(c == '\n')) cs)
> beLexer ('~':cs) = TokenNot : beLexer cs
> beLexer ('!':cs) = TokenNot : beLexer cs
> beLexer ('^':cs) = TokenAnd : beLexer cs
> beLexer ('&':cs) = TokenAnd : beLexer cs
> beLexer ('v':cs) = TokenOr : beLexer cs
> beLexer ('|':cs) = TokenOr : beLexer cs
> beLexer ('=':cs) = TokenEquals : beLexer cs
> beLexer (';':cs) = TokenSep : beLexer cs
> beLexer (',':cs) = TokenComma : beLexer cs
> beLexer ('-':('>':cs)) = TokenImpl : beLexer cs
> beLexer ('<':('-':('>':cs))) = TokenIff : beLexer cs
> beLexer ('<':('-':cs)) = TokenRImpl : beLexer cs
> beLexer ('(':cs) = TokenOB : beLexer cs
> beLexer (')':cs) = TokenCB : beLexer cs
> beLexer (c:cs)
> | isSpace c = beLexer cs
> | isAlpha c = lexVar (c:cs)
> lexVar cs =
> case span isAlphanum cs of
> ("TRUE",rest) -> TokenTrue : beLexer rest
> ("true",rest) -> TokenTrue : beLexer rest
> ("FALSE",rest) -> TokenFalse : beLexer rest
> ("false",rest) -> TokenFalse : beLexer rest
> ("and",rest) -> TokenAnd : beLexer rest
> ("or",rest) -> TokenOr : beLexer rest
> ("not",rest) -> TokenNot : beLexer rest
> (var,rest) -> TokenVar var : beLexer rest
To run the program, call this in gofer, or use some code
to print it.
runCalc :: String -> Exp
runCalc = calc . lexer
Here we test our parser.
main = case runCalc "1 + 2 + 3" of {
(Exp1 (Plus (Plus (Term (Factor (Int 1))) (Factor (Int 2))) (Factor (Int 3))))
->
case runCalc "1 * 2 + 3" of {
(Exp1 (Plus (Term (Times (Factor (Int 1)) (Int 2))) (Factor (Int 3)))) ->
case runCalc "1 + 2 * 3" of {
(Exp1 (Plus (Term (Factor (Int 1))) (Times (Factor (Int 2)) (Int 3)))) ->
case runCalc "let x = 2 in x * (x - 2)" of {
(Let "x" (Exp1 (Term (Factor (Int 2)))) (Exp1 (Term (Times (Factor (Var "x"))
(Brack (Exp1 (Minus (Term (Factor (Var "x"))) (Factor (Int 2))))))))) -> print
"AndysTest works\n" ;
_ -> quit } ; _ -> quit } ; _ -> quit } ; _ -> quit }
quit = print "AndysTest failed\n"
type P a = a
thenP a b = b a
returnP a = a
Now the state monad
> type P a = () -> (a,())
> thenP a b s = case a s of
> (r,s') -> b r s'
> returnP a = \ s -> (a,s)
> }
Please let me know if you need more info. Thanks for your time and
help.
regards
k
--
wot, no .sig?