English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
re-entrant CAMLYACC parsers?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 1999-08-12 (10:14)
From: chet@w...
Subject: re-entrant CAMLYACC parsers?

How do most people implement re-entrancy in caml-yacc parsers which
must manipulate side-state?  E.g., if I want to have some hashtable to
store a mapping from name to right-hand-side, which the lexer will
expand dynamically and push back onto the lexbuf (I've enclosed the
code I use to do that -- it looks right, and it works, but I'm not
certain that I got the semantics of Lexing.lexbuf down), it'd be nice
to store that someplace on the stack, so that I don't have to count on
serialization of calls to the parser.

I've thought about hacking Parsing to have an extra slot in the
parsing_env record, of polymorphic type, and then adding some syntax
to the caml-yacc language to fetch that value.

Anybody done anything like this?


P.S. I realize I could do this trivially with stream-parsers, but I'd
prefer to write a yacc-parser for efficiency and declarativeness.