Module Attribute.Parse

The interface to the abstract parse tree.

The parse tree is a functionally an s-expression.

type tree
type error = ..

an extensible type for reporting ill-formed attributes.

type error +=
  1. | Expect_atom
  2. | Expect_list
val atom : tree -> string option

atom tree is Some atom if tree is an atom.

val list : tree -> tree list option

list tree is Some list if tree is an list.

val tree : atom:(string -> 'a) -> list:(tree list -> 'a) -> tree -> 'a

tree ~atom:f ~list:g tree parses tree.

Calls f x if atom tree is not None, otherwise calls g x.

val fail : error -> tree list -> _

fail problem tree reports an ill-formed attribute declaration.

The passed tree is used to properly report error that references the original source code and its location.

It could be an empty if the problem is somewhat generic and doesn't reference any particular tree or source.