本文介绍了使用亚历克斯/快乐与Cabal的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为正在编写的课程编写了一个编译器。该类不是特别的Haskell,但我使用Haskell编写我的编译器和解释器。我有一个cabal包安装程序,希望可以让我的教授轻松运行/编译。我有两个可执行文件在build-tools字段中都很开心,但是Cabal忽略了这一点,然后抱怨说找不到Happy和Alex应该生成的模块。如果我手动运行:

I'm writing a compiler for a class I'm taking. The class isn't specifically Haskell but I'm using Haskell to write my compiler and interpreter. I have a cabal package setup to hopefully make it easy for my prof to run/compile. I have happy and alex in the build-tools field for both executables but Cabal ignores that and then complains that it cannot find the modules that Happy and Alex should be generating. If I manually run:

alex LimpScanner.x
happy LimpParser.y

然后cabal完美地运行。

then cabal runs perfectly.

我以为我有cabal会自动运行它们,或许我记不完美。

I thought I had cabal automatically running them earlier but perhaps I remember imperfectly.

limp.cabal:

limp.cabal:

-- 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:          [email protected]

-- 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

目录布局:

limp/
├── Setup.hs
├── limp.cabal
└── src/
    ├── Limp.hs
    ├── LimpInterpreter.hs
    ├── LimpParser.ly
    ├── LimpScanner.x
    └── LimpToken.hs


推荐答案

显然我错过的其实是其他模块:字段。一旦添加了这个内容,愉快地(赦免双关语)建立我的翻译。

Apparently what I was missing was actually the Other-modules: field. Once this was added, cabal happily (pardon the pun) built my interpreter.

这篇关于使用亚历克斯/快乐与Cabal的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 07:02