BNFC / bnfc

BNF Converter
http://bnfc.digitalgrammars.com/
587 stars 165 forks source link

Haskell: Int not imported in Abs.hs but needed for position token #296

Closed wmacmil closed 4 years ago

wmacmil commented 4 years ago

Am trying to just compile the cubicaltt file in

Will someone please discuss how to resolve the bnfc grammar error i get when I run make after having run bnfc -m --haskell Exp.cf? I'm getting the follow (i) error. If I import Data.Int I just get the error (ii) below it, ad infinitum. Are there any easy resolutions?

(i) $ make ghc --make TestExp.hs -o TestExp [1 of 7] Compiling AbsExp ( AbsExp.hs, AbsExp.o )

AbsExp.hs:13:27: error: Not in scope: type constructor or class ‘Int’ Perhaps you meant one of these: ‘Data.Int.Int’ (imported from Data.Int), ‘Data.Int.Int8’ (imported from Data.Int) Perhaps you want to add ‘Int’ to the import list in the import of ‘Prelude’ (AbsExp.hs:8:1-46). 13 newtype AIdent = AIdent ((Int,Int),String)

(ii) $ make ghc --make TestExp.hs -o TestExp [1 of 7] Compiling AbsExp ( AbsExp.hs, AbsExp.o )

AbsExp.hs:14:42: error: • No instance for (IsString ((Int, Int), String)) arising from the 'deriving' clause of a data type declaration Possible fix: use a standalone 'deriving instance' declaration, so you can specify the instance context yourself • When deriving the instance for (IsString AIdent) | 14 | deriving (C.Eq, C.Ord, C.Show, C.Read, Data.String.IsString) | ^^^^^^^^^^^^^^^^^^^^

andreasabel commented 4 years ago

Am trying to just compile the cubicaltt file in

Yes, where?

wmacmil commented 4 years ago

https://github.com/mortberg/cubicaltt/blob/master/Exp.cf sorry i don't know what happened

andreasabel commented 4 years ago

This is indeed a regression in BNFC (master), thanks for the report!
Int should be imported in Abs.hs to accomodate position tokens.

I managed to compile cubical with GHC 8.0.2 and BNFC 2.8.3 (latest release).

cabal install --program-suffix=-2.8.3 BNFC-2.8.3
cd cubicaltt
rm -rf Exp
BNFC=bnfc-2.8.3 make -f GNUmakefile

Let me know if this works.

wmacmil commented 4 years ago

works for me! tack

andreasabel commented 4 years ago

After 173f2482feda1fc9e51e9b712ffb7947c6250430, cubicaltt builds again with BNFC-master.