13

私が取っているクラスのコンパイラを書いています。このクラスは特に Haskell ではありませんが、Haskell を使用してコンパイラとインタープリターを作成しています。私の教授が簡単に実行/コンパイルできるように、cabal パッケージをセットアップしました。両方の実行可能ファイルの build-tools フィールドに happy と alex がありますが、Cabal はそれを無視し、Happy と Alex が生成すべきモジュールが見つからないと文句を言います。手動で実行した場合:

alex LimpScanner.x
happy LimpParser.y

その後、陰謀団は完全に実行されます。

以前は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
4

2 に答える 2

17

ウォーレン・ハリスや彼のような人 (および私自身) が後で登場する可能性があるため、other-modules には、build-tools にリストされているツールによってビルドされると予想される (私が推測する?) モジュール名のリストを設定する必要があります。

したがって、私の場合、.cabal ファイルの関連セクションは次のようになりました。

build-tools:         alex, happy
other-modules:       Language.Heidi.Parser,
                     Language.Heidi.Lexer
于 2013-04-04T08:44:31.970 に答える
10

どうやら私が見逃していたのは、実際には Other-modules: フィールドでした。これが追加されると、cabal は喜んで (駄洒落を許してください)、私のインタープリターを構築しました。

于 2010-12-17T01:31:32.233 に答える