* [Caml-list] stream parser jump-back
@ 2002-08-04 18:59 Max Kirillov
2002-08-05 6:40 ` Daniel de Rauglaudre
0 siblings, 1 reply; 3+ messages in thread
From: Max Kirillov @ 2002-08-04 18:59 UTC (permalink / raw)
To: caml-list
Hello!
Is it possible in a stream parser to parse again already
accepted token.
An example (a little incorrect) follows.
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 -> ... ]]
"Note" may be parsed as either module expression or a usual
one. But, expr cannot be followed by a period (that's wrong,
I know, but let's forget about it for a while). Then,
writing None, I've got the Stream.Error and parsing error.
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)?
Thanks for your attention.
Max.
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] stream parser jump-back
2002-08-04 18:59 [Caml-list] stream parser jump-back Max Kirillov
@ 2002-08-05 6:40 ` Daniel de Rauglaudre
2002-08-06 3:05 ` Max Kirillov
0 siblings, 1 reply; 3+ messages in thread
From: Daniel de Rauglaudre @ 2002-08-05 6:40 UTC (permalink / raw)
To: caml-list
Hi,
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.
No.
> 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 (pa_o.ml, 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.
--
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] stream parser jump-back
2002-08-05 6:40 ` Daniel de Rauglaudre
@ 2002-08-06 3:05 ` Max Kirillov
0 siblings, 0 replies; 3+ messages in thread
From: Max Kirillov @ 2002-08-06 3:05 UTC (permalink / raw)
To: caml-list
On Mon, Aug 05, 2002 at 08:40:39AM +0200, Daniel de Rauglaudre wrote:
>> Is it possible in a stream parser to parse again already
>> accepted token.
> No.
Sad.
Well, in the case I can simply note that little of module_expr
may be misparsed as expr, and define something like
module_expr_or_expr:
[[ ... -> (<:module_expr< ...>>,<:expr< ...>>)]]
expr:
[[ (m1,_) = module_expr_or_expr; "." ...
| (_,e1) = module_expr_or_expr -> e1
]]
and so on.
> You can add a grammar entry defined by a parser. There are examples of
> that in the "normal" syntax (pa_o.ml, 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.
Thank you.
That funcs use Stream.npeek to get a content of the stream,
than parse it manually. Hmm...
Max.
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-08-06 3:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-04 18:59 [Caml-list] stream parser jump-back Max Kirillov
2002-08-05 6:40 ` Daniel de Rauglaudre
2002-08-06 3:05 ` Max Kirillov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox