|
q_MLast.cmo
'' in Camlp4 library directory provides
some quotations expanders to create abstract syntax tree nodes using a
concrete syntax.MLast
''
provided in the library, but not documented, for the normal usage is
to use these quotations.
|
antiquotation ::= $ { name : } string $ |
name ::= identifier |
$
.
|
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$ } >>
: sequence.
<:expr< $e1$ .[ $e2$ ] >>
: string access.
<:expr< $str:s$ >>
: (escaped) string constant.
<:expr< try $e$ with [ $list:pwel$ ] >>
:
try
statement.
<:expr< ( $list:el$ ) >>
: tuple.
<:expr< ( $e$ : $t$ ) >>
: type constraint.
<:expr< $uid:s$ >>
: identifier starring with an
uppercase letter.
<:expr< while $e$ do { $list:el$ } >>
:
while
statement.
|
Ast.patt
. The basic nodes are:
<:patt< $p1$ . $p2$ >>
: access in module.
<:patt< $anti:e$ >>
: location node for Ast antiquotations
(temporary node).
<:patt< ( $p1$ as $p2$ ) >>
: alias.
<:patt< _ >>
: wildcard.
<:patt< $p1$ $p2$ >>
: application.
<:patt< $chr:c$ >>
: (escaped) character constant.
<:patt< $int:s$ >>
: integer constant.
<:patt< $lid:i$ >>
: identifier starting with a
lowercase letter.
<:patt< $p1$ | $p2$ >>
: ``or'' pattern.
<:patt< $p1$ .. $p2$ >>
: range.
<:patt< { $ppl$ } >>
: record.
<:patt< $str:s$ >>
: (escaped) string constant.
<:patt< ( $list:pl$ ) >>
: tuple.
<:patt< ( $p$ : $t$ ) >>
: type constraint.
<:patt< $uid:s$ >>
: identifier starting with an
uppercase letter.
|
Ast.ctyp
. The basic nodes are:
<:ctyp< $t1$ . $t2$ >>
: access in module.
<:ctyp< $t1$ as $t2$ >>
: type alias
<:ctyp< _ >>
: wildcard.
<:ctyp< $t1$ $t2$ >>
: application.
<:ctyp< $t1$ -> $t2$ >>
: arrow.
<:ctyp< $lid:s$ >>
: identifier starting with a
lowercase letter.
<:ctyp< '$s$ >>
: type variable.
<:ctyp< $t1$ == $t2$ >>
: type manifest.
<:ctyp< { $list:sbtl$ } >>
: record definition.
<:ctyp< [ $list:stll$ ] >>
: concrete type definition.
<:ctyp< ( $list:tl$ ) >>
: tuple.
<:ctyp< $uid:s$ >>
: identifier starting with an
uppercase letter.
|
Ast.sig_item
. The basic nodes are:
<:sig_item< declare $list:sil$ end >>
: declare.
<:sig_item< exception $s$ of $list:tl$ >>
:
exception declaration.
<:sig_item< external $s$ : $t$ = $list:sl$ >>
:
declaration of external.
<:sig_item< module $s$ : $mt$ >>
: module declaration.
<:sig_item< module type $s$ = $mt$ >>
: module type
declaration.
<:sig_item< open $sl$ >>
: open.
<:sig_item< type $list:sslt$ >>
: type declaration.
<:sig_item< value $s$ : $t$ >>
: variable declaration.
|
Ast.str_item
. The basic nodes are:
<:str_item< declare $list:stl$ end >>
: declare.
<:str_item< exception $s$ of $list:tl$ >>
: exception
declaration.
<:str_item< $exp:e$ >>
: toplevel expression.
<:str_item< external $s$ : $t$ = $list:sl$ >>
:
declaration of external.
<:str_item< module $s$ = $me$ >>
: module declaration.
<:str_item< module type $s$ = $mt$ >>
: module type
declaration.
<:str_item< open $sl$ >>
: open.
<:str_item< type $list:sslt$ >>
: type declaration.
<:str_item< value $rec:b$ $list:pel$ >>
: variables
definition.
|
Ast.module_type
. The basic nodes are:
<:module_type< $mt1$ . $mt2$ >>
: access in module.
<:module_type< $mt1$ $mt2$ >>
: application.
<:module_type< functor ( $s$ : $mt1$ ) -> $mt2$ >>
: functor.
<:module_type< $lid:i$ >>
: identifier starting with a
lowercase letter.
<:module_type< sig $list:sil$ end >>
: signature.
<:module_type< $uid:i$ >>
: identifier starting with an
uppercase letter.
<:module_type< $mt$ with $list:wcl$ >>
: module type
with constraint.
|
Ast.module_expr
. The basic nodes are:
<:module_expr< $me1$ . $me2$ >>
: access in module.
<:module_expr< $me1$ $me2$ >>
: application.
<:module_expr< functor ( $s$ : $mt$ ) -> $me$ >>
: functor.
<:module_expr< struct $list:stl$ end >>
: structure.
<:module_expr< ( $me$ : $mt$ ) ] >>
: module type constraint.
<:module_expr< $uid:i$ >>
: identifier starting with an
uppercase letter.
|
Ast.class_expr
. The basic nodes are:
<:class_expr< $ce$ $e$ >>
: application of a class
to an expression.
<:class_expr< $list:sl$ [ $list:tl$ ] >>
: class
constructor with its parameters (sl
is a string list
representing its access list, and tl
a type list). If no
parameter, the [ ]
part can be omitted.
<:class_expr< fun $p$ -> $ce$ >>
: class function
<:class_expr< let $rec:b$ $list:lb$ in $ce$ >>
: let binding
<:class_expr< object $p$ $list:csil$ end >>
: object
<:class_expr< ( $ce$ : $ct$ ) >>
: type constraint
|
Ast.class_type
. The basic nodes are:
<:class_type< $list:sl$ [ $list:tl$ ] >>
: class
constructor with its parameters (sl
is a string list
representing its access list, and tl
a type list). If no
parameter, the [ ]
part can be omitted.
<:class_type< [ $t$ ] -> $ct$ >>
: arrow class type
<:class_type< object $s$ $list:csil$ end >>
: class
object type
|
Ast.class_sig_item
. The basic nodes are:<:class_type< type $t1$ = $t2$ >>
: constraint.
<:class_type< declare $list:csil$ end >>
: declare.
<:class_type< inherit $ct$ >>
: inheritance.
<:class_type< method $s$ : $t$ >>
: method type.
<:class_type< method private $s$ : $t$ >>
: private
method type.
<:class_type< value $mut:m$ $s$ = $t$ >>
: value.
<:class_type< method virtual $s$ : $t$ >>
: virtual method type.
<:class_type< method virtual private $s$ : $t$ >>
:
virtual private method type.