Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

genlex(3) [centos man page]

Genlex(3)							   OCaml library							 Genlex(3)

NAME
Genlex - A generic lexical analyzer. Module Module Genlex Documentation Module Genlex : sig end A generic lexical analyzer. This module implements a simple ``standard'' lexical analyzer, presented as a function from character streams to token streams. It imple- ments roughly the lexical conventions of OCaml, but is parameterized by the set of keywords of your language. Example: a lexer suitable for a desk calculator is obtained by let lexer = make_lexer ["+";"-";"*";"/";"let";"="; ( ; ) ] The associated parser would be a function from token stream to, for instance, int , and would have rules such as: let parse_expr = parser [< 'Int n >] -> n | [< 'Kwd ( ; n = parse_expr; 'Kwd ) >] -> n | [< n1 = parse_expr; n2 = parse_remainder n1 >] -> n2 and parse_remainder n1 = parser [< 'Kwd + ; n2 = parse_expr >] -> n1+n2 | ... One should notice that the use of the parser keyword and associated notation for streams are only available through camlp4 extensions. This means that one has to preprocess its sources e. g. by using the -pp command-line switch of the compilers. type token = | Kwd of string | Ident of string | Int of int | Float of float | String of string | Char of char The type of tokens. The lexical classes are: Int and Float for integer and floating-point numbers; String for string literals, enclosed in double quotes; Char for character literals, enclosed in single quotes; Ident for identifiers (either sequences of letters, digits, under- scores and quotes, or sequences of ``operator characters'' such as + , * , etc); and Kwd for keywords (either identifiers or single ``spe- cial characters'' such as ( , } , etc). val make_lexer : string list -> char Stream.t -> token Stream.t Construct the lexer function. The first argument is the list of keywords. An identifier s is returned as Kwd s if s belongs to this list, and as Ident s otherwise. A special character s is returned as Kwd s if s belongs to this list, and cause a lexical error (exception Parse_error ) otherwise. Blanks and newlines are skipped. Comments delimited by (* and *) are skipped as well, and can be nested. OCamldoc 2014-06-09 Genlex(3)

Check Out this Related Man Page

JOCAMLYACC(1)						      General Commands Manual						     JOCAMLYACC(1)

NAME
jocamlyacc - The JoCaml parser generator SYNOPSIS
jocamlyacc [ -v ] [ -bprefix ] filename.mly DESCRIPTION
The jocamlyacc(1) command produces a parser from a LALR(1) context-free grammar specification with attached semantic actions, in the style of yacc(1). Assuming the input file is grammar.mly, running jocamlyacc produces Caml code for a parser in the file grammar.ml, and its interface in file grammar.mli. The generated module defines one parsing function per entry point in the grammar. These functions have the same names as the entry points. Parsing functions take as arguments a lexical analyzer (a function from lexer buffers to tokens) and a lexer buffer, and return the seman- tic attribute of the corresponding entry point. Lexical analyzer functions are usually generated from a lexer specification by the jocam- llex(1) program. Lexer buffers are an abstract data type implemented in the standard library module Lexing. Tokens are values from the con- crete type token, defined in the interface file grammar.mli produced by jocamlyacc(1). OPTIONS
The jocamlyacc(1) command recognizes the following options: -v Generate a description of the parsing tables and a report on conflicts resulting from ambiguities in the grammar. The description is put in file grammar.output. -bprefix Name the output files prefix.ml, prefix.mli, prefix.output, instead of the default naming convention. SEE ALSO
jocamllex(1). The Objective Caml user's manual, chapter "Lexer and parser generators". JOCAMLYACC(1)
Man Page