Skip to content

Commit

Permalink
[ Haskell ] Do not put %token into happy file if there are no tokens
Browse files Browse the repository at this point in the history
Otherwise, we get a happy parse error.
  • Loading branch information
andreasabel committed Jan 2, 2019
1 parent 6bb327b commit f42310d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions source/src/BNFC/Backend/Haskell/CFtoHappy.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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) ++
Expand Down

0 comments on commit f42310d

Please sign in to comment.