<commit_before>%
% (c) The GRASP/AQUA Project, Glasgow University, 1993-1998
%
\section[GHC_Main]{Main driver for Glasgow Haskell compiler}

\begin{code}
module Main ( main ) where

#include "HsVersions.h"

import IO		( hPutStr, stderr )
import HsSyn
import BasicTypes	( NewOrData(..) )

import RdrHsSyn		( RdrNameHsModule )
import FastString	( mkFastCharString, unpackFS )
import StringBuffer	( hGetStringBuffer )
import Parser		( parse )
import Lex		( PState(..), P, ParseResult(..) )
import SrcLoc		( mkSrcLoc )

import Rename		( renameModule )

import MkIface		( startIface, ifaceDecls, endIface )
import TcModule		( TcResults(..), typecheckModule )
import Desugar		( deSugar )
import SimplCore	( core2core )
import CoreLint		( endPass )
import CoreTidy		( tidyCorePgm )
import CoreToStg	( topCoreBindsToStg )
import StgSyn		( collectFinalStgBinders, pprStgBindings )
import SimplStg		( stg2stg )
import CodeGen		( codeGen )
import CodeOutput	( codeOutput )

import Module		( ModuleName, moduleNameUserString )
import AbsCSyn		( absCNop )
import CmdLineOpts
import ErrUtils		( ghcExit, doIfSet, dumpIfSet )
import Maybes		( maybeToBool, MaybeErr(..) )
import TyCon		( isDataTyCon )
import Class		( classTyCon )
import UniqSupply	( mkSplitUniqSupply )

import FiniteMap	( emptyFM )
import Outputable
import Char		( isSpace )
#if REPORT_TO_MOTHERLODE && __GLASGOW_HASKELL__ >= 303
import SocketPrim
import BSD
import IOExts		( unsafePerformIO )
import NativeInfo       ( os, arch )
#endif

\end{code}

\begin{code}
main =
 --  _scc_ "main" 
 doIt classifyOpts
\end{code}

\begin{code}
parseModule :: IO (ModuleName, RdrNameHsModule)
parseModule = do
    buf <- hGetStringBuffer True{-expand tabs-} (unpackFS src_filename)
    case parse buf PState{ bol = 0#, atbol = 1#,
		           context = [], glasgow_exts = glaexts,
		           loc = mkSrcLoc src_filename 1 } of

	PFailed err -> do
		printErrs err
		ghcExit 1
		return (error "parseModule") -- just to get the types right

	POk _ m@(HsModule mod _ _ _ _ _) -> 
		return (mod, m)
  where
	glaexts | opt_GlasgowExts = 1#
		| otherwise       = 0#
\end{code}

\begin{code}
doIt :: ([CoreToDo], [StgToDo]) -> IO ()

doIt (core_cmds, stg_cmds)
  = doIfSet opt_Verbose 
	(hPutStr stderr "Glasgow Haskell Compiler, version " 	>>
 	 hPutStr stderr compiler_version                    	>>
	 hPutStr stderr ", for Haskell 98\n"			>>
	 hPutStr stderr "\tcompiled by GHC version "		>>
	 hPutStr stderr booter_version				>>
	 hPutStr stderr "\n")					>>

	--------------------------  Reader  ----------------
    show_pass "Parser"	>>
    _scc_     "Parser"
    parseModule		>>= \ (mod_name, rdr_module) ->

    dumpIfSet opt_D_dump_parsed "Parser" (ppr rdr_module) >>

    dumpIfSet opt_D_source_stats "Source Statistics"
	(ppSourceStats False rdr_module)	 	>><commit_msg>[project @ 1999-07-06 15:21:01 by simonmar] print the compiler version on the same line as the compilee version; looks a bit tidier.<commit_after>%
% (c) The GRASP/AQUA Project, Glasgow University, 1993-1998
%
\section[GHC_Main]{Main driver for Glasgow Haskell compiler}

\begin{code}
module Main ( main ) where

#include "HsVersions.h"

import IO		( hPutStr, stderr )
import HsSyn
import BasicTypes	( NewOrData(..) )

import RdrHsSyn		( RdrNameHsModule )
import FastString	( mkFastCharString, unpackFS )
import StringBuffer	( hGetStringBuffer )
import Parser		( parse )
import Lex		( PState(..), P, ParseResult(..) )
import SrcLoc		( mkSrcLoc )

import Rename		( renameModule )

import MkIface		( startIface, ifaceDecls, endIface )
import TcModule		( TcResults(..), typecheckModule )
import Desugar		( deSugar )
import SimplCore	( core2core )
import CoreLint		( endPass )
import CoreTidy		( tidyCorePgm )
import CoreToStg	( topCoreBindsToStg )
import StgSyn		( collectFinalStgBinders, pprStgBindings )
import SimplStg		( stg2stg )
import CodeGen		( codeGen )
import CodeOutput	( codeOutput )

import Module		( ModuleName, moduleNameUserString )
import AbsCSyn		( absCNop )
import CmdLineOpts
import ErrUtils		( ghcExit, doIfSet, dumpIfSet )
import Maybes		( maybeToBool, MaybeErr(..) )
import TyCon		( isDataTyCon )
import Class		( classTyCon )
import UniqSupply	( mkSplitUniqSupply )

import FiniteMap	( emptyFM )
import Outputable
import Char		( isSpace )
#if REPORT_TO_MOTHERLODE && __GLASGOW_HASKELL__ >= 303
import SocketPrim
import BSD
import IOExts		( unsafePerformIO )
import NativeInfo       ( os, arch )
#endif

\end{code}

\begin{code}
main =
 --  _scc_ "main" 
 doIt classifyOpts
\end{code}

\begin{code}
parseModule :: IO (ModuleName, RdrNameHsModule)
parseModule = do
    buf <- hGetStringBuffer True{-expand tabs-} (unpackFS src_filename)
    case parse buf PState{ bol = 0#, atbol = 1#,
		           context = [], glasgow_exts = glaexts,
		           loc = mkSrcLoc src_filename 1 } of

	PFailed err -> do
		printErrs err
		ghcExit 1
		return (error "parseModule") -- just to get the types right

	POk _ m@(HsModule mod _ _ _ _ _) -> 
		return (mod, m)
  where
	glaexts | opt_GlasgowExts = 1#
		| otherwise       = 0#
\end{code}

\begin{code}
doIt :: ([CoreToDo], [StgToDo]) -> IO ()

doIt (core_cmds, stg_cmds)
  = doIfSet opt_Verbose 
	(hPutStr stderr "Glasgow Haskell Compiler, version " 	>>
 	 hPutStr stderr compiler_version                    	>>
	 hPutStr stderr ", for Haskell 98, compiled by GHC version " >>
	 hPutStr stderr booter_version				>>
	 hPutStr stderr "\n")					>>

	--------------------------  Reader  ----------------
    show_pass "Parser"	>>
    _scc_     "Parser"
    parseModule		>>= \ (mod_name, rdr_module) ->

    dumpIfSet opt_D_dump_parsed "Parser" (ppr rdr_module) >>

    dumpIfSet opt_D_source_stats "Source Statistics"
	(ppSourceStats False rdr_module)	 	>>
{'fraction_non_alphanumeric': 0.11031593646360621, 'fraction_numerical': 0.009774829813230931, 'mean_word_length': 3.4384198295894657, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3595830', 'n_tokens_mistral': 2213, 'n_tokens_neox': 2060, 'n_words': 546}