Higlo.LangSyntax highligthing
type token = | Bcomment of stringblock comment
*)| Constant of string| Directive of string| Escape of stringEscape sequence like \123
| Id of string| Keyword of int * string| Lcomment of stringone line comment
*)| Numeric of string| String of string| Symbol of int * string| Text of stringUsed for everything else
*)Tokens read in the given code. These names are inspired from the highlight tool. Keyword and Symbol are parametrized by an integer to be able to distinguish different families of keywords and symbols, as kwa, kwb, ..., in highlight.
val string_of_token : token -> stringFor debug printing.
exception Error of errorval string_of_error : error -> stringval pp : Format.formatter -> error -> unittype lexer = Sedlexing.lexbuf -> token listLexers are based on Sedlex. A lexer returns a list of tokens, in the same order they appear in the read string. Text tokens are merged by the parse function.
val get_lexer : string -> lexerget_lexer lang returns the lexer registered for the given language lang or raises Unknown_lang if no such language was registered.
val register_lang : string -> lexer -> unitIf a lexer was registered for the same language, it is not available any more.
val parse : ?raise_exn:bool -> lang:string -> string -> token listparse ?raise_exn ~lang code gets the lexer associated to lang and uses it to build a list of tokens. Consecutive Text tokens are merged. If no lexer is associated to the given language, then the function returns [Text code].