module Grammar:Extensible grammars.sig..end
This module implements the Camlp5 extensible grammars system.
Grammars entries can be extended using the EXTEND statement,
added by loading the Camlp5 pa_extend.cmo file.
type g
typetoken =string * string
val gcreate : token Plexing.lexer -> gval tokens : g -> string -> (string * int) listExamples:
Grammar.tokens g "" returns the keywords list.Grammar.tokens g "IDENT" returns the list of all usages
of the pattern "IDENT" in the EXTEND statements.val glexer : g -> token Plexing.lexertype parsable
val parsable : g -> char Stream.t -> parsableEntry.parse_parsable belowmodule Entry:sig..end
val of_entry : 'a Entry.e -> gmodule Unsafe:sig..end
typeparse_algorithm =Gramext.parse_algorithm=
| |
Predictive |
|||
| |
Backtracking |
|||
| |
DefaultAlgorithm |
(* | Type of algorithm used in grammar entries.
Predictive: use imperative streams with predictive parsing
Backtracking: use functional streams with full backtracking
DefaultAlgorithm: found in the variable backtrack_parse below.
The default, when a grammar is created, is DefaultAlgorithm. | *) |
val set_algorithm : g -> parse_algorithm -> unitval backtrack_parse : bool Pervasives.refTrue, the default parsing uses full backtracking. If False,
it uses parsing with normal streams. If the environment variable
CAMLP5PARAM contains "b", the default is True; otherwise, the
default is False.val backtrack_stalling_limit : int Pervasives.refmodule type GLexerType =sig..end
Grammar.GMake: te is the
type of the tokens.
module type S =sig..end
Grammar.GMake.
module GMake:
val skip_item : 'a -> 'aGrammar.skip_item x can be called in a semantic action of
a grammar rule to ask the grammar to skip that item if it
is called in a list (LIST0 or LIST1). The function returns
the item itself (for typing reasons) but its value is ignored.
This function is used to allow IFDEF and IFNDEF for cases of
constructor declarations and pattern matchings.val error_verbose : bool Pervasives.refFalseval warning_verbose : bool Pervasives.refTrueval strict_parsing : bool Pervasives.refFalseval print_entry : Format.formatter -> 'a Gramext.g_entry -> unitval iter_entry : ('a Gramext.g_entry -> unit) -> 'a Gramext.g_entry -> unitGrammar.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 -> 'bGrammar.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.val reinit_entry_functions : 'a Gramext.g_entry -> unitval loc_of_token_interval : int -> int -> Ploc.tval extend : ('a Gramext.g_entry * Gramext.position option *
(string option * Gramext.g_assoc option *
('a Gramext.g_symbol list * Gramext.g_action) list)
list)
list -> unitval delete_rule : 'a Entry.e -> token Gramext.g_symbol list -> unitval parse_top_symb : 'a Gramext.g_entry -> 'a Gramext.g_symbol -> 'a Stream.t -> Obj.tval symb_failed_txt : 'a Gramext.g_entry -> 'a Gramext.g_symbol -> 'a Gramext.g_symbol -> stringval create_local_entry : g -> string -> 'a Entry.e