BNFC / bnfc

BNF Converter
http://bnfc.digitalgrammars.com/
583 stars 162 forks source link

grammar does not fit in 16-bit representation #375

Closed saw235 closed 2 years ago

saw235 commented 3 years ago

Any idea what the following error message is trying to convey?

alex --ghc Sv/Lex.x
happy --array --info --ghc --coerce Sv/Par.y
unused rules: 40
unused terminals: 1
Grammar info written to: Sv/Par.info
shift/reduce conflicts:  11361
reduce/reduce conflicts: 9108
happy: grammar does not fit in 16-bit representation that is used with '--ghc'
CallStack (from HasCallStack):
  error, called at src/ProduceCode.lhs:1441:36 in main:ProduceCode
Makefile:20: recipe for target 'Sv/Par.hs' failed
make: *** [Sv/Par.hs] Error 1
andreasabel commented 3 years ago

This error is thrown by happy. You could try plain

happy Sv/Par.y

to see whether this works (e.g. change the BNFC-generated Makefile).

Judging from

shift/reduce conflicts:  11361
reduce/reduce conflicts: 9108

the grammar is very big (and has lots of problems still; conflicts are bad most of the time).

saw235 commented 3 years ago

@andreasabel Disabling --ghc didn't work but removing all the other flags seems to be generating the .hs file correctly.

saw235 commented 3 years ago

@andreasabel It still doesn't compile because of the huge memory requirements. Is there some options to split it into smaller modules?

andreasabel commented 3 years ago

@andreasabel It still doesn't compile because of the huge memory requirements. Is there some options to split it into smaller modules?

Unfortunately not, because the LR parser that happy produces has a single LR-automaton at its base. If this is busting your memory, maybe refactoring the grammar would be the way to go.

andreasabel commented 2 years ago

Closing, please reopen with more information if needed.