From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by sympa.inria.fr (Postfix) with ESMTPS id 147407ED34 for ; Sun, 8 Jul 2012 12:19:19 +0200 (CEST) Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of gabriel.scherer@gmail.com) identity=pra; client-ip=209.85.214.180; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail1-smtp-roc.national.inria.fr: domain of gabriel.scherer@gmail.com designates 209.85.214.180 as permitted sender) identity=mailfrom; client-ip=209.85.214.180; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-ob0-f180.google.com) identity=helo; client-ip=209.85.214.180; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="postmaster@mail-ob0-f180.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AuABAEZe+U/RVda0kGdsb2JhbABFDqZEkQMIIgEBAQEJCQ0HFAQjgiABAQEEEgIsARsSCwEDDAYFCwcGDSEiAREBBQEKBA4GExIQh1sBAwwLm2oJA4wjgnGDaQoZJwMKV4hxAQUMizSGDAOVNoESjRY+g0U7 X-IronPort-AV: E=Sophos;i="4.77,546,1336341600"; d="scan'208";a="166019765" Received: from mail-ob0-f180.google.com ([209.85.214.180]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 08 Jul 2012 12:19:13 +0200 Received: by obbuo19 with SMTP id uo19so27748364obb.39 for ; Sun, 08 Jul 2012 03:19:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=JLAthakSzR7n1IAccI14iIUKEgJV+I+SpWBFjQWrfE0=; b=eXZLy8+mNwugBeCJHtAN592A2mdOxjGAP7CmUNRyYwgyIpMe2MXbx7hXsew+y84PHg DFZpfrjaP6PBCNQgCzPPKSeoFl+jhU/25OP38a5r+VzQpZRnMvlhNMIeO5Rz/qpvWs6z U8gC6YfQqRPdTsxyHhSnmEkXTdx2kCf9gh2H0qJkuVHBKH45m1eXmBzHd/LiC1/V0WpK wRnv+xarJlr4XDbZmfvmIY2Hwsz2+Hg4urYgGZFTrvqw2a+V8VSKbQZunA1FPkkkHzEa IjNox55j7ZFFj1GvWZqdfjzvN5J+8kfwG0hdubXekfIBjW7mPVNzvegYlYPFpXNcb6E0 /+4Q== Received: by 10.50.202.8 with SMTP id ke8mr6179126igc.6.1341742751634; Sun, 08 Jul 2012 03:19:11 -0700 (PDT) MIME-Version: 1.0 Received: by 10.50.94.39 with HTTP; Sun, 8 Jul 2012 03:18:30 -0700 (PDT) In-Reply-To: <73F2C118-89C0-4EFB-849D-1F70B4B58AA4@math.harvard.edu> References: <73F2C118-89C0-4EFB-849D-1F70B4B58AA4@math.harvard.edu> From: Gabriel Scherer Date: Sun, 8 Jul 2012 12:18:30 +0200 Message-ID: To: Nicolas Ojeda Bar Cc: caml-list@yquem.inria.fr Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [Caml-list] stream parsers with location information? Indeed: you need your lexer to produce location information. Instead of manipulating a (token Stream.t), you will produce (and then parse at the lexer level) a ((token * location) Stream.t). This is the way Camlp4 parsers are implemented (recursive descent over a stream of tokens and positions). See also "Planck", an experiment at combinator parser libraries by Jun Furuse, using a similar (but different) architecture. http://bluestorm.info/camlp4/camlp4-doc/Sig.Lexer.html https://bitbucket.org/camlspotter/planck/ http://camlspotter.blogspot.fr/2011/05/planck-small-parser-combinator-library.html On Sun, Jul 8, 2012 at 12:01 PM, Nicolas Ojeda Bar wrote: > Hi, > > Is there a clean way to use stream parsers/lexers if I want to have > location (line number, character position) information attached to > each token? > > Thanks! > Nicolas > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa-roc.inria.fr/wws/info/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs >