Plan 9 from Bell Labs’s /usr/web/sources/contrib/fernan/nhc98/src/cpphs/Language/Preprocessor/Cpphs/RunCpphs.hs

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


{-
-- The main program for cpphs, a simple C pre-processor written in Haskell.

-- Copyright (c) 2004 Malcolm Wallace
-- This file is GPL, although the libraries it uses are either standard
-- Haskell'98 or distributed under the LGPL.
-}
module Language.Preprocessor.Cpphs.RunCpphs ( runCpphs ) where

import Language.Preprocessor.Cpphs.CppIfdef (cppIfdef)
import Language.Preprocessor.Cpphs.MacroPass(macroPass)
import Language.Preprocessor.Cpphs.Options  (CpphsOptions(..), BoolOptions(..))
import Language.Preprocessor.Unlit as Unlit (unlit)


runCpphs :: CpphsOptions -> FilePath -> String -> String
runCpphs options filename input =
  let bools = boolopts options

      pass1 = cppIfdef filename (defines options) (includes options) bools input
      pass2 = macroPass (defines options) bools pass1
      result= if not (macros bools) then unlines (map snd pass1) else pass2
      pass3 = if literate bools then Unlit.unlit filename else id

  in pass3 result

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.