Previous Contents
Appendix A Quotations for creating abstract syntax trees
The file ``q_MLast.cmo'' in Camlp4 library directory provides some quotations expanders to create abstract syntax tree nodes using a concrete syntax.

The types generated are defined in the module ``MLast'' provided in the library, but not documented, for the normal usage is to use these quotations.

A.1 General rules

The syntax used in quotations use the revised concrete syntax (chapter 5) with a system of ``antiquotations'' to insert expressions or patterns of the language in the concrete syntax, to make all possible values of the syntax tree nodes. These antiquotations have the format:
antiquotation ::= $ { name : } string $
name ::= identifier
where string is any sequence of characters not holding any $.

A.2 Quotation expr

Syntax tree nodes for language expressions, of type Ast.expr. The basic nodes are:
<:expr< $e1$ . $e2$ >>: access in records and in modules.
<:expr< $anti:e$ >>: location node for Ast antiquotations (temporary node).
<:expr< $e1$ $e2$ >>: application.
<:expr< $e1$ .( $e2$ ) >>: array access.
<:expr< [| $list:el$ |] >>: array.
<:expr< $e1$ := $e2$ >>: assignment.
<:expr< $chr:c$ >>: (escaped) character constant.
<:expr< $flo:s$ >>: float constant.
<:expr< for $s$ = $e1$ $to:b$ $e2$ do { $list:el$ } >>: for loop.
<:expr< fun [ $list:pwel$ ] >>: function.
<:expr< if $e1$ then $e2$ else $e3$ >>: if statement.
<:expr< $int:s$ >>: integer constant.
<:expr< let $rec:b$ $list:pel$ in $e$ >>: let statement.
<:expr< ( $lid:s$ >>: identifier starting with a lowercase letter.
<:expr< match $e$ with [ $list:pwel$ ] >>: match statement.
<:expr< { $list:eel$ } >>: record.
<:expr< do { $list:el$ } >