0
-- compiler/main/HscMain.hs hscParse関数hscParse mod_summary = do    dflags <- getDynFlags    let src_filename = ms_hspp_fil...
liftIO $ showPass dflags "Parser"*** Parser:
詳細:http://www.kotha.net/ghcguide_ja/7.0.4/profiling.html#idp19148320
liftIO $ dumpIfSet_dyn dflags Opt_D_dump_parsed                   "Parser" $ ppr rdr_module==================== Parser ===...
hscParse :: ModSummary -> Hsc HsParsedModulehscParse mod_summary = do   dflags <- getDynFlags--snip--   case unP parseModu...
unP parseModule (mkPState dflags buf loc)* unP: compiler/parser/Lexer.xで定義* parseModule: compiler/parser/Parser.y.ppで定義* m...
http://www.haskell.org/alex/http://www.haskell.org/happy/
-- Parser.y.pp%monad { P } { >>= } { return }%lexer { lexer } { L _ ITeof }%name parseModule module%name parseStmt maybe_s...
module :: { Located (HsModule RdrName) }    : maybedocheader module modid maybemodwarning                   maybeexports w...
GHCソースコード読みのススメ
GHCソースコード読みのススメ
GHCソースコード読みのススメ
GHCソースコード読みのススメ
GHCソースコード読みのススメ
GHCソースコード読みのススメ
GHCソースコード読みのススメ
GHCソースコード読みのススメ
GHCソースコード読みのススメ
Upcoming SlideShare
Loading in...5
×

GHCソースコード読みのススメ

1,266

Published on

Published in: Technology
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,266
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
4
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

Transcript of "GHCソースコード読みのススメ"

  1. 1. -- compiler/main/HscMain.hs hscParse関数hscParse mod_summary = do dflags <- getDynFlags let src_filename = ms_hspp_file mod_summary maybe_src_buf = ms_hspp_buf mod_summary liftIO $ showPass dflags "Parser" {-# SCC "Parser" #-} do buf <- case maybe_src_buf of Just b -> return b Nothing -> liftIO $ hGetStringBuffer src_filename let loc = mkRealSrcLoc (mkFastString src_filename) 1 1 case unP parseModule (mkPState dflags buf loc) of PFailed span err ->
  2. 2. liftIO $ showPass dflags "Parser"*** Parser:
  3. 3. 詳細:http://www.kotha.net/ghcguide_ja/7.0.4/profiling.html#idp19148320
  4. 4. liftIO $ dumpIfSet_dyn dflags Opt_D_dump_parsed "Parser" $ ppr rdr_module==================== Parser =============module Queue ( Queue(..) ) whereimport Prelude hiding ( head, tail )class Queue q where {
  5. 5. hscParse :: ModSummary -> Hsc HsParsedModulehscParse mod_summary = do dflags <- getDynFlags--snip-- case unP parseModule (mkPState dflags buf loc) of PFailed span err -> liftIO $ throwOneError (mkPlainErrMsg span err) POk pst rdr_module -> do logWarningsReportErrors (getMessages pst)--snip-- return HsParsedModule { hpm_module = rdr_module, hpm_src_files = srcs2 }
  6. 6. unP parseModule (mkPState dflags buf loc)* unP: compiler/parser/Lexer.xで定義* parseModule: compiler/parser/Parser.y.ppで定義* mkPState: compiler/parser/Lexer.xで定義
  7. 7. http://www.haskell.org/alex/http://www.haskell.org/happy/
  8. 8. -- Parser.y.pp%monad { P } { >>= } { return }%lexer { lexer } { L _ ITeof }%name parseModule module%name parseStmt maybe_stmt%name parseIdentifier identifier%name parseType ctype%partial parseHeader header%tokentype { (Located Token) }http://www.haskell.org/happy/doc/html/sec-monads.html
  9. 9. module :: { Located (HsModule RdrName) } : maybedocheader module modid maybemodwarning maybeexports where body {% fileSrcSpan >>= loc -> return (L loc (HsModule (Just $3) $5 (fst $7) (snd $7) $4 $1) )} | body2 {% fileSrcSpan >>= loc -> return (L loc (HsModule Nothing Nothing (fst $1) (snd $1) Nothing Nothing )) }
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×