| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
exception ParseError of string |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
type norec |
| 26 |
type mayrec |
| 27 |
|
| 28 |
module type S = sig |
| 29 |
type keyword_state |
| 30 |
type te |
| 31 |
type 'c pattern |
| 32 |
type ty_pattern = TPattern : 'a pattern -> ty_pattern |
| 33 |
|
| 34 |
type peek_error = unit |
| 35 |
|
| 36 |
type 'a parser_v = ('a, peek_error) result |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
type 'a with_gstate |
| 48 |
|
| 49 |
|
| 50 |
type 'a with_kwstate |
| 51 |
|
| 52 |
|
| 53 |
type 'a with_estate |
| 54 |
|
| 55 |
|
| 56 |
type 'a mod_estate |
| 57 |
|
| 58 |
|
| 59 |
module Parsable : sig |
| 60 |
type t |
| 61 |
val make : ?loc:Loc.t -> (unit,char) Stream.t -> t |
| 62 |
val comments : t -> ((int * int) * string) list |
| 63 |
val loc : t -> Loc.t |
| 64 |
val consume : t -> int -> unit with_kwstate |
| 65 |
end |
| 66 |
|
| 67 |
module Entry : sig |
| 68 |
type 'a t |
| 69 |
val make : string -> 'a t mod_estate |
| 70 |
val parse : 'a t -> Parsable.t -> 'a with_gstate |
| 71 |
val name : 'a t -> string |
| 72 |
type 'a parser_fun = { parser_fun : keyword_state -> (keyword_state,te) LStream.t -> 'a parser_v } |
| 73 |
val of_parser : string -> 'a parser_fun -> 'a t mod_estate |
| 74 |
val parse_token_stream : 'a t -> (keyword_state,te) LStream.t -> 'a parser_v with_gstate |
| 75 |
val print : Format.formatter -> 'a t -> unit with_kwstate with_estate |
| 76 |
val is_empty : 'a t -> bool with_estate |
| 77 |
|
| 78 |
type any_t = Any : 'a t -> any_t |
| 79 |
val accumulate_in : any_t list -> any_t list CString.Map.t with_estate |
| 80 |
val all_in : unit -> any_t list CString.Map.t with_estate |
| 81 |
end |
| 82 |
|
| 83 |
module rec Symbol : sig |
| 84 |
|
| 85 |
type ('self, 'trec, 'a) t |
| 86 |
val nterm : 'a Entry.t -> ('self, norec, 'a) t |
| 87 |
val nterml : 'a Entry.t -> string -> ('self, norec, 'a) t |
| 88 |
val list0 : ('self, 'trec, 'a) t -> ('self, 'trec, 'a list) t |
| 89 |
val list0sep : |
| 90 |
('self, 'trec, 'a) t -> ('self, norec, unit) t -> |
| 91 |
('self, 'trec, 'a list) t |
| 92 |
val list1 : ('self, 'trec, 'a) t -> ('self, 'trec, 'a list) t |
| 93 |
val list1sep : |
| 94 |
('self, 'trec, 'a) t -> ('self, norec, unit) t -> |
| 95 |
('self, 'trec, 'a list) t |
| 96 |
val opt : ('self, 'trec, 'a) t -> ('self, 'trec, 'a option) t |
| 97 |
val self : ('self, mayrec, 'self) t |
| 98 |
val next : ('self, mayrec, 'self) t |
| 99 |
val token : 'c pattern -> ('self, norec, 'c) t |
| 100 |
val tokens : ty_pattern list -> ('self, norec, unit) t |
| 101 |
val rules : 'a Rules.t list -> ('self, norec, 'a) t |
| 102 |
|
| 103 |
end and Rule : sig |
| 104 |
|
| 105 |
type ('self, 'trec, 'f, 'r) t |
| 106 |
|
| 107 |
val stop : ('self, norec, 'r, 'r) t |
| 108 |
val next : |
| 109 |
('self, _, 'a, 'r) t -> ('self, _, 'b) Symbol.t -> |
| 110 |
('self, mayrec, 'b -> 'a, 'r) t |
| 111 |
val next_norec : |
| 112 |
('self, norec, 'a, 'r) Rule.t -> ('self, norec, 'b) Symbol.t -> |
| 113 |
('self, norec, 'b -> 'a, 'r) t |
| 114 |
|
| 115 |
end and Rules : sig |
| 116 |
|
| 117 |
type 'a t |
| 118 |
val make : (_, norec, 'f, Loc.t -> 'a) Rule.t -> 'f -> 'a t |
| 119 |
|
| 120 |
end |
| 121 |
|
| 122 |
module Production : sig |
| 123 |
type 'a t |
| 124 |
val make : ('a, _, 'f, Loc.t -> 'a) Rule.t -> 'f -> 'a t |
| 125 |
end |
| 126 |
|
| 127 |
type 'a single_extend_statement = |
| 128 |
string option * Gramext.g_assoc option * 'a Production.t list |
| 129 |
|
| 130 |
type 'a extend_statement = |
| 131 |
| Reuse of string option * 'a Production.t list |
| 132 |
|
| 133 |
| Fresh of Gramext.position * 'a single_extend_statement list |
| 134 |
|
| 135 |
|
| 136 |
val generalize_symbol : ('a, 'tr, 'c) Symbol.t -> ('b, norec, 'c) Symbol.t option |
| 137 |
|
| 138 |
|
| 139 |
val level_of_nonterm : ('a, norec, 'c) Symbol.t -> string option |
| 140 |
|
| 141 |
end |
| 142 |
|
| 143 |
|
| 144 |
module type ExtS = sig |
| 145 |
|
| 146 |
type keyword_state |
| 147 |
|
| 148 |
module EState : sig |
| 149 |
type t |
| 150 |
val empty : t |
| 151 |
end |
| 152 |
module GState : sig |
| 153 |
type t = { |
| 154 |
estate : EState.t; |
| 155 |
kwstate : keyword_state; |
| 156 |
recover : bool; |
| 157 |
has_non_assoc : bool; |
| 158 |
} |
| 159 |
end |
| 160 |
|
| 161 |
include S |
| 162 |
with type keyword_state := keyword_state |
| 163 |
and type 'a with_gstate := GState.t -> 'a |
| 164 |
and type 'a with_kwstate := keyword_state -> 'a |
| 165 |
and type 'a with_estate := EState.t -> 'a |
| 166 |
and type 'a mod_estate := EState.t -> EState.t * 'a |
| 167 |
|
| 168 |
type 's add_kw = { add_kw : 'c. 's -> 'c pattern -> 's } |
| 169 |
|
| 170 |
val safe_extend : 's add_kw -> EState.t -> 's -> 'a Entry.t -> 'a extend_statement -> EState.t * 's |
| 171 |
|
| 172 |
module Unsafe : sig |
| 173 |
val existing_entry : EState.t -> 'a Entry.t -> EState.t |
| 174 |
val existing_of_parser : EState.t -> 'a Entry.t -> 'a Entry.parser_fun -> EState.t |
| 175 |
end |
| 176 |
|
| 177 |
end |
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
module GMake (L : Plexing.S) : ExtS |
| 190 |
with type keyword_state := L.keyword_state |
| 191 |
and type te := L.te |
| 192 |
and type 'c pattern := 'c L.pattern |