1 (***********************************************************************)
5 (* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
7 (* Copyright 1996 Institut National de Recherche en Informatique et *)
8 (* en Automatique. All rights reserved. This file is distributed *)
9 (* under the terms of the GNU Library General Public License, with *)
10 (* the special exception on linking described in file ../LICENSE. *)
12 (***********************************************************************)
14 (* $Id: parsing.mli 8983 2008-08-06 09:38:25Z xleroy $ *)
16 (** The run-time library for parsers generated by [ocamlyacc]. *)
18 val symbol_start : unit -> int
19 (** [symbol_start] and {!Parsing.symbol_end} are to be called in the
20 action part of a grammar rule only. They return the offset of the
21 string that matches the left-hand side of the rule: [symbol_start()]
22 returns the offset of the first character; [symbol_end()] returns the
23 offset after the last character. The first character in a file is at
26 val symbol_end : unit -> int
27 (** See {!Parsing.symbol_start}. *)
29 val rhs_start : int -> int
30 (** Same as {!Parsing.symbol_start} and {!Parsing.symbol_end}, but
31 return the offset of the string matching the [n]th item on the
32 right-hand side of the rule, where [n] is the integer parameter
33 to [rhs_start] and [rhs_end]. [n] is 1 for the leftmost item. *)
35 val rhs_end : int -> int
36 (** See {!Parsing.rhs_start}. *)
38 val symbol_start_pos : unit -> Lexing.position;;
39 (** Same as [symbol_start], but return a [position] instead of an offset. *)
41 val symbol_end_pos : unit -> Lexing.position
42 (** Same as [symbol_end], but return a [position] instead of an offset. *)
44 val rhs_start_pos : int -> Lexing.position
45 (** Same as [rhs_start], but return a [position] instead of an offset. *)
47 val rhs_end_pos : int -> Lexing.position
48 (** Same as [rhs_end], but return a [position] instead of an offset. *)
50 val clear_parser : unit -> unit
51 (** Empty the parser stack. Call it just after a parsing function
52 has returned, to remove all pointers from the parser stack
53 to structures that were built by semantic actions during parsing.
54 This is optional, but lowers the memory requirements of the
58 (** Raised when a parser encounters a syntax error.
59 Can also be raised from the action part of a grammar rule,
60 to initiate error recovery. *)
62 val set_trace: bool -> bool
63 (** Control debugging support for [ocamlyacc]-generated parsers.
64 After [Parsing.set_trace true], the pushdown automaton that
65 executes the parsers prints a trace of its actions (reading a token,
66 shifting a state, reducing by a rule) on standard output.
67 [Parsing.set_trace false] turns this debugging trace off.
68 The boolean returned is the previous state of the trace flag. *)
74 (** The following definitions are used by the generated parsers only.
75 They are not intended to be used by user programs. *)
80 { actions : (parser_env -> Obj.t) array;
81 transl_const : int array;
82 transl_block : int array;
93 error_function : string -> unit;
95 names_block : string }
97 exception YYexit of Obj.t
100 parse_tables -> int -> (Lexing.lexbuf -> 'a) -> Lexing.lexbuf -> 'b
101 val peek_val : parser_env -> int -> 'a
102 val is_current_lookahead : 'a -> bool
103 val parse_error : string -> unit