CAMLYACC(1)

NAME
camlyacc - a parser generator for Caml Light

SYNOPSIS
camlyacc [ -vs ] [ -bprefix ] grammar.mly

DESCRIPTION
camlyacc produces a parser from a context-free grammar specification with attached semantic actions, in the style of yacc(1). Assuming the input file is grammar.mly camlyacc outputs the two files grammar.mli and grammar.ml. The two output files must be compiled by Caml Light, and linked with the rest of the program. 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 semantic attribute of the corresponding entry point. Lexical analyzer functions are usually generated from a lexer specification by camllex(1). Lexer buffers are an abstract data type implemented in the standard library "lexing". Tokens are values from the concrete type "token", defined in the interface file grammar.mli produced by camlyacc.

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.

-s  Generate a grammar.ml file with smaller phrases. Semantic actions are presented in the grammar.ml output file as one large vector of functions. By default, this vector is built by a single phrase. When the grammar is large, or contains complicated semantic actions, the resulting phrase may require large amounts of memory to be compiled by Caml Light. With the -s option, the vector of actions is constructed incrementally, one phrase per action. This lowers the memory requirements for the compiler, but it is not possible anymore to infer the types of nonterminal symbols: typechecking is turned off on symbols that do not have a type specified by a %type directive.

-bprefix
    Name the output files prefix.ml, prefix.mli, prefix.output, instead of the default naming convention.

SEE ALSO
camllex(1)
The Caml Light user's manual,

chapter "Lexer and parser generators".
YACC - Yet Another Compiler Compiler,

by S. C. Johnson.
Compilers - Principles, Techniques, and Tools

(chapter 4), by A. V. Aho, R. Sethi, and J. D. Ullman.

DIAGNOSTICS
The number of reduce-reduce conflicts, shift-reduce conflicts, and unused rules is reported on the standard output. A more detailed report can be obtained with the -v flag.

BUGS
Error recovery is not implemented. Type checking is performed when compiling the `.ml' output file, not when compiling the grammar. This does not break type safety, since the `.ml' output file is well-typed iff the input grammar is well-typed. However, this results in type error messages that are somewhat hard to relate to the input grammar.