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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id B6A8DBC37 for ; Tue, 10 Nov 2009 15:42:54 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjgBAMQK+UpDww+7mWdsb2JhbACEco0WgQCIeQEBAQEBCAsKBxOxGyiBOYYyiGoBBgQBgS2COFQE X-IronPort-AV: E=Sophos;i="4.44,716,1249250400"; d="scan'208";a="37862253" Received: from web111510.mail.gq1.yahoo.com ([67.195.15.187]) by mail3-smtp-sop.national.inria.fr with SMTP; 10 Nov 2009 15:42:53 +0100 Received: (qmail 64539 invoked by uid 60001); 10 Nov 2009 14:42:52 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1257864172; bh=8Qrr0M1f/JX5uorWBhBLKUP4uUOwS7qbjjryFK7TZRk=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=p/yANmr1IbXL81Pwx4aKK7CLjSQU5BwsYLg7SBnKvnTgHp0rvAp7iYVmH1LabTHz8uVqKhn9nlhF/nt/M2qaTKTv3EJK+qEU3wAWzZ0ToeQo2avDswUq3sUBgHGJ9DK5fbhhHAdB/LSPll+IQC+EpRrM4/PsR/3Vul+cq/SnSRo= DomainKey-Signature:a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=vFfXzbzCWu2XGcuG/WMt6MYTb3I+SPy/JKUMMuUZT8h4wzVyi2aqPGp3NjdFS/hZBKh594MgKg0piRZiP7IvnYk/5a05r8GOArf/O0aI0S6V1PVKYi0HwK0SE8tKes32Bvbg/dxmDQBAMykTckHuVnzCIXy/XmgwjRDr85bnnMo=; Message-ID: <514622.64398.qm@web111510.mail.gq1.yahoo.com> X-YMail-OSG: EV0gF9QVM1lm72UPrakcS5S.PiQp68M6mla7Px3zD9P_6GyplXrWfzbyun7.QEgYjqtbMXsXcM0zZIdnYrMt6jcSdGxuM_fwHFF36LE92kzWnujJ8AewWGdPDk7zRnz3RXTd_IW8Es.qJbN.CAVM_wMGIM8HeTLyD1JmggzMqUbm3vxXsU3hg9aqBcNRbKLt0bcY2tofgE3UwRo_jZaHK7bw0R1f6zs.hEHtXCgROu3Xa4.84ICCuLd5UHHKsyRfOmT8ht4s3wbAbu7Q1aEBr6ANY8TtFT4YBDeXxaBpq6sg8iv52nrn.dicwkmt8PVu2IEoXMss0OmWFtATrOxYNBw- Received: from [213.205.71.57] by web111510.mail.gq1.yahoo.com via HTTP; Tue, 10 Nov 2009 06:42:52 PST X-Mailer: YahooMailClassic/8.1.6 YahooMailWebService/0.7.361.4 Date: Tue, 10 Nov 2009 06:42:52 -0800 (PST) From: Dario Teixeira Subject: The lexer hack To: caml-list@yquem.inria.fr MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; lexer:01 parser:01 lexers:01 parser:01 lexing:01 lexer:01 compiler:01 tokens:01 error-prone:01 real-world:01 partial:01 parsing:01 parsing:01 module:03 hack:04 Hi,=0A=0AI'm creating a parser for a LaTeX-ish language that features verba= tim blocks.=0ATo handle them I want to switch lexers on-the-fly, depending = on the parsing=0Acontext. Therefore, I need the state from the (Menhir gen= erated) parser=0Ato influence the lexing process (I believe this is called = the "lexer hack"=0Ain compiler lore).=0A=0APresently I am doing this by pla= cing a module between the lexer and the=0Aparser, listening in on the flow = of tokens, and using a crude state machine=0Ato figure out the parsing cont= ext. This solution is however error-prone=0Aand a bit wasteful, since I'm = reimplementing by hand stuff that should be=0Athe sole competence of the pa= rser generator.=0A=0AAnyway, since I'm sure this problem pops up often, doe= s someone have any=0Aalternative suggestions? I would preferably keep Menh= ir, but I'll switch=0Aif some other generator offers a better approach(*).= =0A=0AThanks + best regards,=0ADario Teixeira=0A=0A=0A(*) I've looked into = Dypgen, and its partial actions may offer a way out.=0A Does someone hav= e any experience with those and with real-world usage=0A of Dypgen in ge= neral? (In other words, is it stable enough for=0A production use?)=0A= =0A=0A=0A