1Stdlib.Genlex(3)                 OCaml library                Stdlib.Genlex(3)
2
3
4

NAME

6       Stdlib.Genlex - no description
7

Module

9       Module   Stdlib.Genlex
10

Documentation

12       Module Genlex
13        : (module Stdlib__genlex)
14
15
16
17
18
19
20
21       type token =
22        | Kwd of string
23        | Ident of string
24        | Int of int
25        | Float of float
26        | String of string
27        | Char of char
28
29
30       The  type of tokens. The lexical classes are: Int and Float for integer
31       and floating-point numbers; String for  string  literals,  enclosed  in
32       double  quotes; Char for character literals, enclosed in single quotes;
33       Ident for identifiers (either sequences of letters, digits, underscores
34       and quotes, or sequences of 'operator characters' such as + , * , etc);
35       and Kwd for keywords (either identifiers or single 'special characters'
36       such as ( , } , etc).
37
38
39
40       val make_lexer : string list -> char Stream.t -> token Stream.t
41
42       Construct  the  lexer  function. The first argument is the list of key‐
43       words. An identifier s is returned as Kwd s if s belongs to this  list,
44       and  as  Ident s otherwise.  A special character s is returned as Kwd s
45       if s belongs to  this  list,  and  cause  a  lexical  error  (exception
46       Stream.Error  with  the  offending  lexeme as its parameter) otherwise.
47       Blanks and newlines are skipped. Comments delimited by (*  and  *)  are
48       skipped  as  well,  and  can  be  nested. A Stream.Failure exception is
49       raised if end of stream is unexpectedly reached.
50
51
52
53
54
55OCamldoc                          2019-07-30                  Stdlib.Genlex(3)
Impressum