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 -> g
val tokens : g -> string -> (string * int) list
Examples:
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.lexer
type
parsable
val parsable : g -> char Stream.t -> parsable
Entry.parse_parsable
belowmodule Entry:sig
..end
val of_entry : 'a Entry.e -> g
module 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 -> unit
val backtrack_parse : bool Pervasives.ref
True
, 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.ref
module 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 -> 'a
Grammar.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.ref
False
val warning_verbose : bool Pervasives.ref
True
val strict_parsing : bool Pervasives.ref
False
val print_entry : Format.formatter -> 'a Gramext.g_entry -> unit
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.val reinit_entry_functions : 'a Gramext.g_entry -> unit
val loc_of_token_interval : int -> int -> Ploc.t
val 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 -> unit
val delete_rule : 'a Entry.e -> token Gramext.g_symbol list -> unit
val parse_top_symb : 'a Gramext.g_entry -> 'a Gramext.g_symbol -> 'a Stream.t -> Obj.t
val symb_failed_txt : 'a Gramext.g_entry -> 'a Gramext.g_symbol -> 'a Gramext.g_symbol -> string
val create_local_entry : g -> string -> 'a Entry.e