Spec-Zone.ru › OCaml

Модуль Ast_iterator

module Ast_iterator: sig .. end

Ast_iterator.iterator позволяет инспектировать AST с использованием открытой рекурсии. Типичный маппер будет основан на Ast_iterator.default_iterator, тривиальном итераторе, и будет использовать его для обработки синтаксиса, который он не изменяет.

Предупреждение: этот модуль нестабилен и является частью compiler-libs.

Общий итератор дерева разбора

type iterator = {
attribute : iterator -> Parsetree.attribute -> unit;
attributes : iterator -> Parsetree.attribute list -> unit;
binding_op : iterator -> Parsetree.binding_op -> unit;
case : iterator -> Parsetree.case -> unit;
cases : iterator -> Parsetree.case list -> unit;
class_declaration : iterator -> Parsetree.class_declaration -> unit;
class_description : iterator -> Parsetree.class_description -> unit;
class_expr : iterator -> Parsetree.class_expr -> unit;
class_field : iterator -> Parsetree.class_field -> unit;
class_signature : iterator -> Parsetree.class_signature -> unit;
class_structure : iterator -> Parsetree.class_structure -> unit;
class_type : iterator -> Parsetree.class_type -> unit;
class_type_declaration : iterator -> Parsetree.class_type_declaration -> unit;
class_type_field : iterator -> Parsetree.class_type_field -> unit;
constructor_declaration : iterator -> Parsetree.constructor_declaration -> unit;
directive_argument : iterator -> Parsetree.directive_argument -> unit;
expr : iterator -> Parsetree.expression -> unit;
extension : iterator -> Parsetree.extension -> unit;
extension_constructor : iterator -> Parsetree.extension_constructor -> unit;
include_declaration : iterator -> Parsetree.include_declaration -> unit;
include_description : iterator -> Parsetree.include_description -> unit;
label_declaration : iterator -> Parsetree.label_declaration -> unit;
location : iterator -> Location.t -> unit;
module_binding : iterator -> Parsetree.module_binding -> unit;
module_declaration : iterator -> Parsetree.module_declaration -> unit;
module_substitution : iterator -> Parsetree.module_substitution -> unit;
module_expr : iterator -> Parsetree.module_expr -> unit;
module_type : iterator -> Parsetree.module_type -> unit;
module_type_declaration : iterator -> Parsetree.module_type_declaration -> unit;
open_declaration : iterator -> Parsetree.open_declaration -> unit;
open_description : iterator -> Parsetree.open_description -> unit;
pat : iterator -> Parsetree.pattern -> unit;
payload : iterator -> Parsetree.payload -> unit;
signature : iterator -> Parsetree.signature -> unit;
signature_item : iterator -> Parsetree.signature_item -> unit;
structure : iterator -> Parsetree.structure -> unit;
structure_item : iterator -> Parsetree.structure_item -> unit;
toplevel_directive : iterator -> Parsetree.toplevel_directive -> unit;
toplevel_phrase : iterator -> Parsetree.toplevel_phrase -> unit;
typ : iterator -> Parsetree.core_type -> unit;
row_field : iterator -> Parsetree.row_field -> unit;
object_field : iterator -> Parsetree.object_field -> unit;
type_declaration : iterator -> Parsetree.type_declaration -> unit;
type_extension : iterator -> Parsetree.type_extension -> unit;
type_exception : iterator -> Parsetree.type_exception -> unit;
type_kind : iterator -> Parsetree.type_kind -> unit;
value_binding : iterator -> Parsetree.value_binding -> unit;
value_description : iterator -> Parsetree.value_description -> unit;
with_constraint : iterator -> Parsetree.with_constraint -> unit;
}

Запись iterator реализует один «метод» на каждую синтаксическую категорию, используя стиль открытой рекурсии: каждый метод принимает в качестве первого аргумента итератор, который должен быть применён к дочерним элементам в синтаксическом дереве.

val default_iterator : iterator

Итератор по умолчанию, который реализует отображение «ничего не делать».

© 1995-2024 INRIA.
https://ocaml.org/manual/5.2/api/compilerlibref/Ast_iterator.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API