我正在为我正在学习的课程编写一个编译器。该类不是专门的 Haskell,但我使用 Haskell 来编写我的编译器和解释器。我有一个 cabal 包设置,希望能让我的教授轻松运行/编译。
我有快乐和亚历克斯在build-tools
两个可执行文件的字段,但 Cabal 忽略了这一点,然后抱怨它找不到 Happy 和 Alex 应该生成的模块。
如果我手动运行:
alex LimpScanner.x
happy LimpParser.y
然后阴谋集团完美运行。
我以为我早些时候已经让阴谋集团自动运行它们,但也许我记得不完整。
内容limp.cabal
:
Name: limp
Version: 0.1
Synopsis: LIMP Compiler (Compiler Construction course project)
Homepage: http://www.cs.rit.edu/~eca7215/limp/
License: AllRightsReserved
License-file: LICENSE
Author: Edward Amsden
Maintainer: [email protected] /cdn-cgi/l/email-protection
Category: Language
Build-type: Simple
Cabal-version: >=1.2
Executable limp
-- .hs or .lhs file containing the Main module.
Main-is: Limp.hs
hs-source-dirs: src
-- Packages needed in order to build this package.
Build-depends: base, array, haskell98
-- Modules not exported by this package.
-- Other-modules:
-- Extra tools (e.g. alex, hsc2hs, ...) needed to build the source.
Build-tools: alex, happy
Executable limpi
Main-is: LimpInterpreter.hs
hs-source-dirs: src
Build-depends: base, array, haskell98
Build-tools: alex, happy
目录布局:
limp/
├── Setup.hs
├── limp.cabal
└── src/
├── Limp.hs
├── LimpInterpreter.hs
├── LimpParser.ly
├── LimpScanner.x
└── LimpToken.hs
对于 Warren Harris 和其他像他(和我自己)一样的人来说,其他模块需要设置为模块名称列表(我猜?)预计将由构建工具中列出的工具构建。
因此,就我而言,.cabal 文件的相关部分最终如下所示:
build-tools: alex, happy
other-modules: Language.Heidi.Parser,
Language.Heidi.Lexer
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)