Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] stream parser jump-back
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Daniel de Rauglaudre <daniel.de_rauglaudre@i...>
Subject: Re: [Caml-list] stream parser jump-back

On Mon, Aug 05, 2002 at 01:59:38AM +0700, Max Kirillov wrote:

> Is it possible in a stream parser to parse again already
> accepted token.


> I'd like to make this in camlp:
> A(B).c --> let module M = A(B) in M.c
> To do that, i write (scematically):
> expr:
> [[ m = module_expr; "."; e = expr -> ... ]]

This is complicated, because "module_expr" have several rules starting
with rules already starting "expr". This extension will introduce syntax
errors in many normal cases.

> So, can I write something like:
> [[ TRY (m = module_expr); "."; ... and so on, do get parsing
> failure insted of error, and push the successful head of failed
> structute back into a stream, to parse it again (as an expr
> now)?

You can add a grammar entry defined by a parser. There are examples of
that in the "normal" syntax (, in Camlp4, subdirectory etc).
See entries "test_ctyp_minusgreater", "test_label_eq",
"test_typevar_list_dot". But I consider they are "hacks" to make
some situation work.

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: