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=2.8 required=5.0 tests=DNS_FROM_RFC_POST,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 mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 7240ABBAF for ; Tue, 23 Jun 2009 22:30:53 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkYCALDXQEpKfS4djWdsb2JhbACON4l0PwEBAQEJCQoJEQWpZjGHK4hJAQMCBIQGBYE0hgA X-IronPort-AV: E=Sophos;i="4.42,277,1243807200"; d="scan'208";a="31811603" Received: from yw-out-2324.google.com ([74.125.46.29]) by mail1-smtp-roc.national.inria.fr with ESMTP; 23 Jun 2009 22:30:52 +0200 Received: by yw-out-2324.google.com with SMTP id 9so164323ywe.3 for ; Tue, 23 Jun 2009 13:30:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to:cc :content-type:content-transfer-encoding; bh=c8ECKX8ekt6M23bWxeSyVt7pJzg5dA0EjK28R4wFcvQ=; b=q10oTjEuuobpkhYjdbr0sljnm33DwQJ2rtBNXdBbLKc9iewE4ZWWMNZ0VCiXEl4HP4 ha1TYfktVLxAOA8Y2UJk6nAaSzmUiNHdgxwiBaaDyiANEEOFASIO0kr/QHfEqdb1NfLQ t8xMYNTW08G/LaaVYqZjnpq0PoEKxdDaU1hWI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=Xxu/Nj/GmQiop1iA2mg48sxxy1anti9ExUWOOAiz4er23eYtpHKamyvzGfTm+4dDF7 gaEFPM6PHbC7LUzj4kzu0zr+U+Lc+8gRywkVfX3yK6DJR3WE2BNSeCILgw6loUyNRqfK y2SSnoJI2bh1bHuKHR/6Khclt+CkGON7ROP+A= MIME-Version: 1.0 Sender: willtor@gmail.com Received: by 10.100.46.3 with SMTP id t3mr718437ant.94.1245789051503; Tue, 23 Jun 2009 13:30:51 -0700 (PDT) In-Reply-To: <8401c38a0906231310t727c3e84na237c67e0ec1031c@mail.gmail.com> References: <8401c38a0906231310t727c3e84na237c67e0ec1031c@mail.gmail.com> Date: Tue, 23 Jun 2009 16:30:51 -0400 X-Google-Sender-Auth: 11f389c89a038248 Message-ID: Subject: Re: [Caml-list] multiple %start symbols in parser From: Will Leiserson To: Ligia Nistor Cc: caml-list@yquem.inria.fr Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; parser:01 rpi:01 ocamlyacc:01 ocamlyacc:01 parser:01 ocaml:01 lexbuf:01 lexing:01 lexbuf:01 beginner's:01 ocaml:01 bug:01 alum:98 23,:98 2009:98 Hi Ligia, I haven't used ocamlyacc, but remember that in a PDA you can always combine two into one. E.g., --- main ::=3D ... main2 ::=3D ... becomes, start ::=3D main | main2; main ::=3D ... main2 ::=3D ... --- Thus, you can still have a single entry point, which (I imagine) is how ocamlyacc wants things to be. Will On Tue, Jun 23, 2009 at 4:10 PM, Ligia Nistor wro= te: > Hi, > > I am writing a small parser in ocaml, using ocamlyacc. I need to define 2 > start symbols in my file parser.mly, but I don't know how to use them. Th= e > name of the 2 start symbols are "main"and "main2". I know how to use one > start symbol, as here(taken form "calc.ml"): > > =A0let _ =3D > =A0=A0=A0=A0=A0=A0=A0=A0=A0 try > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 let in_channel =3D open_in "lines.txt" = in > > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 let lexbuf =3D Lexing.from_channel in_c= hannel in > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 while true do > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 let result =3D HorsParser.main Ho= rsLexer.token lexbuf in > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 Hors.print_pair_list result= ; > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 done > =A0=A0=A0=A0=A0=A0=A0=A0=A0 with HorsLexer.Eof -> > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 exit 0 > > but I don't know how to call the function "HorsParser.main2". > I want to parse a part of the file "lines.txt" using the rule "main", and > then, the other part of the file using "main2". Is this possible? > =A0I tried to call "HorsParser.main2", but I got a "Parsing.parse_error". > > Thanks, > Ligia > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > >