gpt4 book ai didi

haskell - 使用 alex/happy 和 Cabal

转载 作者:行者123 更新时间:2023-12-03 23:22:27 28 4
gpt4 key购买 nike

我正在为我正在学习的类(class)编写编译器。该类不是专门的 Haskell,但我使用 Haskell 来编写我的编译器和解释器。我有一个 cabal 包设置,希望能让我的教授轻松运行/编译。我在这两个可执行文件的构建工具字段中都有 happy 和 alex,但 Cabal 忽略了这一点,然后提示它找不到 Happy 和 Alex 应该生成的模块。如果我手动运行:

alex LimpScanner.x
happy LimpParser.y

然后 cabal 完美运行。

我以为我早先让 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: 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

目录布局:
limp/
├── Setup.hs
├── limp.cabal
└── src/
├── Limp.hs
├── LimpInterpreter.hs
├── LimpParser.ly
├── LimpScanner.x
└── LimpToken.hs

最佳答案

对于 Warren Harris 和其他像他(和我自己)可能会在以后出现的人,需要将 other-modules 设置为(我猜?)预计将由 build-tools 中列出的工具构建的模块名称列表。

所以,就我而言,我的 .cabal 文件的相关部分最终看起来像这样:

build-tools:         alex, happy
other-modules: Language.Heidi.Parser,
Language.Heidi.Lexer

关于haskell - 使用 alex/happy 和 Cabal,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4465666/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com