caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Vesa Karvonen" <vesa.karvonen@housemarque.fi>
To: <caml-list@inria.fr>
Subject: [Caml-list] On ocamlyacc and ocamllex
Date: Sun, 23 Sep 2001 00:09:14 +0300	[thread overview]
Message-ID: <000b01c143aa$d5218690$422aa8c0@housemarque.fi> (raw)

Hi,

Ocamlyacc with the standard Parsing module seems to generate non-reentrant
parsers, because the env is stored as a global variable in the Parsing module.
(BTW: Having a reentrant Parsing module would also eliminate the need for the
clear_parser function.)

Ocamllex with the Lexing module generates a lexer that seems to be difficult
to extend without using global variables. You may wonder what I mean with
extending the lexer. I would like to make it so that the lexer would record
the positions of line breaks so that I could directly give line number and
column information in error messages. I would like to effectively augment the
lexbuf with additional fields and write new functions for the augmented lexbuf
(functions manipulating the new fields).

Has someone written extensible and reentrant lexing and parsing modules for
Ocaml?

Is someone interested in such lexer and parser modules?

I was thinking about writing replacements for the Lexing and Parsing modules
that would use the (lex_)engine and parse_engine external functions. The
replacements would effectively be parameterized layers on top of some of the
facilities in Lexing and Parsing modules. In addition I also thought about
writing a program that modifies the files generated by ocamllex and ocamlyacc
so that they can be used with the replacement Lexing and Parsing modules.

Are the some hidden problems with the above approach?

Alternatively, the tools and modules of the Ocaml distribution could be
modified, but this isn't necessarily an easy route.

As my project schedule is tight and I may be able to live with the global
variables, I don't necessarily want to spend time on this, but if there are
others interested in such modules, I might put in some extra time to implement
them.

...

Another issue with ocamllex and ocamlyacc (and lex/flex and yacc/bison) is
that the dependencies between the generated lexer and parser are not quite
optimal. Currently the generated lexer is dependent on the parser, because the
parser generates the token type. This means that each time the grammar is
modified, but not the token definitions, the lexer is recompiled. This could
be avoided by making it so that the token type is defined in a separate
module.

Currently: lexer -> parser.token
Effect: lexer recompiled when grammar or token type is modified

Ideally: lexer -> token <- parser
Effect: lexer recompiled only when token type is modified



-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


             reply	other threads:[~2001-09-22 21:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-22 21:09 Vesa Karvonen [this message]
2001-09-23  1:10 ` Christian Lindig
2001-09-23 16:27   ` Vesa Karvonen
2001-09-23 17:44     ` Christian Lindig
2001-09-23 19:32       ` Vesa Karvonen
2001-09-23 20:09         ` Christian Lindig
2001-09-23 20:51           ` Vesa Karvonen
2001-10-22 17:09           ` John Max Skaller
2001-10-22 16:47       ` John Max Skaller
2001-09-24  1:05 ` Christian RINDERKNECHT
2001-09-24 11:17   ` Vesa Karvonen
2001-10-22 17:24     ` John Max Skaller

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='000b01c143aa$d5218690$422aa8c0@housemarque.fi' \
    --to=vesa.karvonen@housemarque.fi \
    --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).