* [Caml-list] Ocamlyacc reentrancy
@ 2004-05-01 3:08 skaller
2004-05-01 4:47 ` Jon Harrop
0 siblings, 1 reply; 6+ messages in thread
From: skaller @ 2004-05-01 3:08 UTC (permalink / raw)
To: caml-list
As far as I can tell, Ocamlyacc parsers aren't
reentrant: it uses static storage to hold
the parser stack. There is even an argumentless
clear function to empty 'the' stack after a parse
is finished.
It would be nice if we could get a re-entrant
parser so recursive parsing could be done.
This can be useful for processing '#include"
files in C for example, if you want to handle
that at the parse level instead of the token level.
However, it may be possible to 'hack' something
which allows this for sequential progamming
(i.e. not with threads) by providing two functions:
get_parser_state
set_parser_state
Does this make sense? Would it be useful to anyone else?
Can it be implemented without too much fuss
in lieu of a fully re-entrant parser?
--
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850,
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net
-------------------
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] 6+ messages in thread
* Re: [Caml-list] Ocamlyacc reentrancy
2004-05-01 3:08 [Caml-list] Ocamlyacc reentrancy skaller
@ 2004-05-01 4:47 ` Jon Harrop
2004-05-01 5:36 ` skaller
0 siblings, 1 reply; 6+ messages in thread
From: Jon Harrop @ 2004-05-01 4:47 UTC (permalink / raw)
To: caml-list
Apparently the Parser module should be reentrant because it is careful to save
and load its global data.
http://pauillac.inria.fr/caml/caml-list/0258.html
Cheers,
Jon.
-------------------
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] 6+ messages in thread
* Re: [Caml-list] Ocamlyacc reentrancy
2004-05-01 4:47 ` Jon Harrop
@ 2004-05-01 5:36 ` skaller
2004-05-02 20:38 ` Eckart Goehler
2004-05-05 11:52 ` Keith Wansbrough
0 siblings, 2 replies; 6+ messages in thread
From: skaller @ 2004-05-01 5:36 UTC (permalink / raw)
To: Jon Harrop; +Cc: caml-list
On Sat, 2004-05-01 at 14:47, Jon Harrop wrote:
> Apparently the Parser module should be reentrant because it is careful to save
> and load its global data.
>
> http://pauillac.inria.fr/caml/caml-list/0258.html
Thanks for that link. Xavier says:
"The module Parsing is supposed to be reentrant. Yes, there's some
global state inside, but we're careful to save and restore it across
entries. If you have a program demonstrating non-reentrance, please
send it to me privately and I'll try to fix that."
--
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850,
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net
-------------------
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] 6+ messages in thread
* Re: [Caml-list] Ocamlyacc reentrancy
2004-05-01 5:36 ` skaller
@ 2004-05-02 20:38 ` Eckart Goehler
2004-05-05 11:52 ` Keith Wansbrough
1 sibling, 0 replies; 6+ messages in thread
From: Eckart Goehler @ 2004-05-02 20:38 UTC (permalink / raw)
To: skaller; +Cc: caml-list
On Sat, 1 May 2004, skaller wrote:
> On Sat, 2004-05-01 at 14:47, Jon Harrop wrote:
> > Apparently the Parser module should be reentrant because it is careful to save
> > and load its global data.
> >
> > http://pauillac.inria.fr/caml/caml-list/0258.html
>
> Thanks for that link. Xavier says:
>
> "The module Parsing is supposed to be reentrant. Yes, there's some
> global state inside, but we're careful to save and restore it across
> entries. If you have a program demonstrating non-reentrance, please
> send it to me privately and I'll try to fix that."
I only remark that ocamlyacc produces code which might be reentrant but
fails for the original problem mentioned because the parsing function is
not recursive.
For fixing that I refer to an already posted article:
http://caml.inria.fr/archives/200309/msg00258.html
cheers
ekat
-----------------------------------------------------
Eckart Goehler
Sand 1
IAAT, Astronomy
72076 Tuebingen
Tel. : ++49-7071-297 54 73
Fax. : ++49-7071-29 34 58
e-mail : goehler@astro.uni-tuebingen.de
-----------------------------------------------------
-------------------
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] 6+ messages in thread
* Re: [Caml-list] Ocamlyacc reentrancy
2004-05-01 5:36 ` skaller
2004-05-02 20:38 ` Eckart Goehler
@ 2004-05-05 11:52 ` Keith Wansbrough
2004-05-05 14:00 ` skaller
1 sibling, 1 reply; 6+ messages in thread
From: Keith Wansbrough @ 2004-05-05 11:52 UTC (permalink / raw)
To: skaller; +Cc: Jon Harrop, caml-list
> On Sat, 2004-05-01 at 14:47, Jon Harrop wrote:
> > Apparently the Parser module should be reentrant because it is careful to save
> > and load its global data.
> >
> > http://pauillac.inria.fr/caml/caml-list/0258.html
>
> Thanks for that link. Xavier says:
>
> "The module Parsing is supposed to be reentrant. Yes, there's some
> global state inside, but we're careful to save and restore it across
> entries. If you have a program demonstrating non-reentrance, please
> send it to me privately and I'll try to fix that."
What about multithreaded code?
We wrote a couple of scripts that hack the output of ocamllex and
ocamlyacc, and a slightly modified lexing.ml and parsing.ml, that give
you purely functional lexers and parsers. The modification is trivial
- just pass the state around in an argument, rather than a global
variable.
Let me know if you are interested. I think we got some positive
noises from INRIA, but I'll leave it to them to comment re future
OCaml releases. We didn't consider performance impact.
--KW 8-)
-------------------
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] 6+ messages in thread
* Re: [Caml-list] Ocamlyacc reentrancy
2004-05-05 11:52 ` Keith Wansbrough
@ 2004-05-05 14:00 ` skaller
0 siblings, 0 replies; 6+ messages in thread
From: skaller @ 2004-05-05 14:00 UTC (permalink / raw)
To: Keith Wansbrough; +Cc: Jon Harrop, caml-list
On Wed, 2004-05-05 at 21:52, Keith Wansbrough wrote:
> > On Sat, 2004-05-01 at 14:47, Jon Harrop wrote:
> >
> > Thanks for that link. Xavier says:
> >
> > "The module Parsing is supposed to be reentrant. Yes, there's some
> > global state inside, but we're careful to save and restore it across
> > entries. If you have a program demonstrating non-reentrance, please
> > send it to me privately and I'll try to fix that."
>
> What about multithreaded code?
The practical problem I have is that parsing C does
require *client* state to be passed around.
So the internal reentrancy of ocamlyacc parsers isn't
enough. The client has to wrap all the parses with
copyup/copy down code too... and they didn't.
If there been a state variable the authors might
have taken the trouble to use it.
Ocamllex lexers are now very easy to make reentrant!
--
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850,
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net
-------------------
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] 6+ messages in thread
end of thread, other threads:[~2004-05-05 14:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-01 3:08 [Caml-list] Ocamlyacc reentrancy skaller
2004-05-01 4:47 ` Jon Harrop
2004-05-01 5:36 ` skaller
2004-05-02 20:38 ` Eckart Goehler
2004-05-05 11:52 ` Keith Wansbrough
2004-05-05 14:00 ` skaller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox