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

Proposal: parsetree rewriters #5634

Closed
vicuna opened this issue Jun 5, 2012 · 1 comment
Closed

Proposal: parsetree rewriters #5634

vicuna opened this issue Jun 5, 2012 · 1 comment
Assignees

Comments

@vicuna
Copy link

vicuna commented Jun 5, 2012

Original bug ID: 5634
Reporter: @alainfrisch
Assigned to: @alainfrisch
Status: closed (set by @xavierleroy on 2015-12-11T18:04:56Z)
Resolution: fixed
Priority: normal
Severity: feature
Category: ~DO NOT USE (was: OCaml general)
Monitored by: @gasche @glondu @hcarty

Bug description

I believe many Camlp4 syntax-extension could be implemented with a much more basic technology. I've described a proposal for extending the OCaml syntax with a fixed number of extension points (attributes and quotations) and letting the compilers pipe the parsed AST through one or several external rewriters:

http://www.lexifi.com/blog/syntax-extensions-without-camlp4

Now that "compilerlibs" are officially installed, and as a first step towards this proposal, I'd like to propose for inclusion the tiny attached patch (also in the ast_rewriter branch of the SVN). It only extends the compilers with a new "-ppx" flag, similar to (and compatible with) the existing "-pp". Invoking the compiler with "-ppx cmd" pipes the parsed AST (interface/implementation) through the specified command (actually, it passes two filenames -- input and ouput -- as extra arguments to the command).

An example of how to write an AST rewriter is available in the SVN:

http://caml.inria.fr/cgi-bin/viewvc.cgi/ocaml/branches/ast_rewriter/experimental/frisch/

File attachments

@vicuna
Copy link
Author

vicuna commented Jun 13, 2012

Comment author: @alainfrisch

The branch has been merged to the trunk.

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

No branches or pull requests

2 participants