haskell - 当使用 -F -pgmF 调用时,给 Haskell 自定义预处理器的前两个参数有什么区别?
问题描述
使用 -pgmF cmd 选择要用作预处理器的程序。调用时,cmd 预处理器在其命令行上至少有三个参数:第一个参数是原始源文件的名称,第二个是保存输入的文件的名称,第三个是名称cmd 应该将其输出写入的文件。
我试图编写一个示例预处理器,以查看传递给预处理器的三个参数之间的区别。
我有以下两个文件:
主文件
{-# OPTIONS_GHC -F -pgmF preprocess.sh #-}
预处理.sh
#!/bin/sh
echo $1 " -- the original source file"
echo $2 " -- file holding the input"
echo $3 " -- the file where cmd should write its output to"
echo "{-# LINE 1 \"$2\" #-}\nmain = return ()" > $3
当我使用 编译 Haskell 文件ghc
时,我得到以下输出:
Main.hs -- the original source file
Main.hs -- file holding the input
/tmp/ghc13496_0/ghc_1.hspp -- the file where cmd should write its output to
前两个参数是否应该始终相同?在哪些情况下它们可以具有不同的值?
解决方案
推荐阅读
- jenkins - 如何从 Jenkins 中的特定 git 版本构建
- django - 最终测试:为生产设置 Django 应用程序
- r - 如何使用 HTTR 在 R 中自动执行 YouTube OAuth 身份验证/重新身份验证
- linux - FNF 编译不起作用 [LINUX] - source/Alphabet.hx:17: characters 2-3 : Expected }
- javascript - 无法通过函数的参数访问对象的属性
- json - MarkLogic 中的 JSON 模式验证错误 - XDMP-VALIDATEERRORS
- python - 如何将 DSD 字节转换为 PCM
- git - 项目导出永远不会完成并且链接过期
- maven - 在哪里指定 GitLab ci/cd 管道的存储库凭据?
- python - 使用交互式图例突出显示时在分层条上方显示文本值