List Info

Thread: Re: "ocaml_beginners"::[] ocamlyacc and AST's




Re: "ocaml_beginners"::[] ocamlyacc and AST's
country flaguser name
United States
2007-05-08 16:57:08

--- In ocaml_beginners%40yahoogroups.com">ocaml_beginnersyahoogroups.com, "William D. Neumann"
<wneumann...> wrote:
&gt;
> On Tue, 8 May 2007, mo.deeq wrote:
&gt;
> > Hi all
> > First of all, sorry for the complete newbie question, I'm trying to
> > create an abstract syntax tree + parser for a small language, can
> > some one help me understand what they following error is telling me
> > and why?
>; >
>; >
>; > -----
&gt; > The implementation parser.ml does not match the interface parser.cmi:
> > Values do not match:
&gt; > val file : (Lexing.lexbuf -> Lexer.token) -> Lexing.lexbuf -> Ast.ast
> > is not included in
> > val file : (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Ast.ast
> > make: *** [parser.cmo] Error 2
>
>
> What it's telling you is that your lexer is returning a type of
> Lexer.token, rather than the expected (Parser.)token. Did you
define your
> set of tokens over in your mll file as well? If so, you'll want to use
> the ones defined by the parser. You can do this easily enough by
tossing
> an "open Parser&quot; up in the header of the lexer source. Just make
sure you
> compile parser.mli before lexer.ml so it'll have the token type
> information.
>
> William D. Neumann
>
> ---
>
> "There's just so many extra children, we could just feed the
> children to these tigers. We don't need them, we're not doing
> anything with them.
&gt;
> Tigers are noble and sleek; children are loud and messy.&quot;
>
> -- Neko Case
>;
> Life is unfair. Kill yourself or get over it.
> -- Black Box Recorder
>

Hi William,
Thank you very much for that, it made sense, I have defined them in
my lexer, however, i had also included a "open Parser&quot; to the top of
my .mll file ... but it seemed to make no difference. However
removing the definitions from my .mll file has finally got is compiling.

Thanks again....
p.s. is there a knack or pointers to understanding the somewhat
cryptic (to a newbie at least) error messages that ocaml returns?

-deeq

__._,_.___
.

__,_._,___
Re: "ocaml_beginners"::[] ocamlyacc and AST's
country flaguser name
United States
2007-05-08 17:07:47

On Tue, 8 May 2007, mo.deeq wrote:

> Thank you very much for that, it made sense, I have defined them in
> my lexer, however, i had also included a "open Parser&quot; to the top of
> my .mll file ... but it seemed to make no difference. However
> removing the definitions from my .mll file has finally got is compiling.

Yeah. If they were defined after the open Parser statement then they'd
shadow the parser's tokens.

> Thanks again....
> p.s. is there a knack or pointers to understanding the somewhat
> cryptic (to a newbie at least) error messages that ocaml returns?

Not that I know of. Just experience.
Just remember, if it says "X is not included in Y" or "has type X but is
used here with type Y", then it is expecting Y, but you gave it X. Also
if you ever get the "&quot;has type X but is used here with type X" then you
must have redefined a type and used it with something that was bound to
the old definition. That's the classic head scratcher.

William D. Neumann

---

"There's just so many extra children, we could just feed the
children to these tigers. We don't need them, we're not doing
anything with them.

Tigers are noble and sleek; children are loud and messy.&quot;

-- Neko Case

Life is unfair. Kill yourself or get over it.
-- Black Box Recorder

__._,_.___
.

__,_._,___
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )