首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用alex/happy with Cabal

使用alex/happy with Cabal
EN

Stack Overflow用户
提问于 2010-12-17 05:45:34
回答 2查看 4.2K关注 0票数 13

我正在为我正在学习的一个类编写编译器。这个类并不是专门针对Haskell的,但是我正在使用Haskell来编写我的编译器和解释器。我有一个cabal包设置,希望能让我的教授很容易运行/编译。我在两个可执行文件的build-tools字段中都有happy和alex,但Cabal忽略了这一点,然后抱怨说它找不到Happy和Alex应该生成的模块。如果我手动运行:

代码语言:javascript
复制
alex LimpScanner.x
happy LimpParser.y

然后阴谋就完美地运行了。

我认为我有阴谋自动运行他们早些时候,但也许我记得不太清楚。

limp.cabal:

代码语言:javascript
复制
-- limp.cabal auto-generated by cabal init. For additional options,
-- see
-- http://www.haskell.org/cabal/release/cabal-latest/doc/users-guide/authors.html#pkg-descr.
-- The name of the package.
Name:                limp

-- The package version. See the Haskell package versioning policy
-- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for
-- standards guiding when and how versions should be incremented.
Version:             0.1

-- A short (one-line) description of the package.
Synopsis:            LIMP Compiler (Compiler Construction course project)

-- A longer description of the package.
-- Description:         

-- URL for the project homepage or repository.
Homepage:            http://www.cs.rit.edu/~eca7215/limp/

-- The license under which the package is released.
License:             AllRightsReserved

-- The file containing the license text.
License-file:        LICENSE

-- The package author(s).
Author:              Edward Amsden

-- An email address to which users can send suggestions, bug reports,
-- and patches.
Maintainer:          eca7215@cs.rit.edu

-- A copyright notice.
-- Copyright:           

Category:            Language

Build-type:          Simple

-- Extra files to be distributed with the package, such as examples or
-- a README.
-- Extra-source-files:  

-- Constraint on the version of Cabal needed to build this package.
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

目录布局:

代码语言:javascript
复制
limp/
├── Setup.hs
├── limp.cabal
└── src/
    ├── Limp.hs
    ├── LimpInterpreter.hs
    ├── LimpParser.ly
    ├── LimpScanner.x
    └── LimpToken.hs
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2010-12-17 09:31:32

显然,我遗漏的实际上是其他模块: field。一旦添加了这个,卡巴尔高兴地(请原谅我的双关语)构建了我的解释器。

票数 10
EN

Stack Overflow用户

发布于 2013-04-04 16:44:32

对于Warren Harris和其他像他这样的人(和我自己),其他模块需要设置为一个模块名称列表(我猜?)预计将由build-tools中列出的工具构建。

因此,在我的例子中,我的.cabal文件的相关部分最终如下所示:

代码语言:javascript
复制
build-tools:         alex, happy
other-modules:       Language.Heidi.Parser,
                     Language.Heidi.Lexer
票数 17
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4465666

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档