-- Gleaned most of the structure of this file from -- http://www.haskell.org/happy/doc/html/sec-using.html -- Put main in Main.hs however. -- -- Turning this file into Parser15min.hs: -- happy Parser15min.y -i -- The above also creates an Parser15min.info file, which is -- useful for debugging. -- -- To generate a parser that prints debugging information to stderr -- use the following command: -- happy Parser15min.y -i -a -d { module Parser15min where import Lexer15min } %name parser %tokentype { Token } %error { parseError } %token triangle { TokenTRIANGLE } circle { TokenCIRCLE } int { TokenNUM $$ } ';' { TokenSemi } %% Stmts : Stmt Stmts { $1 ++ $2 } | -- epsilon { "" } Stmt : triangle ';' { "256 0 moveto 125 125 lineto 0 512 lineto fill\n" } | circle int int int ';' { (show $2)++" "++(show $3)++" "++(show $4)++" 0 360 arc fill\n" } { parseError :: [Token] -> a parseError _ = error "Parse error" }