Skip to content

Commit

Permalink
Separate and export parse raw CF
Browse files Browse the repository at this point in the history
  • Loading branch information
chaserhkj committed Jul 23, 2024
1 parent acd56e9 commit 34fb29e
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions source/src/BNFC/GetCF.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
-- | Check LBNF input file and turn it into the 'CF' internal representation.

module BNFC.GetCF
( parseCF
( parseCF, parseRawCF
, checkRule, transItem
) where

Expand Down Expand Up @@ -63,18 +63,23 @@ type Err = Either String
-- $setup
-- >>> import BNFC.Print

-- | Entrypoint.
-- | Parse raw CF from LBNF file without checking backend requirements

parseCF :: SharedOptions -> Target -> String -> IO CF
parseCF opts target content = do
cf <- runErr $ pGrammar (myLexer content)
parseRawCF :: FilePath -> String -> Err CF
parseRawCF fileName content = pGrammar (myLexer content)
-- <&> expandRules -- <&> from ghc 8.4
>>= return . expandRules
>>= getCF (lbnfFile opts)
>>= getCF fileName
>>= return . markTokenCategories
-- Construct the typing information in 'define' expressions.
>>= runTypeChecker . checkDefinitions

-- | Entrypoint. Parses full CF from LBNF file and checks against
-- all backend requirements

-- Construct the typing information in 'define' expressions.
cf <- either die return $ runTypeChecker $ checkDefinitions cf
parseCF :: SharedOptions -> Target -> String -> IO CF
parseCF opts target content = do
cf <- runErr $ parseRawCF (lbnfFile opts) content

-- Some backends do not allow the grammar name to coincide with
-- one of the category or constructor names.
Expand Down

0 comments on commit 34fb29e

Please sign in to comment.