Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce a common syntactic subset between cppo and bucklescript #69

Open
bobzhang opened this issue Sep 26, 2019 · 3 comments
Open

Introduce a common syntactic subset between cppo and bucklescript #69

bobzhang opened this issue Sep 26, 2019 · 3 comments

Comments

@bobzhang
Copy link
Contributor

Related issue rescript-lang/rescript-compiler#3820

BuckleScript added a primitive conditional compilation support in the ocaml compiler codebase. We can not use cppo there since it would make the patches to ocaml codebase more intrusive(including changes to the build script). Since it is a patch to the ocaml lexer, it is small and minimal so we don't have too much complexity budget as cppo.

I am wondering if we can work together to tweak the syntax to make a minimal common subset to achieve code reuse.

The syntax is documented here https://bucklescript.github.io/docs/en/conditional-compilation#docsNav

cc @ELLIOTTCABLE

@pmetzger
Copy link
Member

pmetzger commented Sep 26, 2019

@bobzhang I'll note that Rust has an interesting syntax for specifying conditional compilation that does not break parsing tools by pretending to be a preprocessor; it would be possible to implement something similar in OCaml pretty easily using attributes or extension nodes.

@bobzhang
Copy link
Contributor Author

there are some cases cpp style is better than ast level, e.g,

type t = 
  | ... (* 100 branches*)
#if HAS_XX 
  | HAS_XX
#end  

@pmetzger
Copy link
Member

Generally, though, such usage inhibits automatic refactoring tools.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants