1(* Parsing -- runtime library for parsers generated by mosmlyac            *)
2(* Based on the runtime library for camlyacc; copyright 1993 INRIA, France *)
3
4local open Vector Obj Lexing in
5
6val symbolStart : unit -> int
7val symbolEnd   : unit -> int
8val itemStart   : int -> int
9val itemEnd     : int -> int
10val clearParser : unit -> unit
11
12(* For internal use in generated parsers: *)
13
14type parseTables =
15    (* actions *)    (unit -> obj) vector  *
16    (* transl *)     int vector *
17    (* lhs *)        string *
18    (* len *)        string *
19    (* defred *)     string *
20    (* dgoto *)      string *
21    (* sindex *)     string *
22    (* rindex *)     string *
23    (* gindex *)     string *
24    (* tablesize *)  int *
25    (* table *)      string *
26    (* check *)      string
27
28exception yyexit of obj
29exception ParseError of (obj -> bool)
30
31val yyparse : parseTables -> int -> (lexbuf -> 'a) -> lexbuf -> 'b
32val peekVal : int -> 'a
33
34end
35
36(*
37   These functions are for use in mosmlyac-generated parsers.  For
38   further information, see the Moscow ML Owner's Manual.  For
39   examples, see mosml/examples/lexyacc and mosml/examples/calc.
40
41   A grammar definition (input to mosmlyac) consists of fragments of
42   this form
43
44       nonterm :
45          grsyms1   { action1 }
46        | grsyms2   { action2 }
47        | grsyms3   { action3 }
48        | ...
49
50   where the grsyms are sequences of grammar symbols, matching some
51   string of characters, and the actions are corresponding semantic
52   actions, written in ML.  The following functions can be used in the
53   semantic actions:
54
55   [symbolStart ()] returns the start position of the string that
56   matches the sequence of grammar symbols.  The first character in
57   the input stream has position 0.  May be called in a semantic
58   action only.
59
60   [symbolEnd ()] returns the end position, plus one, of the string
61   that matches the sequence of grammar symbols.  The first character
62   in the input stream has position 0.  May be called in a semantic
63   action only.
64
65   [itemStart i] returns the start position of the string that matches
66   the i'th grammar symbol in the sequence.  The first grammar symbol
67   has number 1.  The first character in the input stream has position
68   0.  May be called in a semantic action only.
69
70   [itemEnd i] returns the end position, plus one, of the string that
71   matches the i'th grammar symbol in the sequence.  The first grammar
72   symbols has number 1.  The first character in the input stream has
73   position 0.  May be called in a semantic action only.
74
75   [clearParser ()] clears the parser stack.  It may be called after a
76   parsing function has returned, to remove all pointers from the
77   parser stack to structures that were built by semantic actions
78   during parsing.  This is not strict necessary, but reduces the
79   memory requirements of the program.
80*)
81