GaloisInc / daedalus

The Daedalus data description language
BSD 3-Clause "New" or "Revised" License
63 stars 11 forks source link

daedalus panic on the PDF spec #50

Open mtullsen opened 3 years ago

mtullsen commented 3 years ago

Compiling the Pdf spec in the repo causes a daedalus panic:

$ daedalus --compile-hs --out-dir=tmp-hs pdf-cos/spec/PdfDecl.ddl
You have encountered a bug in Daedalus's implementation.
 *** Please create an issue at https://github.com/GaloisInc/daedalus/issues

%< ---------------------------------------------------
  Revision:  150b3658a46963db4368c91fad07628a3f9f7bd6
  Branch:    master (uncommited files present)
  Location:  lkpInEnv
  Message:   Missing variable
             Name: PdfDecl.ASCII85Decode
             Env: envExtern
             Keys:
CallStack (from HasCallStack):
  panic, called at src/Daedalus/Panic.hs:17:9 in daedalus-utils-0.1.0.0-inplace:Daedalus.Panic
  panic, called at src/Daedalus/CompileHS.hs:33:16 in daedalus-0.1.0.0-inplace:Daedalus.CompileHS
%< ---------------------------------------------------

It appears the .ddl is bad/incomplete. The panic occurs in previous versions of pdf-cos/spec/PdfDecl.ddl, I need to revert (the spec) back to 1430ec64 to get a clean run:

$ git ch 1430ec64 -- pdf-cos/spec
$ daedalus --compile-hs --out-dir=tmp-hs pdf-cos/spec/PdfDecl.ddl
pdf-cos/spec/PdfValue.ddl:14:45--14:53: Failed to match types:
                                          • bool
                                          • uint 8
yav commented 3 years ago

This panic happens because --compile-hs does not support external primitives and the PDF spec uses them. Currently, to compile a grammar that uses external primitives you have to write a small Haskell program that specifies how to generate code for the primitives. For an example, that program for pdf-cos is in: pdf-cos/generator/Main.hs