From aeabc955c8b107e5467cb6b384b40320fb453176 Mon Sep 17 00:00:00 2001 From: Inari Listenmaa Date: Fri, 31 Jul 2020 15:05:46 +0200 Subject: [PATCH] Remove characters that aren't allowed in Haskell data types. GF allows more characters in its types, as long as they are inside single quotes. E.g. 'VP/Object' is a valid name for a GF category, but not for a Haskell data type. --- src/compiler/GF/Compile/PGFtoHaskell.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/compiler/GF/Compile/PGFtoHaskell.hs b/src/compiler/GF/Compile/PGFtoHaskell.hs index e1fbc49aa..41f928d31 100644 --- a/src/compiler/GF/Compile/PGFtoHaskell.hs +++ b/src/compiler/GF/Compile/PGFtoHaskell.hs @@ -40,8 +40,10 @@ grammar2haskell opts name gr = foldr (++++) [] $ gadt = haskellOption opts HaskellGADT dataExt = haskellOption opts HaskellData lexical cat = haskellOption opts HaskellLexical && isLexicalCat opts cat - gId | haskellOption opts HaskellNoPrefix = id - | otherwise = ("G"++) + gId | haskellOption opts HaskellNoPrefix = rmForbiddenChars + | otherwise = ("G"++) . rmForbiddenChars + -- GF grammars allow weird identifier names inside '', e.g. 'VP/Object' + rmForbiddenChars = filter (`notElem` "'!#$%&*+./<=>?@\\^|-~") pragmas | gadt = ["{-# OPTIONS_GHC -fglasgow-exts #-}","{-# LANGUAGE GADTs #-}"] | dataExt = ["{-# LANGUAGE DeriveDataTypeable #-}"] | otherwise = []