From f42310d1a511f2079f06f0a963e4bb6e782747aa Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Wed, 2 Jan 2019 15:26:19 +0100 Subject: [PATCH] [ Haskell ] Do not put %token into happy file if there are no tokens Otherwise, we get a happy parse error. --- source/src/BNFC/Backend/Haskell/CFtoHappy.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/src/BNFC/Backend/Haskell/CFtoHappy.hs b/source/src/BNFC/Backend/Haskell/CFtoHappy.hs index 3814579f..dde9e7b2 100644 --- a/source/src/BNFC/Backend/Haskell/CFtoHappy.hs +++ b/source/src/BNFC/Backend/Haskell/CFtoHappy.hs @@ -107,6 +107,9 @@ delimiter = "\n%%\n" -- Generate the list of tokens and their identifiers. tokens :: [(String,Int)] -> String +tokens [] = "-- no tokens\n" + -- Andreas, 2019-01-02: "%token" followed by nothing is a Happy parse error. + -- Thus, if we have no tokens, do not output anything. tokens toks = "%token\n" ++ prTokens toks where prTokens [] = [] prTokens ((t,k):tk) = " " ++ render (convert t) ++