From 090f69ea2d465f78933da056b3321b25c852f8ed Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Tue, 10 Nov 2020 01:27:46 +0100 Subject: [PATCH] [ Haskell ] Name created test parser as file, not Main + avoids conflicts with user-written Main module - harder to compile, needs ghc -main-is option --- source/src/BNFC/Backend/Haskell.hs | 5 +++-- source/src/BNFC/Backend/Haskell/HsOpts.hs | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/source/src/BNFC/Backend/Haskell.hs b/source/src/BNFC/Backend/Haskell.hs index 6863ad930..15adf1cca 100644 --- a/source/src/BNFC/Backend/Haskell.hs +++ b/source/src/BNFC/Backend/Haskell.hs @@ -255,7 +255,8 @@ makefile opts makeFile = vcat -- | Rule to build Haskell test parser. testParserRule :: Doc - testParserRule = Makefile.mkRule tgt deps [ "ghc --make $< -o $@" ] + testParserRule = Makefile.mkRule tgt deps + [ unwords [ "ghc --make $<", "-main-is", tFileM opts, "-o $@" ] ] where tgt :: String tgt = tFileExe opts @@ -288,7 +289,7 @@ testfile :: Options -> CF -> String testfile opts cf = unlines $ concat $ [ [ "-- Program to test parser, automatically generated by BNF Converter." , "" - , "module Main where" + , unwords [ "module", tFileM opts, "where" ] , "" ] , case tokenText opts of diff --git a/source/src/BNFC/Backend/Haskell/HsOpts.hs b/source/src/BNFC/Backend/Haskell/HsOpts.hs index b5d692640..27436af38 100644 --- a/source/src/BNFC/Backend/Haskell/HsOpts.hs +++ b/source/src/BNFC/Backend/Haskell/HsOpts.hs @@ -16,7 +16,8 @@ absFile, absFileM, templateFile, templateFileM, printerFile, printerFileM, layoutFile, layoutFileM, - tFile, tFileExe :: Options -> String + tFile, tFileM, tFileExe + :: Options -> String absFile = mkFile withLang "Abs" "hs" absFileM = mkMod withLang "Abs" alexFile = mkFile withLang "Lex" "x" @@ -31,6 +32,7 @@ templateFileM = mkMod withLang "Skel" printerFile = mkFile withLang "Print" "hs" printerFileM = mkMod withLang "Print" tFile = mkFile withLang "Test" "hs" +tFileM = mkMod withLang "Test" tFileExe = mkFile withLang "Test" "" errFile = mkFile noLang "ErrM" "hs" errFileM = mkMod noLang "ErrM"