Module Excmd.Lexer
val pp_position : Format.formatter -> position -> Ppx_deriving_runtime.unitval show_position : position -> Ppx_deriving_runtime.string
exceptionLexError of position * string
val sedlex_of_buffer : buffer -> Sedlexing.lexbufConstructors
val buffer_of_sedlex : Sedlexing.lexbuf -> bufferval buffer_of_string : string -> bufferval token : Tokens.token located -> Tokens.tokenAccessors
val example_tokens : Tokens.token arrayA static list of all tokens available at runtime, with arbitrary (but legal) payloads when appropriate.
(Necessary for the incremental parser.)
val compare_token : Tokens.token -> Tokens.token -> boolval show_token : Tokens.token -> stringshow_token tokwill provide an arbitrary, unique string-representation of that token, useful for debugging purposes. e.g.show_token SEMICOLONwould return"SEMICOLON".For a more human-friendly version, see
example_of_token.
val example_of_token : Tokens.token -> string optionexample_of_token tokwill provide an example string that, when consumed by the lexer (in, of course, an appropriate position), would produce the given token. e.g.example_of_token FLAG_LONGwould produce"--flag".Notably, this *does not* produce a full, parseable input-fragment; simple an example of one token. e.g.
example_of_token COMMENTproduces"comment", not"/* comment */".
val token_is_erroneous : Tokens.token -> booltoken_is_erroneous tokindicates whether lexing should reasonably be expected to continue after readingtok.This lexer will return tokens, instead of raising exceptions, for some common failure-states; this allows error-handling to be lifted into the parser, and more importantly, allows incremental recovery. In the parser itself, this is handled simply by not handling these erroneous tokens; if you're calling the lexer directly for any reason, you can use this function to ensure valid output.
val token_body : Tokens.token -> string optiontoken_body tokproducesSome string_payloadif the token carries a body-payload, andNoneif that type of token has no payload (or in the case of errors - seetoken_is_erroneous.) e.g.token_body (IDENTIFIER "hi")yields"hi".
val token_is_erroneous : Tokens.token -> booltoken_is_erroneous tokindicates whether lexing should reasonably be expected to continue after readingtok.This lexer will return tokens, instead of raising exceptions, for some common failure-states; this allows error-handling to be lifted into the parser, and more importantly, allows incremental recovery. In the parser itself, this is handled simply by not handling these erroneous tokens; if you're calling the lexer directly for any reason, you can use this function to ensure valid output.
val token_error_message : Tokens.token -> string optiontoken_error_message tokproducesSome messageif the token represents a lexing-error (seetoken_is_erroneous), andNonefor all non-erroneous tokens.
val start_lnum : Tokens.token located -> intval start_cnum : Tokens.token located -> intval end_lnum : Tokens.token located -> intval end_cnum : Tokens.token located -> intval error_loc_exn : exn -> positionval error_desc_exn : exn -> stringval position_fname : position -> stringval position_lnum : position -> intval position_bol : position -> intval position_cnum : position -> int
Lexing functions
val next_loc : buffer -> Tokens.token locatedval next_loc_exn : buffer -> Tokens.token locatedval next : buffer -> Tokens.tokenval next_exn : buffer -> Tokens.tokenval gen_loc : buffer -> Tokens.token located genval gen_loc_exn : buffer -> Tokens.token located genval gen : buffer -> Tokens.token genval gen_exn : buffer -> Tokens.token genval tokens_loc : buffer -> Tokens.token located arrayval tokens_loc_exn : buffer -> Tokens.token located arrayval tokens : buffer -> Tokens.token arrayval tokens_exn : buffer -> Tokens.token arrayval show_loctoken : Tokens.token located -> stringshow_loctoken tokdisplays the internal OCaml representation of the located tokentok.
val string_of_loctoken : Tokens.token located -> stringstring_of_loctoken tokdisplays a simple, human-readable representation of the located tokentok.
val string_of_position : position -> stringstring_of_position posdisplays a simple, human-readable representation of the individual positionpos.