From: Will Leiserson <wml@alum.rpi.edu>
To: Ligia Nistor <ligia.nicoleta@gmail.com>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] multiple %start symbols in parser
Date: Tue, 23 Jun 2009 16:30:51 -0400 [thread overview]
Message-ID: <a66003f60906231330m77e3ed5dg47c9492120bb0063@mail.gmail.com> (raw)
In-Reply-To: <8401c38a0906231310t727c3e84na237c67e0ec1031c@mail.gmail.com>
Hi Ligia,
I haven't used ocamlyacc, but remember that in a PDA you can always
combine two into one. E.g.,
---
main ::= ...
main2 ::= ...
becomes,
start ::= main | main2;
main ::= ...
main2 ::= ...
---
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<ligia.nicoleta@gmail.com> wrote:
> 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. The
> name of the 2 start symbols are "main"and "main2". I know how to use one
> start symbol, as here(taken form "calc.ml"):
>
> let _ =
> try
> let in_channel = open_in "lines.txt" in
>
> let lexbuf = Lexing.from_channel in_channel in
> while true do
> let result = HorsParser.main HorsLexer.token lexbuf in
> Hors.print_pair_list result;
> done
> with HorsLexer.Eof ->
> 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?
> I 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
>
>
next prev parent reply other threads:[~2009-06-23 20:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-23 20:10 Ligia Nistor
2009-06-23 20:30 ` Will Leiserson [this message]
2009-06-23 21:37 ` [Caml-list] " Jon Harrop
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a66003f60906231330m77e3ed5dg47c9492120bb0063@mail.gmail.com \
--to=wml@alum.rpi.edu \
--cc=caml-list@yquem.inria.fr \
--cc=ligia.nicoleta@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox