caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] ocamlyacc bug?
@ 2003-04-22  6:06 SooHyoung Oh
  2003-04-22 14:28 ` Damien Doligez
  0 siblings, 1 reply; 2+ messages in thread
From: SooHyoung Oh @ 2003-04-22  6:06 UTC (permalink / raw)
  To: Caml-List


Is the following an ocamlyacc bug?

When making application with using ocamlyacc + ocamllex,
you can make main function in trailer part (after second "%%") of "foo.mly"
It that case, it generates an error like this:
    This expression has type Lexing.lexbuf -> Eg_parse.token
    but is here used with type Lexing.lexbuf -> token

It can be fixed by excluding type specification of start non-terminal
function in "foo.ml" like this:
(before)

    let line (lexfun : Lexing.lexbuf -> token) (lexbuf : Lexing.lexbuf) =
       (yyparse yytables 1 lexfun lexbuf : int)

(after)

    let line lexfun (lexbuf : Lexing.lexbuf) =
       (yyparse yytables 1 lexfun lexbuf : int)

If you want, you can view my full source in
http://www.duonix.com/~shoh/ocaml/ocamlyacc.html#bug

---
SooHyoung Oh

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] ocamlyacc bug?
  2003-04-22  6:06 [Caml-list] ocamlyacc bug? SooHyoung Oh
@ 2003-04-22 14:28 ` Damien Doligez
  0 siblings, 0 replies; 2+ messages in thread
From: Damien Doligez @ 2003-04-22 14:28 UTC (permalink / raw)
  To: Caml-List

On Tuesday, April 22, 2003, at 08:06 AM, SooHyoung Oh wrote:

> Is the following an ocamlyacc bug?

No.  At worst, it is a misfeature that results in an unclear error
message.

> When making application with using ocamlyacc + ocamllex,
> you can make main function in trailer part (after second "%%") of 
> "foo.mly"
> It that case, it generates an error like this:
>     This expression has type Lexing.lexbuf -> Eg_parse.token
>     but is here used with type Lexing.lexbuf -> token

The problem in your source, is that you add your main function at
the end of the parser.  But this function uses the lexer, so you
make Eg_parse depend on Eg_lex.  But the design of ocamllex/ocamlyacc
is that the parser is declaring the type of tokens, and the lexer
opens the parser module to use this declaration, so it is Eg_lex
that depends on Eg_parse.

By adding your main function at the end of eg_parse.ml, you make a
circular dependency between eg_parse and eg_lex.  You should add your
main function at the end of eg_lex instead.

-- Damien

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-04-22 14:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-22  6:06 [Caml-list] ocamlyacc bug? SooHyoung Oh
2003-04-22 14:28 ` Damien Doligez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).