-
Notifications
You must be signed in to change notification settings - Fork 710
Supporting BNFC #6726
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Adding |
This assumption is correct. From one .cf file, BNFC generates:
Makes sense not to add it then.
I certainly would not expect all of these changes to happen in Cabal just for this. Is this versatility (i.e., more than one file being generated, having different package and executable names) generally desired for the future of cabal, or would this just be annoying to maintain and not provide much benefit? I see their benefit in theory, but I'm just not sure if you've every encountered this before, or expect to. |
I don't think this is big issue, it's just not done.
Is the tricky bit build-system wise. |
Found this comment on situations where several files are generated: |
Just a comment which I don't know if/how it is related. Currently, with cabal-3.4, adding BNFC to the setup build dependencies does not seem to be enough (or I don't know how to do it):
Instead of installing BNFC as an executable, therefore letting me run it, it installs BNFC as a library. The result is that the following setup program: -- | Custom Setup that runs bnfc to generate the language sub-libraries
-- for the parsers included in Ogma.
module Main (main) where
import Distribution.Simple ( defaultMainWithHooks, hookedPrograms,
postConf, preBuild, simpleUserHooks )
import Distribution.Simple.Program ( Program (..), findProgramVersion,
simpleProgram )
import System.Process ( system )
-- | Run BNFC on the grammar before the actual build step.
--
-- All options for bnfc are hard-coded here. There is an open bug in Cabal's
-- github repo about supporting BNFC.
main :: IO ()
main = defaultMainWithHooks $ simpleUserHooks
{ hookedPrograms = [ bnfcProgram ]
, postConf = \args flags packageDesc localBuildInfo -> do
_ <- system "bnfc --haskell -p Language.W -o src/ grammar/W.cf"
postConf simpleUserHooks args flags packageDesc localBuildInfo
}
-- | TODO: This should be in Cabal.Distribution.Simple.Program.Builtin.
bnfcProgram :: Program
bnfcProgram = (simpleProgram "bnfc")
{ programFindVersion = findProgramVersion "--version" id
} cannot find bnfc in the
although the directory src does exist in the repo. Btw, if I first install BNFC first with:
then it puts the executable in |
Correct, as discussed in the ticket you linked, |
Indeed. Unfortunately, that did not work for me on 3.6 because of #7644. |
Uh oh!
There was an error while loading. Please reload this page.
I'd like to propose that Cabal support BNFC as a build tool. BNFC is a well-known, multi-language parser generator that supports Haskell via Happy & Alex.
Additional context
From what I understand, the required changes would be:
cabal/Cabal/Distribution/Simple/BuildToolDepends.hs
Lines 31 to 45 in 0c97920
cabal/cabal-install/Distribution/Client/Init/Heuristics.hs
Lines 215 to 225 in 72d67bf
cabal/Cabal/Distribution/Simple/Program/Builtin.hs
Line 13 in 9537238
cabal/Cabal/Distribution/Simple/Program/Builtin.hs
Lines 69 to 70 in 9537238
Questions:
--haskell -p <PATH> -o <directory> <file.cf>
? Would doing this immediately make cabal understand--with-bnfc
,--with-bnfc-options
andbnfc-options:
?The text was updated successfully, but these errors were encountered: