package fmlib
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=d47f6539af49a4c3e947dbfbe416c1e78d534897cd6d9d8e3660aae0cf8d9494
md5=d649b8a62403362bd3a24cbf1a9af590
doc/fmlib.fmlib_parse/Fmlib_parse/Generic/Make/Parser/index.html
Module Make.Parser
The final parser.
include Interfaces.PARSER
with type token = Token.t
and type final = Final.t
and type expect = Expect.t
and type semantic = Semantic.t
and type state = State.t
A parser p is a sink of token. As long as it signals needs_more p more token can be pushed into the parser via put token p or the input stream can be ended via put_end p.
If the parser does not need more token (has_ended p is equivalent to not (needs_more p)), then it has either succeeded or failed.
If it has succeeded the final value is available via final p.
There are two types of failure:
- Syntax error: In that case
failed_expectations preturns the list of failed expectations.
- Semantic error: In that case
failed_semantic preturns the encountered semantic error.
The function state returns the user state.
The function lookaheads returns a pair. The first part of the pair is an array of unprocessed lookahead token and the second part is a flag indicating if the endtoken has been received via put_end.
type token = Token.tToken type.
type state = State.tUser state.
type final = Final.tType of the final object constructed in case of success.
type expect = Expect.tType of a failed expectation.
type semantic = Semantic.tType a semantic error.
val needs_more : t -> boolneeds_more p Does the parser p need more token?
val has_ended : t -> boolhas_ended p Has the parser p ended parsing and either succeeded or failed?
has_ended p is the same as not (needs_more p)
put token p Push token into the parser p.
Even if the parser has ended, more token can be pushed into the parser. The parser stores the token as lookahead token.
val has_succeeded : t -> boolhas_succeeded p Has the parser p succeeded?
val has_failed_syntax : t -> boolhas_failed_syntax p Has the parser p failed with a syntax error?
val has_failed_semantic : t -> boolhas_failed_semantic p Has the parser p failed with a semantic error?
final p The final object constructed by the parser p in case of success.
Precondition: has_succeeded p
failed_expectations p The failed expectations due to a syntax error.
Precondition: has_failed_syntax p
failed_semantic p The failed semantic error.
Precondition: has_failed_semantic p