Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
multiple %start symbols in parser
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-06-23 (20:10)
From: Ligia Nistor <ligia.nicoleta@g...>
Subject: multiple %start symbols in parser

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 ""):

 let _ =
            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;
          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".