使用Alex生成器或快乐解析器生成器创建Lexer.x或Parser.y解析器时,将这些分析器编译为Haskell文件,并将其编译为对象文件,默认情况下,这将生成以下“警告”:
$ ghc Lexer
line-map.c: file "<command-line>" left but not entered
line-map.c: file "<command-line>" left but not entered
[1 of 1] Compiling Lexer ( Lexer.hs, Lexer.o )
$ happy Parser.y
$ ghc Parser
line-map.c: file "<command-line>" left but not entered
line-map.c: file "<command-line>" left but not entered
[2 of 2] Compiling Parser ( Parser.hs, Parser.o )这些行是嵌入在生成的.hs文件中的下列行的结果:
{-# LINE 1 "<command-line>" #-}为什么这些行包括在内,如果命令行显然没有用于生成的lexer和解析器中的任何内容,那么是否有一种方法来抑制这些消息呢?
发布于 2014-07-12 16:02:13
在谷歌上搜索“左而不入”意味着这样的信息表明gcc配置不当。以下是苹果版本中生成信息的代码:
void
linemap_check_files_exited (struct line_maps *set)
{
struct line_map *map;
/* Depending upon whether we are handling preprocessed input or
not, this can be a user error or an ICE. */
for (map = &set->maps[set->used - 1]; ! MAIN_FILE_P (map);
map = INCLUDED_FROM (set, map))
fprintf (stderr, "line-map.c: file \"%s\" entered but not left\n",
map->to_file);
}(来自http://www.opensource.apple.com/source/gcc/gcc-5484/libcpp/line-map.c )
这里"ICE“指的是”内部编译器错误“。
插入#行指令,以便ghc可以根据.x或.y文件中的位置报告错误。它说下一行实际上是另一个文件中的某一行。伪文件名<command-line>和<built-in>的#行指令可以忽略,因为它们总是紧跟在真正文件名的#行指令后面,例如:
...
{-# LINE 1 "<built-in>" #-}
{-# LINE 1 "<command-line>" #-}
{-# LINE 1 "templates/wrappers.hs" #-}
...
{-# LINE 1 "<built-in>" #-}
{-# LINE 1 "<command-line>" #-}
{-# LINE 1 "templates/GenericTemplate.hs" #-}
...作为一种测试,您可以简单地删除<command-line>的#行指令,并查看警告是否消失。我也会尝试重新安装/升级您的gcc和/或您的Haskell平台。
https://stackoverflow.com/questions/18060029
复制相似问题