Suppress certain Haskell Alex/Happy compilation messages
Asked Answered
K

1

8

When creating either a Lexer.x or a Parser.y parser using the Alex lexer generator or the Happy parser generator, compiling those into Haskell files, and compiling those into object files, by default this will generate the following "warnings":

$ 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 )

Those lines occur as a result of the following lines embedded in the generated .hs files:

{-# LINE 1 "<command-line>" #-}

Why are those lines included, and is there a way to suppress those messages in case the command-line is not apparently used for anything in the generated lexer and parser?

Kopp answered 5/8, 2013 at 13:57 Comment(0)
G
1

Googling "left but not entered" suggests that messages like this indicate a misconfigured gcc. Here is the code in Apple's version which generates the message:

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);
}

(from http://www.opensource.apple.com/source/gcc/gcc-5484/libcpp/line-map.c )

Here "ICE" refers to "internal compiler error".

The #LINE directives are inserted so that ghc can report errors based on the locations in the .x or .y files. It says that the following line is really a certain line from another file. The #LINE directives for the pseudo file names <command-line> and <built-in> can be ignored because they are always immediately followed by a #LINE directive for a real file name, e.g.:

...
{-# 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" #-}
...

As a test you can simply remove the #LINE directives for <command-line> and see if the warnings go away. I would also try re-installing/upgrading your gcc and/or your Haskell Platform.

Gap answered 12/7, 2014 at 16:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.