2 @c This is part of the GNU Guile Reference Manual.
3 @c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2007, 2009, 2010
4 @c Free Software Foundation, Inc.
5 @c See the file guile.texi for copying conditions.
9 @section LALR(1) Parsing
11 The @code{(system base lalr)} module provides the
12 @uref{http://code.google.com/p/lalr-scm/, @code{lalr-scm} LALR(1) parser
13 generator by Dominique Boucher}. @code{lalr-scm} uses the same algorithm as GNU
14 Bison (@pxref{Introduction, Introduction to Bison,, bison, Bison@comma{} The
15 Yacc-compatible Parser Generator}). Parsers are defined using the
16 @code{lalr-parser} macro.
18 @deffn {Scheme Syntax} lalr-parser [@var{options}] @var{tokens} @var{rules}...
19 Generate an LALR(1) syntax analyzer. @var{tokens} is a list of symbols
20 representing the terminal symbols of the grammar. @var{rules} are the grammar
23 Each rule has the form @code{(@var{non-terminal} (@var{rhs} ...) : @var{action}
24 ...)}, where @var{non-terminal} is the name of the rule, @var{rhs} are the
25 right-hand sides, i.e., the production rule, and @var{action} is a semantic
26 action associated with the rule.
28 The generated parser is a two-argument procedure that takes a
29 @dfn{tokenizer} and a @dfn{syntax error procedure}. The tokenizer
30 should be a thunk that returns lexical tokens as produced by
31 @code{make-lexical-token}. The syntax error procedure may be called
32 with at least an error message (a string), and optionally the lexical
33 token that caused the error.
36 Please refer to the @code{lalr-scm} documentation for details.