purescript-codegen / purescript-ps-cst

Purescript code printer, inspired by official purescript-cst types https://hackage.haskell.org/package/purescript/docs/Language-PureScript-CST-Types.html
BSD 3-Clause "New" or "Revised" License
10 stars 5 forks source link

The big question: Parsing #6

Open i-am-the-slime opened 4 years ago

i-am-the-slime commented 4 years ago

How do you see parsing in relation to this library? Would you say it should live in a different library?

flip111 commented 4 years ago

Well there is of course this https://github.com/purescript/purescript-in-purescript which is outdated. I don't think it's a good idea to develop in parallel a parser to the official purescript parser which is in the purescript compiler. Instead i would prefer import / export of the syntax tree.

For codegen the purescript code tree would be constructed directly, so we don't need a parser.

Would be interesting though (for testing as well) to do:

  1. create arbitrary code structures (AST / CST) with Arbitrary instance from haskell quickcheck
  2. export to intermediate format (not clear which format is suitable)
  3. import into this library
  4. pretty print with purescript code
  5. read printed source file with official purescript parser in purescript compiler
  6. compare structures for equility

By the way .. i vaguely remember that there were some parts to split of some parts of the official purescript compiler into their own library ... this might become interesting in the future.

srghma commented 3 years ago

https://github.com/natefaubion/purescript-language-cst-parser/blob/main/src/PureScript/CST/Types.purs