Camlp4 - Fields of Application

Fields of Application

Domain-specific languages are a major application of Camlp4. Since OCaml is a multi-paradigm language, with an interactive toplevel and a native code compiler, it can be used as a backend for any kind of original language. The only thing that the developer has to do is write a Camlp4 grammar which converts the domain-specific language in question into a regular OCaml program. Other target languages can also be used, such as C.

If the target language is OCaml, simple syntax add-ons or syntactic sugar can be defined, in order to provide an expressivity which is not easy to achieve using the standard features of the OCaml language. A syntax extension is defined by a compiled OCaml module, which is passed to the camlp4o executable along with the program to process.

Interestingly, Camlp4 includes a domain-specific language as it provides syntax extensions which ease the development of syntax extensions. These extensions allow a compact definition of grammars (EXTEND statements) and quotations such as <:expr< 1 + 1 >>, i.e. deconstructing and constructing abstract syntax trees in concrete syntax.

Read more about this topic:  Camlp4

Famous quotes containing the words fields and/or application:

    The need to exert power, when thwarted in the open fields of life, is the more likely to assert itself in trifles.
    Charles Horton Cooley (1864–1929)

    Preaching is the expression of the moral sentiment in application to the duties of life.
    Ralph Waldo Emerson (1803–1882)