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.0 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 7C0B0BC0A for ; Thu, 5 Apr 2007 16:37:56 +0200 (CEST) Received: from nz-out-0506.google.com (nz-out-0506.google.com [64.233.162.238]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l35EbtsD014295 for ; Thu, 5 Apr 2007 16:37:56 +0200 Received: by nz-out-0506.google.com with SMTP id l8so338955nzf for ; Thu, 05 Apr 2007 07:37:54 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=Z6+S9Qh/0B/ZCi2yI7w5VQrUwoDqrRIAcFlBMksPHLR/EEUkg/Hbv9e5oz2MiuVoyxWwD5b2It+s3WCg6H1wVbUFF+cFKpQw1HkCs5Q2v8bXw4FPdo0KPmIXBQeNBKUy4OvUFm4JiW7xfH1YuvMX6z5yyKHqAC0M89pBkU3tnCk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=jNqbzQAD0MXU8Ex6qLv9JDXYlyR2G2Kgl5V4kotP99jJct1XmaGqltTt56s779NdBw3+qCQ+6ux83my3wUnu5YPO/MApegtBBQBfjnCmcWtpG7fPvAs0QS5/SHQri2WMjtesM6CMd+h7Vf+zgSLGK0jH/Ryee4yMhAPv6B6vUeU= Received: by 10.114.179.1 with SMTP id b1mr769028waf.1175783872939; Thu, 05 Apr 2007 07:37:52 -0700 (PDT) Received: by 10.114.72.17 with HTTP; Thu, 5 Apr 2007 07:37:47 -0700 (PDT) Message-ID: <700d600f0704050737r3ea45a16gb318ac7acf8e3178@mail.gmail.com> Date: Thu, 5 Apr 2007 17:37:47 +0300 From: "Janne Hellsten" To: caml-list@inria.fr Subject: Matching start of input in lexer created with ocamllex MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-j-chkmail-Score: MSGID : 461509C3.000 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 461509C3.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; lexer:01 ocamllex:01 lexer:01 token:01 matched:01 matched:01 lex:01 ident:02 ident:02 match:02 parse:02 string:02 string:02 loc:03 loc:03 Hi, I'd like to match the beginning of input (or beginning of line) in my lexer. Is there an easy way to do that? I have a lexer that looks something like this (simplified): rule initial = parse | '!' [' ' '\t']* "for" { FOR (current_loc ()) } | ident as id { IDENT (id, current_loc ()) } | '!' { BANG (current_loc ()) } The !for token should only be matched at the beginning of a line/input. However, in the above lexer, there's nothing that prevents !for from being matched in the middle of an input string. This causes a problem: An input string containing !forbidXyz will be lexed FOR, IDENT "bidXyz". I'd like to lex it as BANG, IDENT "forbidXyz". Thank you for your help! Janne