haskell / alex

A lexical analyser generator for Haskell
https://hackage.haskell.org/package/alex
BSD 3-Clause "New" or "Revised" License
297 stars 82 forks source link

Get rid of long lines in produced files #107

Closed sergv closed 7 years ago

sergv commented 7 years ago

Solution for #84.

sergv commented 7 years ago

@simonmar @erikd Thanks for looking at it! I have clarified how concatInChunks works and done some testing against clang as well as gcc which I have tested already.

Regarding continuation lines in general - as far as I recall, these will work with any standard-compliant C preprocessor. The only catch is that \ must be the last character on the line, which it is in this case.

Per your suggestion, I've done testing with clang and gcc on my Debian Linux machine. Unfortunately I don't own a MacBook so I cannot test against Apple toolchain. I've modified tests to run ghc with clang in addition to stock ghc that picks up gcc on my system. That is, alex output files were compiled with ghc -pgmP "clang -E -undef -traditional" command, which from https://guide.aelve.com/haskell/cpp-vww0qd72#item-v27x182d (please correct me if it's somehow incorrect). Both gcc-based and clang-based tests worked correctly. However clang required small fix in the tokens_scan_user.x test because test has the following lambda defined \u _ibt _l _iat -> ... and clang wants to interpret \u as start of unicode character, but fails.

I guess it could be useful to submit my tweaks of the Makefile, but I think it's worth to replace makefile with some sort of Haskell testing framework as I outlined in #106. This way tests can easily detect whether clang or gcc is available on the user's machine and either warn about tool absence or disable tests for that tool. I'm aware that makefiles can also try detecting that, but it does require some hackery.

Software used during testing:

$ uname -a
Linux debian 4.9.0-3-amd64 #1 SMP Debian 4.9.30-2 (2017-06-12) x86_64 GNU/Linux
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.0.2
$ gcc --version
gcc (Debian 6.3.0-18) 6.3.0 20170516
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ clang --version
clang version 3.8.1-24 (tags/RELEASE_381/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
sergv commented 7 years ago

I have fixed the comments.