caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: skaller <skaller@maxtal.com.au>
To: caml-list@inria.fr
Subject: ocamlyacc/lex reentrancy
Date: Sat, 25 Dec 1999 08:31:11 +1100	[thread overview]
Message-ID: <3863E61F.E27029EF@maxtal.com.au> (raw)

At present, ocamllex cannot be used reentrantly by the client,
since there is nowhere to put auxilliary data.

The obvious place to attach this data is the lexbuf;
(say by using get and set functions):
this would be transparent (allow existing lexers to work
without source code modification). Also, no changes to the
lexer would be required (only the lexbuf).

At present, ocamlyacc parsers accept a lexer and a lexbuf.
In principle, this is the wrong interface: the lexer and
parser should be decoupled; the parser should only
require a function which acts as a token source.

However, there is also no place for auxilliary data 
to be stored while parsing. If the lexbuf is extended to
provide access to client data, the current interface would
support supplying that data to client code processing
non-terminals on reduction.

This suggests that each start symbol should generate two
parsers: one using the old interface, and a new interface
passing a function:

	'a -> token

The old interface can call the new interface, after fetching
the client data from the lexbuf.

These changes together would seem to allow all existing
ocamllex/ocamlyacc sources to continue to work unmodified,
while allowing new codes for both ocamllex and ocamlyacc
to be written which are reentrant, and also allow alternate
sources of tokens to be used with ocamlyacc.

One minor problem: the type 'a could not be infered for the lexbuf,
if client code never used it? Is there a good way to modify
ocamlyacc/lex, so existing code works, but which also
supports supplying auxilliary data, so that both
the lexer and parser can be reentered?

-- 
John Skaller, mailto:skaller@maxtal.com.au
10/1 Toxteth Rd Glebe NSW 2037 Australia
homepage: http://www.maxtal.com.au/~skaller
voice: 61-2-9660-0850




             reply	other threads:[~1999-12-30 10:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-12-24 21:31 skaller [this message]
1999-12-30 18:30 ` Francois Rouaix
1999-12-30 19:09   ` skaller
2000-01-03  9:46     ` Markus Mottl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3863E61F.E27029EF@maxtal.com.au \
    --to=skaller@maxtal.com.au \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).