From 793e85dc09a86ee318e705c1351501be18f40089 Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Sat, 24 Apr 2021 09:38:54 +0200 Subject: [PATCH] [ #352 ] TokenText flag to cf2Layout is obsolete --- source/src/BNFC/Backend/Haskell.hs | 2 +- source/src/BNFC/Backend/Haskell/CFtoLayout.hs | 8 +++----- source/src/BNFC/Backend/HaskellGADT.hs | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/source/src/BNFC/Backend/Haskell.hs b/source/src/BNFC/Backend/Haskell.hs index d67c36a9..726b9738 100644 --- a/source/src/BNFC/Backend/Haskell.hs +++ b/source/src/BNFC/Backend/Haskell.hs @@ -59,7 +59,7 @@ makeHaskell opts cf = do liftIO $ printf "Use Alex 3 to compile %s.\n" (alexFile opts) Ctrl.when (hasLayout cf) $ mkfile (layoutFile opts) $ - cf2Layout (tokenText opts) layMod lexMod cf + cf2Layout layMod lexMod cf -- Generate Happy parser and matching test program. do diff --git a/source/src/BNFC/Backend/Haskell/CFtoLayout.hs b/source/src/BNFC/Backend/Haskell/CFtoLayout.hs index d762e4d0..d3bef070 100644 --- a/source/src/BNFC/Backend/Haskell/CFtoLayout.hs +++ b/source/src/BNFC/Backend/Haskell/CFtoLayout.hs @@ -7,13 +7,11 @@ module BNFC.Backend.Haskell.CFtoLayout where -import Data.List ( sort ) import Data.Maybe ( fromMaybe ) import BNFC.CF import BNFC.Options ( TokenText ) import BNFC.PrettyPrint -import BNFC.Backend.Haskell.Utils ( tokenTextImport, tokenTextPackParens, tokenTextUnpack ) import BNFC.Utils ( caseMaybe, for, whenJust ) data TokSymbol = TokSymbol String Int @@ -22,8 +20,8 @@ data TokSymbol = TokSymbol String Int data LayoutDelimiters = LayoutDelimiters TokSymbol (Maybe TokSymbol) (Maybe TokSymbol) deriving Show -cf2Layout :: TokenText -> String -> String -> CF -> String -cf2Layout tokenText layName lexName cf = unlines $ concat +cf2Layout :: String -> String -> CF -> String +cf2Layout layName lexName cf = unlines $ concat [ [ "-- Generated by the BNF Converter" , "" , "{-# OPTIONS_GHC -fno-warn-incomplete-patterns #-}" @@ -55,7 +53,7 @@ cf2Layout tokenText layName lexName cf = unlines $ concat , "layoutWords :: [(TokSymbol, LayoutDelimiters)]" , render $ prettyList 2 "layoutWords =" "[" "]" "," $ for lay $ \ (kw, delims) -> - prettyList 2 "" "(" ")" "," $ + prettyList 0 empty "(" ")" "," $ map text [ show kw, show delims ] , "" , "layoutStopWords :: [TokSymbol]" diff --git a/source/src/BNFC/Backend/HaskellGADT.hs b/source/src/BNFC/Backend/HaskellGADT.hs index f1198ea9..b2760b21 100644 --- a/source/src/BNFC/Backend/HaskellGADT.hs +++ b/source/src/BNFC/Backend/HaskellGADT.hs @@ -49,7 +49,7 @@ makeHaskellGadt opts cf = do mkfile (templateFile opts) $ cf2Template (templateFileM opts) absMod cf mkfile (printerFile opts) $ cf2Printer StringToken False True prMod absMod cf when (hasLayout cf) $ mkfile (layoutFile opts) $ - cf2Layout (tokenText opts) layMod lexMod cf + cf2Layout layMod lexMod cf mkfile (tFile opts) $ Haskell.testfile opts cf mkfile (errFile opts) $ mkErrM errMod Makefile.mkMakefile opts $ Haskell.makefile opts cf