package batteries

  1. Overview
  2. Docs
A community-maintained standard library extension

Install

Dune Dependency

Authors

Maintainers

Sources

v3.7.2.tar.gz
md5=1fd7bddce07cf5d244fc9427f7b5e4d4
sha512=c0f2a0fdc8253e0ea999d8d4c58bfbf32b18d251a2e1d9656bf279de5f01a33e9aabac3af4d95f465f8b671e7711ebd37218043face233340a0c11b08fa62f78

doc/batteries.unthreaded/BatGenlex/Languages/Make/index.html

Module Languages.MakeSource

Create a lexer from a language definition

Parameters

module M : Definition

Signature

High-level API

Drop comments, present reserved operators and reserved names as Kwd, operators and identifiers as Ident, integer numbers as Int, floating-point numbers as Float and characters as Char.

If the language is not case_sensitive, identifiers and keywords are returned in lower-case.

Medium-level API

Remove any leading whitespaces

Sourceval ident : (char, string, BatCharParser.position) BatParserCo.t

Accepts any non-reserved identifier/operator. If the language is not case_sensitive, the identifier is returned in lower-case.

Accepts any identifier. If the language is not case_sensitive, the identifier is returned in lower-case.

Sourceval identifier : string -> (char, unit, BatCharParser.position) BatParserCo.t
Sourceval keyword : string -> (char, unit, BatCharParser.position) BatParserCo.t
Sourceval char_literal : (char, char, BatCharParser.position) BatParserCo.t

Accepts a character literal, i.e. one character (or an escape) between two quotes.

Sourceval string_literal : (char, string, BatCharParser.position) BatParserCo.t

Accepts a string, i.e. one sequence of characters or escapes between two double quotes, on one line.

Sourceval integer : (char, int, BatCharParser.position) BatParserCo.t

Parse an integer.

Sourceval float : (char, float, BatCharParser.position) BatParserCo.t

Parse a floating-point number.

Sourceval number : (char, [ `Float of float | `Integer of int ], BatCharParser.position) BatParserCo.t

Parse either an integer or a floating-point number.

Sourceval char : char -> (char, char, BatCharParser.position) BatParserCo.t

Low-level API

As CharParser.char, but case-insensitive if specified by case_sensitive.

Sourceval string : string -> (char, string, BatCharParser.position) BatParserCo.t

As CharParser.string, but case-insensitive if specified by case_sensitive.

Sourceval line_comment : (char, unit, BatCharParser.position) BatParserCo.t
Sourceval multiline_comment : (char, unit, BatCharParser.position) BatParserCo.t
Sourceval comment : (char, unit, BatCharParser.position) BatParserCo.t
Sourceval whitespaces : (char, unit, BatCharParser.position) BatParserCo.t

Apply this filter to your own parsers if you want them to ignore following comments.

OCaml

Innovation. Community. Security.