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 of, 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)

    a child’s
    Forgotten mornings when he walked with his mother
    Through the parables
    Of sunlight
    And the legends of the green chapels

    And the twice-told fields of infancy
    Dylan Thomas (1914–1953)

    The application requisite to the duties of the office I hold [governor of Virginia] is so excessive, and the execution of them after all so imperfect, that I have determined to retire from it at the close of the present campaign.
    Thomas Jefferson (1743–1826)