Module Cf_lex.Op

module Op: sig .. end

Open this module to bring the operator functions for simple parsers into the current scope.


include Cf_lex.Expr_Op_T

Include the expression operators common among lexical analyzers.

val ($=) : Cf_lex.x -> 'a -> 'a Cf_lex.r

Literal token rule. Use e $= obj to compose a rule that outputs the literal object obj when the expression e is recognized.

val ($>) : Cf_lex.x -> (string -> 'a) -> 'a Cf_lex.r

String token rule. Use e $> f to compose a rule that applies the string recognized by the expression e to the tokenizer function f to produce its result.

val ($@) : Cf_lex.x -> (int -> 'a Cf_lex.t) -> 'a Cf_lex.r

Advanced token rule. Use e $@ f to compose a rule that applies the length of the character sequence recognized by the expression e to the advanced tokenizer function f to obtain a parser that produces the output of the rule and makes any other manipulations necessary to continue parsing the input stream. If the parser returned by f does not recognize the input, then no output is produced and no other rules are matched.

val (!@) : 'a Cf_lex.r list -> 'a Cf_lex.r

Rule aggregation. Use this operator to combine a list of rules into a single rule.

val ?~ : Cf_lex.x -> string Cf_lex.t

String parser. Use ?~x to create a simple parser that recognizes any string that matches the expression x. Note: Care should be taken when composing parsers with this operator to keep the lazy DFA from being recreated in every pass.

val ?$ : string -> string Cf_lex.t

String parser. Use ?$s to create a simple parser that recognizes any string that matches the regular expression specified in the string s according to the grammar in the Cf_regex module. Raises Cf_regex.Error if the string is not a regular expression. Note: Care should be taken when composing parsers with this operator to keep from parsing the argument string in every pass.