]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/ocaml/contrib/stdlib/parsing.mli
update
[l4.git] / l4 / pkg / ocaml / contrib / stdlib / parsing.mli
1 (***********************************************************************)
2 (*                                                                     *)
3 (*                           Objective Caml                            *)
4 (*                                                                     *)
5 (*            Xavier Leroy, projet Cristal, INRIA Rocquencourt         *)
6 (*                                                                     *)
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.     *)
11 (*                                                                     *)
12 (***********************************************************************)
13
14 (* $Id: parsing.mli 8983 2008-08-06 09:38:25Z xleroy $ *)
15
16 (** The run-time library for parsers generated by [ocamlyacc]. *)
17
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
24    offset 0. *)
25
26 val symbol_end : unit -> int
27 (** See {!Parsing.symbol_start}. *)
28
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. *)
34
35 val rhs_end : int -> int
36 (** See {!Parsing.rhs_start}. *)
37
38 val symbol_start_pos : unit -> Lexing.position;;
39 (** Same as [symbol_start], but return a [position] instead of an offset. *)
40
41 val symbol_end_pos : unit -> Lexing.position
42 (** Same as [symbol_end], but return a [position] instead of an offset. *)
43
44 val rhs_start_pos : int -> Lexing.position
45 (** Same as [rhs_start], but return a [position] instead of an offset. *)
46
47 val rhs_end_pos : int -> Lexing.position
48 (** Same as [rhs_end], but return a [position] instead of an offset. *)
49
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
55    programs. *)
56
57 exception Parse_error
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. *)
61
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. *)
69
70 (**/**)
71
72 (** {6  } *)
73
74 (** The following definitions are used by the generated parsers only.
75    They are not intended to be used by user programs. *)
76
77 type parser_env
78
79 type parse_tables =
80   { actions : (parser_env -> Obj.t) array;
81     transl_const : int array;
82     transl_block : int array;
83     lhs : string;
84     len : string;
85     defred : string;
86     dgoto : string;
87     sindex : string;
88     rindex : string;
89     gindex : string;
90     tablesize : int;
91     table : string;
92     check : string;
93     error_function : string -> unit;
94     names_const : string;
95     names_block : string }
96
97 exception YYexit of Obj.t
98
99 val yyparse :
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