From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id pAOFN8VJ030748 for ; Thu, 24 Nov 2011 16:23:08 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtQAAClhzk7RVdQ2kGdsb2JhbABDhQKlaAgiAQEBAQkJDQcUBCGCCwITGQEbHAIDEhARBRYNCwMCAQIBEREBBQEvCAEBHpxwglwKixYIRYJmhQ49iHECBQqBIoYhgXuBGgSHdSyMKYZxhmc9hBQ X-IronPort-AV: E=Sophos;i="4.69,565,1315173600"; d="scan'208";a="120738486" Received: from mail-vw0-f54.google.com ([209.85.212.54]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-MD5; 24 Nov 2011 16:22:55 +0100 Received: by mail-vw0-f54.google.com with SMTP id fa15so3818793vbb.27 for ; Thu, 24 Nov 2011 07:22:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; bh=RW7R1zQtbYPsx9QGmcf+l0aJqf0Tpzjr5WQ8Lw++MfI=; b=HelfSOxBarpaG0l5mtoTNnoz7ezGQHUltU3I6kAscVOFEo0HxbSnzfgwsoOBB0a7+g ja6BZuzgss/QJwX0F+AoW++ukDc7s0uR+tF4Y3GSAvVqGoYxr/LFPts7+3oEVvQNEgwJ 031N+IgoynT19LD2fbzZOSwXfzzsQ6GwtAge0= Received: by 10.52.30.130 with SMTP id s2mr30234739vdh.55.1322148175732; Thu, 24 Nov 2011 07:22:55 -0800 (PST) Received: from bobmatoMacBook-Pro.local ([66.250.143.212]) by mx.google.com with ESMTPS id p2sm29603707vdi.22.2011.11.24.07.22.54 (version=SSLv3 cipher=OTHER); Thu, 24 Nov 2011 07:22:54 -0800 (PST) Message-ID: <4ECE614D.3040504@gmail.com> Date: Thu, 24 Nov 2011 10:22:53 -0500 From: bob zhang User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 MIME-Version: 1.0 To: caml-list@inria.fr Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: 7bit Subject: [Caml-list] Weird behavior of Camlp4 Parser Hi List, I have came across a strange behavior of the camlp4 parser, (maybe not that weird due to my limited knowledge of the parser) The contrived mini-examples as follows : module MGram = MakeGram(Lexer) ;; EXTEND MGram GLOBAL: m_expr ; m_expr : [[ "foo"; f -> print_endline "first" | "foo" ; "bar"; "baz" -> print_endline "second"] ]; f : [["bar"; "baz" ]]; END;; MGram.parse_string m_expr (Loc.mk "") "foo bar baz ";; second (** choose the second branch, maybe the token rule has a higher priority *) MGram.Entry.clear m_expr;; EXTEND MGram GLOBAL: m_expr ; m_expr : [[ "foo"; f -> print_endline "first" | "foo" ; "bar"; "bax" -> print_endline "second"] ]; f : [["bar"; "baz" ]]; END;; - : unit = () # MGram.parse_string m_expr (Loc.mk "") "foo bar baz ";; first (** here choose the first branch, but the token rule can consume one token, I thought this should fail *) Many Thanks