2010-12-16 5 views
12

나는 수업을 듣기 위해 컴파일러를 작성하고 있습니다. 클래스는 하스켈이 아니지만 하스켈을 사용하여 컴파일러와 인터프리터를 작성합니다. 나는 cabal 패키지 셋업을 사용하여 나의 교수가 쉽게 컴파일/컴파일 할 수있게 만들었습니다. 두 실행 파일의 build-tools 필드에는 행복하고 알렉스가 있지만 Cabal은이를 무시한 다음 Happy와 Alex가 생성해야하는 모듈을 찾을 수 없다고 불평합니다. 수동으로 실행하는 경우 :alex/happy with Cabal 사용

alex LimpScanner.x 
happy LimpParser.y 

다음 도주가 완벽하게 실행됩니다.

나는 캐럴이 자동으로 이전에 실행한다고 생각했지만 불완전하게 기억할 것입니다.

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

을 언제 까지나 :

그래서, 내 경우에는, 내 .cabal 파일의 관련 부분은 다음과 같이보고 결국 'LimpParser.x'와'LimpScanner.ly' 파일에 Alex와 Happy가 설치되어 있다면 지난 해의 Cabal 버전은 자동으로'alex'와'happy'를 실행해야합니다. 흠. – ephemient

+0

자세한 내용이 필요합니다. 귀하의 디렉토리 레이아웃은 무엇입니까? Cabal 파일은 무엇입니까? –

+0

다른 길은 아닌가요? LimpParser.ly 및 LimpScanner.x? – Edward

답변

10

내가 없어진 분명히 어떤 실제로 다른 모듈들이었다 필드. 이것이 추가되면, 행복하게 (말장난을 용서하십시오) 통역관이 통역관을지었습니다.

+1

직접 대답 해 주셔서 감사합니다. –

+6

예제를 완성하고 다른 모듈을 설정해야하는 것을 보여줄 수 있습니까? 감사, –

14

Warren Harris와 그와 같은 사람들이 나중에 나올 수도 있습니다. 다른 모듈은 다음에 나열된 도구로 빌드 될 것으로 예상되는 모듈 이름 목록으로 설정해야합니다. 빌드 도구. 당신은, 모듈`LimpParser`와`LimpScanner`를 사용라는 이름의 파일이 있는지 상태로

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