* [Caml-list] putting stuff in an ocamlyacc-generated mli file
@ 2001-10-19 8:04 Rafael 'Dido' Sevilla
2001-10-19 8:56 ` Christian RINDERKNECHT
2001-10-19 9:10 ` Markus Mottl
0 siblings, 2 replies; 3+ messages in thread
From: Rafael 'Dido' Sevilla @ 2001-10-19 8:04 UTC (permalink / raw)
To: Caml List
I've been trying to streamline the error handling for my ocamlyacc-based
compiler, and have this exception defined in my parser.mly:
exception Undef_sym of string;
This is raised whenever the compiler encounters an undefined symbol.
The file that actually uses the compiler, compiler.ml does something like:
try
let result = Parser.main Lexer.token lexbuf in
...
with
Parser.Undef_sym x -> Printf.fprintf stderr "Undefined symbol %s" x
Unfortunately, compiling the compiler with this causes it to choke
saying that Parser.Undef_sym is not found. It's not in the generated
parser.mli file, of course. So apart from editing that (automatically
generated) file manually, how do I get ocamlyacc to put them there?
--
Rafael R. Sevilla <sevillar@team.ph.inter.net> +63(2) 8177746 ext. 8311
Programmer, Inter.Net Philippines +63(917) 4458925
http://dido.engr.internet.org.ph/ OpenPGP Key ID: 0x5CDA17D8
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] putting stuff in an ocamlyacc-generated mli file
2001-10-19 8:04 [Caml-list] putting stuff in an ocamlyacc-generated mli file Rafael 'Dido' Sevilla
@ 2001-10-19 8:56 ` Christian RINDERKNECHT
2001-10-19 9:10 ` Markus Mottl
1 sibling, 0 replies; 3+ messages in thread
From: Christian RINDERKNECHT @ 2001-10-19 8:56 UTC (permalink / raw)
To: Rafael 'Dido' Sevilla; +Cc: Caml List
On Fri, Oct 19, 2001 at 04:04:26PM +0800, Rafael 'Dido' Sevilla wrote:
> [I] have this exception defined in my parser.mly:
>
> exception Undef_sym of string;
>
> [...] compiler.ml does something like:
>
> try
> let result = Parser.main Lexer.token lexbuf in
> ...
> with
> Parser.Undef_sym x -> Printf.fprintf stderr "Undefined symbol %s" x
>
> Unfortunately, compiling the compiler with this causes it to choke
> saying that Parser.Undef_sym is not found. It's not in the generated
> parser.mli file, of course. So apart from editing that (automatically
> generated) file manually, how do I get ocamlyacc to put them there?
Put your exception in a separate module, say syntax.mli:
exception Undef_sym of string
Then in parser.mly, you can do:
raise (Syntax.Undef_sym "Ooops!")
and in compiler.ml:
try
...
with
Syntax.Undef_sym x -> ...
Hope this helps.
--
Christian
------------------------------------------------------------------------
Christian Rinderknecht Phone +82 42 866 6147
Network Architecture Laboratory Fax +82 42 866 6154
Information and Communications University WWW http://nalab.icu.ac.kr
58-4 Hwaam-dong, Yuseong-gu, Daejeon, e-mail rinderkn@icu.ac.kr
305-732, Korea
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] putting stuff in an ocamlyacc-generated mli file
2001-10-19 8:04 [Caml-list] putting stuff in an ocamlyacc-generated mli file Rafael 'Dido' Sevilla
2001-10-19 8:56 ` Christian RINDERKNECHT
@ 2001-10-19 9:10 ` Markus Mottl
1 sibling, 0 replies; 3+ messages in thread
From: Markus Mottl @ 2001-10-19 9:10 UTC (permalink / raw)
To: Rafael 'Dido' Sevilla; +Cc: Caml List
On Fri, 19 Oct 2001, Rafael 'Dido' Sevilla wrote:
> Unfortunately, compiling the compiler with this causes it to choke
> saying that Parser.Undef_sym is not found. It's not in the generated
> parser.mli file, of course. So apart from editing that (automatically
> generated) file manually, how do I get ocamlyacc to put them there?
You can define the exception externally in a third file (e.g.
parser_defs.mli) to refer to it from both outside and inside the
.mly-file.
Regards,
Markus Mottl
--
Markus Mottl markus@oefai.at
Austrian Research Institute
for Artificial Intelligence http://www.oefai.at/~markus
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2001-10-19 11:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-19 8:04 [Caml-list] putting stuff in an ocamlyacc-generated mli file Rafael 'Dido' Sevilla
2001-10-19 8:56 ` Christian RINDERKNECHT
2001-10-19 9:10 ` Markus Mottl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox