From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 57152BC37 for ; Tue, 10 Nov 2009 17:33:33 +0100 (CET) X-IronPort-AV: E=Sophos;i="4.44,717,1249250400"; d="scan'208";a="39877486" Received: from yquem.inria.fr ([128.93.8.37]) by mail1-relais-roc.national.inria.fr with ESMTP; 10 Nov 2009 17:33:33 +0100 Received: by yquem.inria.fr (Postfix, from userid 18965) id 3D95DBC37; Tue, 10 Nov 2009 17:33:33 +0100 (CET) Date: Tue, 10 Nov 2009 17:33:33 +0100 From: Francois Pottier To: Dario Teixeira Cc: caml-list@inria.fr, Jeff Shaw Subject: Re: [Caml-list] Re: The lexer hack Message-ID: <20091110163333.GD19182@yquem.inria.fr> Reply-To: Francois.Pottier@inria.fr References: <4AF98624.70106@msu.edu> <698547.213.qm@web111509.mail.gq1.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <698547.213.qm@web111509.mail.gq1.yahoo.com> User-Agent: Mutt/1.5.9i X-Spam: no; 0.00; lexer:01 parser:01 lexer:01 10,:98 2009:98 token:01 token:01 wrote:01 parsing:01 verb:01 verb:01 inline:01 caml-list:01 pottier:01 pottier:01 Hello, On Tue, Nov 10, 2009 at 08:26:23AM -0800, Dario Teixeira wrote: > Anyway, I was looking at Dypgen's early actions, and an idea > occurred to me: I can create dummy empty actions that simply > change a global "parsing context" variable: > > inline: > | (...) > | BEGIN_VERB enter_verb RAW END_VERB exit_verb {Ast.Verbatim $3} > | (...) > > enter_verb: /* empty */ {Global.context := Global.Verbatim} > exit_verb: /* empty */ {Global.context := Global.General} > > > Still hackish, but better than creating a state machine... Interesting. Have you confirmed that this works? I am slightly worried by the fact that an LR parser reads one token ahead, i.e. one token past BEGIN_VERB might already have been read before the enter_verb semantic action is executed. If that is so, then this token would be read while the lexer is still in the wrong mode. -- François Pottier Francois.Pottier@inria.fr http://gallium.inria.fr/~fpottier/