Typing problem with 'a
I have the following error message when compiling:
This expression has type
(Lexing.lexbuf -> Pred_parser.token) -> Lexing.lexbuf ->
but is here used with type
(Lexing.lexbuf -> Prop_parser.token) -> Lexing.lexbuf ->
The code is:
let parse_pred file_name line_off bol_off str =
parse "Parsing error of first order predicate logic formula."
Pred_parser.statement file_name line_off bol_off str
where "parse" returns a generic type 'a
The type reported by the system is correct. I don't understand
why the general type 'a of "parse" is not bound to the expected
type "Parse_utils.source_pos Pred.expr". In addition to this a
few lines before this I also have:
let parse_prop file_name line_off bol_off str =
parse "Parsing error of propositional formula." Prop_parser.statement
file_name line_off bol_off str
which compiles and executes correctly.
Note that both Prop_parser.statement and
Pred_parser.statement are generated by Menhir using
a common lexical analyser.
Any ideas on how to diagnose this?
- On Fri, Aug 08, 2008 at 10:44:48AM +0100, hmf@... wrote:
> Any ideas on how to diagnose this?(1) Post a minimal example to the menhir mailing list.
(2) Try adding type declarations to some of the values in the code
(with what you think is the correct type), ie. change:
... v ...
... (v : type) ...
Richard Jones wrote:
> On Fri, Aug 08, 2008 at 10:44:48AM +0100, hmf@... wrote:I have been unable to make a minimal example because it involves
>> Any ideas on how to diagnose this?
> (1) Post a minimal example to the menhir mailing list.
parsers and lexical analyser. Anyway, after a lot of experimenting
and testing it seems that the error is because I had to share tokens
between two parsers and the code was not being correctly compiled.
I have been wrestling with ocamlbuild and menhir to do this but have
failed miserably. I have therefore sent an (very simple) example to the
senior's/expert's list with a very simple example.
> (2) Try adding type declarations to some of the values in the codeYes, I had already tried this but as I said the returned type
> (with what you think is the correct type), ie. change:
> ... v ...
> ... (v : type) ...
that was reported was correct. It just was not able to bind 'a
with the type.
Thanks for the suggestions.