From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.1 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 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 C9E7CBBC1 for ; Fri, 7 Mar 2008 10:57:29 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsoBACCg0EfAXQImh2dsb2JhbACQfgEBAQgKKZNmhxE X-IronPort-AV: E=Sophos;i="4.25,461,1199660400"; d="scan'208";a="9082499" Received: from discorde.inria.fr ([192.93.2.38]) by mail1-smtp-roc.national.inria.fr with ESMTP; 07 Mar 2008 10:57:29 +0100 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id m279vRjC018690 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Fri, 7 Mar 2008 10:57:29 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApABALKg0EfRVciugWdsb2JhbACQfgEBCAUECQoWk2KHEw X-IronPort-AV: E=Sophos;i="4.25,461,1199660400"; d="scan'208";a="9986326" Received: from wf-out-1314.google.com ([209.85.200.174]) by mail3-smtp-sop.national.inria.fr with ESMTP; 07 Mar 2008 10:57:28 +0100 Received: by wf-out-1314.google.com with SMTP id 26so551925wfd.0 for ; Fri, 07 Mar 2008 01:57:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; bh=IEhJSL6EgmsqkXxsOIWMQF2MvUY4OUk7Brab5Yq3BJc=; b=jxCAEwTymKqbyTXOeESfwja26mCc+gIOin0RObH8oqf7uSwr6iSF28L0KN6x6jK04RHzLUHdQjvENuV+kc1jxr6K8Zft7C5y05wM1jM8Dxh2Ll8sC0osHfuWPWOkTs0sGu4ZgkZK2Enf+iio3Mbnoawsd9yzVNPwthyGqFmVc58= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=nPLfYxNx9ZE1OMMiLGpgoWUGnlqCJfaLlbjP+uar/cBMnZu1O3youK7kvCUcFwXweKb+tICJZ6+MS5BaENN/MA2SHpvPestI9Xq3MFAMa63kXzD/s3WAAqvhSW1V04XZglVSNgHOHjArw6REdmwB2ToA6kuovgL765Whtnb0tWY= Received: by 10.142.131.18 with SMTP id e18mr466971wfd.39.1204883848612; Fri, 07 Mar 2008 01:57:28 -0800 (PST) Received: by 10.142.115.3 with HTTP; Fri, 7 Mar 2008 01:57:28 -0800 (PST) Message-ID: <9d3ec8300803070157y6bb173eew865e2f232cb4c789@mail.gmail.com> Date: Fri, 7 Mar 2008 09:57:28 +0000 From: "Till Varoquaux" To: OCaml Subject: Ocamllex newline counting... MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Miltered: at discorde with ID 47D11187.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocamllex:01 ocamllex:01 lexbuf:01 lexbuf:01 lexer:01 newlines:01 newlines:01 cheers:01 curr:01 curr:01 lex:01 lex:01 newline:02 newline:02 seems:03 The title is pretty self explanetory: Ocamllex is able to keep track of positions automatically but it needs help with new lines ( you need to register new lines with a function like: let newline lexbuf = let pos = lexbuf.lex_curr_p in lexbuf.lex_curr_p <- { pos with pos_lnum = pos.pos_lnum + 1; pos_bol = pos.pos_cnum } ). This tends to pollute the code and require you to add additional rules and underlying machinery. I can see one easy workaround: pipe the function you build your lexer from trough an additional function that registers newlines. This seems a bit costly at run time but should be just fine in most cases. Is there any fundamental reason I am missing why newlines are not handled natively in the generated automaton? Cheers, Till