.TH "Parsing" 3o source: 2019-01-25 OCamldoc "OCaml library" .SH NAME Parsing \- The run-time library for parsers generated by ocamlyacc. .SH Module Module Parsing .SH Documentation .sp Module .BI "Parsing" : .B sig end .sp The run\-time library for parsers generated by .B ocamlyacc \&. .sp .sp .sp .I val symbol_start : .B unit -> int .sp .B symbol_start and .B Parsing\&.symbol_end are to be called in the action part of a grammar rule only\&. They return the offset of the string that matches the left\-hand side of the rule: .B symbol_start() returns the offset of the first character; .B symbol_end() returns the offset after the last character\&. The first character in a file is at offset 0\&. .sp .I val symbol_end : .B unit -> int .sp See .B Parsing\&.symbol_start \&. .sp .I val rhs_start : .B int -> int .sp Same as .B Parsing\&.symbol_start and .B Parsing\&.symbol_end , but return the offset of the string matching the .B n th item on the right\-hand side of the rule, where .B n is the integer parameter to .B rhs_start and .B rhs_end \&. .B n is 1 for the leftmost item\&. .sp .I val rhs_end : .B int -> int .sp See .B Parsing\&.rhs_start \&. .sp .I val symbol_start_pos : .B unit -> Lexing.position .sp Same as .B symbol_start , but return a .B position instead of an offset\&. .sp .I val symbol_end_pos : .B unit -> Lexing.position .sp Same as .B symbol_end , but return a .B position instead of an offset\&. .sp .I val rhs_start_pos : .B int -> Lexing.position .sp Same as .B rhs_start , but return a .B position instead of an offset\&. .sp .I val rhs_end_pos : .B int -> Lexing.position .sp Same as .B rhs_end , but return a .B position instead of an offset\&. .sp .I val clear_parser : .B unit -> unit .sp Empty the parser stack\&. Call it just after a parsing function has returned, to remove all pointers from the parser stack to structures that were built by semantic actions during parsing\&. This is optional, but lowers the memory requirements of the programs\&. .sp .I exception Parse_error .sp Raised when a parser encounters a syntax error\&. Can also be raised from the action part of a grammar rule, to initiate error recovery\&. .sp .I val set_trace : .B bool -> bool .sp Control debugging support for .B ocamlyacc \-generated parsers\&. After .B Parsing\&.set_trace true , the pushdown automaton that executes the parsers prints a trace of its actions (reading a token, shifting a state, reducing by a rule) on standard output\&. .B Parsing\&.set_trace false turns this debugging trace off\&. The boolean returned is the previous state of the trace flag\&. .sp .B "Since" 3.11.0 .sp