Module Grammar


module Grammar: sig  end
Extensible grammars.

This module implements the Camlp4 extensible grammars system. Grammars entries can be extended using the EXTEND statement, added by loading the Camlp4 pa_extend.cmo file.


type g 
The type for grammars, holding entries.
val gcreate : Token.t Token.glexer -> g
Create a new grammar, without keywords, using the lexer given as parameter.
val tokens : g -> string -> (string * int) list
Given a grammar and a token pattern constructor, returns the list of the corresponding values currently used in all entries of this grammar. The integer is the number of times this pattern value is used.

Examples:


val glexer : g -> Token.t Token.glexer
Return the lexer used by the grammar
module Entry: sig  end
Module to handle entries.
val of_entry : 'a Entry.e -> g
Return the grammar associated with an entry.


Clearing grammars and entries


module Unsafe: sig  end
Module for clearing grammars and entries.


Functorial interface



Alternative for grammars use. Grammars are no more Ocaml values: there is no type for them. Modules generated preserve the rule "an entry cannot call an entry of another grammar" by normal OCaml typing.

module type GLexerType = sig  end
The input signature for the functor Grammar.GMake: te is the type of the tokens.
module type S = sig  end
Signature type of the functor Grammar.GMake.
module GMake: functor (L : GLexerType) -> sig  end


Miscellaneous


val error_verbose : bool ref
Flag for displaying more information in case of parsing error; default = False
val warning_verbose : bool ref
Flag for displaying warnings while extension; default = True
val strict_parsing : bool ref
Flag to apply strict parsing, without trying to recover errors; default = False
val print_entry : Format.formatter -> 'a Gramext.g_entry -> unit
General printer for all kinds of entries (obj entries)
val iter_entry : ('a Gramext.g_entry -> unit) -> 'a Gramext.g_entry -> unit
Grammar.iter_entry f e applies f to the entry e and transitively all entries called by e. The order in which the entries are passed to f is the order they appear in each entry. Each entry is passed only once.
val fold_entry : ('a Gramext.g_entry -> 'b -> 'b) -> 'a Gramext.g_entry -> 'b -> 'b
Grammar.fold_entry f e init computes (f eN .. (f e2 (f e1 init))), where e1 .. eN are e and transitively all entries called by e. The order in which the entries are passed to f is the order they appear in each entry. Each entry is passed only once.