fix the buggy parser example in the Genlex documentation (issue reported by Armael Geneau)

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13613 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Gabriel Scherer 2013-04-28 14:28:55 +00:00
parent 35d1dde122
commit c089c9a6dd
1 changed files with 7 additions and 6 deletions

View File

@ -27,13 +27,14 @@
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
let rec parse_expr = parser
| [< n1 = parse_atom; n2 = parse_remainder n1 >] -> n2
and parse_atom = parser
| [< 'Int n >] -> n
| [< 'Kwd "("; n = parse_expr; 'Kwd ")" >] -> n
and parse_remainder n1 = parser
[< 'Kwd "+"; n2 = parse_expr >] -> n1+n2
| ...
| [< 'Kwd "+"; n2 = parse_expr >] -> n1+n2
| [< >] -> n1
]}
One should notice that the use of the [parser] keyword and associated