[Git][ghc/ghc][wip/az/ghc-cpp] Require # against left margin for all GHC_CPP directives

Alan Zimmerman pushed to branch wip/az/ghc-cpp at Glasgow Haskell Compiler / GHC Commits: 32bc5dfb by Alan Zimmerman at 2025-05-25T18:27:52+01:00 Require # against left margin for all GHC_CPP directives - - - - - 3 changed files: - compiler/GHC/Parser/Lexer.x - testsuite/tests/ghc-cpp/GhcCpp01.hs - testsuite/tests/ghc-cpp/GhcCpp01.stderr Changes: ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -328,7 +328,7 @@ $unigraphic / { isSmartQuote } { smart_quote_error } <bol> { \n ; -- Ghc CPP symbols, see https://timsong-cpp.github.io/cppwp/n4140/cpp#1 - ^\ * \# \ * @cppkeyword .* \n / { ifExtensionGhcCppNotComment } { cppToken cpp_prag } + ^\# \ * @cppkeyword .* \n / { ifExtensionGhcCppNotComment } { cppToken cpp_prag } ^\# line { begin line_prag1 } ^\# / { followedByDigit } { begin line_prag1 } @@ -350,7 +350,7 @@ $unigraphic / { isSmartQuote } { smart_quote_error } -- GhcCppBit is set. <skipping> { -- Ghc CPP symbols - ^\ * \# \ * @cppkeyword .* \n { cppToken cpp_prag } + ^\# \ * @cppkeyword .* \n { cppToken cpp_prag } ^.*\n { cppSkip } } @@ -361,7 +361,7 @@ $unigraphic / { isSmartQuote } { smart_quote_error } \{ / { notFollowedBy '-' } { hopefully_open_brace } -- we might encounter {-# here, but {- has been handled already \n ; - ^\ * \# \ * @cppkeyword .* \n / { ifExtension GhcCppBit } { cppToken cpp_prag } + ^\# \ * @cppkeyword .* \n / { ifExtension GhcCppBit } { cppToken cpp_prag } ^\# (line)? { begin line_prag1 } ^\#.*\n / { ifExtension GhcCppBit } { cppSkip } @@ -436,7 +436,7 @@ $unigraphic / { isSmartQuote } { smart_quote_error } -- This one does not check for GhcCpp being set, we use it to -- terminate normal pragma processing - ^\ * \# \ * @cppkeyword .* \n { cppToken cpp_prag } + ^\# \ * @cppkeyword .* \n { cppToken cpp_prag } -- ^\# .*\n { cppSkip } } ===================================== testsuite/tests/ghc-cpp/GhcCpp01.hs ===================================== @@ -3,7 +3,7 @@ module GhcCpp01 where -- Check leading whitespace on a directive - # define FOO(A,B) A + B +# define FOO(A,B) A + B #define FOO(A,B,C) A + B + C #if FOO(1,FOO(3,4)) == 8 ===================================== testsuite/tests/ghc-cpp/GhcCpp01.stderr ===================================== @@ -202,7 +202,7 @@ |module GhcCpp01 where - |-- Check leading whitespace on a directive -- | # define FOO(A,B) A + B +- |# define FOO(A,B) A + B - |#define FOO(A,B,C) A + B + C - |#if FOO(1,FOO(3,4)) == 8 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/32bc5dfbbd32bcf249ffebe01ac7e742... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/32bc5dfbbd32bcf249ffebe01ac7e742... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Alan Zimmerman (@alanz)